org.tritonus.share.sampled.convert
Class TEncodingFormatConversionProvider
java.lang.Object
javax.sound.sampled.spi.FormatConversionProvider
org.tritonus.share.sampled.convert.TFormatConversionProvider
org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
org.tritonus.share.sampled.convert.TEncodingFormatConversionProvider
- Direct Known Subclasses:
- AlawFormatConversionProvider, ImaAdpcmFormatConversionProvider, JorbisFormatConversionProvider, UlawFormatConversionProvider, VorbisFormatConversionProvider
- public abstract class TEncodingFormatConversionProvider
- extends TSimpleFormatConversionProvider
This is a base class for FormatConversionProviders that only
change the encoding, i.e. they never
- change the sample size in bits without changing the encoding
- change the sample rate
- change the number of channels
It is assumed that each source format can be encoded to all
target formats.
In the sourceFormats and targetFormats collections that are passed to
the constructor of this class, fields may be set to AudioSystem.NOT_SPECIFIED.
This means that it handles all values of that field, but cannot change it.
This class prevents that a conversion is done (e.g. for sample rates),
because the overriding class specified AudioSystem.NOT_SPECIFIED as sample rate,
meaning it handles all sample rates.
Overriding classes must implement at least
AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
and provide a constructor that calls the protected constructor of this class.
- Author:
- Florian Bomers
Methods inherited from class org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider |
disable, doMatch, doMatch, getCollectionSourceEncodings, getCollectionSourceFormats, getCollectionTargetEncodings, getCollectionTargetFormats, getFrameSize, getSourceEncodings, getTargetEncodings, getTargetEncodings, isAllowedSourceEncoding, isAllowedSourceFormat, isAllowedTargetEncoding, isAllowedTargetFormat, isSourceEncodingSupported, isTargetEncodingSupported, replaceNotSpecified |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TEncodingFormatConversionProvider
protected TEncodingFormatConversionProvider(Collection sourceFormats,
Collection targetFormats)
getTargetFormats
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding,
AudioFormat sourceFormat)
- This implementation assumes that the converter can convert
from each of its source formats to each of its target
formats. If this is not the case, the converter has to
override this method.
When conversion is supported, for every target encoding,
the fields sample size in bits, channels and sample rate are checked:
- When a field in both the source and target format is AudioSystem.NOT_SPECIFIED,
one instance of that targetFormat is returned with this field set to AudioSystem.NOT_SPECIFIED.
- When a field in sourceFormat is set and it is AudioSystem.NOT_SPECIFIED in the target format,
the value of the field of source format is set in the returned format.
- The same applies for the other way round.
For this, replaceNotSpecified(sourceFormat, targetFormat)
in the base
class TSimpleFormatConversionProvider is used - and accordingly, the frameSize
is recalculated with getFrameSize(...)
if a field with AudioSystem.NOT_SPECIFIED
is replaced. Inheriting classes may wish to override this method if the
default mode of calculating the frame size is not appropriate.
- Overrides:
getTargetFormats
in class TSimpleFormatConversionProvider