Java Code Examples for com.google.android.exoplayer2.C#ENCODING_PCM_16BIT
The following examples show how to use
com.google.android.exoplayer2.C#ENCODING_PCM_16BIT .
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: SonicAudioProcessor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; pendingSonicRecreation = true; return true; }
Example 2
Source File: FfmpegDecoder.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public FfmpegDecoder( int numInputBuffers, int numOutputBuffers, int initialInputBufferSize, Format format, boolean outputFloat) throws FfmpegDecoderException { super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]); Assertions.checkNotNull(format.sampleMimeType); codecName = Assertions.checkNotNull( FfmpegLibrary.getCodecName(format.sampleMimeType, format.pcmEncoding)); extraData = getExtraData(format.sampleMimeType, format.initializationData); encoding = outputFloat ? C.ENCODING_PCM_FLOAT : C.ENCODING_PCM_16BIT; outputBufferSize = outputFloat ? OUTPUT_BUFFER_SIZE_32BIT : OUTPUT_BUFFER_SIZE_16BIT; nativeContext = ffmpegInitialize(codecName, extraData, outputFloat, format.sampleRate, format.channelCount); if (nativeContext == 0) { throw new FfmpegDecoderException("Initialization failed."); } setInitialInputBufferSize(initialInputBufferSize); }
Example 3
Source File: Util.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Converts a sample bit depth to a corresponding PCM encoding constant. * * @param bitDepth The bit depth. Supported values are 8, 16, 24 and 32. * @return The corresponding encoding. One of {@link C#ENCODING_PCM_8BIT}, * {@link C#ENCODING_PCM_16BIT}, {@link C#ENCODING_PCM_24BIT} and * {@link C#ENCODING_PCM_32BIT}. If the bit depth is unsupported then * {@link C#ENCODING_INVALID} is returned. */ @C.PcmEncoding public static int getPcmEncoding(int bitDepth) { switch (bitDepth) { case 8: return C.ENCODING_PCM_8BIT; case 16: return C.ENCODING_PCM_16BIT; case 24: return C.ENCODING_PCM_24BIT; case 32: return C.ENCODING_PCM_32BIT; default: return C.ENCODING_INVALID; } }
Example 4
Source File: SonicAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } int outputSampleRateHz = pendingOutputSampleRateHz == SAMPLE_RATE_NO_CHANGE ? sampleRateHz : pendingOutputSampleRateHz; if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.outputSampleRateHz == outputSampleRateHz) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.outputSampleRateHz = outputSampleRateHz; sonic = null; return true; }
Example 5
Source File: Util.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Converts a sample bit depth to a corresponding PCM encoding constant. * * @param bitDepth The bit depth. Supported values are 8, 16, 24 and 32. * @return The corresponding encoding. One of {@link C#ENCODING_PCM_8BIT}, * {@link C#ENCODING_PCM_16BIT}, {@link C#ENCODING_PCM_24BIT} and * {@link C#ENCODING_PCM_32BIT}. If the bit depth is unsupported then * {@link C#ENCODING_INVALID} is returned. */ @C.PcmEncoding public static int getPcmEncoding(int bitDepth) { switch (bitDepth) { case 8: return C.ENCODING_PCM_8BIT; case 16: return C.ENCODING_PCM_16BIT; case 24: return C.ENCODING_PCM_24BIT; case 32: return C.ENCODING_PCM_32BIT; default: return C.ENCODING_INVALID; } }
Example 6
Source File: Util.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Returns the frame size for audio with {@code channelCount} channels in the specified encoding. * * @param pcmEncoding The encoding of the audio data. * @param channelCount The channel count. * @return The size of one audio frame in bytes. */ public static int getPcmFrameSize(@C.PcmEncoding int pcmEncoding, int channelCount) { switch (pcmEncoding) { case C.ENCODING_PCM_8BIT: return channelCount; case C.ENCODING_PCM_16BIT: return channelCount * 2; case C.ENCODING_PCM_24BIT: return channelCount * 3; case C.ENCODING_PCM_32BIT: case C.ENCODING_PCM_FLOAT: return channelCount * 4; case C.ENCODING_PCM_A_LAW: case C.ENCODING_PCM_MU_LAW: case C.ENCODING_INVALID: case Format.NO_VALUE: default: throw new IllegalArgumentException(); } }
Example 7
Source File: ResamplingAudioProcessor.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 (encoding != C.ENCODING_PCM_8BIT && encoding != C.ENCODING_PCM_16BIT && encoding != C.ENCODING_PCM_24BIT && encoding != C.ENCODING_PCM_32BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount && this.encoding == encoding) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; this.encoding = encoding; return true; }
Example 8
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
private static int getMaximumEncodedRateBytesPerSecond(@C.Encoding int encoding) { switch (encoding) { case C.ENCODING_AC3: return 640 * 1000 / 8; case C.ENCODING_E_AC3: case C.ENCODING_E_AC3_JOC: return 6144 * 1000 / 8; case C.ENCODING_AC4: return 2688 * 1000 / 8; case C.ENCODING_DTS: // DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s. return 1536 * 1000 / 8; case C.ENCODING_DTS_HD: return 18000 * 1000 / 8; case C.ENCODING_DOLBY_TRUEHD: return 24500 * 1000 / 8; case C.ENCODING_INVALID: case C.ENCODING_PCM_16BIT: case C.ENCODING_PCM_24BIT: case C.ENCODING_PCM_32BIT: case C.ENCODING_PCM_8BIT: case C.ENCODING_PCM_A_LAW: case C.ENCODING_PCM_FLOAT: case C.ENCODING_PCM_MU_LAW: case Format.NO_VALUE: default: throw new IllegalArgumentException(); } }
Example 9
Source File: ChannelMappingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, @Encoding int encoding) throws UnhandledFormatException { boolean outputChannelsChanged = !Arrays.equals(pendingOutputChannels, outputChannels); outputChannels = pendingOutputChannels; if (outputChannels == null) { active = false; return outputChannelsChanged; } if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } if (!outputChannelsChanged && this.sampleRateHz == sampleRateHz && this.channelCount == channelCount) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; active = channelCount != outputChannels.length; for (int i = 0; i < outputChannels.length; i++) { int channelIndex = outputChannels[i]; if (channelIndex >= channelCount) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } active |= (channelIndex != i); } return true; }
Example 10
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
private static AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) { int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE. int channelConfig = AudioFormat.CHANNEL_OUT_MONO; @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT; int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback. return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize, MODE_STATIC, audioSessionId); }
Example 11
Source File: SilenceSkippingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean configure(int sampleRateHz, int channelCount, int encoding) throws UnhandledFormatException { if (encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledFormatException(sampleRateHz, channelCount, encoding); } if (this.sampleRateHz == sampleRateHz && this.channelCount == channelCount) { return false; } this.sampleRateHz = sampleRateHz; this.channelCount = channelCount; bytesPerFrame = channelCount * 2; return true; }
Example 12
Source File: Util.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Returns whether {@code encoding} is one of the linear PCM encodings. * * @param encoding The encoding of the audio data. * @return Whether the encoding is one of the PCM encodings. */ public static boolean isEncodingLinearPcm(@C.Encoding int encoding) { return encoding == C.ENCODING_PCM_8BIT || encoding == C.ENCODING_PCM_16BIT || encoding == C.ENCODING_PCM_24BIT || encoding == C.ENCODING_PCM_32BIT || encoding == C.ENCODING_PCM_FLOAT; }
Example 13
Source File: ResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return encoding != C.ENCODING_INVALID && encoding != C.ENCODING_PCM_16BIT; }
Example 14
Source File: SonicAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 15
Source File: SonicAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 16
Source File: SilenceSkippingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public @C.Encoding int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 17
Source File: TrimmingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 18
Source File: ResamplingAudioProcessor.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 19
Source File: TrimmingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int getOutputEncoding() { return C.ENCODING_PCM_16BIT; }
Example 20
Source File: ResamplingAudioProcessor.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean isActive() { return encoding != C.ENCODING_INVALID && encoding != C.ENCODING_PCM_16BIT; }