Prevent frozen frames when the decoder is always late.
Create a MediaCodecVideoTrackRenderer.shouldDropFrame function that can be overriden by a child class. The YouTube override prevents a frame drop if we haven't rendered anything in the last 35 ms. The YouTube override is off at the moment, I plan to use a server side flag to do a slow and controlled experiment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142190774
This commit is contained in:
parent
65490f52f8
commit
6c4795b496
@ -403,7 +403,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
bufferPresentationTimeUs, unadjustedFrameReleaseTimeNs);
|
||||
earlyUs = (adjustedReleaseTimeNs - systemTimeNs) / 1000;
|
||||
|
||||
if (earlyUs < -30000) {
|
||||
if (shouldDropOutputBuffer(earlyUs, elapsedRealtimeUs)) {
|
||||
// We're more than 30ms late rendering the frame.
|
||||
dropOutputBuffer(codec, bufferIndex);
|
||||
return true;
|
||||
@ -437,6 +437,17 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current frame should be dropped.
|
||||
*
|
||||
* @param earlyUs Time indicating how early the frame is. Negative values indicate late frame.
|
||||
* @param elapsedRealtimeUs Wall clock time.
|
||||
*/
|
||||
protected boolean shouldDropOutputBuffer(long earlyUs, long elapsedRealtimeUs) {
|
||||
// Drop the frame if we're more than 30ms late rendering the frame.
|
||||
return earlyUs < -30000;
|
||||
}
|
||||
|
||||
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
|
||||
TraceUtil.beginSection("skipVideoBuffer");
|
||||
codec.releaseOutputBuffer(bufferIndex, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user