Java Code Examples for com.google.android.exoplayer2.util.MimeTypes#AUDIO_RAW
The following examples show how to use
com.google.android.exoplayer2.util.MimeTypes#AUDIO_RAW .
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: MediaCodecAudioRenderer.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override protected void configureCodec( MediaCodecInfo codecInfo, MediaCodec codec, Format format, @Nullable MediaCrypto crypto, float codecOperatingRate) { codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name); passthroughEnabled = codecInfo.passthrough; String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType; MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); if (passthroughEnabled) { // Store the input MIME type if we're using the passthrough codec. passthroughMediaFormat = mediaFormat; passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); } else { passthroughMediaFormat = null; } }
Example 2
Source File: MediaCodecAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void configureCodec( MediaCodecInfo codecInfo, MediaCodec codec, Format format, MediaCrypto crypto, float codecOperatingRate) { codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); passthroughEnabled = codecInfo.passthrough; String codecMimeType = codecInfo.mimeType == null ? MimeTypes.AUDIO_RAW : codecInfo.mimeType; MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); if (passthroughEnabled) { // Store the input MIME type if we're using the passthrough codec. passthroughMediaFormat = mediaFormat; passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); } else { passthroughMediaFormat = null; } }
Example 3
Source File: FfmpegAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private boolean shouldUseFloatOutput(Format inputFormat) { Assertions.checkNotNull(inputFormat.sampleMimeType); if (!enableFloatOutput || !supportsOutputEncoding(C.ENCODING_PCM_FLOAT)) { return false; } switch (inputFormat.sampleMimeType) { case MimeTypes.AUDIO_RAW: // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit. return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT; case MimeTypes.AUDIO_AC3: // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding. return false; default: // For all other formats, assume that it's worth using 32-bit float encoding. return true; } }
Example 4
Source File: MediaCodecAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void configureCodec( MediaCodecInfo codecInfo, MediaCodec codec, Format format, MediaCrypto crypto, float codecOperatingRate) { codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); passthroughEnabled = codecInfo.passthrough; String codecMimeType = codecInfo.mimeType == null ? MimeTypes.AUDIO_RAW : codecInfo.mimeType; MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); if (passthroughEnabled) { // Store the input MIME type if we're using the passthrough codec. passthroughMediaFormat = mediaFormat; passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); } else { passthroughMediaFormat = null; } }
Example 5
Source File: FfmpegAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private boolean shouldUseFloatOutput(Format inputFormat) { Assertions.checkNotNull(inputFormat.sampleMimeType); if (!enableFloatOutput || !supportsOutputEncoding(C.ENCODING_PCM_FLOAT)) { return false; } switch (inputFormat.sampleMimeType) { case MimeTypes.AUDIO_RAW: // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit. return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT; case MimeTypes.AUDIO_AC3: // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding. return false; default: // For all other formats, assume that it's worth using 32-bit float encoding. return true; } }
Example 6
Source File: SoftAudioRenderer.java From DanDanPlayForAndroid with MIT License | 6 votes |
private boolean shouldUseFloatOutput(Format inputFormat) { Assertions.checkNotNull(inputFormat.sampleMimeType); if (!enableFloatOutput || !supportsOutput(inputFormat.channelCount, C.ENCODING_PCM_FLOAT)) { return false; } switch (inputFormat.sampleMimeType) { case MimeTypes.AUDIO_RAW: // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit. return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT; case MimeTypes.AUDIO_AC3: // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding. return false; default: // For all other formats, assume that it's worth using 32-bit float encoding. return true; } }
Example 7
Source File: MediaCodecAudioRenderer.java From K-Sonic with MIT License | 6 votes |
@Override protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputFormat) throws ExoPlaybackException { boolean passthrough = passthroughMediaFormat != null; String mimeType = passthrough ? passthroughMediaFormat.getString(MediaFormat.KEY_MIME) : MimeTypes.AUDIO_RAW; MediaFormat format = passthrough ? passthroughMediaFormat : outputFormat; int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT); int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE); int[] channelMap; if (codecNeedsDiscardChannelsWorkaround && channelCount == 6 && this.channelCount < 6) { channelMap = new int[this.channelCount]; for (int i = 0; i < this.channelCount; i++) { channelMap[i] = i; } } else { channelMap = null; } try { audioTrack.configure(mimeType, channelCount, sampleRate, pcmEncoding, 0, channelMap); } catch (AudioTrack.ConfigurationException e) { throw ExoPlaybackException.createForRenderer(e, getIndex()); } }
Example 8
Source File: MediaCodecAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override protected void configureCodec( MediaCodecInfo codecInfo, MediaCodec codec, Format format, MediaCrypto crypto, float codecOperatingRate) { codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name); passthroughEnabled = codecInfo.passthrough; String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType; MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); if (passthroughEnabled) { // Store the input MIME type if we're using the passthrough codec. passthroughMediaFormat = mediaFormat; passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); } else { passthroughMediaFormat = null; } }
Example 9
Source File: FfmpegAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private boolean shouldUseFloatOutput(Format inputFormat) { Assertions.checkNotNull(inputFormat.sampleMimeType); if (!enableFloatOutput || !supportsOutput(inputFormat.channelCount, C.ENCODING_PCM_FLOAT)) { return false; } switch (inputFormat.sampleMimeType) { case MimeTypes.AUDIO_RAW: // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit. return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT; case MimeTypes.AUDIO_AC3: // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding. return false; default: // For all other formats, assume that it's worth using 32-bit float encoding. return true; } }
Example 10
Source File: MediaCodecAudioRenderer.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override protected void configureCodec( MediaCodecInfo codecInfo, MediaCodec codec, Format format, MediaCrypto crypto, float codecOperatingRate) { codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name); passthroughEnabled = codecInfo.passthrough; String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType; MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); if (passthroughEnabled) { // Store the input MIME type if we're using the passthrough codec. passthroughMediaFormat = mediaFormat; passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); } else { passthroughMediaFormat = null; } }
Example 11
Source File: FfmpegAudioRenderer.java From Telegram with GNU General Public License v2.0 | 6 votes |
private boolean shouldUseFloatOutput(Format inputFormat) { Assertions.checkNotNull(inputFormat.sampleMimeType); if (!enableFloatOutput || !supportsOutput(inputFormat.channelCount, C.ENCODING_PCM_FLOAT)) { return false; } switch (inputFormat.sampleMimeType) { case MimeTypes.AUDIO_RAW: // For raw audio, output in 32-bit float encoding if the bit depth is > 16-bit. return inputFormat.pcmEncoding == C.ENCODING_PCM_24BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_32BIT || inputFormat.pcmEncoding == C.ENCODING_PCM_FLOAT; case MimeTypes.AUDIO_AC3: // AC-3 is always 16-bit, so there is no point outputting in 32-bit float encoding. return false; default: // For all other formats, assume that it's worth using 32-bit float encoding. return true; } }
Example 12
Source File: FfmpegLibrary.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null} * if it's unsupported. */ /* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) { switch (mimeType) { case MimeTypes.AUDIO_AAC: return "aac"; case MimeTypes.AUDIO_MPEG: case MimeTypes.AUDIO_MPEG_L1: case MimeTypes.AUDIO_MPEG_L2: return "mp3"; case MimeTypes.AUDIO_AC3: return "ac3"; case MimeTypes.AUDIO_E_AC3: return "eac3"; case MimeTypes.AUDIO_TRUEHD: return "truehd"; case MimeTypes.AUDIO_DTS: case MimeTypes.AUDIO_DTS_HD: return "dca"; case MimeTypes.AUDIO_VORBIS: return "vorbis"; case MimeTypes.AUDIO_OPUS: return "opus"; case MimeTypes.AUDIO_AMR_NB: return "amrnb"; case MimeTypes.AUDIO_AMR_WB: return "amrwb"; case MimeTypes.AUDIO_FLAC: return "flac"; case MimeTypes.AUDIO_ALAC: return "alac"; case MimeTypes.AUDIO_RAW: if (encoding == C.ENCODING_PCM_MU_LAW) { return "pcm_mulaw"; } else if (encoding == C.ENCODING_PCM_A_LAW) { return "pcm_alaw"; } else { return null; } default: return null; } }
Example 13
Source File: FfmpegLibrary.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null} * if it's unsupported. */ /* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) { switch (mimeType) { case MimeTypes.AUDIO_AAC: return "aac"; case MimeTypes.AUDIO_MPEG: case MimeTypes.AUDIO_MPEG_L1: case MimeTypes.AUDIO_MPEG_L2: return "mp3"; case MimeTypes.AUDIO_AC3: return "ac3"; case MimeTypes.AUDIO_E_AC3: return "eac3"; case MimeTypes.AUDIO_TRUEHD: return "truehd"; case MimeTypes.AUDIO_DTS: case MimeTypes.AUDIO_DTS_HD: return "dca"; case MimeTypes.AUDIO_VORBIS: return "vorbis"; case MimeTypes.AUDIO_OPUS: return "opus"; case MimeTypes.AUDIO_AMR_NB: return "amrnb"; case MimeTypes.AUDIO_AMR_WB: return "amrwb"; case MimeTypes.AUDIO_FLAC: return "flac"; case MimeTypes.AUDIO_ALAC: return "alac"; case MimeTypes.AUDIO_RAW: if (encoding == C.ENCODING_PCM_MU_LAW) { return "pcm_mulaw"; } else if (encoding == C.ENCODING_PCM_A_LAW) { return "pcm_alaw"; } else { return null; } default: return null; } }
Example 14
Source File: AudioDecoder.java From DanDanPlayForAndroid with MIT License | 4 votes |
/** * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null} * if it's unsupported. */ private static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) { switch (mimeType) { case MimeTypes.AUDIO_AAC: return "aac"; case MimeTypes.AUDIO_MPEG: case MimeTypes.AUDIO_MPEG_L1: case MimeTypes.AUDIO_MPEG_L2: return "mp3"; case MimeTypes.AUDIO_AC3: return "ac3"; case MimeTypes.AUDIO_E_AC3: case MimeTypes.AUDIO_E_AC3_JOC: return "eac3"; case MimeTypes.AUDIO_TRUEHD: return "truehd"; case MimeTypes.AUDIO_DTS: case MimeTypes.AUDIO_DTS_HD: return "dca"; case MimeTypes.AUDIO_VORBIS: return "vorbis"; case MimeTypes.AUDIO_OPUS: return "opus"; case MimeTypes.AUDIO_AMR_NB: return "amrnb"; case MimeTypes.AUDIO_AMR_WB: return "amrwb"; case MimeTypes.AUDIO_FLAC: return "flac"; case MimeTypes.AUDIO_ALAC: return "alac"; case MimeTypes.AUDIO_RAW: if (encoding == C.ENCODING_PCM_MU_LAW) { return "pcm_mulaw"; } else if (encoding == C.ENCODING_PCM_A_LAW) { return "pcm_alaw"; } else { return null; } default: return null; } }
Example 15
Source File: FfmpegLibrary.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null} * if it's unsupported. */ /* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) { switch (mimeType) { case MimeTypes.AUDIO_AAC: return "aac"; case MimeTypes.AUDIO_MPEG: case MimeTypes.AUDIO_MPEG_L1: case MimeTypes.AUDIO_MPEG_L2: return "mp3"; case MimeTypes.AUDIO_AC3: return "ac3"; case MimeTypes.AUDIO_E_AC3: case MimeTypes.AUDIO_E_AC3_JOC: return "eac3"; case MimeTypes.AUDIO_TRUEHD: return "truehd"; case MimeTypes.AUDIO_DTS: case MimeTypes.AUDIO_DTS_HD: return "dca"; case MimeTypes.AUDIO_VORBIS: return "vorbis"; case MimeTypes.AUDIO_OPUS: return "opus"; case MimeTypes.AUDIO_AMR_NB: return "amrnb"; case MimeTypes.AUDIO_AMR_WB: return "amrwb"; case MimeTypes.AUDIO_FLAC: return "flac"; case MimeTypes.AUDIO_ALAC: return "alac"; case MimeTypes.AUDIO_RAW: if (encoding == C.ENCODING_PCM_MU_LAW) { return "pcm_mulaw"; } else if (encoding == C.ENCODING_PCM_A_LAW) { return "pcm_alaw"; } else { return null; } default: return null; } }
Example 16
Source File: FfmpegLibrary.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null} * if it's unsupported. */ /* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) { switch (mimeType) { case MimeTypes.AUDIO_AAC: return "aac"; case MimeTypes.AUDIO_MPEG: case MimeTypes.AUDIO_MPEG_L1: case MimeTypes.AUDIO_MPEG_L2: return "mp3"; case MimeTypes.AUDIO_AC3: return "ac3"; case MimeTypes.AUDIO_E_AC3: case MimeTypes.AUDIO_E_AC3_JOC: return "eac3"; case MimeTypes.AUDIO_TRUEHD: return "truehd"; case MimeTypes.AUDIO_DTS: case MimeTypes.AUDIO_DTS_HD: return "dca"; case MimeTypes.AUDIO_VORBIS: return "vorbis"; case MimeTypes.AUDIO_OPUS: return "opus"; case MimeTypes.AUDIO_AMR_NB: return "amrnb"; case MimeTypes.AUDIO_AMR_WB: return "amrwb"; case MimeTypes.AUDIO_FLAC: return "flac"; case MimeTypes.AUDIO_ALAC: return "alac"; case MimeTypes.AUDIO_RAW: if (encoding == C.ENCODING_PCM_MU_LAW) { return "pcm_mulaw"; } else if (encoding == C.ENCODING_PCM_A_LAW) { return "pcm_alaw"; } else { return null; } default: return null; } }