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_