Report dropped frames from the VideoSink

After 4fad529433, MediaCodecVideoRenderer does not report if frames
are dropped from the VideoSink. This commit fixes this.

#minor-release

PiperOrigin-RevId: 571905721
This commit is contained in:
christosts 2023-10-09 05:01:37 -07:00 committed by Copybara-Service
parent 3ed7e561bb
commit 05b17b5430
4 changed files with 15 additions and 1 deletions

View File

@ -552,7 +552,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private void releaseProcessedFrameInternal(long releaseTimeNs, boolean isLastFrame) {
videoFrameProcessor.renderOutputFrame(releaseTimeNs);
processedFramesBufferTimestampsUs.remove();
if (releaseTimeNs != VideoFrameProcessor.DROP_OUTPUT_FRAME) {
if (releaseTimeNs == VideoFrameProcessor.DROP_OUTPUT_FRAME) {
renderControl.onFrameDropped();
} else {
renderControl.onFrameRendered();
if (!renderedFirstFrame) {
if (listener != null) {

View File

@ -564,6 +564,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer implements Video
lastRenderRealtimeUs = Util.msToUs(getClock().elapsedRealtime());
}
@Override
public void onFrameDropped() {
updateDroppedBufferCounters(
/* droppedInputBufferCount= */ 0, /* droppedDecoderBufferCount= */ 1);
}
// Other methods
/**

View File

@ -100,6 +100,9 @@ import java.util.concurrent.Executor;
/** Informs the rendering control that a video frame was rendered. */
void onFrameRendered();
/** Informs the rendering control that a video frame was dropped. */
void onFrameDropped();
}
/**

View File

@ -175,5 +175,8 @@ public final class CompositingVideoSinkProviderTest {
@Override
public void onFrameRendered() {}
@Override
public void onFrameDropped() {}
}
}