Skip to content

Commit

Permalink
Propagate non-standard MIME type aliases
Browse files Browse the repository at this point in the history
Issue: #5938
PiperOrigin-RevId: 261150349
  • Loading branch information
ojw28 committed Aug 1, 2019
1 parent 23ace19 commit 7162bd8
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 115 deletions.
6 changes: 4 additions & 2 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
ExoPlayer library classes.
* Switch normalized BCP-47 language codes to use 2-letter ISO 639-1 language
tags instead of 3-letter ISO 639-2 language tags.
* Ensure the `SilenceMediaSource` position is in range
([#6229](https://github.com/google/ExoPlayer/issues/6229)).
* Fix issue where initial seek positions get ignored when playing a preroll ad
([#6201](https://github.com/google/ExoPlayer/issues/6201)).
* Fix issue where invalid language tags were normalized to "und" instead of
keeping the original
([#6153](https://github.com/google/ExoPlayer/issues/6153)).
* Fix `DataSchemeDataSource` re-opening and range requests
([#6192](https://github.com/google/ExoPlayer/issues/6192)).
* Ensure the `SilenceMediaSource` position is in range
([#6229](https://github.com/google/ExoPlayer/issues/6229)).
* Fix Flac and ALAC playback on some LG devices
([#5938](https://github.com/google/ExoPlayer/issues/5938)).
* Flac extension: Parse `VORBIS_COMMENT` and `PICTURE` metadata
([#5527](https://github.com/google/ExoPlayer/issues/5527)).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected void configureCodec(
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
passthroughEnabled = codecInfo.passthrough;
String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.mimeType;
String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType;
MediaFormat mediaFormat =
getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ public final class MediaCodecInfo {
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.
* 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
* known.
*/
public final @Nullable CodecCapabilities capabilities;

Expand Down Expand Up @@ -98,6 +105,7 @@ public static MediaCodecInfo newPassthroughInstance(String name) {
return new MediaCodecInfo(
name,
/* mimeType= */ null,
/* codecMimeType= */ null,
/* capabilities= */ null,
/* passthrough= */ true,
/* forceDisableAdaptive= */ false,
Expand All @@ -109,49 +117,42 @@ public static MediaCodecInfo newPassthroughInstance(String name) {
*
* @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.
* @return The created instance.
*/
public static MediaCodecInfo newInstance(String name, String mimeType,
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.
* @param codecMimeType The MIME type that the codec uses for media of type {@code #mimeType}.
* Equal to {@code mimeType} unless the codec is known to use a non-standard MIME type alias.
* @param capabilities The capabilities of the {@link MediaCodec} for the specified mime type, or
* {@code null} if not known.
* @param forceDisableAdaptive Whether {@link #adaptive} should be forced to {@code false}.
* @param forceSecure Whether {@link #secure} should be forced to {@code true}.
* @return The created instance.
*/
public static MediaCodecInfo newInstance(
String name,
String mimeType,
CodecCapabilities capabilities,
String codecMimeType,
@Nullable CodecCapabilities capabilities,
boolean forceDisableAdaptive,
boolean forceSecure) {
return new MediaCodecInfo(
name, mimeType, capabilities, /* passthrough= */ false, forceDisableAdaptive, forceSecure);
name,
mimeType,
codecMimeType,
capabilities,
/* passthrough= */ false,
forceDisableAdaptive,
forceSecure);
}

private MediaCodecInfo(
String name,
@Nullable String mimeType,
@Nullable String codecMimeType,
@Nullable CodecCapabilities capabilities,
boolean passthrough,
boolean forceDisableAdaptive,
boolean forceSecure) {
this.name = Assertions.checkNotNull(name);
this.mimeType = mimeType;
this.codecMimeType = codecMimeType;
this.capabilities = capabilities;
this.passthrough = passthrough;
adaptive = !forceDisableAdaptive && capabilities != null && isAdaptive(capabilities);
Expand Down
Loading

0 comments on commit 7162bd8

Please sign in to comment.