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

Unified Diff: webrtc/video/video_receive_stream.cc

Issue 2996823002: Reland of quest keyframes more frequently on stream start/decoding error. (Closed)
Patch Set: Fix Created 3 years, 4 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 e8a9da22455c7a79d9b2948071347103987496f7..9d753138ccc68270c124c3957b5deadb30dc5514 100644
--- a/webrtc/video/video_receive_stream.cc
+++ b/webrtc/video/video_receive_stream.cc
@@ -491,9 +491,14 @@ void VideoReceiveStream::DecodeThreadFunction(void* ptr) {
bool VideoReceiveStream::Decode() {
TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode");
static const int kMaxWaitForFrameMs = 3000;
+ static const int kMaxWaitForKeyFrameMs = 200;
+
+ int wait_ms = keyframe_required_ ? kMaxWaitForKeyFrameMs : kMaxWaitForFrameMs;
std::unique_ptr<video_coding::FrameObject> frame;
+ // TODO(philipel): Call NextFrame with |keyframe_required| argument when
+ // downstream project has been fixed.
video_coding::FrameBuffer::ReturnReason res =
- frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame);
+ frame_buffer_->NextFrame(wait_ms, &frame);
if (res == video_coding::FrameBuffer::ReturnReason::kStopped) {
video_receiver_.DecodingStopped();
@@ -502,8 +507,15 @@ bool VideoReceiveStream::Decode() {
if (frame) {
RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound);
- if (video_receiver_.Decode(frame.get()) == VCM_OK)
+ if (video_receiver_.Decode(frame.get()) == VCM_OK) {
+ keyframe_required_ = false;
rtp_video_stream_receiver_.FrameDecoded(frame->picture_id);
+ } else if (keyframe_required_ == false) {
stefan-webrtc 2017/08/11 09:27:59 !keyframe_required_
+ keyframe_required_ = true;
+ // TODO(philipel): Remove this keyframe request when downstream project
+ // has been fixed.
+ RequestKeyFrame();
+ }
} else {
RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout);
int64_t now_ms = clock_->TimeInMilliseconds();
@@ -516,15 +528,14 @@ bool VideoReceiveStream::Decode() {
// 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.
+ // If we recently have been receiving packets belonging to a keyframe then
+ // we assume a keyframe is currently being received.
bool receiving_keyframe =
last_keyframe_packet_ms &&
- now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs;
+ now_ms - *last_keyframe_packet_ms < kMaxWaitForKeyFrameMs;
if (stream_is_active && !receiving_keyframe) {
- LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
+ LOG(LS_WARNING) << "No decodable frame in " << wait_ms
<< " ms, requesting keyframe.";
RequestKeyFrame();
}
« webrtc/modules/video_coding/video_receiver.cc ('K') | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698