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