Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Unified Diff: webrtc/video/video_receive_stream.cc

Issue 2853503002: Dont request keyframes if the stream is inactive or if we are currently receiving a keyframe. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698