Java Code Examples for javax.sound.sampled.spi.FormatConversionProvider#getTargetEncodings()

The following examples show how to use javax.sound.sampled.spi.FormatConversionProvider#getTargetEncodings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()]);
}
 
Example 2
Source File: AudioSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: AudioSystem.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: AudioSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: AudioSystem.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: AudioSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: AudioSystem.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: AudioSystem.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: AudioSystem.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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()]);
}
 
Example 12
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: AudioSystem.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: AudioSystem.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: AudioSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}