Skip to content

Commit

Permalink
Use the codec MIME type for configuration
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewlewis authored and ojw28 committed May 7, 2018
1 parent a07471d commit 5926e20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
* Fix an issue where playback of TrueHD streams would get stuck after seeking
due to not finding a syncframe
((#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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,14 @@ protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format
MediaCrypto crypto) {
codecMaxInputSize = getCodecMaxInputSize(format, getStreamFormats());
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) {
// 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.setString(MediaFormat.KEY_MIME, MimeTypes.AUDIO_RAW);
codec.configure(passthroughMediaFormat, null, crypto, 0);
passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
} else {
codec.configure(mediaFormat, null, crypto, 0);
passthroughMediaFormat = null;
}
}
Expand Down Expand Up @@ -535,13 +534,15 @@ protected int getCodecMaxInputSize(Format format, Format[] streamFormats) {
* for decoding the given {@link Format} for playback.
*
* @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.
*/
@SuppressLint("InlinedApi")
protected MediaFormat getMediaFormat(Format format, int codecMaxInputSize) {
protected MediaFormat getMediaFormat(Format format, String codecMimeType, int codecMaxInputSize) {
MediaFormat mediaFormat = new MediaFormat();
// 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_SAMPLE_RATE, format.sampleRate);
MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public final class MediaCodecInfo {
*/
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.
*
Expand All @@ -76,14 +85,6 @@ public final class MediaCodecInfo {
*/
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.
*
Expand Down Expand Up @@ -134,13 +135,13 @@ public static MediaCodecInfo newInstance(

private MediaCodecInfo(
String name,
String mimeType,
@Nullable String mimeType,
@Nullable CodecCapabilities capabilities,
boolean forceDisableAdaptive,
boolean forceSecure) {
this.name = Assertions.checkNotNull(name);
this.capabilities = capabilities;
this.mimeType = mimeType;
this.capabilities = capabilities;
adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities);
tunneling = capabilities != null && isTunneling(capabilities);
secure = forceSecure || (capabilities != null && isSecure(capabilities));
Expand Down

0 comments on commit 5926e20

Please sign in to comment.