| Index: webrtc/video/video_receive_stream.cc
|
| diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc
|
| index 0ce3794eb58e40142b7c99d25b0467e5b534689b..6e7ea13b2a05de0f7c167bb26a8d5ea84d99a570 100644
|
| --- a/webrtc/video/video_receive_stream.cc
|
| +++ b/webrtc/video/video_receive_stream.cc
|
| @@ -477,9 +477,28 @@ bool VideoReceiveStream::Decode() {
|
| if (video_receiver_.Decode(frame.get()) == VCM_OK)
|
| rtp_stream_receiver_.FrameDecoded(frame->picture_id);
|
| } else {
|
| - LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
|
| - << " ms, requesting keyframe.";
|
| - RequestKeyFrame();
|
| + int64_t now_ms = clock_->TimeInMilliseconds();
|
| + rtc::Optional<int64_t> last_packet_ms =
|
| + rtp_stream_receiver_.LastReceivedPacketMs();
|
| + rtc::Optional<int64_t> last_keyframe_packet_ms =
|
| + rtp_stream_receiver_.LastReceivedKeyframePacketMs();
|
| +
|
| + // To avoid spamming keyframe requests for a stream that is not active we
|
| + // check if we have received a packet within the last 5 seconds.
|
| + bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000;
|
| +
|
| + // If we recently (within |kMaxWaitForFrameMs|) have been receiving packets
|
| + // belonging to a keyframe then we assume a keyframe is being received right
|
| + // now.
|
| + bool receiving_keyframe =
|
| + last_keyframe_packet_ms &&
|
| + now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs;
|
| +
|
| + if (stream_is_active && !receiving_keyframe) {
|
| + LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
|
| + << " ms, requesting keyframe.";
|
| + RequestKeyFrame();
|
| + }
|
| }
|
| return true;
|
| }
|
|
|