Commit efe8f09f by andrewlewis Committed by Oliver Woodman

Propagate EoS in renderer when using video tunneling

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210529471
parent 23817eec
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
* Scale up the initial video decoder maximum input size so playlist item * Scale up the initial video decoder maximum input size so playlist item
transitions with small increases in maximum sample size don't require transitions with small increases in maximum sample size don't require
reinitialization ([#4510](https://github.com/google/ExoPlayer/issues/4510)). reinitialization ([#4510](https://github.com/google/ExoPlayer/issues/4510)).
* Propagate the end-of-stream signal directly in the renderer when using
tunneling, to fix an issue where the player would remain ready after the
stream ended.
* Allow apps to pass a `CacheKeyFactory` for setting custom cache keys when * Allow apps to pass a `CacheKeyFactory` for setting custom cache keys when
creating a `CacheDataSource`. creating a `CacheDataSource`.
* Turned on Java 8 compiler support for the ExoPlayer library. Apps that depend * Turned on Java 8 compiler support for the ExoPlayer library. Apps that depend
......
...@@ -292,12 +292,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -292,12 +292,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
private @AdaptationWorkaroundMode int codecAdaptationWorkaroundMode; private @AdaptationWorkaroundMode int codecAdaptationWorkaroundMode;
private boolean codecNeedsDiscardToSpsWorkaround; private boolean codecNeedsDiscardToSpsWorkaround;
private boolean codecNeedsFlushWorkaround; private boolean codecNeedsFlushWorkaround;
private boolean codecNeedsEosPropagationWorkaround;
private boolean codecNeedsEosFlushWorkaround; private boolean codecNeedsEosFlushWorkaround;
private boolean codecNeedsEosOutputExceptionWorkaround; private boolean codecNeedsEosOutputExceptionWorkaround;
private boolean codecNeedsMonoChannelCountWorkaround; private boolean codecNeedsMonoChannelCountWorkaround;
private boolean codecNeedsAdaptationWorkaroundBuffer; private boolean codecNeedsAdaptationWorkaroundBuffer;
private boolean shouldSkipAdaptationWorkaroundOutputBuffer; private boolean shouldSkipAdaptationWorkaroundOutputBuffer;
private boolean codecNeedsEosPropagation;
private ByteBuffer[] inputBuffers; private ByteBuffer[] inputBuffers;
private ByteBuffer[] outputBuffers; private ByteBuffer[] outputBuffers;
private long codecHotswapDeadlineMs; private long codecHotswapDeadlineMs;
...@@ -468,10 +468,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -468,10 +468,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName); codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName);
codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format); codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName); codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
codecNeedsEosPropagationWorkaround = codecNeedsEosPropagationWorkaround(codecInfo);
codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName); codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName); codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
codecNeedsMonoChannelCountWorkaround = codecNeedsMonoChannelCountWorkaround(codecName, format); codecNeedsMonoChannelCountWorkaround = codecNeedsMonoChannelCountWorkaround(codecName, format);
codecNeedsEosPropagation =
codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();
codecHotswapDeadlineMs = codecHotswapDeadlineMs =
getState() == STATE_STARTED getState() == STATE_STARTED
? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS) ? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS)
...@@ -486,6 +487,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -486,6 +487,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return true; return true;
} }
/**
* Returns whether the codec needs the renderer to propagate the end-of-stream signal directly,
* rather than by using an end-of-stream buffer queued to the codec.
*/
protected boolean getCodecNeedsEosPropagation() {
return false;
}
protected final MediaCodec getCodec() { protected final MediaCodec getCodec() {
return codec; return codec;
} }
...@@ -553,11 +562,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -553,11 +562,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecNeedsDiscardToSpsWorkaround = false; codecNeedsDiscardToSpsWorkaround = false;
codecNeedsFlushWorkaround = false; codecNeedsFlushWorkaround = false;
codecAdaptationWorkaroundMode = ADAPTATION_WORKAROUND_MODE_NEVER; codecAdaptationWorkaroundMode = ADAPTATION_WORKAROUND_MODE_NEVER;
codecNeedsEosPropagationWorkaround = false;
codecNeedsEosFlushWorkaround = false; codecNeedsEosFlushWorkaround = false;
codecNeedsMonoChannelCountWorkaround = false; codecNeedsMonoChannelCountWorkaround = false;
codecNeedsAdaptationWorkaroundBuffer = false; codecNeedsAdaptationWorkaroundBuffer = false;
shouldSkipAdaptationWorkaroundOutputBuffer = false; shouldSkipAdaptationWorkaroundOutputBuffer = false;
codecNeedsEosPropagation = false;
codecReceivedEos = false; codecReceivedEos = false;
codecReconfigurationState = RECONFIGURATION_STATE_NONE; codecReconfigurationState = RECONFIGURATION_STATE_NONE;
codecReinitializationState = REINITIALIZATION_STATE_NONE; codecReinitializationState = REINITIALIZATION_STATE_NONE;
...@@ -855,7 +864,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -855,7 +864,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
if (codecReinitializationState == REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM) { if (codecReinitializationState == REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM) {
// We need to re-initialize the codec. Send an end of stream signal to the existing codec so // We need to re-initialize the codec. Send an end of stream signal to the existing codec so
// that it outputs any remaining buffers before we release it. // that it outputs any remaining buffers before we release it.
if (codecNeedsEosPropagationWorkaround) { if (codecNeedsEosPropagation) {
// Do nothing. // Do nothing.
} else { } else {
codecReceivedEos = true; codecReceivedEos = true;
...@@ -923,7 +932,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -923,7 +932,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return false; return false;
} }
try { try {
if (codecNeedsEosPropagationWorkaround) { if (codecNeedsEosPropagation) {
// Do nothing. // Do nothing.
} else { } else {
codecReceivedEos = true; codecReceivedEos = true;
...@@ -1254,7 +1263,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1254,7 +1263,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return true; return true;
} }
/* MediaCodec.INFO_TRY_AGAIN_LATER (-1) or unknown negative return value */ /* MediaCodec.INFO_TRY_AGAIN_LATER (-1) or unknown negative return value */
if (codecNeedsEosPropagationWorkaround if (codecNeedsEosPropagation
&& (inputStreamEnded && (inputStreamEnded
|| codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM)) { || codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM)) {
processEndOfStream(); processEndOfStream();
......
...@@ -448,6 +448,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -448,6 +448,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
} }
@Override @Override
protected boolean getCodecNeedsEosPropagation() {
// In tunneling mode we can't dequeue an end-of-stream buffer, so propagate it in the renderer.
return tunneling;
}
@Override
protected void configureCodec( protected void configureCodec(
MediaCodecInfo codecInfo, MediaCodecInfo codecInfo,
MediaCodec codec, MediaCodec codec,
......
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