From bd64dfb661abaf20a453f269bb0db6a35f1dc0d9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 May 2022 22:10:49 -0500 Subject: [PATCH] Submit codec config data with a timestamp of 0 like MediaCodec does with csd-0 --- .../video/MediaCodecDecoderRenderer.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index 60cc01bd..92c95174 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -772,17 +772,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C int inputBufferIndex; ByteBuffer buf; - - long timestampUs = enqueueTimeMs * 1000; - - if (timestampUs <= lastTimestampUs) { - // We can't submit multiple buffers with the same timestamp - // so bump it up by one before queuing - timestampUs = lastTimestampUs + 1; - } - - lastTimestampUs = timestampUs; - + long timestampUs; int codecFlags = 0; // H264 SPS @@ -948,6 +938,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C // This is the CSD blob codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG; + timestampUs = 0; } else { // Batch this to submit together with the next I-frame @@ -1001,6 +992,16 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C codecFlags |= MediaCodec.BUFFER_FLAG_SYNC_FRAME; } + timestampUs = enqueueTimeMs * 1000; + + if (timestampUs <= lastTimestampUs) { + // We can't submit multiple buffers with the same timestamp + // so bump it up by one before queuing + timestampUs = lastTimestampUs + 1; + } + + lastTimestampUs = timestampUs; + numFramesIn++; } @@ -1071,8 +1072,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C // Queue the new SPS return queueInputBuffer(inputIndex, 0, inputBuffer.position(), - System.nanoTime() / 1000, - MediaCodec.BUFFER_FLAG_CODEC_CONFIG); + 0, MediaCodec.BUFFER_FLAG_CODEC_CONFIG); } @Override