Index: webrtc/video/video_receive_stream.cc |
diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc |
index cee62d297c796c4fec7d42ddfb7e9ff4418103fe..e48143cf64862a73651856e251af3aec27ef0978 100644 |
--- a/webrtc/video/video_receive_stream.cc |
+++ b/webrtc/video/video_receive_stream.cc |
@@ -482,9 +482,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) { |
philipel
2017/04/28 12:11:29
I know we talked about this as a potential problem
ilnik
2017/04/28 12:40:55
How about a following workaround: prohibit keyfram
philipel
2017/04/28 12:58:24
I just realized that we can update the timestamps
|
+ LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs |
+ << " ms, requesting keyframe."; |
+ RequestKeyFrame(); |
+ } |
} |
return true; |
} |