diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index 36905913f8..c0a75146c6 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -416,16 +416,19 @@ bool VideoReceiveStream::Decode() { } if (frame) { + int64_t now_ms = clock_->TimeInMilliseconds(); RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound); if (video_receiver_.Decode(frame.get()) == VCM_OK) { keyframe_required_ = false; frame_decoded_ = true; rtp_video_stream_receiver_.FrameDecoded(frame->picture_id); - } else if (!keyframe_required_ || !frame_decoded_) { + } else if (!frame_decoded_ || !keyframe_required_ || + (last_keyframe_request_ms_ + kMaxWaitForKeyFrameMs < now_ms)) { keyframe_required_ = true; // TODO(philipel): Remove this keyframe request when downstream project // has been fixed. RequestKeyFrame(); + last_keyframe_request_ms_ = now_ms; } } else { RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index b2eaa5e2e2..a5f9108b4a 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -159,6 +159,8 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, // If we have successfully decoded any frame. bool frame_decoded_ = false; + + int64_t last_keyframe_request_ms_ = 0; }; } // namespace internal } // namespace webrtc