From 48462b6ef707e9a790579090085f73e6982c3558 Mon Sep 17 00:00:00 2001 From: philipel Date: Tue, 26 Sep 2017 02:54:58 -0700 Subject: [PATCH] Continuously request keyframes if decoding does not recover. This is a workaround until downstream projects have been fixed. BUG=webrtc:8220 Review-Url: https://codereview.webrtc.org/3017613002 Cr-Commit-Position: refs/heads/master@{#19966} --- video/video_receive_stream.cc | 5 ++++- video/video_receive_stream.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) 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