• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FormatConversionProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.sound.sampled.spi.FormatConversionProvider的典型用法代码示例。如果您正苦于以下问题:Java FormatConversionProvider类的具体用法?Java FormatConversionProvider怎么用?Java FormatConversionProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormatConversionProvider类属于javax.sound.sampled.spi包,在下文中一共展示了FormatConversionProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getProviders

import javax.sound.sampled.spi.FormatConversionProvider; //导入依赖的package包/类
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:JDK13Services.java


示例2: getTargetEncodings

import javax.sound.sampled.spi.FormatConversionProvider; //导入依赖的package包/类
/**
 * Obtains the encodings that the system can obtain from an
 * audio input stream with the specified encoding using the set
 * of installed format converters.
 * @param sourceEncoding the encoding for which conversion support
 * is queried
 * @return array of encodings.  If <code>sourceEncoding</code>is not supported,
 * an array of length 0 is returned. Otherwise, the array will have a length
 * of at least 1, representing <code>sourceEncoding</code> (no conversion).
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) {

    List codecs = getFormatConversionProviders();
    Vector encodings = new Vector();

    AudioFormat.Encoding encs[] = null;

    // gather from all the codecs
    for(int i=0; i<codecs.size(); i++ ) {
        FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i);
        if( codec.isSourceEncodingSupported( sourceEncoding ) ) {
            encs = codec.getTargetEncodings();
            for (int j = 0; j < encs.length; j++) {
                encodings.addElement( encs[j] );
            }
        }
    }
    AudioFormat.Encoding encs2[] = (AudioFormat.Encoding[]) encodings.toArray(new AudioFormat.Encoding[0]);
    return encs2;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:AudioSystem.java


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


示例4: getTargetEncodings

import javax.sound.sampled.spi.FormatConversionProvider; //导入依赖的package包/类
/**
 * Obtains the encodings that the system can obtain from an audio input
 * stream with the specified encoding using the set of installed format
 * converters.
 *
 * @param  sourceEncoding the encoding for which conversion support is
 *         queried
 * @return array of encodings. If {@code sourceEncoding} is not supported,
 *         an array of length 0 is returned. Otherwise, the array will have
 *         a length of at least 1, representing {@code sourceEncoding}
 *         (no conversion).
 * @throws NullPointerException if {@code sourceEncoding} is {@code null}
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) {
    Objects.requireNonNull(sourceEncoding);

    List<FormatConversionProvider> codecs = getFormatConversionProviders();
    Vector<AudioFormat.Encoding> encodings = new Vector<>();

    AudioFormat.Encoding encs[] = null;

    // gather from all the codecs
    for(int i=0; i<codecs.size(); i++ ) {
        FormatConversionProvider codec = codecs.get(i);
        if( codec.isSourceEncodingSupported( sourceEncoding ) ) {
            encs = codec.getTargetEncodings();
            for (int j = 0; j < encs.length; j++) {
                encodings.addElement( encs[j] );
            }
        }
    }
    if (!encodings.contains(sourceEncoding)) {
        encodings.addElement(sourceEncoding);
    }

    return encodings.toArray(new AudioFormat.Encoding[encodings.size()]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:AudioSystem.java


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


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


示例7: getTargetEncodings

import javax.sound.sampled.spi.FormatConversionProvider; //导入依赖的package包/类
/**
 * Obtains the encodings that the system can obtain from an audio input
 * stream with the specified encoding using the set of installed format
 * converters.
 *
 * @param  sourceEncoding the encoding for which conversion support is
 *         queried
 * @return array of encodings. If {@code sourceEncoding}is not supported, an
 *         array of length 0 is returned. Otherwise, the array will have a
 *         length of at least 1, representing {@code sourceEncoding}
 *         (no conversion).
 * @throws NullPointerException if {@code sourceEncoding} is {@code null}
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) {
    Objects.requireNonNull(sourceEncoding);

    List<FormatConversionProvider> codecs = getFormatConversionProviders();
    Vector<AudioFormat.Encoding> encodings = new Vector<>();

    AudioFormat.Encoding encs[] = null;

    // gather from all the codecs
    for(int i=0; i<codecs.size(); i++ ) {
        FormatConversionProvider codec = codecs.get(i);
        if( codec.isSourceEncodingSupported( sourceEncoding ) ) {
            encs = codec.getTargetEncodings();
            for (int j = 0; j < encs.length; j++) {
                encodings.addElement( encs[j] );
            }
        }
    }
    if (!encodings.contains(sourceEncoding)) {
        encodings.addElement(sourceEncoding);
    }

    return encodings.toArray(new AudioFormat.Encoding[encodings.size()]);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:38,代码来源:AudioSystem.java


示例8: getTargetEncodings

import javax.sound.sampled.spi.FormatConversionProvider; //导入依赖的package包/类
/**
 * Given a source encoding, return an array of all target encodings to which
 * data in this form can be converted.
 * @param source the source encoding
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding source)
{
  HashSet<AudioFormat.Encoding> result
    = new HashSet<AudioFormat.Encoding>();
  Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
  while (i.hasNext())
    {
      FormatConversionProvider prov = (FormatConversionProvider) i.next();
      if (! prov.isSourceEncodingSupported(source))
        continue;
      AudioFormat.Encoding[] es = prov.getTargetEncodings();
      for (int j = 0; j < es.length; ++j)
        result.add(es[j]);
    }
  return result.toArray(new AudioFormat.Encoding[result.size()]);
}
 
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:AudioSystem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TtsSpan类代码示例发布时间:2022-05-21
下一篇:
Java ARRAY类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap