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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // downstream project has been fixed. | 403 // downstream project has been fixed. |
404 video_coding::FrameBuffer::ReturnReason res = | 404 video_coding::FrameBuffer::ReturnReason res = |
405 frame_buffer_->NextFrame(wait_ms, &frame); | 405 frame_buffer_->NextFrame(wait_ms, &frame); |
406 | 406 |
407 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) { | 407 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) { |
408 video_receiver_.DecodingStopped(); | 408 video_receiver_.DecodingStopped(); |
409 return false; | 409 return false; |
410 } | 410 } |
411 | 411 |
412 if (frame) { | 412 if (frame) { |
| 413 int64_t now_ms = clock_->TimeInMilliseconds(); |
413 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound); | 414 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound); |
414 if (video_receiver_.Decode(frame.get()) == VCM_OK) { | 415 if (video_receiver_.Decode(frame.get()) == VCM_OK) { |
415 keyframe_required_ = false; | 416 keyframe_required_ = false; |
416 frame_decoded_ = true; | 417 frame_decoded_ = true; |
417 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id); | 418 rtp_video_stream_receiver_.FrameDecoded(frame->picture_id); |
418 } else if (!keyframe_required_ || !frame_decoded_) { | 419 } else if (!frame_decoded_ || !keyframe_required_ || |
| 420 (last_keyframe_request_ms_ + kMaxWaitForKeyFrameMs < now_ms)) { |
419 keyframe_required_ = true; | 421 keyframe_required_ = true; |
420 // TODO(philipel): Remove this keyframe request when downstream project | 422 // TODO(philipel): Remove this keyframe request when downstream project |
421 // has been fixed. | 423 // has been fixed. |
422 RequestKeyFrame(); | 424 RequestKeyFrame(); |
| 425 last_keyframe_request_ms_ = now_ms; |
423 } | 426 } |
424 } else { | 427 } else { |
425 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); | 428 RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kTimeout); |
426 int64_t now_ms = clock_->TimeInMilliseconds(); | 429 int64_t now_ms = clock_->TimeInMilliseconds(); |
427 rtc::Optional<int64_t> last_packet_ms = | 430 rtc::Optional<int64_t> last_packet_ms = |
428 rtp_video_stream_receiver_.LastReceivedPacketMs(); | 431 rtp_video_stream_receiver_.LastReceivedPacketMs(); |
429 rtc::Optional<int64_t> last_keyframe_packet_ms = | 432 rtc::Optional<int64_t> last_keyframe_packet_ms = |
430 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs(); | 433 rtp_video_stream_receiver_.LastReceivedKeyframePacketMs(); |
431 | 434 |
432 // To avoid spamming keyframe requests for a stream that is not active we | 435 // To avoid spamming keyframe requests for a stream that is not active we |
(...skipping 11 matching lines...) Expand all Loading... |
444 if (stream_is_active && !receiving_keyframe) { | 447 if (stream_is_active && !receiving_keyframe) { |
445 LOG(LS_WARNING) << "No decodable frame in " << wait_ms | 448 LOG(LS_WARNING) << "No decodable frame in " << wait_ms |
446 << " ms, requesting keyframe."; | 449 << " ms, requesting keyframe."; |
447 RequestKeyFrame(); | 450 RequestKeyFrame(); |
448 } | 451 } |
449 } | 452 } |
450 return true; | 453 return true; |
451 } | 454 } |
452 } // namespace internal | 455 } // namespace internal |
453 } // namespace webrtc | 456 } // namespace webrtc |
OLD | NEW |