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