本文整理汇总了Java中javax.sound.sampled.spi.FormatConversionProvider.isConversionSupported方法的典型用法代码示例。如果您正苦于以下问题:Java FormatConversionProvider.isConversionSupported方法的具体用法?Java FormatConversionProvider.isConversionSupported怎么用?Java FormatConversionProvider.isConversionSupported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.spi.FormatConversionProvider
的用法示例。
在下文中一共展示了FormatConversionProvider.isConversionSupported方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains an audio input stream of the indicated format, by converting the
* provided audio input stream.
* @param targetFormat the desired audio format after conversion
* @param sourceStream the stream to be converted
* @return an audio input stream of the indicated format
* @throws IllegalArgumentException if the conversion is not supported
* #see #getTargetEncodings(AudioFormat)
* @see #getTargetFormats(AudioFormat.Encoding, AudioFormat)
* @see #isConversionSupported(AudioFormat, AudioFormat)
* @see #getAudioInputStream(AudioFormat.Encoding, AudioInputStream)
*/
public static AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream) {
if (sourceStream.getFormat().matches(targetFormat)) {
return sourceStream;
}
List codecs = getFormatConversionProviders();
for(int i = 0; i < codecs.size(); i++) {
FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i);
if(codec.isConversionSupported(targetFormat,sourceStream.getFormat()) ) {
return codec.getAudioInputStream(targetFormat,sourceStream);
}
}
// we ran out of options...
throw new IllegalArgumentException("Unsupported conversion: " + targetFormat + " from " + sourceStream.getFormat());
}
示例2: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Indicates whether an audio input stream of the specified encoding can be
* obtained from an audio input stream that has the specified format.
*
* @param targetEncoding the desired encoding after conversion
* @param sourceFormat the audio format before conversion
* @return {@code true} if the conversion is supported, otherwise
* {@code false}
* @throws NullPointerException if {@code targetEncoding} or
* {@code sourceFormat} are {@code null}
*/
public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
Objects.requireNonNull(sourceFormat);
if (sourceFormat.getEncoding().equals(targetEncoding)) {
return true;
}
List<FormatConversionProvider> codecs = getFormatConversionProviders();
for(int i=0; i<codecs.size(); i++ ) {
FormatConversionProvider codec = codecs.get(i);
if(codec.isConversionSupported(targetEncoding,sourceFormat) ) {
return true;
}
}
return false;
}
示例3: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains an audio input stream of the indicated encoding, by converting
* the provided audio input stream.
*
* @param targetEncoding the desired encoding after conversion
* @param sourceStream the stream to be converted
* @return an audio input stream of the indicated encoding
* @throws IllegalArgumentException if the conversion is not supported
* @throws NullPointerException if {@code targetEncoding} or
* {@code sourceStream} are {@code null}
* @see #getTargetEncodings(AudioFormat.Encoding)
* @see #getTargetEncodings(AudioFormat)
* @see #isConversionSupported(AudioFormat.Encoding, AudioFormat)
* @see #getAudioInputStream(AudioFormat, AudioInputStream)
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding,
AudioInputStream sourceStream) {
Objects.requireNonNull(targetEncoding);
Objects.requireNonNull(sourceStream);
if (sourceStream.getFormat().getEncoding().equals(targetEncoding)) {
return sourceStream;
}
List<FormatConversionProvider> codecs = getFormatConversionProviders();
for(int i = 0; i < codecs.size(); i++) {
FormatConversionProvider codec = codecs.get(i);
if( codec.isConversionSupported( targetEncoding, sourceStream.getFormat() ) ) {
return codec.getAudioInputStream( targetEncoding, sourceStream );
}
}
// we ran out of options, throw an exception
throw new IllegalArgumentException("Unsupported conversion: " + targetEncoding + " from " + sourceStream.getFormat());
}
示例4: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Indicates whether an audio input stream of a specified format can be
* obtained from an audio input stream of another specified format.
*
* @param targetFormat the desired audio format after conversion
* @param sourceFormat the audio format before conversion
* @return {@code true} if the conversion is supported, otherwise
* {@code false}
* @throws NullPointerException if {@code targetFormat} or
* {@code sourceFormat} are {@code null}
*/
public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) {
Objects.requireNonNull(targetFormat);
Objects.requireNonNull(sourceFormat);
if (sourceFormat.matches(targetFormat)) {
return true;
}
List<FormatConversionProvider> codecs = getFormatConversionProviders();
for(int i=0; i<codecs.size(); i++ ) {
FormatConversionProvider codec = codecs.get(i);
if(codec.isConversionSupported(targetFormat, sourceFormat) ) {
return true;
}
}
return false;
}
示例5: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Indicates whether an audio input stream of the specified encoding
* can be obtained from an audio input stream that has the specified
* format.
* @param targetEncoding the desired encoding after conversion
* @param sourceFormat the audio format before conversion
* @return <code>true</code> if the conversion is supported,
* otherwise <code>false</code>
*/
public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) {
List codecs = getFormatConversionProviders();
for(int i=0; i<codecs.size(); i++ ) {
FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i);
if(codec.isConversionSupported(targetEncoding,sourceFormat) ) {
return true;
}
}
return false;
}
示例6: testAfterConversion
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Verifies the frame length after the stream was converted to other
* stream.
*
* @see FormatConversionProvider#getAudioInputStream(AudioFormat,
* AudioInputStream)
*/
private static void testAfterConversion(final FormatConversionProvider fcp,
final AudioFormat to,
final AudioInputStream ais) {
if (fcp.isConversionSupported(to, ais.getFormat())) {
validate(fcp.getAudioInputStream(to, ais).getFrameLength());
}
}
示例7: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Return true if the currently installed providers are able to
* convert data from the given source format to the given target encoding.
* @param targ the target encoding
* @param source the source format
*/
public static boolean isConversionSupported(AudioFormat.Encoding targ,
AudioFormat source)
{
Iterator i
= ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (prov.isConversionSupported(targ, source))
return true;
}
return false;
}
示例8: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose format matches the given target format. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target format
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat targ,
AudioInputStream ais)
{
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("format not supported for stream");
}
示例9: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose encoding matches the given target encoding. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target encoding
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
AudioInputStream ais)
{
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("encoding not supported for stream");
}
示例10: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Return true if the currently installed providers are able to
* convert data from the given source format to the given target encoding.
* @param targ the target encoding
* @param source the source format
*/
public static boolean isConversionSupported(AudioFormat.Encoding targ,
AudioFormat source)
{
Iterator i
= ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (prov.isConversionSupported(targ, source))
return true;
}
return false;
}
示例11: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose encoding matches the given target encoding. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target encoding
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
AudioInputStream ais)
{
Iterator<FormatConversionProvider> i =
ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("encoding not supported for stream");
}
示例12: isConversionSupported
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Return true if the currently installed providers are able to
* convert data from the given source format to the given target encoding.
* @param targ the target encoding
* @param source the source format
*/
public static boolean isConversionSupported(AudioFormat.Encoding targ,
AudioFormat source)
{
Iterator<FormatConversionProvider> i
= ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = i.next();
if (prov.isConversionSupported(targ, source))
return true;
}
return false;
}