Commit 6f5c7b38 by olly Committed by Oliver Woodman

Wait for first sync frame in MediaCodecRenderer

For the video renderer, it's not true that the source always
provides from a sync frame specifically in the case where
the surface has been replaced on the renderer. In this case
the source doesn't know that it should be providing from a
sync frame.

Issue: #2093

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145562222
parent 98db14e7
......@@ -201,6 +201,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
private boolean inputStreamEnded;
private boolean outputStreamEnded;
private boolean waitingForKeys;
private boolean waitingForFirstSyncFrame;
protected DecoderCounters decoderCounters;
......@@ -366,6 +367,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS) : C.TIME_UNSET;
inputIndex = C.INDEX_UNSET;
outputIndex = C.INDEX_UNSET;
waitingForFirstSyncFrame = true;
decoderCounters.decoderInitCount++;
}
......@@ -504,6 +506,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecHotswapDeadlineMs = C.TIME_UNSET;
inputIndex = C.INDEX_UNSET;
outputIndex = C.INDEX_UNSET;
waitingForFirstSyncFrame = true;
waitingForKeys = false;
shouldSkipOutputBuffer = false;
decodeOnlyPresentationTimestamps.clear();
......@@ -633,6 +636,16 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
return false;
}
if (waitingForFirstSyncFrame && !buffer.isKeyFrame()) {
buffer.clear();
if (codecReconfigurationState == RECONFIGURATION_STATE_QUEUE_PENDING) {
// The buffer we just cleared contained reconfiguration data. We need to re-write this
// data into a subsequent buffer (if there is one).
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
}
return true;
}
waitingForFirstSyncFrame = false;
boolean bufferEncrypted = buffer.isEncrypted();
waitingForKeys = shouldWaitForKeys(bufferEncrypted);
if (waitingForKeys) {
......
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