mirror of
https://github.com/samsonjs/media.git
synced 2026-04-10 12:05:47 +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)).
|
||||
* 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)).
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue