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

Side by Side Diff: webrtc/video/video_receive_stream.cc

Issue 2993793002: Request keyframes more frequently on stream start/decoding error. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 485
486 void VideoReceiveStream::DecodeThreadFunction(void* ptr) { 486 void VideoReceiveStream::DecodeThreadFunction(void* ptr) {
487 while (static_cast<VideoReceiveStream*>(ptr)->Decode()) { 487 while (static_cast<VideoReceiveStream*>(ptr)->Decode()) {
488 } 488 }
489 } 489 }
490 490
491 bool VideoReceiveStream::Decode() { 491 bool VideoReceiveStream::Decode() {
492 TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode"); 492 TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode");
493 static const int kMaxWaitForFrameMs = 3000; 493 static const int kMaxWaitForFrameMs = 3000;
494 static const int kMaxWaitForKeyFrameMs = 200;
terelius 2017/08/07 12:00:06 Isn't 200 ms a bit short? It will take at least 1
philipel 2017/08/07 12:09:07 I agree that waiting an RTT between requests is be
noahric 2017/08/07 15:12:29 I don't think you want to wait a full RTT when RTT
philipel 2017/08/07 16:27:49 The old jitter buffer requested a new KF every 500
noahric 2017/08/07 16:48:44 If a decoder requests keyframes on every incoming
495
496 int wait_ms = keyframe_required_ ? kMaxWaitForKeyFrameMs : kMaxWaitForFrameMs;
494 std::unique_ptr<video_coding::FrameObject> frame; 497 std::unique_ptr<video_coding::FrameObject> frame;
495 video_coding::FrameBuffer::ReturnReason res = 498 video_coding::FrameBuffer::ReturnReason res =
496 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame); 499 frame_buffer_->NextFrame(wait_ms, &frame, keyframe_required_);
497 500
498 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) { 501 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) {
499 video_receiver_.DecodingStopped(); 502 video_receiver_.DecodingStopped();
500 return false; 503 return false;
501 } 504 }
502 505
503 if (frame) { 506 if (frame) {
504 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound); 507 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound);
505 if (video_receiver_.Decode(frame.get()) == VCM_OK) 508 if (video_receiver_.Decode(frame.get()) == VCM_OK) {
509 keyframe_required_ = false;
stefan-webrtc 2017/08/07 11:54:38 Is this the behavior we want? https://bugs.chromiu
philipel 2017/08/07 11:59:34 I think this CL will solve that problem as well, i
stefan-webrtc 2017/08/07 12:24:53 Right, I missed that. Do we have test coverage for
philipel 2017/08/07 13:30:11 We don't have any tests for VideoReceiveStream exc
stefan-webrtc 2017/08/09 07:02:35 Ok, perhaps we can write an end-to-end test using
506 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id); 510 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id);
511 } else {
512 keyframe_required_ = true;
terelius 2017/08/07 12:00:05 Where do we actually send the keyframe request?
philipel 2017/08/07 12:09:07 What happens when we require a keyframe is that we
terelius 2017/08/07 12:48:56 Acknowledged.
513 }
507 } else { 514 } else {
508 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); 515 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout);
509 int64_t now_ms = clock_->TimeInMilliseconds(); 516 int64_t now_ms = clock_->TimeInMilliseconds();
510 rtc::Optional<int64_t> last_packet_ms = 517 rtc::Optional<int64_t> last_packet_ms =
511 rtp_video_stream_receiver_.LastReceivedPacketMs(); 518 rtp_video_stream_receiver_.LastReceivedPacketMs();
512 rtc::Optional<int64_t> last_keyframe_packet_ms = 519 rtc::Optional<int64_t> last_keyframe_packet_ms =
513 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs(); 520 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs();
514 521
515 // To avoid spamming keyframe requests for a stream that is not active we 522 // To avoid spamming keyframe requests for a stream that is not active we
516 // check if we have received a packet within the last 5 seconds. 523 // check if we have received a packet within the last 5 seconds.
517 bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000; 524 bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000;
518 525
519 // If we recently (within |kMaxWaitForFrameMs|) have been receiving packets 526 // If we recently (within |kMaxWaitForFrameMs|) have been receiving packets
520 // belonging to a keyframe then we assume a keyframe is being received right 527 // belonging to a keyframe then we assume a keyframe is being received right
521 // now. 528 // now.
522 bool receiving_keyframe = 529 bool receiving_keyframe =
523 last_keyframe_packet_ms && 530 last_keyframe_packet_ms &&
524 now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs; 531 now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs;
525 532
526 if (stream_is_active && !receiving_keyframe) { 533 if (stream_is_active && !receiving_keyframe) {
527 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs 534 LOG(LS_WARNING) << "No decodable frame in " << wait_ms
528 << " ms, requesting keyframe."; 535 << " ms, requesting keyframe.";
529 RequestKeyFrame(); 536 RequestKeyFrame();
530 } 537 }
531 } 538 }
532 return true; 539 return true;
533 } 540 }
534 } // namespace internal 541 } // namespace internal
535 } // namespace webrtc 542 } // namespace webrtc
OLDNEW
« 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