Java Code Examples for com.google.android.exoplayer2.util.Util#isEncodingHighResolutionIntegerPcm()
The following examples show how to use
com.google.android.exoplayer2.util.Util#isEncodingHighResolutionIntegerPcm() .
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: FloatResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @C.Encoding int encoding) throws UnhandledFormatException { if (!Util.isEncodingHighResolutionIntegerPcm(encoding)) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && sourceEncoding == encoding) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; sourceEncoding = encoding; return true; }
Example 2
Source File: FloatResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @C.Encoding int encoding) throws UnhandledFormatException { if (!Util.isEncodingHighResolutionIntegerPcm(encoding)) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && sourceEncoding == encoding) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; sourceEncoding = encoding; return true; }
Example 3
Source File: FloatResamplingAudioProcessor.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { if (!Util.isEncodingHighResolutionIntegerPcm(inputAudioFormat.encoding)) { throw new UnhandledAudioFormatException(inputAudioFormat); } return Util.isEncodingHighResolutionIntegerPcm(inputAudioFormat.encoding) ? new AudioFormat( inputAudioFormat.sampleRate, inputAudioFormat.channelCount, C.ENCODING_PCM_FLOAT) : AudioFormat.NOT_SET; }
Example 4
Source File: FloatResamplingAudioProcessor.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @C.PcmEncoding int encoding) throws UnhandledFormatException { if (!Util.isEncodingHighResolutionIntegerPcm(encoding)) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } return setInputFormat(sampleRateHz, channelCount, encoding); }
Example 5
Source File: FloatResamplingAudioProcessor.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @C.PcmEncoding int encoding) throws UnhandledFormatException { if (!Util.isEncodingHighResolutionIntegerPcm(encoding)) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } return setInputFormat(sampleRateHz, channelCount, encoding); }
Example 6
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 4 votes |
@Override public void configure( @C.Encoding int inputEncoding, int inputChannelCount, int inputSampleRate, int specifiedBufferSize, @Nullable int[] outputChannels, int trimStartFrames, int trimEndFrames) throws ConfigurationException { if (Util.SDK_INT < 21 && inputChannelCount == 8 && outputChannels == null) { // AudioTrack doesn't support 8 channel output before Android L. Discard the last two (side) // channels to give a 6 channel stream that is supported. outputChannels = new int[6]; for (int i = 0; i < outputChannels.length; i++) { outputChannels[i] = i; } } boolean isInputPcm = Util.isEncodingLinearPcm(inputEncoding); boolean processingEnabled = isInputPcm && inputEncoding != C.ENCODING_PCM_FLOAT; int sampleRate = inputSampleRate; int channelCount = inputChannelCount; @C.Encoding int encoding = inputEncoding; boolean shouldConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat && supportsOutput(inputChannelCount, C.ENCODING_PCM_FLOAT) && Util.isEncodingHighResolutionIntegerPcm(inputEncoding); AudioProcessor[] availableAudioProcessors = shouldConvertHighResIntPcmToFloat ? toFloatPcmAvailableAudioProcessors : toIntPcmAvailableAudioProcessors; if (processingEnabled) { trimmingAudioProcessor.setTrimFrameCount(trimStartFrames, trimEndFrames); channelMappingAudioProcessor.setChannelMap(outputChannels); AudioProcessor.AudioFormat inputAudioFormat = new AudioProcessor.AudioFormat(sampleRate, channelCount, encoding); AudioProcessor.AudioFormat outputAudioFormat = inputAudioFormat; for (AudioProcessor audioProcessor : availableAudioProcessors) { try { outputAudioFormat = audioProcessor.configure(inputAudioFormat); } catch (UnhandledAudioFormatException e) { throw new ConfigurationException(e); } if (audioProcessor.isActive()) { inputAudioFormat = outputAudioFormat; } } sampleRate = outputAudioFormat.sampleRate; channelCount = outputAudioFormat.channelCount; encoding = outputAudioFormat.encoding; } int outputChannelConfig = getChannelConfig(channelCount, isInputPcm); if (outputChannelConfig == AudioFormat.CHANNEL_INVALID) { throw new ConfigurationException("Unsupported channel count: " + channelCount); } int inputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(inputEncoding, inputChannelCount) : C.LENGTH_UNSET; int outputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(encoding, channelCount) : C.LENGTH_UNSET; boolean canApplyPlaybackParameters = processingEnabled && !shouldConvertHighResIntPcmToFloat; Configuration pendingConfiguration = new Configuration( isInputPcm, inputPcmFrameSize, inputSampleRate, outputPcmFrameSize, sampleRate, outputChannelConfig, encoding, specifiedBufferSize, processingEnabled, canApplyPlaybackParameters, availableAudioProcessors); if (isInitialized()) { this.pendingConfiguration = pendingConfiguration; } else { configuration = pendingConfiguration; } }
Example 7
Source File: FloatResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return Util.isEncodingHighResolutionIntegerPcm(sourceEncoding); }
Example 8
Source File: FloatResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return Util.isEncodingHighResolutionIntegerPcm(sourceEncoding); }
Example 9
Source File: DefaultAudioSink.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void configure( @C.Encoding int inputEncoding, int inputChannelCount, int inputSampleRate, int specifiedBufferSize, @Nullable int[] outputChannels, int trimStartFrames, int trimEndFrames) throws ConfigurationException { if (Util.SDK_INT < 21 && inputChannelCount == 8 && outputChannels == null) { // AudioTrack doesn't support 8 channel output before Android L. Discard the last two (side) // channels to give a 6 channel stream that is supported. outputChannels = new int[6]; for (int i = 0; i < outputChannels.length; i++) { outputChannels[i] = i; } } boolean isInputPcm = Util.isEncodingLinearPcm(inputEncoding); boolean processingEnabled = isInputPcm && inputEncoding != C.ENCODING_PCM_FLOAT; int sampleRate = inputSampleRate; int channelCount = inputChannelCount; @C.Encoding int encoding = inputEncoding; boolean shouldConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat && supportsOutput(inputChannelCount, C.ENCODING_PCM_FLOAT) && Util.isEncodingHighResolutionIntegerPcm(inputEncoding); AudioProcessor[] availableAudioProcessors = shouldConvertHighResIntPcmToFloat ? toFloatPcmAvailableAudioProcessors : toIntPcmAvailableAudioProcessors; boolean flushAudioProcessors = false; if (processingEnabled) { trimmingAudioProcessor.setTrimFrameCount(trimStartFrames, trimEndFrames); channelMappingAudioProcessor.setChannelMap(outputChannels); for (AudioProcessor audioProcessor : availableAudioProcessors) { try { flushAudioProcessors |= audioProcessor.configure(sampleRate, channelCount, encoding); } catch (AudioProcessor.UnhandledFormatException e) { throw new ConfigurationException(e); } if (audioProcessor.isActive()) { channelCount = audioProcessor.getOutputChannelCount(); sampleRate = audioProcessor.getOutputSampleRateHz(); encoding = audioProcessor.getOutputEncoding(); } } } int outputChannelConfig = getChannelConfig(channelCount, isInputPcm); if (outputChannelConfig == AudioFormat.CHANNEL_INVALID) { throw new ConfigurationException("Unsupported channel count: " + channelCount); } int inputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(inputEncoding, inputChannelCount) : C.LENGTH_UNSET; int outputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(encoding, channelCount) : C.LENGTH_UNSET; boolean canApplyPlaybackParameters = processingEnabled && !shouldConvertHighResIntPcmToFloat; Configuration pendingConfiguration = new Configuration( isInputPcm, inputPcmFrameSize, inputSampleRate, outputPcmFrameSize, sampleRate, outputChannelConfig, encoding, specifiedBufferSize, processingEnabled, canApplyPlaybackParameters, availableAudioProcessors); // If we have a pending configuration already, we always drain audio processors as the preceding // configuration may have required it (even if this one doesn't). boolean drainAudioProcessors = flushAudioProcessors || this.pendingConfiguration != null; if (isInitialized() && (!pendingConfiguration.canReuseAudioTrack(configuration) || drainAudioProcessors)) { this.pendingConfiguration = pendingConfiguration; } else { configuration = pendingConfiguration; } }
Example 10
Source File: FloatResamplingAudioProcessor.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return Util.isEncodingHighResolutionIntegerPcm(encoding); }
Example 11
Source File: DefaultAudioSink.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void configure( @C.Encoding int inputEncoding, int inputChannelCount, int inputSampleRate, int specifiedBufferSize, @Nullable int[] outputChannels, int trimStartFrames, int trimEndFrames) throws ConfigurationException { if (Util.SDK_INT < 21 && inputChannelCount == 8 && outputChannels == null) { // AudioTrack doesn't support 8 channel output before Android L. Discard the last two (side) // channels to give a 6 channel stream that is supported. outputChannels = new int[6]; for (int i = 0; i < outputChannels.length; i++) { outputChannels[i] = i; } } boolean isInputPcm = Util.isEncodingLinearPcm(inputEncoding); boolean processingEnabled = isInputPcm && inputEncoding != C.ENCODING_PCM_FLOAT; int sampleRate = inputSampleRate; int channelCount = inputChannelCount; @C.Encoding int encoding = inputEncoding; boolean shouldConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat && supportsOutput(inputChannelCount, C.ENCODING_PCM_FLOAT) && Util.isEncodingHighResolutionIntegerPcm(inputEncoding); AudioProcessor[] availableAudioProcessors = shouldConvertHighResIntPcmToFloat ? toFloatPcmAvailableAudioProcessors : toIntPcmAvailableAudioProcessors; boolean flushAudioProcessors = false; if (processingEnabled) { trimmingAudioProcessor.setTrimFrameCount(trimStartFrames, trimEndFrames); channelMappingAudioProcessor.setChannelMap(outputChannels); for (AudioProcessor audioProcessor : availableAudioProcessors) { try { flushAudioProcessors |= audioProcessor.configure(sampleRate, channelCount, encoding); } catch (AudioProcessor.UnhandledFormatException e) { throw new ConfigurationException(e); } if (audioProcessor.isActive()) { channelCount = audioProcessor.getOutputChannelCount(); sampleRate = audioProcessor.getOutputSampleRateHz(); encoding = audioProcessor.getOutputEncoding(); } } } int outputChannelConfig = getChannelConfig(channelCount, isInputPcm); if (outputChannelConfig == AudioFormat.CHANNEL_INVALID) { throw new ConfigurationException("Unsupported channel count: " + channelCount); } int inputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(inputEncoding, inputChannelCount) : C.LENGTH_UNSET; int outputPcmFrameSize = isInputPcm ? Util.getPcmFrameSize(encoding, channelCount) : C.LENGTH_UNSET; boolean canApplyPlaybackParameters = processingEnabled && !shouldConvertHighResIntPcmToFloat; Configuration pendingConfiguration = new Configuration( isInputPcm, inputPcmFrameSize, inputSampleRate, outputPcmFrameSize, sampleRate, outputChannelConfig, encoding, specifiedBufferSize, processingEnabled, canApplyPlaybackParameters, availableAudioProcessors); // If we have a pending configuration already, we always drain audio processors as the preceding // configuration may have required it (even if this one doesn't). boolean drainAudioProcessors = flushAudioProcessors || this.pendingConfiguration != null; if (isInitialized() && (!pendingConfiguration.canReuseAudioTrack(configuration) || drainAudioProcessors)) { this.pendingConfiguration = pendingConfiguration; } else { configuration = pendingConfiguration; } }
Example 12
Source File: FloatResamplingAudioProcessor.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return Util.isEncodingHighResolutionIntegerPcm(encoding); }