Java Code Examples for javax.sound.sampled.spi.FormatConversionProvider#isConversionSupported()
The following examples show how to use
javax.sound.sampled.spi.FormatConversionProvider#isConversionSupported() .
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 |
/** * 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()); }
Example 2
Source File: AudioSystem.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * 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; }
Example 3
Source File: AudioSystem.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * 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()); }
Example 4
Source File: AudioSystem.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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()); }
Example 5
Source File: AudioSystem.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * 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 * @throws NullPointerException if {@code targetFormat} or * {@code sourceStream} are {@code null} * @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<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { FormatConversionProvider codec = 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()); }
Example 6
Source File: AudioSystem.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 7
Source File: AudioSystem.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * 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()); }
Example 8
Source File: AudioSystem.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 * @throws NullPointerException if {@code targetFormat} or * {@code sourceStream} are {@code null} * @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<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { FormatConversionProvider codec = 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()); }
Example 9
Source File: AudioSystem.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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</code> if the conversion is supported, * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; }
Example 10
Source File: AudioSystem.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 11
Source File: AudioSystem.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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 * @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) { List codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { FormatConversionProvider codec = (FormatConversionProvider) 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()); }
Example 12
Source File: AudioSystem.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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 * @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) { List codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { FormatConversionProvider codec = (FormatConversionProvider) 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()); }
Example 13
Source File: AudioSystem.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 14
Source File: AudioSystem.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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</code> if the conversion is supported, * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; }
Example 15
Source File: AudioSystem.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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</code> if the conversion is supported, * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; }
Example 16
Source File: AudioSystem.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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</code> if the conversion is supported, * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; }
Example 17
Source File: AudioSystem.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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</code> if the conversion is supported, * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; }
Example 18
Source File: AudioSystem.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 19
Source File: AudioSystem.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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 * @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) { List codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { FormatConversionProvider codec = (FormatConversionProvider) 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()); }
Example 20
Source File: AudioSystem.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }