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

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

Issue 1864313003: Move Ownership of RtpModules to VideoSendStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 4 years, 8 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/vie_channel.h ('k') | webrtc/video/vie_receiver.h » ('j') | 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) 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 17 matching lines...) Expand all
28 #include "webrtc/modules/video_coding/include/video_coding.h" 28 #include "webrtc/modules/video_coding/include/video_coding.h"
29 #include "webrtc/modules/video_processing/include/video_processing.h" 29 #include "webrtc/modules/video_processing/include/video_processing.h"
30 #include "webrtc/modules/video_render/video_render_defines.h" 30 #include "webrtc/modules/video_render/video_render_defines.h"
31 #include "webrtc/system_wrappers/include/metrics.h" 31 #include "webrtc/system_wrappers/include/metrics.h"
32 #include "webrtc/video/call_stats.h" 32 #include "webrtc/video/call_stats.h"
33 #include "webrtc/video/payload_router.h" 33 #include "webrtc/video/payload_router.h"
34 #include "webrtc/video/receive_statistics_proxy.h" 34 #include "webrtc/video/receive_statistics_proxy.h"
35 35
36 namespace webrtc { 36 namespace webrtc {
37 37
38 static const int kMinSendSidePacketHistorySize = 600;
39 static const int kMaxPacketAgeToNack = 450; 38 static const int kMaxPacketAgeToNack = 450;
40 static const int kMaxNackListSize = 250; 39 static const int kMaxNackListSize = 250;
41 40
41 namespace {
42
43 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
44 ReceiveStatistics* receive_statistics,
45 Transport* outgoing_transport,
46 RtcpRttStats* rtt_stats,
47 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
48 RemoteBitrateEstimator* remote_bitrate_estimator,
49 RtpPacketSender* paced_sender,
50 TransportSequenceNumberAllocator* transport_sequence_number_allocator) {
51 RtpRtcp::Configuration configuration;
52 configuration.audio = false;
53 configuration.receiver_only = true;
54 configuration.receive_statistics = receive_statistics;
55 configuration.outgoing_transport = outgoing_transport;
56 configuration.intra_frame_callback = nullptr;
57 configuration.rtt_stats = rtt_stats;
58 configuration.rtcp_packet_type_counter_observer =
59 rtcp_packet_type_counter_observer;
60 configuration.paced_sender = paced_sender;
61 configuration.transport_sequence_number_allocator =
62 transport_sequence_number_allocator;
63 configuration.send_bitrate_observer = nullptr;
64 configuration.send_frame_count_observer = nullptr;
65 configuration.send_side_delay_observer = nullptr;
66 configuration.bandwidth_callback = nullptr;
67 configuration.transport_feedback_callback = nullptr;
68
69 std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration));
70 rtp_rtcp->SetSendingStatus(false);
71 rtp_rtcp->SetSendingMediaStatus(false);
72 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
73
74 return rtp_rtcp;
75 }
76
77 } // namespace
78
42 // Helper class receiving statistics callbacks. 79 // Helper class receiving statistics callbacks.
43 class ChannelStatsObserver : public CallStatsObserver { 80 class ChannelStatsObserver : public CallStatsObserver {
44 public: 81 public:
45 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} 82 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {}
46 virtual ~ChannelStatsObserver() {} 83 virtual ~ChannelStatsObserver() {}
47 84
48 // Implements StatsObserver. 85 // Implements StatsObserver.
49 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 86 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
50 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 87 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
51 } 88 }
52 89
53 private: 90 private:
54 ViEChannel* const owner_; 91 ViEChannel* const owner_;
55 }; 92 };
56 93
57 class ViEChannelProtectionCallback : public VCMProtectionCallback {
58 public:
59 explicit ViEChannelProtectionCallback(ViEChannel* owner) : owner_(owner) {}
60 ~ViEChannelProtectionCallback() {}
61
62
63 int ProtectionRequest(
64 const FecProtectionParams* delta_fec_params,
65 const FecProtectionParams* key_fec_params,
66 uint32_t* sent_video_rate_bps,
67 uint32_t* sent_nack_rate_bps,
68 uint32_t* sent_fec_rate_bps) override {
69 return owner_->ProtectionRequest(delta_fec_params, key_fec_params,
70 sent_video_rate_bps, sent_nack_rate_bps,
71 sent_fec_rate_bps);
72 }
73 private:
74 ViEChannel* owner_;
75 };
76
77 ViEChannel::ViEChannel(Transport* transport, 94 ViEChannel::ViEChannel(Transport* transport,
78 ProcessThread* module_process_thread, 95 ProcessThread* module_process_thread,
79 PayloadRouter* send_payload_router,
80 VideoCodingModule* vcm, 96 VideoCodingModule* vcm,
81 RtcpIntraFrameObserver* intra_frame_observer,
82 RtcpBandwidthObserver* bandwidth_observer,
83 TransportFeedbackObserver* transport_feedback_observer,
84 RemoteBitrateEstimator* remote_bitrate_estimator, 97 RemoteBitrateEstimator* remote_bitrate_estimator,
85 RtcpRttStats* rtt_stats, 98 RtcpRttStats* rtt_stats,
86 PacedSender* paced_sender, 99 PacedSender* paced_sender,
87 PacketRouter* packet_router, 100 PacketRouter* packet_router)
88 size_t max_rtp_streams, 101 : module_process_thread_(module_process_thread),
89 bool sender)
90 : sender_(sender),
91 module_process_thread_(module_process_thread),
92 send_payload_router_(send_payload_router),
93 vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
94 vcm_(vcm), 102 vcm_(vcm),
95 vie_receiver_(vcm_, remote_bitrate_estimator, this), 103 vie_receiver_(vcm_, remote_bitrate_estimator, this),
96 stats_observer_(new ChannelStatsObserver(this)), 104 stats_observer_(new ChannelStatsObserver(this)),
97 receive_stats_callback_(nullptr), 105 receive_stats_callback_(nullptr),
98 incoming_video_stream_(nullptr), 106 incoming_video_stream_(nullptr),
99 intra_frame_observer_(intra_frame_observer),
100 rtt_stats_(rtt_stats), 107 rtt_stats_(rtt_stats),
101 paced_sender_(paced_sender), 108 paced_sender_(paced_sender),
102 packet_router_(packet_router), 109 packet_router_(packet_router),
103 bandwidth_observer_(bandwidth_observer),
104 transport_feedback_observer_(transport_feedback_observer),
105 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 110 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
106 pre_render_callback_(nullptr), 111 pre_render_callback_(nullptr),
107 last_rtt_ms_(0), 112 last_rtt_ms_(0),
108 rtp_rtcp_modules_( 113 rtp_rtcp_(CreateRtpRtcpModule(vie_receiver_.GetReceiveStatistics(),
109 CreateRtpRtcpModules(!sender, 114 transport,
110 vie_receiver_.GetReceiveStatistics(), 115 rtt_stats_,
111 transport, 116 &rtcp_packet_type_counter_observer_,
112 intra_frame_observer_, 117 remote_bitrate_estimator,
113 bandwidth_observer_.get(), 118 paced_sender_,
114 transport_feedback_observer_, 119 packet_router_)) {
115 rtt_stats_, 120 vie_receiver_.Init(rtp_rtcp_.get());
116 &rtcp_packet_type_counter_observer_, 121 RTC_DCHECK(vcm_);
117 remote_bitrate_estimator, 122 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
118 paced_sender_,
119 packet_router_,
120 &send_bitrate_observer_,
121 &send_frame_count_observer_,
122 &send_side_delay_observer_,
123 max_rtp_streams)) {
124 vie_receiver_.Init(rtp_rtcp_modules_);
125 if (sender_) {
126 RTC_DCHECK(send_payload_router_);
127 RTC_DCHECK(!vcm_);
128 } else {
129 RTC_DCHECK(!send_payload_router_);
130 RTC_DCHECK(vcm_);
131 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
132 }
133 } 123 }
134 124
135 int32_t ViEChannel::Init() { 125 int32_t ViEChannel::Init() {
136 static const int kDefaultRenderDelayMs = 10; 126 static const int kDefaultRenderDelayMs = 10;
137 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); 127 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics());
138 128
139 // RTP/RTCP initialization. 129 // RTP/RTCP initialization.
140 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 130 module_process_thread_->RegisterModule(rtp_rtcp_.get());
141 module_process_thread_->RegisterModule(rtp_rtcp); 131 packet_router_->AddRtpModule(rtp_rtcp_.get());
142 packet_router_->AddRtpModule(rtp_rtcp); 132
133 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
134 if (vcm_->RegisterReceiveCallback(this) != 0) {
135 return -1;
143 } 136 }
137 vcm_->RegisterFrameTypeCallback(this);
138 vcm_->RegisterReceiveStatisticsCallback(this);
139 vcm_->RegisterDecoderTimingCallback(this);
140 vcm_->SetRenderDelay(kDefaultRenderDelayMs);
144 141
145 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
146 if (paced_sender_) {
147 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
148 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize);
149 }
150 if (sender_) {
151 send_payload_router_->SetSendingRtpModules(1);
152 RTC_DCHECK(!send_payload_router_->active());
153 } else {
154 if (vcm_->RegisterReceiveCallback(this) != 0) {
155 return -1;
156 }
157 vcm_->RegisterFrameTypeCallback(this);
158 vcm_->RegisterReceiveStatisticsCallback(this);
159 vcm_->RegisterDecoderTimingCallback(this);
160 vcm_->SetRenderDelay(kDefaultRenderDelayMs);
161 }
162 return 0; 142 return 0;
163 } 143 }
164 144
165 ViEChannel::~ViEChannel() { 145 ViEChannel::~ViEChannel() {
166 // Make sure we don't get more callbacks from the RTP module. 146 // Make sure we don't get more callbacks from the RTP module.
167 module_process_thread_->DeRegisterModule( 147 module_process_thread_->DeRegisterModule(
168 vie_receiver_.GetReceiveStatistics()); 148 vie_receiver_.GetReceiveStatistics());
169 if (sender_) { 149
170 send_payload_router_->SetSendingRtpModules(0); 150 packet_router_->RemoveRtpModule(rtp_rtcp_.get());
171 } 151 module_process_thread_->DeRegisterModule(rtp_rtcp_.get());
172 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
173 packet_router_->RemoveRtpModule(rtp_rtcp);
174 module_process_thread_->DeRegisterModule(rtp_rtcp);
175 delete rtp_rtcp;
176 }
177 } 152 }
178 153
179 void ViEChannel::SetProtectionMode(bool enable_nack, 154 void ViEChannel::SetProtectionMode(bool enable_nack,
180 bool enable_fec, 155 bool enable_fec,
181 int payload_type_red, 156 int payload_type_red,
182 int payload_type_fec) { 157 int payload_type_fec) {
183 // Validate payload types. If either RED or FEC payload types are set then 158 // Validate payload types. If either RED or FEC payload types are set then
184 // both should be. If FEC is enabled then they both have to be set. 159 // both should be. If FEC is enabled then they both have to be set.
185 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { 160 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) {
186 RTC_DCHECK_GE(payload_type_red, 0); 161 RTC_DCHECK_GE(payload_type_red, 0);
187 RTC_DCHECK_GE(payload_type_fec, 0); 162 RTC_DCHECK_GE(payload_type_fec, 0);
188 RTC_DCHECK_LE(payload_type_red, 127); 163 RTC_DCHECK_LE(payload_type_red, 127);
189 RTC_DCHECK_LE(payload_type_fec, 127); 164 RTC_DCHECK_LE(payload_type_fec, 127);
190 } else { 165 } else {
191 // Payload types unset. 166 // Payload types unset.
192 RTC_DCHECK_EQ(payload_type_red, -1); 167 RTC_DCHECK_EQ(payload_type_red, -1);
193 RTC_DCHECK_EQ(payload_type_fec, -1); 168 RTC_DCHECK_EQ(payload_type_fec, -1);
194 // Set to valid uint8_ts to be castable later without signed overflows. 169 // Set to valid uint8_ts to be castable later without signed overflows.
195 payload_type_red = 0; 170 payload_type_red = 0;
196 payload_type_fec = 0; 171 payload_type_fec = 0;
197 } 172 }
198 173
199 VCMVideoProtection protection_method; 174 VCMVideoProtection protection_method;
200 if (enable_nack) { 175 if (enable_nack) {
201 protection_method = enable_fec ? kProtectionNackFEC : kProtectionNack; 176 protection_method = enable_fec ? kProtectionNackFEC : kProtectionNack;
202 } else { 177 } else {
203 protection_method = kProtectionNone; 178 protection_method = kProtectionNone;
204 } 179 }
205 180
206 if (!sender_) 181 vcm_->SetVideoProtection(protection_method, true);
207 vcm_->SetVideoProtection(protection_method, true);
208 182
209 // Set NACK. 183 // Set NACK.
210 ProcessNACKRequest(enable_nack); 184 ProcessNACKRequest(enable_nack);
211 185
212 // Set FEC. 186 // Set FEC.
213 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 187 rtp_rtcp_->SetGenericFECStatus(enable_fec,
214 rtp_rtcp->SetGenericFECStatus(enable_fec, 188 static_cast<uint8_t>(payload_type_red),
215 static_cast<uint8_t>(payload_type_red), 189 static_cast<uint8_t>(payload_type_fec));
216 static_cast<uint8_t>(payload_type_fec));
217 }
218 } 190 }
219 191
220 void ViEChannel::ProcessNACKRequest(const bool enable) { 192 void ViEChannel::ProcessNACKRequest(const bool enable) {
221 if (enable) { 193 if (enable) {
222 // Turn on NACK. 194 // Turn on NACK.
223 if (rtp_rtcp_modules_[0]->RTCP() == RtcpMode::kOff) 195 if (rtp_rtcp_->RTCP() == RtcpMode::kOff)
224 return; 196 return;
225 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_); 197 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_);
198 vcm_->RegisterPacketRequestCallback(this);
199 // Don't introduce errors when NACK is enabled.
200 vcm_->SetDecodeErrorMode(kNoErrors);
226 201
227 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
228 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize);
229
230 if (!sender_) {
231 vcm_->RegisterPacketRequestCallback(this);
232 // Don't introduce errors when NACK is enabled.
233 vcm_->SetDecodeErrorMode(kNoErrors);
234 }
235 } else { 202 } else {
236 if (!sender_) { 203 vcm_->RegisterPacketRequestCallback(nullptr);
237 vcm_->RegisterPacketRequestCallback(nullptr); 204 // When NACK is off, allow decoding with errors. Otherwise, the video
238 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 205 // will freeze, and will only recover with a complete key frame.
239 rtp_rtcp->SetStorePacketsStatus(false, 0); 206 vcm_->SetDecodeErrorMode(kWithErrors);
240 // When NACK is off, allow decoding with errors. Otherwise, the video
241 // will freeze, and will only recover with a complete key frame.
242 vcm_->SetDecodeErrorMode(kWithErrors);
243 }
244 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); 207 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_);
245 } 208 }
246 } 209 }
247 210
248 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) { 211 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) {
249 // The max size of the nack list should be large enough to accommodate the 212 // The max size of the nack list should be large enough to accommodate the
250 // the number of packets (frames) resulting from the increased delay. 213 // the number of packets (frames) resulting from the increased delay.
251 // Roughly estimating for ~40 packets per frame @ 30fps. 214 // Roughly estimating for ~40 packets per frame @ 30fps.
252 return target_delay_ms * 40 * 30 / 1000; 215 return target_delay_ms * 40 * 30 / 1000;
253 } 216 }
254 217
255 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { 218 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const {
256 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); 219 RTC_DCHECK(!rtp_rtcp_->Sending());
257 RtpState rtp_state; 220 RTC_DCHECK_EQ(ssrc, rtp_rtcp_->SSRC());
258 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 221 return rtp_rtcp_->GetRtpState();
259 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_state))
260 return rtp_state;
261 }
262 LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc;
263 return rtp_state;
264 } 222 }
265 223
266 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( 224 void ViEChannel::RegisterRtcpPacketTypeCounterObserver(
267 RtcpPacketTypeCounterObserver* observer) { 225 RtcpPacketTypeCounterObserver* observer) {
268 rtcp_packet_type_counter_observer_.Set(observer); 226 rtcp_packet_type_counter_observer_.Set(observer);
269 } 227 }
270 228
271 void ViEChannel::GetSendStreamDataCounters( 229 RtpRtcp* ViEChannel::rtp_rtcp() const {
272 StreamDataCounters* rtp_counters, 230 return rtp_rtcp_.get();
273 StreamDataCounters* rtx_counters) const {
274 *rtp_counters = StreamDataCounters();
275 *rtx_counters = StreamDataCounters();
276 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
277 StreamDataCounters rtp_data;
278 StreamDataCounters rtx_data;
279 rtp_rtcp->GetSendStreamDataCounters(&rtp_data, &rtx_data);
280 rtp_counters->Add(rtp_data);
281 rtx_counters->Add(rtx_data);
282 }
283 }
284
285 void ViEChannel::RegisterSendSideDelayObserver(
286 SendSideDelayObserver* observer) {
287 send_side_delay_observer_.Set(observer);
288 }
289
290 void ViEChannel::RegisterSendBitrateObserver(
291 BitrateStatisticsObserver* observer) {
292 send_bitrate_observer_.Set(observer);
293 }
294
295 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const {
296 return rtp_rtcp_modules_;
297 } 231 }
298 232
299 ViEReceiver* ViEChannel::vie_receiver() { 233 ViEReceiver* ViEChannel::vie_receiver() {
300 return &vie_receiver_; 234 return &vie_receiver_;
301 } 235 }
302 236
303 VCMProtectionCallback* ViEChannel::vcm_protection_callback() {
304 return vcm_protection_callback_.get();
305 }
306
307 CallStatsObserver* ViEChannel::GetStatsObserver() { 237 CallStatsObserver* ViEChannel::GetStatsObserver() {
308 return stats_observer_.get(); 238 return stats_observer_.get();
309 } 239 }
310 240
311 // Do not acquire the lock of |vcm_| in this function. Decode callback won't 241 // Do not acquire the lock of |vcm_| in this function. Decode callback won't
312 // necessarily be called from the decoding thread. The decoding thread may have 242 // necessarily be called from the decoding thread. The decoding thread may have
313 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring 243 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring
314 // the same lock in the path of decode callback can deadlock. 244 // the same lock in the path of decode callback can deadlock.
315 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT 245 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT
316 rtc::CritScope lock(&crit_); 246 rtc::CritScope lock(&crit_);
317 247
318 if (pre_render_callback_) 248 if (pre_render_callback_)
319 pre_render_callback_->FrameCallback(&video_frame); 249 pre_render_callback_->FrameCallback(&video_frame);
320 250
321 // TODO(pbos): Remove stream id argument. 251 // TODO(pbos): Remove stream id argument.
322 incoming_video_stream_->RenderFrame(0xFFFFFFFF, video_frame); 252 incoming_video_stream_->RenderFrame(0xFFFFFFFF, video_frame);
323 return 0; 253 return 0;
324 } 254 }
325 255
326 int32_t ViEChannel::ReceivedDecodedReferenceFrame( 256 int32_t ViEChannel::ReceivedDecodedReferenceFrame(
327 const uint64_t picture_id) { 257 const uint64_t picture_id) {
328 return rtp_rtcp_modules_[0]->SendRTCPReferencePictureSelection(picture_id); 258 return rtp_rtcp_->SendRTCPReferencePictureSelection(picture_id);
329 } 259 }
330 260
331 void ViEChannel::OnIncomingPayloadType(int payload_type) { 261 void ViEChannel::OnIncomingPayloadType(int payload_type) {
332 rtc::CritScope lock(&crit_); 262 rtc::CritScope lock(&crit_);
333 if (receive_stats_callback_) 263 if (receive_stats_callback_)
334 receive_stats_callback_->OnIncomingPayloadType(payload_type); 264 receive_stats_callback_->OnIncomingPayloadType(payload_type);
335 } 265 }
336 266
337 void ViEChannel::OnDecoderImplementationName(const char* implementation_name) { 267 void ViEChannel::OnDecoderImplementationName(const char* implementation_name) {
338 rtc::CritScope lock(&crit_); 268 rtc::CritScope lock(&crit_);
(...skipping 29 matching lines...) Expand all
368 int render_delay_ms) { 298 int render_delay_ms) {
369 rtc::CritScope lock(&crit_); 299 rtc::CritScope lock(&crit_);
370 if (!receive_stats_callback_) 300 if (!receive_stats_callback_)
371 return; 301 return;
372 receive_stats_callback_->OnDecoderTiming( 302 receive_stats_callback_->OnDecoderTiming(
373 decode_ms, max_decode_ms, current_delay_ms, target_delay_ms, 303 decode_ms, max_decode_ms, current_delay_ms, target_delay_ms,
374 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms, last_rtt_ms_); 304 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms, last_rtt_ms_);
375 } 305 }
376 306
377 int32_t ViEChannel::RequestKeyFrame() { 307 int32_t ViEChannel::RequestKeyFrame() {
378 return rtp_rtcp_modules_[0]->RequestKeyFrame(); 308 return rtp_rtcp_->RequestKeyFrame();
379 } 309 }
380 310
381 int32_t ViEChannel::SliceLossIndicationRequest( 311 int32_t ViEChannel::SliceLossIndicationRequest(
382 const uint64_t picture_id) { 312 const uint64_t picture_id) {
383 return rtp_rtcp_modules_[0]->SendRTCPSliceLossIndication( 313 return rtp_rtcp_->SendRTCPSliceLossIndication(
384 static_cast<uint8_t>(picture_id)); 314 static_cast<uint8_t>(picture_id));
385 } 315 }
386 316
387 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, 317 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers,
388 uint16_t length) { 318 uint16_t length) {
389 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); 319 return rtp_rtcp_->SendNACK(sequence_numbers, length);
390 } 320 }
391 321
392 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 322 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
393 if (!sender_) 323 vcm_->SetReceiveChannelParameters(max_rtt_ms);
394 vcm_->SetReceiveChannelParameters(max_rtt_ms);
395 324
396 rtc::CritScope lock(&crit_); 325 rtc::CritScope lock(&crit_);
397 last_rtt_ms_ = avg_rtt_ms; 326 last_rtt_ms_ = avg_rtt_ms;
398 } 327 }
399 328
400 int ViEChannel::ProtectionRequest(const FecProtectionParams* delta_fec_params,
401 const FecProtectionParams* key_fec_params,
402 uint32_t* video_rate_bps,
403 uint32_t* nack_rate_bps,
404 uint32_t* fec_rate_bps) {
405 *video_rate_bps = 0;
406 *nack_rate_bps = 0;
407 *fec_rate_bps = 0;
408 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
409 uint32_t not_used = 0;
410 uint32_t module_video_rate = 0;
411 uint32_t module_fec_rate = 0;
412 uint32_t module_nack_rate = 0;
413 rtp_rtcp->SetFecParameters(delta_fec_params, key_fec_params);
414 rtp_rtcp->BitrateSent(&not_used, &module_video_rate, &module_fec_rate,
415 &module_nack_rate);
416 *video_rate_bps += module_video_rate;
417 *nack_rate_bps += module_nack_rate;
418 *fec_rate_bps += module_fec_rate;
419 }
420 return 0;
421 }
422
423 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules(
424 bool receiver_only,
425 ReceiveStatistics* receive_statistics,
426 Transport* outgoing_transport,
427 RtcpIntraFrameObserver* intra_frame_callback,
428 RtcpBandwidthObserver* bandwidth_callback,
429 TransportFeedbackObserver* transport_feedback_callback,
430 RtcpRttStats* rtt_stats,
431 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
432 RemoteBitrateEstimator* remote_bitrate_estimator,
433 RtpPacketSender* paced_sender,
434 TransportSequenceNumberAllocator* transport_sequence_number_allocator,
435 BitrateStatisticsObserver* send_bitrate_observer,
436 FrameCountObserver* send_frame_count_observer,
437 SendSideDelayObserver* send_side_delay_observer,
438 size_t num_modules) {
439 RTC_DCHECK_GT(num_modules, 0u);
440 RtpRtcp::Configuration configuration;
441 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
442 configuration.audio = false;
443 configuration.receiver_only = receiver_only;
444 configuration.receive_statistics = receive_statistics;
445 configuration.outgoing_transport = outgoing_transport;
446 configuration.intra_frame_callback = intra_frame_callback;
447 configuration.rtt_stats = rtt_stats;
448 configuration.rtcp_packet_type_counter_observer =
449 rtcp_packet_type_counter_observer;
450 configuration.paced_sender = paced_sender;
451 configuration.transport_sequence_number_allocator =
452 transport_sequence_number_allocator;
453 configuration.send_bitrate_observer = send_bitrate_observer;
454 configuration.send_frame_count_observer = send_frame_count_observer;
455 configuration.send_side_delay_observer = send_side_delay_observer;
456 configuration.bandwidth_callback = bandwidth_callback;
457 configuration.transport_feedback_callback = transport_feedback_callback;
458
459 std::vector<RtpRtcp*> modules;
460 for (size_t i = 0; i < num_modules; ++i) {
461 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
462 rtp_rtcp->SetSendingStatus(false);
463 rtp_rtcp->SetSendingMediaStatus(false);
464 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
465 modules.push_back(rtp_rtcp);
466 // Receive statistics and remote bitrate estimator should only be set for
467 // the primary (first) module.
468 configuration.receive_statistics = null_receive_statistics;
469 configuration.remote_bitrate_estimator = nullptr;
470 }
471 return modules;
472 }
473
474 void ViEChannel::RegisterPreRenderCallback( 329 void ViEChannel::RegisterPreRenderCallback(
475 I420FrameCallback* pre_render_callback) { 330 I420FrameCallback* pre_render_callback) {
476 RTC_DCHECK(!sender_);
477 rtc::CritScope lock(&crit_); 331 rtc::CritScope lock(&crit_);
478 pre_render_callback_ = pre_render_callback; 332 pre_render_callback_ = pre_render_callback;
479 } 333 }
480 334
481 // TODO(pbos): Remove as soon as audio can handle a changing payload type 335 // TODO(pbos): Remove as soon as audio can handle a changing payload type
482 // without this callback. 336 // without this callback.
483 int32_t ViEChannel::OnInitializeDecoder( 337 int32_t ViEChannel::OnInitializeDecoder(
484 const int8_t payload_type, 338 const int8_t payload_type,
485 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 339 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
486 const int frequency, 340 const int frequency,
487 const size_t channels, 341 const size_t channels,
488 const uint32_t rate) { 342 const uint32_t rate) {
489 RTC_NOTREACHED(); 343 RTC_NOTREACHED();
490 return 0; 344 return 0;
491 } 345 }
492 346
493 void ViEChannel::OnIncomingSSRCChanged(const uint32_t ssrc) { 347 void ViEChannel::OnIncomingSSRCChanged(const uint32_t ssrc) {
494 rtp_rtcp_modules_[0]->SetRemoteSSRC(ssrc); 348 rtp_rtcp_->SetRemoteSSRC(ssrc);
495 } 349 }
496 350
497 void ViEChannel::OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) {} 351 void ViEChannel::OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) {}
498 352
499 void ViEChannel::RegisterSendFrameCountObserver(
500 FrameCountObserver* observer) {
501 send_frame_count_observer_.Set(observer);
502 }
503
504 void ViEChannel::RegisterReceiveStatisticsProxy( 353 void ViEChannel::RegisterReceiveStatisticsProxy(
505 ReceiveStatisticsProxy* receive_statistics_proxy) { 354 ReceiveStatisticsProxy* receive_statistics_proxy) {
506 rtc::CritScope lock(&crit_); 355 rtc::CritScope lock(&crit_);
507 receive_stats_callback_ = receive_statistics_proxy; 356 receive_stats_callback_ = receive_statistics_proxy;
508 } 357 }
509 358
510 void ViEChannel::SetIncomingVideoStream( 359 void ViEChannel::SetIncomingVideoStream(
511 IncomingVideoStream* incoming_video_stream) { 360 IncomingVideoStream* incoming_video_stream) {
512 rtc::CritScope lock(&crit_); 361 rtc::CritScope lock(&crit_);
513 incoming_video_stream_ = incoming_video_stream; 362 incoming_video_stream_ = incoming_video_stream;
514 } 363 }
515 } // namespace webrtc 364 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_channel.h ('k') | webrtc/video/vie_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698