if (!(input instanceof AudioFormat))
{
logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
return new Format[] {null};
}
final AudioFormat inputCast = (AudioFormat) input;
if (!inputCast.getEncoding().equals(AudioFormat.ULAW) ||
(inputCast.getSampleSizeInBits() != 8 && inputCast.getSampleSizeInBits() != Format.NOT_SPECIFIED) ||
(inputCast.getChannels() != 1 && inputCast.getChannels() != Format.NOT_SPECIFIED) ||
(inputCast.getSigned() != AudioFormat.SIGNED && inputCast.getSigned() != Format.NOT_SPECIFIED) ||
(inputCast.getFrameSizeInBits() != 8 && inputCast.getFrameSizeInBits() != Format.NOT_SPECIFIED) ||
(inputCast.getDataType() != null && inputCast.getDataType() != Format.byteArray)
)
{ logger.warning(this.getClass().getSimpleName() + ".getSupportedOutputFormats: input format does not match, returning format array of {null} for " + input); // this can cause an NPE in JMF if it ever happens.
return new Format[] {null};
}
// mgodehardt if input is 8Bit, it has no endian, this causes problems with other codecs when you give them 16bit with no endian
// TODO: it would be nice to have it based on target platform ( is mac big endian ? )
int endian = inputCast.getEndian();
if ( inputCast.getSampleSizeInBits() == 8 )
{
endian = AudioFormat.LITTLE_ENDIAN;
}
final AudioFormat result = new AudioFormat(AudioFormat.LINEAR, inputCast.getSampleRate(), 16,
1, endian, AudioFormat.SIGNED, 16,
inputCast.getFrameRate(), Format.byteArray);
return new Format[] {result};
}