mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Rename onOutputFormatChanged.
Clarify `Format` vs `MediaFormat` in MediaCodecRenderer. PiperOrigin-RevId: 283353651
This commit is contained in:
parent
63d1086715
commit
7c1b1c456b
4 changed files with 16 additions and 13 deletions
|
|
@ -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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
* @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 {
|
||||||
|
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 {
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue