mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
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
This commit is contained in:
parent
a07471ddef
commit
5926e20105
3 changed files with 21 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -259,15 +259,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -535,13 +534,15 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
* 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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -134,13 +135,13 @@ public final class MediaCodecInfo {
|
|||
|
||||
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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue