org.tritonus.share.sampled.convert
Class TEncodingFormatConversionProvider

java.lang.Object
  extended by javax.sound.sampled.spi.FormatConversionProvider
      extended by org.tritonus.share.sampled.convert.TFormatConversionProvider
          extended by org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
              extended by org.tritonus.share.sampled.convert.TEncodingFormatConversionProvider
Direct Known Subclasses:
ImaAdpcmFormatConversionProvider, JorbisFormatConversionProvider, LawDecoder, LawEncoder, VorbisFormatConversionProvider, VorbisFormatConversionProvider

public abstract class TEncodingFormatConversionProvider
extends TSimpleFormatConversionProvider

This is a base class for FormatConversionProviders that only change the encoding, i.e. they never

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.


Method Summary
 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.
 
Methods inherited from class org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
getSourceEncodings, getTargetEncodings, getTargetEncodings, isSourceEncodingSupported, isTargetEncodingSupported
 
Methods inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
getAudioInputStream, getMatchingFormat, isConversionSupported
 
Methods inherited from class javax.sound.sampled.spi.FormatConversionProvider
getAudioInputStream, isConversionSupported
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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:

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