Commit 7c1b1c45 by samrobinson Committed by bachinger

Rename `onOutputFormatChanged`.

Clarify `Format` vs `MediaFormat` in MediaCodecRenderer.

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