From b84931107c9fc4aa43b8f2a6548c7e1bad0bfe37 Mon Sep 17 00:00:00 2001 From: philipel Date: Fri, 16 Apr 2021 12:10:22 +0200 Subject: [PATCH] Update last received keyframe packet timestamp on all packets with the same RTP timestamp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:12579,webrtc:12680 Change-Id: Id6e7b2c4199f52b3872ad407d8b602bed8b6cf3a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215325 Reviewed-by: Erik Språng Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#33770} --- video/rtp_video_stream_receiver.cc | 10 +++++++++- video/rtp_video_stream_receiver.h | 2 ++ video/rtp_video_stream_receiver2.cc | 7 ++++++- video/rtp_video_stream_receiver2.h | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index a5937b027b..bdca0397fa 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -801,6 +801,12 @@ void RtpVideoStreamReceiver::OnInsertedPacket( } RTC_DCHECK(frame_boundary); if (result.buffer_cleared) { + { + MutexLock lock(&sync_info_lock_); + last_received_rtp_system_time_.reset(); + last_received_keyframe_rtp_system_time_.reset(); + last_received_keyframe_rtp_timestamp_.reset(); + } RequestKeyFrame(); } } @@ -1189,7 +1195,9 @@ void RtpVideoStreamReceiver::UpdatePacketReceiveTimestamps( Timestamp now = clock_->CurrentTime(); { MutexLock lock(&sync_info_lock_); - if (is_keyframe) { + if (is_keyframe || + last_received_keyframe_rtp_timestamp_ == packet.Timestamp()) { + last_received_keyframe_rtp_timestamp_ = packet.Timestamp(); last_received_keyframe_rtp_system_time_ = now; } last_received_rtp_system_time_ = now; diff --git a/video/rtp_video_stream_receiver.h b/video/rtp_video_stream_receiver.h index b275fb6e9c..090488c4a8 100644 --- a/video/rtp_video_stream_receiver.h +++ b/video/rtp_video_stream_receiver.h @@ -383,6 +383,8 @@ class RtpVideoStreamReceiver : public LossNotificationSender, mutable Mutex sync_info_lock_; absl::optional last_received_rtp_timestamp_ RTC_GUARDED_BY(sync_info_lock_); + absl::optional last_received_keyframe_rtp_timestamp_ + RTC_GUARDED_BY(sync_info_lock_); absl::optional last_received_rtp_system_time_ RTC_GUARDED_BY(sync_info_lock_); absl::optional last_received_keyframe_rtp_system_time_ diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 3c23a3d2cd..c96dbed673 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -767,6 +767,9 @@ void RtpVideoStreamReceiver2::OnInsertedPacket( } RTC_DCHECK(frame_boundary); if (result.buffer_cleared) { + last_received_rtp_system_time_.reset(); + last_received_keyframe_rtp_system_time_.reset(); + last_received_keyframe_rtp_timestamp_.reset(); RequestKeyFrame(); } } @@ -1127,7 +1130,9 @@ void RtpVideoStreamReceiver2::UpdatePacketReceiveTimestamps( const RtpPacketReceived& packet, bool is_keyframe) { Timestamp now = clock_->CurrentTime(); - if (is_keyframe) { + if (is_keyframe || + last_received_keyframe_rtp_timestamp_ == packet.Timestamp()) { + last_received_keyframe_rtp_timestamp_ = packet.Timestamp(); last_received_keyframe_rtp_system_time_ = now; } last_received_rtp_system_time_ = now; diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index 4076837ade..6649246cbc 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -336,6 +336,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, absl::optional last_received_rtp_timestamp_ RTC_GUARDED_BY(worker_task_checker_); + absl::optional last_received_keyframe_rtp_timestamp_ + RTC_GUARDED_BY(worker_task_checker_); absl::optional last_received_rtp_system_time_ RTC_GUARDED_BY(worker_task_checker_); absl::optional last_received_keyframe_rtp_system_time_