/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author Jan Borgersen
*/
};
};
/**
* Constructs a new PCMtoPCM codec object.
*/
public PCMtoPCMCodec() {
super( inputEncodings, outputEncodings);
}
// NEW CODE
/**
*/
return encs;
} else {
}
}
/**
*/
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
}
}
}
return formatArray;
}
/**
*/
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {
sourceFormat.isBigEndian() );
} else {
throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + targetEncoding.toString() );
}
}
/**
* use old code
*/
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
}
// OLD CODE
/**
* Opens the codec with the specified parameters.
* @param stream stream from which data to be processed should be read
* @param outputFormat desired data format of the stream after processing
* @return stream from which processed data may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
/* public AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {*/
} else {
tempBuffer = new byte[tempBufferSize];
}
return cs;
}
/**
* Obtains the set of output formats supported by the codec
* given a particular input format.
* If no output formats are supported for this input format,
* returns an array of length 0.
* @return array of supported output formats.
*/
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
if ( sampleSize==8 ) {
false );
}
false );
}
} else if ( sampleSize==16 ) {
true );
false );
false );
}
true );
false );
false );
}
false );
true );
true );
}
false );
true );
true );
}
}
synchronized(formats) {
}
}
return formatArray;
}
private final int sampleSizeInBytes;
int sampleSizeInBits = 0;
boolean inputIsBigEndian;
boolean outputIsBigEndian;
// throw an IllegalArgumentException if not ok
throw new IllegalArgumentException("Unsupported conversion: " + inputFormat.toString() + " to " + outputFormat.toString());
}
// determine conversion to perform
if( sampleSizeInBits==8 ) {
}
} else {
}
}
// set the audio stream length in frames if we know it
frameSize=1;
}
if( stream instanceof AudioInputStream ) {
} else {
}
// set framePos to zero
framePos = 0;
}
/**
* Note that this only works for sign conversions.
* Other conversions require a read of at least 2 bytes.
*/
// $$jb: do we want to implement this function?
int temp;
byte tempbyte;
if( frameSize==1 ) {
if( conversionType == PCM_SWITCH_SIGNED_8BIT ) {
return temp;
} else {
// $$jb: what to return here?
throw new IOException("cannot read a single byte if frame size > 1");
}
} else {
throw new IOException("cannot read a single byte if frame size > 1");
}
}
}
int i;
// don't read fractional frames
}
// don't read past our own set length
}
byte tempByte;
return readCount;
}
// now do the conversions
switch( conversionType ) {
case PCM_SWITCH_SIGNED_8BIT:
break;
case PCM_SWITCH_ENDIAN:
break;
case PCM_SWITCH_SIGNED_LE:
break;
case PCM_SWITCH_SIGNED_BE:
break;
break;
break;
default:
// do nothing
}
// we've done the conversion, just return the readCount
return readCount;
}
b[i] = (b[i] >= 0) ? (byte)(0x80 | b[i]) : (byte)(0x7F & b[i]);
}
}
b[i] = (b[i] >= 0) ? (byte)(0x80 | b[i]) : (byte)(0x7F & b[i]);
}
}
b[i] = (b[i] >= 0) ? (byte)(0x80 | b[i]) : (byte)(0x7F & b[i]);
}
}
if(sampleSizeInBytes == 2) {
byte temp;
temp = b[i];
b[i] = b[i+1];
b[i+1] = temp;
}
}
}
} // end class PCMtoPCMCodecStream
} // end class PCMtoPCMCodec