当前位置: 首页>>代码示例>>Java>>正文


Java FormatConversionProvider.getTargetFormats方法代码示例

本文整理汇总了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()]);
}
 
开发者ID:cfriedt,项目名称:classpath,代码行数:22,代码来源:AudioSystem.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:AudioSystem.java

示例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()]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:AudioSystem.java

示例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()]);
}
 
开发者ID:vilie,项目名称:javify,代码行数:21,代码来源:AudioSystem.java

示例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()]);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:21,代码来源:AudioSystem.java


注:本文中的javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。