From c02488f0f9392f7a674e3817e3b1939a349d52cc Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Tue, 2 Jul 2024 07:59:58 -0700 Subject: [PATCH] Log last decoded frame rtp timestamp in addition to last received frame rtp timestamp. This helps in cases where frames continue to be received but the decoder fails to decode. BUG=None Change-Id: I56ad5f9ef85cc598d3c1a1971c4c697eb6b70165 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/356080 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Philipp Hancke Reviewed-by: Markus Handell Cr-Commit-Position: refs/heads/main@{#42596} --- video/video_receive_stream2.cc | 8 +++++++- video/video_receive_stream2.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index f3a7c329a6..dccf1e9580 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -783,13 +783,14 @@ void VideoReceiveStream2::OnEncodedFrame(std::unique_ptr frame) { RTC_DCHECK_RUN_ON(&decode_sequence_checker_); if (decoder_stopped_) return; + uint32_t rtp_timestamp = frame->RtpTimestamp(); DecodeFrameResult result = HandleEncodedFrameOnDecodeQueue( std::move(frame), keyframe_request_is_due, keyframe_required); // TODO(bugs.webrtc.org/11993): Make this PostTask to the network thread. call_->worker_thread()->PostTask( SafeTask(task_safety_.flag(), - [this, now, result = std::move(result), + [this, now, rtp_timestamp, result = std::move(result), received_frame_is_keyframe, keyframe_request_is_due]() { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); keyframe_required_ = result.keyframe_required; @@ -798,6 +799,7 @@ void VideoReceiveStream2::OnEncodedFrame(std::unique_ptr frame) { rtp_video_stream_receiver_.FrameDecoded( *result.decoded_frame_picture_id); } + last_decoded_rtp_timestamp_ = rtp_timestamp; HandleKeyFrameGeneration(received_frame_is_keyframe, now, result.force_request_key_frame, @@ -832,6 +834,10 @@ void VideoReceiveStream2::OnDecodableFrameTimeout(TimeDelta wait) { << " requesting keyframe. Last RTP timestamp " << (last_timestamp ? rtc::ToString(*last_timestamp) : "") + << ", last decoded frame RTP timestamp " + << (last_decoded_rtp_timestamp_ + ? rtc::ToString(*last_decoded_rtp_timestamp_) + : "") << "."; RequestKeyFrame(now); } diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 05e719c39c..b6e86b2cc9 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -350,6 +350,8 @@ class VideoReceiveStream2 // destructed to avoid races when running tasks on the `decode_queue_` during // VideoReceiveStream2 destruction. std::unique_ptr decode_queue_; + + absl::optional last_decoded_rtp_timestamp_; }; } // namespace internal