FileDocCategorySizeDatePackage
FormatConversionProvider.javaAPI DocJava SE 5 API6444Fri Aug 26 14:57:50 BST 2005javax.sound.sampled.spi

FormatConversionProvider

public abstract class FormatConversionProvider extends Object
A format conversion provider provides format conversion services from one or more input formats to one or more output formats. Converters include codecs, which encode and/or decode audio data, as well as transcoders, etc. Format converters provide methods for determining what conversions are supported and for obtaining an audio stream from which converted data can be read.

The source format represents the format of the incoming audio data, which will be converted.

The target format represents the format of the processed, converted audio data. This is the format of the data that can be read from the stream returned by one of the getAudioInputStream methods.

author
Kara Kytle
version
1.29, 03/12/19
since
1.3

Fields Summary
Constructors Summary
Methods Summary
public abstract javax.sound.sampled.AudioInputStreamgetAudioInputStream(javax.sound.sampled.AudioFormat targetFormat, javax.sound.sampled.AudioInputStream sourceStream)
Obtains an audio input stream with the specified format from the given audio input stream.

param
targetFormat desired data format of the stream after processing
param
sourceStream stream from which data to be processed should be read
return
stream from which processed data with the specified format may be read
throws
IllegalArgumentException if the format combination supplied is not supported.

public abstract javax.sound.sampled.AudioInputStreamgetAudioInputStream(javax.sound.sampled.AudioFormat$Encoding targetEncoding, javax.sound.sampled.AudioInputStream sourceStream)
Obtains an audio input stream with the specified encoding from the given audio input stream.

param
targetEncoding desired encoding of the stream after processing
param
sourceStream stream from which data to be processed should be read
return
stream from which processed data with the specified target encoding may be read
throws
IllegalArgumentException if the format combination supplied is not supported.

public abstract javax.sound.sampled.AudioFormat$Encoding[]getSourceEncodings()
Obtains the set of source format encodings from which format conversion services are provided by this provider.

return
array of source format encodings. The array will always have a length of at least 1.

public abstract javax.sound.sampled.AudioFormat$Encoding[]getTargetEncodings()
Obtains the set of target format encodings to which format conversion services are provided by this provider.

return
array of target format encodings. The array will always have a length of at least 1.

public abstract javax.sound.sampled.AudioFormat$Encoding[]getTargetEncodings(javax.sound.sampled.AudioFormat sourceFormat)
Obtains the set of target format encodings supported by the format converter given a particular source format. If no target format encodings are supported for this source format, an array of length 0 is returned.

return
array of supported target format encodings.

public abstract javax.sound.sampled.AudioFormat[]getTargetFormats(javax.sound.sampled.AudioFormat$Encoding targetEncoding, javax.sound.sampled.AudioFormat sourceFormat)
Obtains the set of target formats with the encoding specified supported by the format converter If no target formats with the specified encoding are supported for this source format, an array of length 0 is returned.

return
array of supported target formats.

public booleanisConversionSupported(javax.sound.sampled.AudioFormat$Encoding targetEncoding, javax.sound.sampled.AudioFormat sourceFormat)
Indicates whether the format converter supports conversion to a particular encoding from a particular format.

param
targetEncoding desired encoding of the outgoing data
param
sourceFormat format of the incoming data
return
true if the conversion is supported, otherwise false


	AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);

	for(int i=0; i<targetEncodings.length; i++) {
	    if( targetEncoding.equals( targetEncodings[i]) ) {
		return true;
	    }
	}
	return false;
    
public booleanisConversionSupported(javax.sound.sampled.AudioFormat targetFormat, javax.sound.sampled.AudioFormat sourceFormat)
Indicates whether the format converter supports conversion to one particular format from another.

param
targetFormat desired format of outgoing data
param
sourceFormat format of the incoming data
return
true if the conversion is supported, otherwise false


	AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

	for(int i=0; i<targetFormats.length; i++) {
	    if( targetFormat.matches( targetFormats[i] ) ) {
		return true;
	    }
	}
	return false;
    
public booleanisSourceEncodingSupported(javax.sound.sampled.AudioFormat$Encoding sourceEncoding)
Indicates whether the format converter supports conversion from the specified source format encoding.

param
sourceEncoding the source format encoding for which support is queried
return
true if the encoding is supported, otherwise false


	AudioFormat.Encoding sourceEncodings[] = getSourceEncodings();

	for(int i=0; i<sourceEncodings.length; i++) {
	    if( sourceEncoding.equals( sourceEncodings[i]) ) {
		return true;
	    }
	}
	return false;
    
public booleanisTargetEncodingSupported(javax.sound.sampled.AudioFormat$Encoding targetEncoding)
Indicates whether the format converter supports conversion to the specified target format encoding.

param
targetEncoding the target format encoding for which support is queried
return
true if the encoding is supported, otherwise false


	AudioFormat.Encoding targetEncodings[] = getTargetEncodings();

	for(int i=0; i<targetEncodings.length; i++) {
	    if( targetEncoding.equals( targetEncodings[i]) ) {
		return true;
	    }
	}
	return false;