Commit 92269ff7 by aquilescanta Committed by Andrew Lewis

Make MediaCodecRenderer#onInputFormatChanged take a FormatHolder

PiperOrigin-RevId: 244056421
parent 4d6aca76
...@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.C; ...@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.PlayerMessage.Target; import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.audio.AudioRendererEventListener.EventDispatcher; import com.google.android.exoplayer2.audio.AudioRendererEventListener.EventDispatcher;
...@@ -419,8 +420,9 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -419,8 +420,9 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
} }
@Override @Override
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
super.onInputFormatChanged(newFormat); super.onInputFormatChanged(formatHolder);
Format newFormat = formatHolder.format;
eventDispatcher.inputFormatChanged(newFormat); eventDispatcher.inputFormatChanged(newFormat);
// If the input format is anything other than PCM then we assume that the audio decoder will // If the input format is anything other than PCM then we assume that the audio decoder will
// output 16-bit PCM. // output 16-bit PCM.
......
...@@ -726,7 +726,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -726,7 +726,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
flagsOnlyBuffer.clear(); flagsOnlyBuffer.clear();
int result = readSource(formatHolder, flagsOnlyBuffer, requireFormat); int result = readSource(formatHolder, flagsOnlyBuffer, requireFormat);
if (result == C.RESULT_FORMAT_READ) { if (result == C.RESULT_FORMAT_READ) {
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
return true; return true;
} else if (result == C.RESULT_BUFFER_READ && flagsOnlyBuffer.isEndOfStream()) { } else if (result == C.RESULT_BUFFER_READ && flagsOnlyBuffer.isEndOfStream()) {
inputStreamEnded = true; inputStreamEnded = true;
...@@ -1029,7 +1029,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1029,7 +1029,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
buffer.clear(); buffer.clear();
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING; codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
} }
onInputFormatChanged(formatHolder.format); onInputFormatChanged(formatHolder);
return true; return true;
} }
...@@ -1141,11 +1141,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1141,11 +1141,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
/** /**
* Called when a new format is read from the upstream {@link MediaPeriod}. * Called when a new format is read from the upstream {@link MediaPeriod}.
* *
* @param newFormat The new format. * @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
* @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}. * @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}.
*/ */
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
Format oldFormat = inputFormat; Format oldFormat = inputFormat;
Format newFormat = formatHolder.format;
inputFormat = newFormat; inputFormat = newFormat;
waitingForFirstSampleInFormat = true; waitingForFirstSampleInFormat = true;
......
...@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.C; ...@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.PlayerMessage.Target; import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
...@@ -631,8 +632,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -631,8 +632,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
} }
@Override @Override
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
super.onInputFormatChanged(newFormat); super.onInputFormatChanged(formatHolder);
Format newFormat = formatHolder.format;
eventDispatcher.inputFormatChanged(newFormat); eventDispatcher.inputFormatChanged(newFormat);
pendingPixelWidthHeightRatio = newFormat.pixelWidthHeightRatio; pendingPixelWidthHeightRatio = newFormat.pixelWidthHeightRatio;
pendingRotationDegrees = newFormat.rotationDegrees; pendingRotationDegrees = newFormat.rotationDegrees;
......
...@@ -24,6 +24,7 @@ import androidx.annotation.Nullable; ...@@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
...@@ -141,8 +142,8 @@ public class DebugRenderersFactory extends DefaultRenderersFactory { ...@@ -141,8 +142,8 @@ public class DebugRenderersFactory extends DefaultRenderersFactory {
} }
@Override @Override
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
super.onInputFormatChanged(newFormat); super.onInputFormatChanged(formatHolder);
// Ensure timestamps of buffers queued after this format change are never inserted into the // Ensure timestamps of buffers queued after this format change are never inserted into the
// queue of expected output timestamps before those of buffers that have already been queued. // queue of expected output timestamps before those of buffers that have already been queued.
minimumInsertIndex = startIndex + queueSize; minimumInsertIndex = startIndex + queueSize;
......
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