Commit 42d3ca27 by olly Committed by Oliver Woodman

Propagate non-standard MIME type aliases

Issue: #5938
PiperOrigin-RevId: 261150349
parent 4c40878b
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
the `Player` set later using `AnalyticsCollector.setPlayer`. the `Player` set later using `AnalyticsCollector.setPlayer`.
* Calculate correct duration for clipped WAV streams * Calculate correct duration for clipped WAV streams
([#6241](https://github.com/google/ExoPlayer/issues/6241)). ([#6241](https://github.com/google/ExoPlayer/issues/6241)).
* Fix Flac and ALAC playback on some LG devices
([#5938](https://github.com/google/ExoPlayer/issues/5938)).
### 2.10.4 ### ### 2.10.4 ###
......
...@@ -392,7 +392,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -392,7 +392,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name); codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
passthroughEnabled = codecInfo.passthrough; passthroughEnabled = codecInfo.passthrough;
String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.mimeType; String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType;
MediaFormat mediaFormat = MediaFormat mediaFormat =
getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate); getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
......
...@@ -54,6 +54,13 @@ public final class MediaCodecInfo { ...@@ -54,6 +54,13 @@ public final class MediaCodecInfo {
@Nullable public final String mimeType; @Nullable public final String mimeType;
/** /**
* The MIME type that the codec uses for media of type {@link #mimeType}, or {@code null} if this
* is a passthrough codec. Equal to {@link #mimeType} unless the codec is known to use a
* non-standard MIME type alias.
*/
@Nullable public final String codecMimeType;
/**
* The capabilities of the decoder, like the profiles/levels it supports, or {@code null} if not * The capabilities of the decoder, like the profiles/levels it supports, or {@code null} if not
* known. * known.
*/ */
...@@ -98,6 +105,7 @@ public final class MediaCodecInfo { ...@@ -98,6 +105,7 @@ public final class MediaCodecInfo {
return new MediaCodecInfo( return new MediaCodecInfo(
name, name,
/* mimeType= */ null, /* mimeType= */ null,
/* codecMimeType= */ null,
/* capabilities= */ null, /* capabilities= */ null,
/* passthrough= */ true, /* passthrough= */ true,
/* forceDisableAdaptive= */ false, /* forceDisableAdaptive= */ false,
...@@ -109,26 +117,8 @@ public final class MediaCodecInfo { ...@@ -109,26 +117,8 @@ public final class MediaCodecInfo {
* *
* @param name The name of the {@link MediaCodec}. * @param name The name of the {@link MediaCodec}.
* @param mimeType A mime type supported by the {@link MediaCodec}. * @param mimeType A mime type supported by the {@link MediaCodec}.
* @param capabilities The capabilities of the {@link MediaCodec} for the specified mime type, or * @param codecMimeType The MIME type that the codec uses for media of type {@code #mimeType}.
* {@code null} if not known. * Equal to {@code mimeType} unless the codec is known to use a non-standard MIME type alias.
* @return The created instance.
*/
public static MediaCodecInfo newInstance(
String name, String mimeType, @Nullable CodecCapabilities capabilities) {
return new MediaCodecInfo(
name,
mimeType,
capabilities,
/* passthrough= */ false,
/* forceDisableAdaptive= */ false,
/* forceSecure= */ false);
}
/**
* Creates an instance.
*
* @param name The name of the {@link MediaCodec}.
* @param mimeType A mime type supported by the {@link MediaCodec}.
* @param capabilities The capabilities of the {@link MediaCodec} for the specified mime type, or * @param capabilities The capabilities of the {@link MediaCodec} for the specified mime type, or
* {@code null} if not known. * {@code null} if not known.
* @param forceDisableAdaptive Whether {@link #adaptive} should be forced to {@code false}. * @param forceDisableAdaptive Whether {@link #adaptive} should be forced to {@code false}.
...@@ -138,22 +128,31 @@ public final class MediaCodecInfo { ...@@ -138,22 +128,31 @@ public final class MediaCodecInfo {
public static MediaCodecInfo newInstance( public static MediaCodecInfo newInstance(
String name, String name,
String mimeType, String mimeType,
String codecMimeType,
@Nullable CodecCapabilities capabilities, @Nullable CodecCapabilities capabilities,
boolean forceDisableAdaptive, boolean forceDisableAdaptive,
boolean forceSecure) { boolean forceSecure) {
return new MediaCodecInfo( return new MediaCodecInfo(
name, mimeType, capabilities, /* passthrough= */ false, forceDisableAdaptive, forceSecure); name,
mimeType,
codecMimeType,
capabilities,
/* passthrough= */ false,
forceDisableAdaptive,
forceSecure);
} }
private MediaCodecInfo( private MediaCodecInfo(
String name, String name,
@Nullable String mimeType, @Nullable String mimeType,
@Nullable String codecMimeType,
@Nullable CodecCapabilities capabilities, @Nullable CodecCapabilities capabilities,
boolean passthrough, boolean passthrough,
boolean forceDisableAdaptive, boolean forceDisableAdaptive,
boolean forceSecure) { boolean forceSecure) {
this.name = Assertions.checkNotNull(name); this.name = Assertions.checkNotNull(name);
this.mimeType = mimeType; this.mimeType = mimeType;
this.codecMimeType = codecMimeType;
this.capabilities = capabilities; this.capabilities = capabilities;
this.passthrough = passthrough; this.passthrough = passthrough;
adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities); adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities);
......
...@@ -603,10 +603,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -603,10 +603,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
Format format, Format format,
MediaCrypto crypto, MediaCrypto crypto,
float codecOperatingRate) { float codecOperatingRate) {
String codecMimeType = codecInfo.codecMimeType;
codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats()); codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
MediaFormat mediaFormat = MediaFormat mediaFormat =
getMediaFormat( getMediaFormat(
format, format,
codecMimeType,
codecMaxValues, codecMaxValues,
codecOperatingRate, codecOperatingRate,
deviceNeedsNoPostProcessWorkaround, deviceNeedsNoPostProcessWorkaround,
...@@ -1164,6 +1166,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -1164,6 +1166,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* Returns the framework {@link MediaFormat} that should be used to configure the decoder. * Returns the framework {@link MediaFormat} that should be used to configure the decoder.
* *
* @param format The format of media. * @param format The format of media.
* @param codecMimeType The MIME type handled by the codec.
* @param codecMaxValues Codec max values that should be used when configuring the decoder. * @param codecMaxValues Codec max values that should be used when configuring the decoder.
* @param codecOperatingRate The codec operating rate, or {@link #CODEC_OPERATING_RATE_UNSET} if * @param codecOperatingRate The codec operating rate, or {@link #CODEC_OPERATING_RATE_UNSET} if
* no codec operating rate should be set. * no codec operating rate should be set.
...@@ -1176,13 +1179,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -1176,13 +1179,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
protected MediaFormat getMediaFormat( protected MediaFormat getMediaFormat(
Format format, Format format,
String codecMimeType,
CodecMaxValues codecMaxValues, CodecMaxValues codecMaxValues,
float codecOperatingRate, float codecOperatingRate,
boolean deviceNeedsNoPostProcessWorkaround, boolean deviceNeedsNoPostProcessWorkaround,
int tunnelingAudioSessionId) { int tunnelingAudioSessionId) {
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_WIDTH, format.width); mediaFormat.setInteger(MediaFormat.KEY_WIDTH, format.width);
mediaFormat.setInteger(MediaFormat.KEY_HEIGHT, format.height); mediaFormat.setInteger(MediaFormat.KEY_HEIGHT, format.height);
MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData); MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
......
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