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

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: Rebase Created 3 years, 7 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
« no previous file with comments | « webrtc/video/rtp_stream_receiver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « webrtc/video/rtp_stream_receiver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698