org.tritonus.share.sampled.convert
Class TEncodingFormatConversionProvider

java.lang.Object
  extended byjavax.sound.sampled.spi.FormatConversionProvider
      extended byorg.tritonus.share.sampled.convert.TFormatConversionProvider
          extended byorg.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
              extended byorg.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

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

Field Summary
 
Fields inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
EMPTY_ENCODING_ARRAY, EMPTY_FORMAT_ARRAY
 
Constructor Summary
protected TEncodingFormatConversionProvider(Collection sourceFormats, Collection targetFormats)
           
 
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
disable, doMatch, doMatch, getCollectionSourceEncodings, getCollectionSourceFormats, getCollectionTargetEncodings, getCollectionTargetFormats, getFrameSize, getSourceEncodings, getTargetEncodings, getTargetEncodings, isAllowedSourceEncoding, isAllowedSourceFormat, isAllowedTargetEncoding, isAllowedTargetFormat, isSourceEncodingSupported, isTargetEncodingSupported, replaceNotSpecified
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TEncodingFormatConversionProvider

protected TEncodingFormatConversionProvider(Collection sourceFormats,
                                            Collection targetFormats)
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