本文整理汇总了Java中javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats方法的典型用法代码示例。如果您正苦于以下问题:Java FormatConversionProvider.getTargetFormats方法的具体用法?Java FormatConversionProvider.getTargetFormats怎么用?Java FormatConversionProvider.getTargetFormats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.spi.FormatConversionProvider
的用法示例。
在下文中一共展示了FormatConversionProvider.getTargetFormats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetFormats
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given a target encoding and a source audio format, return an array of all
* matching audio formats to which data in this source format can be converted.
* @param encoding the target encoding
* @param sourceFmt the source format
*/
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding encoding,
AudioFormat sourceFmt)
{
HashSet<AudioFormat> result = new HashSet<AudioFormat>();
Iterator<FormatConversionProvider> i =
ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = i.next();
AudioFormat[] es = prov.getTargetFormats(encoding, sourceFmt);
for (int j = 0; j < es.length; ++j)
result.add(es[j]);
}
return result.toArray(new AudioFormat[result.size()]);
}
示例2: getTargetFormats
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains the formats that have a particular encoding and that the system can
* obtain from a stream of the specified format using the set of
* installed format converters.
* @param targetEncoding the desired encoding after conversion
* @param sourceFormat the audio format before conversion
* @return array of formats. If no formats of the specified
* encoding are supported, an array of length 0 is returned.
*/
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) {
List codecs = getFormatConversionProviders();
Vector formats = new Vector();
int size = 0;
int index = 0;
AudioFormat fmts[] = null;
// gather from all the codecs
for(int i=0; i<codecs.size(); i++ ) {
FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i);
fmts = codec.getTargetFormats(targetEncoding, sourceFormat);
size += fmts.length;
formats.addElement( fmts );
}
// now build a new array
AudioFormat fmts2[] = new AudioFormat[size];
for(int i=0; i<formats.size(); i++ ) {
fmts = (AudioFormat [])(formats.get(i));
for(int j=0; j<fmts.length; j++ ) {
fmts2[index++] = fmts[j];
}
}
return fmts2;
}
示例3: getTargetFormats
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains the formats that have a particular encoding and that the system
* can obtain from a stream of the specified format using the set of
* installed format converters.
*
* @param targetEncoding the desired encoding after conversion
* @param sourceFormat the audio format before conversion
* @return array of formats. If no formats of the specified encoding are
* supported, an array of length 0 is returned.
* @throws NullPointerException if {@code targetEncoding} or
* {@code sourceFormat} are {@code null}
*/
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) {
Objects.requireNonNull(targetEncoding);
Objects.requireNonNull(sourceFormat);
List<FormatConversionProvider> codecs = getFormatConversionProviders();
List<AudioFormat> formats = new ArrayList<>();
boolean matchFound = false;
// gather from all the codecs
for (final FormatConversionProvider codec : codecs) {
AudioFormat[] elements = codec
.getTargetFormats(targetEncoding, sourceFormat);
for (AudioFormat format : elements) {
formats.add(format);
if (sourceFormat.matches(format)) {
matchFound = true;
}
}
}
if (targetEncoding.equals(sourceFormat.getEncoding())) {
if (!matchFound) {
formats.add(sourceFormat);
}
}
return formats.toArray(new AudioFormat[formats.size()]);
}
示例4: getTargetFormats
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given a target encoding and a source audio format, return an array of all
* matching audio formats to which data in this source format can be converted.
* @param encoding the target encoding
* @param sourceFmt the source format
*/
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding encoding,
AudioFormat sourceFmt)
{
HashSet<AudioFormat> result = new HashSet<AudioFormat>();
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
AudioFormat[] es = prov.getTargetFormats(encoding, sourceFmt);
for (int j = 0; j < es.length; ++j)
result.add(es[j]);
}
return result.toArray(new AudioFormat[result.size()]);
}
示例5: getTargetFormats
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given a target encoding and a source audio format, return an array of all
* matching audio formats to which data in this source format can be converted.
* @param encoding the target encoding
* @param sourceFmt the source format
*/
public static AudioFormat[] getTargetFormats(AudioFormat.Encoding encoding,
AudioFormat sourceFmt)
{
HashSet<AudioFormat> result = new HashSet<AudioFormat>();
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
AudioFormat[] es = prov.getTargetFormats(encoding, sourceFmt);
for (int j = 0; j < es.length; ++j)
result.add(es[j]);
}
return result.toArray(new AudioFormat[result.size()]);
}