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

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

Issue 2995153002: Revert of quest 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
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
495
496 int wait_ms = keyframe_required_ ? kMaxWaitForKeyFrameMs : kMaxWaitForFrameMs;
497 std::unique_ptr<video_coding::FrameObject> frame; 494 std::unique_ptr<video_coding::FrameObject> frame;
498 // TODO(philipel): Call NextFrame with |keyframe_required| argument when
499 // downstream project has been fixed.
500 video_coding::FrameBuffer::ReturnReason res = 495 video_coding::FrameBuffer::ReturnReason res =
501 frame_buffer_->NextFrame(wait_ms, &frame); 496 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame);
502 497
503 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) { 498 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) {
504 video_receiver_.DecodingStopped(); 499 video_receiver_.DecodingStopped();
505 return false; 500 return false;
506 } 501 }
507 502
508 if (frame) { 503 if (frame) {
509 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound); 504 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound);
510 if (video_receiver_.Decode(frame.get()) == VCM_OK) { 505 if (video_receiver_.Decode(frame.get()) == VCM_OK)
511 keyframe_required_ = false;
512 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id); 506 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id);
513 } else if (keyframe_required_ == false) {
514 keyframe_required_ = true;
515 // TODO(philipel): Remove this keyframe request when downstream project
516 // has been fixed.
517 RequestKeyFrame();
518 }
519 } else { 507 } else {
520 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); 508 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout);
521 int64_t now_ms = clock_->TimeInMilliseconds(); 509 int64_t now_ms = clock_->TimeInMilliseconds();
522 rtc::Optional<int64_t> last_packet_ms = 510 rtc::Optional<int64_t> last_packet_ms =
523 rtp_video_stream_receiver_.LastReceivedPacketMs(); 511 rtp_video_stream_receiver_.LastReceivedPacketMs();
524 rtc::Optional<int64_t> last_keyframe_packet_ms = 512 rtc::Optional<int64_t> last_keyframe_packet_ms =
525 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs(); 513 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs();
526 514
527 // To avoid spamming keyframe requests for a stream that is not active we 515 // To avoid spamming keyframe requests for a stream that is not active we
528 // check if we have received a packet within the last 5 seconds. 516 // check if we have received a packet within the last 5 seconds.
529 bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000; 517 bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000;
530 518
531 // If we recently have been receiving packets belonging to a keyframe then 519 // If we recently (within |kMaxWaitForFrameMs|) have been receiving packets
532 // we assume a keyframe is currently being received. 520 // belonging to a keyframe then we assume a keyframe is being received right
521 // now.
533 bool receiving_keyframe = 522 bool receiving_keyframe =
534 last_keyframe_packet_ms && 523 last_keyframe_packet_ms &&
535 now_ms - *last_keyframe_packet_ms < kMaxWaitForKeyFrameMs; 524 now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs;
536 525
537 if (stream_is_active && !receiving_keyframe) { 526 if (stream_is_active && !receiving_keyframe) {
538 LOG(LS_WARNING) << "No decodable frame in " << wait_ms 527 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
539 << " ms, requesting keyframe."; 528 << " ms, requesting keyframe.";
540 RequestKeyFrame(); 529 RequestKeyFrame();
541 } 530 }
542 } 531 }
543 return true; 532 return true;
544 } 533 }
545 } // namespace internal 534 } // namespace internal
546 } // namespace webrtc 535 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698