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

Side by Side 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, 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 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) { 476 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) {
477 video_receiver_.DecodingStopped(); 477 video_receiver_.DecodingStopped();
478 return false; 478 return false;
479 } 479 }
480 480
481 if (frame) { 481 if (frame) {
482 if (video_receiver_.Decode(frame.get()) == VCM_OK) 482 if (video_receiver_.Decode(frame.get()) == VCM_OK)
483 rtp_stream_receiver_.FrameDecoded(frame->picture_id); 483 rtp_stream_receiver_.FrameDecoded(frame->picture_id);
484 } else { 484 } else {
485 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs 485 int64_t now_ms = clock_->TimeInMilliseconds();
486 << " ms, requesting keyframe."; 486 rtc::Optional<int64_t> last_packet_ms =
487 RequestKeyFrame(); 487 rtp_stream_receiver_.LastReceivedPacketMs();
488 rtc::Optional<int64_t> last_keyframe_packet_ms =
489 rtp_stream_receiver_.LastReceivedKeyframePacketMs();
490
491 // To avoid spamming keyframe requests for a stream that is not active we
492 // check if we have received a packet within the last 5 seconds.
493 bool stream_is_active = last_packet_ms && now_ms - *last_packet_ms < 5000;
494
495 // If we recently (within |kMaxWaitForFrameMs|) have been receiving packets
496 // belonging to a keyframe then we assume a keyframe is being received right
497 // now.
498 bool receiving_keyframe =
499 last_keyframe_packet_ms &&
500 now_ms - *last_keyframe_packet_ms < kMaxWaitForFrameMs;
501
502 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
503 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
504 << " ms, requesting keyframe.";
505 RequestKeyFrame();
506 }
488 } 507 }
489 return true; 508 return true;
490 } 509 }
491 } // namespace internal 510 } // namespace internal
492 } // namespace webrtc 511 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698