diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9fcd586452..b0b7351c3d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -14,6 +14,9 @@ ([#6601](https://github.com/google/ExoPlayer/issues/6601)). * Make `MediaSourceEventListener.LoadEventInfo` and `MediaSourceEventListener.MediaLoadData` top-level classes. +* Rename `MediaCodecRenderer.onOutputFormatChanged` to + `MediaCodecRenderer.onOutputMediaFormatChanged`, further + clarifying the distinction between `Format` and `MediaFormat`. * Downloads: Merge downloads in `SegmentDownloader` to improve overall download speed ([#5978](https://github.com/google/ExoPlayer/issues/5978)). diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java index a6a8b03448..d5927196c0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java @@ -475,10 +475,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media protected @KeepCodecResult int canKeepCodec( MediaCodec codec, MediaCodecInfo codecInfo, Format oldFormat, Format newFormat) { // TODO: We currently rely on recreating the codec when encoder delay or padding is non-zero. - // Re-creating the codec is necessary to guarantee that onOutputFormatChanged is called, which - // is where encoder delay and padding are propagated to the sink. We should find a better way to - // propagate these values, and then allow the codec to be re-used in cases where this would - // otherwise be possible. + // Re-creating the codec is necessary to guarantee that onOutputMediaFormatChanged is called, + // which is where encoder delay and padding are propagated to the sink. We should find a better + // way to propagate these values, and then allow the codec to be re-used in cases where this + // would otherwise be possible. if (getCodecMaxInputSize(codecInfo, newFormat) > codecMaxInputSize || oldFormat.encoderDelay != 0 || oldFormat.encoderPadding != 0 @@ -558,7 +558,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media } @Override - protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) + protected void onOutputMediaFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) throws ExoPlaybackException { @C.Encoding int encoding; MediaFormat mediaFormat; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index 84780d72c2..78eda88b4b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -1387,7 +1387,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * @param outputMediaFormat The new output {@link MediaFormat}. * @throws ExoPlaybackException Thrown if an error occurs handling the new output media format. */ - protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) + protected void onOutputMediaFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) throws ExoPlaybackException { // Do nothing. } @@ -1584,7 +1584,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { if (outputIndex < 0) { if (outputIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED /* (-2) */) { - processOutputFormat(); + processOutputMediaFormat(); return true; } else if (outputIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED /* (-3) */) { processOutputBuffersChanged(); @@ -1676,7 +1676,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { } /** Processes a new output {@link MediaFormat}. */ - private void processOutputFormat() throws ExoPlaybackException { + private void processOutputMediaFormat() throws ExoPlaybackException { MediaFormat mediaFormat = codecAdapter.getOutputFormat(); if (codecAdaptationWorkaroundMode != ADAPTATION_WORKAROUND_MODE_NEVER && mediaFormat.getInteger(MediaFormat.KEY_WIDTH) == ADAPTATION_WORKAROUND_SLICE_WIDTH_HEIGHT @@ -1689,7 +1689,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { if (codecNeedsMonoChannelCountWorkaround) { mediaFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1); } - onOutputFormatChanged(codec, mediaFormat); + onOutputMediaFormatChanged(codec, mediaFormat); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java index 38ac80bf26..dd125cc7b0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java @@ -773,26 +773,26 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { } @Override - protected void onOutputFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) { + protected void onOutputMediaFormatChanged(MediaCodec codec, MediaFormat outputMediaFormat) { currentMediaFormat = outputMediaFormat; boolean hasCrop = outputMediaFormat.containsKey(KEY_CROP_RIGHT) && outputMediaFormat.containsKey(KEY_CROP_LEFT) && outputMediaFormat.containsKey(KEY_CROP_BOTTOM) && outputMediaFormat.containsKey(KEY_CROP_TOP); - int width = + int mediaFormatWidth = hasCrop ? outputMediaFormat.getInteger(KEY_CROP_RIGHT) - outputMediaFormat.getInteger(KEY_CROP_LEFT) + 1 : outputMediaFormat.getInteger(MediaFormat.KEY_WIDTH); - int height = + int mediaFormatHeight = hasCrop ? outputMediaFormat.getInteger(KEY_CROP_BOTTOM) - outputMediaFormat.getInteger(KEY_CROP_TOP) + 1 : outputMediaFormat.getInteger(MediaFormat.KEY_HEIGHT); - processOutputFormat(codec, width, height); + processOutputFormat(codec, mediaFormatWidth, mediaFormatHeight); } @Override