| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 28 matching lines...) Expand all Loading... |
| 39 last_rtt_ms_(0) { | 39 last_rtt_ms_(0) { |
| 40 RTC_DCHECK(video_receiver_); | 40 RTC_DCHECK(video_receiver_); |
| 41 | 41 |
| 42 static const int kMaxPacketAgeToNack = 450; | 42 static const int kMaxPacketAgeToNack = 450; |
| 43 static const int kMaxNackListSize = 250; | 43 static const int kMaxNackListSize = 250; |
| 44 video_receiver_->SetNackSettings(kMaxNackListSize, | 44 video_receiver_->SetNackSettings(kMaxNackListSize, |
| 45 kMaxPacketAgeToNack, 0); | 45 kMaxPacketAgeToNack, 0); |
| 46 video_receiver_->RegisterReceiveCallback(this); | 46 video_receiver_->RegisterReceiveCallback(this); |
| 47 video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback); | 47 video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback); |
| 48 video_receiver_->RegisterReceiveStatisticsCallback(this); | 48 video_receiver_->RegisterReceiveStatisticsCallback(this); |
| 49 video_receiver_->RegisterDecoderTimingCallback(this); | |
| 50 | 49 |
| 51 VCMVideoProtection video_protection = | 50 VCMVideoProtection video_protection = |
| 52 enable_nack ? (enable_fec ? kProtectionNackFEC : kProtectionNack) | 51 enable_nack ? (enable_fec ? kProtectionNackFEC : kProtectionNack) |
| 53 : kProtectionNone; | 52 : kProtectionNone; |
| 54 | 53 |
| 55 VCMDecodeErrorMode decode_error_mode = enable_nack ? kNoErrors : kWithErrors; | 54 VCMDecodeErrorMode decode_error_mode = enable_nack ? kNoErrors : kWithErrors; |
| 56 video_receiver_->SetVideoProtection(video_protection, true); | 55 video_receiver_->SetVideoProtection(video_protection, true); |
| 57 video_receiver_->SetDecodeErrorMode(decode_error_mode); | 56 video_receiver_->SetDecodeErrorMode(decode_error_mode); |
| 58 VCMPacketRequestCallback* packet_request_callback = | 57 VCMPacketRequestCallback* packet_request_callback = |
| 59 enable_nack ? vcm_packet_request_callback : nullptr; | 58 enable_nack ? vcm_packet_request_callback : nullptr; |
| 60 video_receiver_->RegisterPacketRequestCallback(packet_request_callback); | 59 video_receiver_->RegisterPacketRequestCallback(packet_request_callback); |
| 61 } | 60 } |
| 62 | 61 |
| 63 VideoStreamDecoder::~VideoStreamDecoder() { | 62 VideoStreamDecoder::~VideoStreamDecoder() { |
| 64 // Note: There's an assumption at this point that the decoder thread is | 63 // Note: There's an assumption at this point that the decoder thread is |
| 65 // *not* running. If it was, then there could be a race for each of these | 64 // *not* running. If it was, then there could be a race for each of these |
| 66 // callbacks. | 65 // callbacks. |
| 67 | 66 |
| 68 // Unset all the callback pointers that we set in the ctor. | 67 // Unset all the callback pointers that we set in the ctor. |
| 69 video_receiver_->RegisterPacketRequestCallback(nullptr); | 68 video_receiver_->RegisterPacketRequestCallback(nullptr); |
| 70 video_receiver_->RegisterDecoderTimingCallback(nullptr); | |
| 71 video_receiver_->RegisterReceiveStatisticsCallback(nullptr); | 69 video_receiver_->RegisterReceiveStatisticsCallback(nullptr); |
| 72 video_receiver_->RegisterFrameTypeCallback(nullptr); | 70 video_receiver_->RegisterFrameTypeCallback(nullptr); |
| 73 video_receiver_->RegisterReceiveCallback(nullptr); | 71 video_receiver_->RegisterReceiveCallback(nullptr); |
| 74 } | 72 } |
| 75 | 73 |
| 76 // Do not acquire the lock of |video_receiver_| in this function. Decode | 74 // Do not acquire the lock of |video_receiver_| in this function. Decode |
| 77 // callback won't necessarily be called from the decoding thread. The decoding | 75 // callback won't necessarily be called from the decoding thread. The decoding |
| 78 // thread may have held the lock when calling VideoDecoder::Decode, Reset, or | 76 // thread may have held the lock when calling VideoDecoder::Decode, Reset, or |
| 79 // Release. Acquiring the same lock in the path of decode callback can deadlock. | 77 // Release. Acquiring the same lock in the path of decode callback can deadlock. |
| 80 int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame, | 78 int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 106 } | 104 } |
| 107 | 105 |
| 108 void VideoStreamDecoder::OnDiscardedPacketsUpdated(int discarded_packets) { | 106 void VideoStreamDecoder::OnDiscardedPacketsUpdated(int discarded_packets) { |
| 109 receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets); | 107 receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets); |
| 110 } | 108 } |
| 111 | 109 |
| 112 void VideoStreamDecoder::OnFrameCountsUpdated(const FrameCounts& frame_counts) { | 110 void VideoStreamDecoder::OnFrameCountsUpdated(const FrameCounts& frame_counts) { |
| 113 receive_stats_callback_->OnFrameCountsUpdated(frame_counts); | 111 receive_stats_callback_->OnFrameCountsUpdated(frame_counts); |
| 114 } | 112 } |
| 115 | 113 |
| 116 void VideoStreamDecoder::OnDecoderTiming(int decode_ms, | |
| 117 int max_decode_ms, | |
| 118 int current_delay_ms, | |
| 119 int target_delay_ms, | |
| 120 int jitter_buffer_ms, | |
| 121 int min_playout_delay_ms, | |
| 122 int render_delay_ms) {} | |
| 123 | |
| 124 void VideoStreamDecoder::OnFrameBufferTimingsUpdated(int decode_ms, | 114 void VideoStreamDecoder::OnFrameBufferTimingsUpdated(int decode_ms, |
| 125 int max_decode_ms, | 115 int max_decode_ms, |
| 126 int current_delay_ms, | 116 int current_delay_ms, |
| 127 int target_delay_ms, | 117 int target_delay_ms, |
| 128 int jitter_buffer_ms, | 118 int jitter_buffer_ms, |
| 129 int min_playout_delay_ms, | 119 int min_playout_delay_ms, |
| 130 int render_delay_ms) {} | 120 int render_delay_ms) {} |
| 131 | 121 |
| 132 void VideoStreamDecoder::OnCompleteFrame(bool is_keyframe, size_t size_bytes) {} | 122 void VideoStreamDecoder::OnCompleteFrame(bool is_keyframe, size_t size_bytes) {} |
| 133 | 123 |
| 134 void VideoStreamDecoder::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 124 void VideoStreamDecoder::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 135 video_receiver_->SetReceiveChannelParameters(max_rtt_ms); | 125 video_receiver_->SetReceiveChannelParameters(max_rtt_ms); |
| 136 | 126 |
| 137 rtc::CritScope lock(&crit_); | 127 rtc::CritScope lock(&crit_); |
| 138 last_rtt_ms_ = avg_rtt_ms; | 128 last_rtt_ms_ = avg_rtt_ms; |
| 139 } | 129 } |
| 140 } // namespace webrtc | 130 } // namespace webrtc |
| OLD | NEW |