mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
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
This commit is contained in:
parent
98db14e7e5
commit
6f5c7b38a7
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user