Commit 5926e201 by andrewlewis Committed by Oliver Woodman

Use the codec MIME type for configuration

This may differ from the format MIME type for audio/eac3-joc.

Issue: #4165

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193906521
parent a07471dd
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
* Fix an issue where playback of TrueHD streams would get stuck after seeking * Fix an issue where playback of TrueHD streams would get stuck after seeking
due to not finding a syncframe due to not finding a syncframe
((#3845)[https://github.com/google/ExoPlayer/issues/3845]). ((#3845)[https://github.com/google/ExoPlayer/issues/3845]).
* Fix an issue with eac3-joc playback where a codec would fail to configure
((#4165)[https://github.com/google/ExoPlayer/issues/4165]).
* Handle non-empty end-of-stream buffers, to fix gapless playback of streams * Handle non-empty end-of-stream buffers, to fix gapless playback of streams
with encoder padding when the decoder returns a non-empty final buffer. with encoder padding when the decoder returns a non-empty final buffer.
* Allow trimming more than one sample when applying an elst audio edit via * Allow trimming more than one sample when applying an elst audio edit via
......
...@@ -259,15 +259,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -259,15 +259,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
MediaCrypto crypto) { MediaCrypto crypto) {
codecMaxInputSize = getCodecMaxInputSize(format, getStreamFormats()); codecMaxInputSize = getCodecMaxInputSize(format, getStreamFormats());
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
MediaFormat mediaFormat = getMediaFormat(format, codecMaxInputSize); String codecMimeType = codecInfo.mimeType == null ? MimeTypes.AUDIO_RAW : codecInfo.mimeType;
MediaFormat mediaFormat = getMediaFormat(format, codecMimeType, codecMaxInputSize);
codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
if (passthroughEnabled) { if (passthroughEnabled) {
// Override the MIME type used to configure the codec if we are using a passthrough decoder. // Store the input MIME type if we're using the passthrough codec.
passthroughMediaFormat = mediaFormat; passthroughMediaFormat = mediaFormat;
passthroughMediaFormat.setString(MediaFormat.KEY_MIME, MimeTypes.AUDIO_RAW);
codec.configure(passthroughMediaFormat, null, crypto, 0);
passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
} else { } else {
codec.configure(mediaFormat, null, crypto, 0);
passthroughMediaFormat = null; passthroughMediaFormat = null;
} }
} }
...@@ -535,13 +534,15 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -535,13 +534,15 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
* for decoding the given {@link Format} for playback. * for decoding the given {@link Format} for playback.
* *
* @param format The format of the media. * @param format The format of the media.
* @param codecMimeType The MIME type handled by the codec.
* @param codecMaxInputSize The maximum input size supported by the codec.
* @return The framework media format. * @return The framework media format.
*/ */
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
protected MediaFormat getMediaFormat(Format format, int codecMaxInputSize) { protected MediaFormat getMediaFormat(Format format, String codecMimeType, int codecMaxInputSize) {
MediaFormat mediaFormat = new MediaFormat(); MediaFormat mediaFormat = new MediaFormat();
// Set format parameters that should always be set. // Set format parameters that should always be set.
mediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType); mediaFormat.setString(MediaFormat.KEY_MIME, codecMimeType);
mediaFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, format.channelCount); mediaFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, format.channelCount);
mediaFormat.setInteger(MediaFormat.KEY_SAMPLE_RATE, format.sampleRate); mediaFormat.setInteger(MediaFormat.KEY_SAMPLE_RATE, format.sampleRate);
MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData); MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
......
...@@ -52,6 +52,15 @@ public final class MediaCodecInfo { ...@@ -52,6 +52,15 @@ public final class MediaCodecInfo {
*/ */
public final String name; public final String name;
/** The MIME type handled by the codec, or {@code null} if this is a passthrough codec. */
public final @Nullable String mimeType;
/**
* The capabilities of the decoder, like the profiles/levels it supports, or {@code null} if this
* is a passthrough codec.
*/
public final @Nullable CodecCapabilities capabilities;
/** /**
* Whether the decoder supports seamless resolution switches. * Whether the decoder supports seamless resolution switches.
* *
...@@ -77,14 +86,6 @@ public final class MediaCodecInfo { ...@@ -77,14 +86,6 @@ public final class MediaCodecInfo {
public final boolean secure; public final boolean secure;
/** /**
* The capabilities of the decoder, like the profiles/levels it supports, or {@code null} if this
* is a passthrough codec.
*/
public final @Nullable CodecCapabilities capabilities;
private final String mimeType;
/**
* Creates an instance representing an audio passthrough decoder. * Creates an instance representing an audio passthrough decoder.
* *
* @param name The name of the {@link MediaCodec}. * @param name The name of the {@link MediaCodec}.
...@@ -134,13 +135,13 @@ public final class MediaCodecInfo { ...@@ -134,13 +135,13 @@ public final class MediaCodecInfo {
private MediaCodecInfo( private MediaCodecInfo(
String name, String name,
String mimeType, @Nullable String mimeType,
@Nullable CodecCapabilities capabilities, @Nullable CodecCapabilities capabilities,
boolean forceDisableAdaptive, boolean forceDisableAdaptive,
boolean forceSecure) { boolean forceSecure) {
this.name = Assertions.checkNotNull(name); this.name = Assertions.checkNotNull(name);
this.capabilities = capabilities;
this.mimeType = mimeType; this.mimeType = mimeType;
this.capabilities = capabilities;
adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities); adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities);
tunneling = capabilities != null && isTunneling(capabilities); tunneling = capabilities != null && isTunneling(capabilities);
secure = forceSecure || (capabilities != null && isSecure(capabilities)); secure = forceSecure || (capabilities != null && isSecure(capabilities));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment