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

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

Issue 1864313003: Move Ownership of RtpModules to VideoSendStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
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 16 matching lines...) Expand all
27 #include "webrtc/video/call_stats.h" 27 #include "webrtc/video/call_stats.h"
28 #include "webrtc/video/video_capture_input.h" 28 #include "webrtc/video/video_capture_input.h"
29 #include "webrtc/video/vie_remb.h" 29 #include "webrtc/video/vie_remb.h"
30 #include "webrtc/video_send_stream.h" 30 #include "webrtc/video_send_stream.h"
31 31
32 namespace webrtc { 32 namespace webrtc {
33 33
34 class RtcpIntraFrameObserver; 34 class RtcpIntraFrameObserver;
35 class TransportFeedbackObserver; 35 class TransportFeedbackObserver;
36 36
37 static const int kMinSendSidePacketHistorySize = 600;
38
39 namespace {
40
41 std::vector<RtpRtcp*> CreateRtpRtcpModules(
42 Transport* outgoing_transport,
43 RtcpIntraFrameObserver* intra_frame_callback,
44 RtcpBandwidthObserver* bandwidth_callback,
45 TransportFeedbackObserver* transport_feedback_callback,
46 RtcpRttStats* rtt_stats,
47 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
48 RtpPacketSender* paced_sender,
49 TransportSequenceNumberAllocator* transport_sequence_number_allocator,
50 BitrateStatisticsObserver* send_bitrate_observer,
51 FrameCountObserver* send_frame_count_observer,
52 SendSideDelayObserver* send_side_delay_observer,
53 size_t num_modules) {
54 RTC_DCHECK_GT(num_modules, 0u);
55 RtpRtcp::Configuration configuration;
56 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
57 configuration.audio = false;
58 configuration.receiver_only = false;
59 configuration.receive_statistics = null_receive_statistics;
60 configuration.outgoing_transport = outgoing_transport;
61 configuration.intra_frame_callback = intra_frame_callback;
62 configuration.rtt_stats = rtt_stats;
63 configuration.rtcp_packet_type_counter_observer =
64 rtcp_packet_type_counter_observer;
65 configuration.paced_sender = paced_sender;
66 configuration.transport_sequence_number_allocator =
67 transport_sequence_number_allocator;
68 configuration.send_bitrate_observer = send_bitrate_observer;
69 configuration.send_frame_count_observer = send_frame_count_observer;
70 configuration.send_side_delay_observer = send_side_delay_observer;
71 configuration.bandwidth_callback = bandwidth_callback;
72 configuration.transport_feedback_callback = transport_feedback_callback;
73
74 std::vector<RtpRtcp*> modules;
75 for (size_t i = 0; i < num_modules; ++i) {
76 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
77 rtp_rtcp->SetSendingStatus(false);
78 rtp_rtcp->SetSendingMediaStatus(false);
79 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
80 modules.push_back(rtp_rtcp);
81 }
82 return modules;
83 }
84
85 } // namespace
86
37 std::string 87 std::string
38 VideoSendStream::Config::EncoderSettings::ToString() const { 88 VideoSendStream::Config::EncoderSettings::ToString() const {
39 std::stringstream ss; 89 std::stringstream ss;
40 ss << "{payload_name: " << payload_name; 90 ss << "{payload_name: " << payload_name;
41 ss << ", payload_type: " << payload_type; 91 ss << ", payload_type: " << payload_type;
42 ss << ", encoder: " << (encoder ? "(VideoEncoder)" : "nullptr"); 92 ss << ", encoder: " << (encoder ? "(VideoEncoder)" : "nullptr");
43 ss << '}'; 93 ss << '}';
44 return ss.str(); 94 return ss.str();
45 } 95 }
46 96
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 remb_(remb), 226 remb_(remb),
177 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"), 227 encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
178 encoder_wakeup_event_(false, false), 228 encoder_wakeup_event_(false, false),
179 stop_encoder_thread_(0), 229 stop_encoder_thread_(0),
180 overuse_detector_( 230 overuse_detector_(
181 Clock::GetRealTimeClock(), 231 Clock::GetRealTimeClock(),
182 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), 232 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time),
183 this, 233 this,
184 config.post_encode_callback, 234 config.post_encode_callback,
185 &stats_proxy_), 235 &stats_proxy_),
186 vie_channel_(config.send_transport,
187 module_process_thread_,
188 &payload_router_,
189 nullptr,
190 &encoder_feedback_,
191 congestion_controller_->GetBitrateController()
192 ->CreateRtcpBandwidthObserver(),
193 congestion_controller_->GetTransportFeedbackObserver(),
194 nullptr,
195 call_stats_->rtcp_rtt_stats(),
196 congestion_controller_->pacer(),
197 congestion_controller_->packet_router(),
198 config_.rtp.ssrcs.size(),
199 true),
200 vie_receiver_(vie_channel_.vie_receiver()),
201 vie_encoder_(num_cpu_cores, 236 vie_encoder_(num_cpu_cores,
202 config_.rtp.ssrcs, 237 config_.rtp.ssrcs,
203 module_process_thread_, 238 module_process_thread_,
204 &stats_proxy_, 239 &stats_proxy_,
205 config.pre_encode_callback, 240 config.pre_encode_callback,
206 &overuse_detector_, 241 &overuse_detector_,
207 congestion_controller_->pacer(), 242 congestion_controller_->pacer(),
208 &payload_router_), 243 &payload_router_),
209 vcm_(vie_encoder_.vcm()), 244 vcm_(vie_encoder_.vcm()),
210 rtp_rtcp_modules_(vie_channel_.rtp_rtcp()), 245 rtp_rtcp_modules_(CreateRtpRtcpModules(
246 config.send_transport,
247 &encoder_feedback_,
248 congestion_controller_->GetBitrateController()
249 ->CreateRtcpBandwidthObserver(),
pbos-webrtc 2016/04/07 16:02:08 This one leaks, perhaps it should go into a scoped
perkj_webrtc 2016/04/08 10:59:04 Done.
250 congestion_controller_->GetTransportFeedbackObserver(),
251 call_stats_->rtcp_rtt_stats(),
252 &stats_proxy_,
253 congestion_controller_->pacer(),
254 congestion_controller_->packet_router(),
255 &stats_proxy_,
pbos-webrtc 2016/04/07 16:02:08 Since this function is only used here can you repl
perkj_webrtc 2016/04/08 10:59:04 Done.
256 &stats_proxy_,
257 &stats_proxy_,
258 config_.rtp.ssrcs.size())),
259 payload_router_(rtp_rtcp_modules_),
211 input_(&encoder_wakeup_event_, 260 input_(&encoder_wakeup_event_,
212 config_.local_renderer, 261 config_.local_renderer,
213 &stats_proxy_, 262 &stats_proxy_,
214 &overuse_detector_) { 263 &overuse_detector_) {
215 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); 264 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString();
216 265
217 RTC_DCHECK(!config_.rtp.ssrcs.empty()); 266 RTC_DCHECK(!config_.rtp.ssrcs.empty());
218 RTC_DCHECK(module_process_thread_); 267 RTC_DCHECK(module_process_thread_);
219 RTC_DCHECK(call_stats_); 268 RTC_DCHECK(call_stats_);
220 RTC_DCHECK(congestion_controller_); 269 RTC_DCHECK(congestion_controller_);
221 RTC_DCHECK(remb_); 270 RTC_DCHECK(remb_);
222 271
223 payload_router_.Init(rtp_rtcp_modules_);
224 RTC_CHECK(vie_encoder_.Init()); 272 RTC_CHECK(vie_encoder_.Init());
225 encoder_feedback_.Init(config_.rtp.ssrcs, &vie_encoder_); 273 encoder_feedback_.Init(config_.rtp.ssrcs, &vie_encoder_);
226 RTC_CHECK(vie_channel_.Init() == 0);
227 274
228 vcm_->RegisterProtectionCallback(vie_channel_.vcm_protection_callback()); 275 // RTP/RTCP initialization.
276 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
277 module_process_thread_->RegisterModule(rtp_rtcp);
278 congestion_controller_->packet_router()->AddRtpModule(rtp_rtcp);
279 }
229 280
230 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); 281 payload_router_.SetSendingRtpModules(1);
pbos-webrtc 2016/04/07 16:02:08 Should this just default to 1 within PayloadRouter
perkj_webrtc 2016/04/08 10:59:04 Done.
282
283 vcm_->RegisterProtectionCallback(this);
284
285 // NOW! This only seems to be used receive side from looking at the code??
pbos-webrtc 2016/04/07 16:02:08 Stefan, do you know what these CallStats are?
286 // call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver());
231 287
232 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { 288 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
233 const std::string& extension = config_.rtp.extensions[i].name; 289 const std::string& extension = config_.rtp.extensions[i].name;
234 int id = config_.rtp.extensions[i].id; 290 int id = config_.rtp.extensions[i].id;
235 // One-byte-extension local identifiers are in the range 1-14 inclusive. 291 // One-byte-extension local identifiers are in the range 1-14 inclusive.
236 RTC_DCHECK_GE(id, 1); 292 RTC_DCHECK_GE(id, 1);
237 RTC_DCHECK_LE(id, 14); 293 RTC_DCHECK_LE(id, 14);
238 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); 294 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
239 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 295 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
240 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension( 296 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension(
(...skipping 12 matching lines...) Expand all
253 // a waste of bandwidth since FEC packets still have to be transmitted. Note 309 // a waste of bandwidth since FEC packets still have to be transmitted. Note
254 // that this is not the case with FLEXFEC. 310 // that this is not the case with FLEXFEC.
255 if (enable_protection_nack && 311 if (enable_protection_nack &&
256 !PayloadTypeSupportsSkippingFecPackets( 312 !PayloadTypeSupportsSkippingFecPackets(
257 config_.encoder_settings.payload_name)) { 313 config_.encoder_settings.payload_name)) {
258 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" 314 LOG(LS_WARNING) << "Transmitting payload type without picture ID using"
259 "NACK+FEC is a waste of bandwidth since FEC packets " 315 "NACK+FEC is a waste of bandwidth since FEC packets "
260 "also have to be retransmitted. Disabling FEC."; 316 "also have to be retransmitted. Disabling FEC.";
261 enable_protection_fec = false; 317 enable_protection_fec = false;
262 } 318 }
319
320 // Set to valid uint8_ts to be castable later without signed overflows.
321 uint8_t payload_type_red = 0;
pbos-webrtc 2016/04/07 16:02:08 Can you break out this block into a separate metho
perkj_webrtc 2016/04/08 10:59:04 Done.
322 uint8_t payload_type_fec = 0;
263 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. 323 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future.
264 vie_channel_.SetProtectionMode(enable_protection_nack, enable_protection_fec, 324 // Validate payload types. If either RED or FEC payload types are set then
265 config_.rtp.fec.red_payload_type, 325 // both should be. If FEC is enabled then they both have to be set.
266 config_.rtp.fec.ulpfec_payload_type); 326 if (enable_protection_fec || config_.rtp.fec.red_payload_type != -1 ||
327 config_.rtp.fec.ulpfec_payload_type != -1) {
328 RTC_DCHECK_GE(config_.rtp.fec.red_payload_type, 0);
329 RTC_DCHECK_GE(config_.rtp.fec.ulpfec_payload_type, 0);
330 RTC_DCHECK_LE(config_.rtp.fec.red_payload_type, 127);
331 RTC_DCHECK_LE(config_.rtp.fec.ulpfec_payload_type, 127);
332 payload_type_red = static_cast<uint8_t>(config_.rtp.fec.red_payload_type);
333 payload_type_fec =
334 static_cast<uint8_t>(config_.rtp.fec.ulpfec_payload_type);
335 } else {
336 // Payload types unset.
337 RTC_DCHECK_EQ(config_.rtp.fec.red_payload_type, -1);
338 RTC_DCHECK_EQ(config_.rtp.fec.ulpfec_payload_type, -1);
339 }
340
341 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
342 // Set NACK.
343 rtp_rtcp->SetStorePacketsStatus(
344 enable_protection_nack || congestion_controller_->pacer(),
345 kMinSendSidePacketHistorySize);
346 // Set FEC.
347 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
348 rtp_rtcp->SetGenericFECStatus(enable_protection_fec, payload_type_red,
349 payload_type_fec);
350 }
351 }
352
267 vie_encoder_.SetProtectionMethod(enable_protection_nack, 353 vie_encoder_.SetProtectionMethod(enable_protection_nack,
268 enable_protection_fec); 354 enable_protection_fec);
269 355
270 ConfigureSsrcs(); 356 ConfigureSsrcs();
271 357
272 // TODO(pbos): Should we set CNAME on all RTP modules? 358 // TODO(pbos): Should we set CNAME on all RTP modules?
273 rtp_rtcp_modules_.front()->SetCNAME(config_.rtp.c_name.c_str()); 359 rtp_rtcp_modules_.front()->SetCNAME(config_.rtp.c_name.c_str());
274 // 28 to match packet overhead in ModuleRtpRtcpImpl. 360 // 28 to match packet overhead in ModuleRtpRtcpImpl.
275 static const size_t kRtpPacketSizeOverhead = 28; 361 static const size_t kRtpPacketSizeOverhead = 28;
276 RTC_DCHECK_LE(config_.rtp.max_packet_size, 0xFFFFu + kRtpPacketSizeOverhead); 362 RTC_DCHECK_LE(config_.rtp.max_packet_size, 0xFFFFu + kRtpPacketSizeOverhead);
(...skipping 11 matching lines...) Expand all
288 RTC_DCHECK(config.encoder_settings.encoder); 374 RTC_DCHECK(config.encoder_settings.encoder);
289 RTC_DCHECK_GE(config.encoder_settings.payload_type, 0); 375 RTC_DCHECK_GE(config.encoder_settings.payload_type, 0);
290 RTC_DCHECK_LE(config.encoder_settings.payload_type, 127); 376 RTC_DCHECK_LE(config.encoder_settings.payload_type, 127);
291 RTC_CHECK_EQ(0, vie_encoder_.RegisterExternalEncoder( 377 RTC_CHECK_EQ(0, vie_encoder_.RegisterExternalEncoder(
292 config.encoder_settings.encoder, 378 config.encoder_settings.encoder,
293 config.encoder_settings.payload_type, 379 config.encoder_settings.payload_type,
294 config.encoder_settings.internal_source)); 380 config.encoder_settings.internal_source));
295 381
296 ReconfigureVideoEncoder(encoder_config); 382 ReconfigureVideoEncoder(encoder_config);
297 383
298 vie_channel_.RegisterSendSideDelayObserver(&stats_proxy_);
299
300 if (config_.post_encode_callback) 384 if (config_.post_encode_callback)
301 vie_encoder_.RegisterPostEncodeImageCallback(&encoded_frame_proxy_); 385 vie_encoder_.RegisterPostEncodeImageCallback(&encoded_frame_proxy_);
302 386
303 if (config_.suspend_below_min_bitrate) { 387 if (config_.suspend_below_min_bitrate) {
304 vcm_->SuspendBelowMinBitrate(); 388 vcm_->SuspendBelowMinBitrate();
305 bitrate_allocator_->EnforceMinBitrate(false); 389 bitrate_allocator_->EnforceMinBitrate(false);
306 } 390 }
307 391
308 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_);
309 vie_channel_.RegisterSendBitrateObserver(&stats_proxy_);
310 vie_channel_.RegisterSendFrameCountObserver(&stats_proxy_);
311
312 module_process_thread_->RegisterModule(&overuse_detector_); 392 module_process_thread_->RegisterModule(&overuse_detector_);
313 393
314 encoder_thread_.Start(); 394 encoder_thread_.Start();
315 encoder_thread_.SetPriority(rtc::kHighPriority); 395 encoder_thread_.SetPriority(rtc::kHighPriority);
316 } 396 }
317 397
318 VideoSendStream::~VideoSendStream() { 398 VideoSendStream::~VideoSendStream() {
319 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString(); 399 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString();
320 400
321 Stop(); 401 Stop();
322 402
323 // Stop the encoder thread permanently. 403 // Stop the encoder thread permanently.
324 rtc::AtomicOps::ReleaseStore(&stop_encoder_thread_, 1); 404 rtc::AtomicOps::ReleaseStore(&stop_encoder_thread_, 1);
325 encoder_wakeup_event_.Set(); 405 encoder_wakeup_event_.Set();
326 encoder_thread_.Stop(); 406 encoder_thread_.Stop();
327 407
328 // This needs to happen after stopping the encoder thread, 408 // This needs to happen after stopping the encoder thread,
329 // since the encoder thread calls AddObserver. 409 // since the encoder thread calls AddObserver.
330 bitrate_allocator_->RemoveObserver(this); 410 bitrate_allocator_->RemoveObserver(this);
331 411
332 module_process_thread_->DeRegisterModule(&overuse_detector_); 412 module_process_thread_->DeRegisterModule(&overuse_detector_);
333 vie_channel_.RegisterSendFrameCountObserver(nullptr);
334 vie_channel_.RegisterSendBitrateObserver(nullptr);
335 vie_channel_.RegisterRtcpPacketTypeCounterObserver(nullptr);
336 413
337 vie_encoder_.DeRegisterExternalEncoder(config_.encoder_settings.payload_type); 414 vie_encoder_.DeRegisterExternalEncoder(config_.encoder_settings.payload_type);
338 415
339 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); 416 // call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver());
340 rtp_rtcp_modules_[0]->SetREMBStatus(false); 417 rtp_rtcp_modules_[0]->SetREMBStatus(false);
341 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); 418 remb_->RemoveRembSender(rtp_rtcp_modules_[0]);
342 419
343 // ViEChannel outlives ViEEncoder so remove encoder from feedback before 420 // What is this???????
344 // destruction. 421 // congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream(
pbos-webrtc 2016/04/07 16:02:08 Looks removable, don't think we need to remote est
345 encoder_feedback_.TearDown(); 422 // vie_receiver_->GetRemoteSsrc());
346 423
347 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream( 424 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
348 vie_receiver_->GetRemoteSsrc()); 425 congestion_controller_->packet_router()->RemoveRtpModule(rtp_rtcp);
426 module_process_thread_->DeRegisterModule(rtp_rtcp);
427 delete rtp_rtcp;
428 }
349 } 429 }
350 430
351 VideoCaptureInput* VideoSendStream::Input() { 431 VideoCaptureInput* VideoSendStream::Input() {
352 return &input_; 432 return &input_;
353 } 433 }
354 434
355 void VideoSendStream::Start() { 435 void VideoSendStream::Start() {
356 if (payload_router_.active()) 436 if (payload_router_.active())
357 return; 437 return;
358 vie_encoder_.Pause(); 438 vie_encoder_.Pause();
359 payload_router_.set_active(true); 439 payload_router_.set_active(true);
360 // Was not already started, trigger a keyframe. 440 // Was not already started, trigger a keyframe.
361 vie_encoder_.SendKeyFrame(); 441 vie_encoder_.SendKeyFrame();
362 vie_encoder_.Restart(); 442 vie_encoder_.Restart();
363 vie_receiver_->StartReceive();
364 } 443 }
365 444
366 void VideoSendStream::Stop() { 445 void VideoSendStream::Stop() {
367 if (!payload_router_.active()) 446 if (!payload_router_.active())
368 return; 447 return;
369 // TODO(pbos): Make sure the encoder stops here. 448 // TODO(pbos): Make sure the encoder stops here.
370 payload_router_.set_active(false); 449 payload_router_.set_active(false);
371 vie_receiver_->StopReceive();
372 } 450 }
373 451
374 bool VideoSendStream::EncoderThreadFunction(void* obj) { 452 bool VideoSendStream::EncoderThreadFunction(void* obj) {
375 static_cast<VideoSendStream*>(obj)->EncoderProcess(); 453 static_cast<VideoSendStream*>(obj)->EncoderProcess();
376 // We're done, return false to abort. 454 // We're done, return false to abort.
377 return false; 455 return false;
378 } 456 }
379 457
380 void VideoSendStream::EncoderProcess() { 458 void VideoSendStream::EncoderProcess() {
381 while (true) { 459 while (true) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 video_codec.maxFramerate = streams[0].max_framerate; 604 video_codec.maxFramerate = streams[0].max_framerate;
527 605
528 video_codec.startBitrate = 606 video_codec.startBitrate =
529 bitrate_allocator_->AddObserver(this, 607 bitrate_allocator_->AddObserver(this,
530 video_codec.minBitrate * 1000, 608 video_codec.minBitrate * 1000,
531 video_codec.maxBitrate * 1000) / 1000; 609 video_codec.maxBitrate * 1000) / 1000;
532 vie_encoder_.SetEncoder(video_codec, config.min_transmit_bitrate_bps); 610 vie_encoder_.SetEncoder(video_codec, config.min_transmit_bitrate_bps);
533 } 611 }
534 612
535 bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { 613 bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
536 return vie_receiver_->DeliverRtcp(packet, length); 614 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
615 rtp_rtcp->IncomingRtcpPacket(packet, length);
616 return true;
537 } 617 }
538 618
539 VideoSendStream::Stats VideoSendStream::GetStats() { 619 VideoSendStream::Stats VideoSendStream::GetStats() {
540 return stats_proxy_.GetStats(); 620 return stats_proxy_.GetStats();
541 } 621 }
542 622
543 void VideoSendStream::OveruseDetected() { 623 void VideoSendStream::OveruseDetected() {
544 if (config_.overuse_callback) 624 if (config_.overuse_callback)
545 config_.overuse_callback->OnLoadUpdate(LoadObserver::kOveruse); 625 config_.overuse_callback->OnLoadUpdate(LoadObserver::kOveruse);
546 } 626 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 rtp_rtcp->SetRtxSendPayloadType(config_.rtp.fec.red_rtx_payload_type, 671 rtp_rtcp->SetRtxSendPayloadType(config_.rtp.fec.red_rtx_payload_type,
592 config_.rtp.fec.red_payload_type); 672 config_.rtp.fec.red_payload_type);
593 } 673 }
594 } 674 }
595 } 675 }
596 676
597 std::map<uint32_t, RtpState> VideoSendStream::GetRtpStates() const { 677 std::map<uint32_t, RtpState> VideoSendStream::GetRtpStates() const {
598 std::map<uint32_t, RtpState> rtp_states; 678 std::map<uint32_t, RtpState> rtp_states;
599 for (size_t i = 0; i < config_.rtp.ssrcs.size(); ++i) { 679 for (size_t i = 0; i < config_.rtp.ssrcs.size(); ++i) {
600 uint32_t ssrc = config_.rtp.ssrcs[i]; 680 uint32_t ssrc = config_.rtp.ssrcs[i];
601 rtp_states[ssrc] = vie_channel_.GetRtpStateForSsrc(ssrc); 681 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
pbos-webrtc 2016/04/07 16:02:08 Can't we use rtp_rtcp_modules_[i]->GetRtpStateForS
perkj_webrtc 2016/04/08 10:59:04 hum.... right...
682 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_states[ssrc]))
683 break;
684 }
602 } 685 }
603 686
604 for (size_t i = 0; i < config_.rtp.rtx.ssrcs.size(); ++i) { 687 for (size_t i = 0; i < config_.rtp.rtx.ssrcs.size(); ++i) {
605 uint32_t ssrc = config_.rtp.rtx.ssrcs[i]; 688 uint32_t ssrc = config_.rtp.rtx.ssrcs[i];
606 rtp_states[ssrc] = vie_channel_.GetRtpStateForSsrc(ssrc); 689 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
690 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_states[ssrc]))
691 break;
692 }
607 } 693 }
608 694
609 return rtp_states; 695 return rtp_states;
610 } 696 }
611 697
612 void VideoSendStream::SignalNetworkState(NetworkState state) { 698 void VideoSendStream::SignalNetworkState(NetworkState state) {
613 // When network goes up, enable RTCP status before setting transmission state. 699 // When network goes up, enable RTCP status before setting transmission state.
614 // When it goes down, disable RTCP afterwards. This ensures that any packets 700 // When it goes down, disable RTCP afterwards. This ensures that any packets
615 // sent due to the network state changed will not be dropped. 701 // sent due to the network state changed will not be dropped.
616 if (state == kNetworkUp) { 702 if (state == kNetworkUp) {
(...skipping 10 matching lines...) Expand all
627 int VideoSendStream::GetPaddingNeededBps() const { 713 int VideoSendStream::GetPaddingNeededBps() const {
628 return vie_encoder_.GetPaddingNeededBps(); 714 return vie_encoder_.GetPaddingNeededBps();
629 } 715 }
630 716
631 void VideoSendStream::OnBitrateUpdated(uint32_t bitrate_bps, 717 void VideoSendStream::OnBitrateUpdated(uint32_t bitrate_bps,
632 uint8_t fraction_loss, 718 uint8_t fraction_loss,
633 int64_t rtt) { 719 int64_t rtt) {
634 vie_encoder_.OnBitrateUpdated(bitrate_bps, fraction_loss, rtt); 720 vie_encoder_.OnBitrateUpdated(bitrate_bps, fraction_loss, rtt);
635 } 721 }
636 722
723
724 int VideoSendStream::ProtectionRequest(const FecProtectionParams* delta_params,
725 const FecProtectionParams* key_params,
726 uint32_t* sent_video_rate_bps,
727 uint32_t* sent_nack_rate_bps,
728 uint32_t* sent_fec_rate_bps) {
729 *sent_video_rate_bps = 0;
730 *sent_nack_rate_bps = 0;
731 *sent_fec_rate_bps = 0;
732 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
733 uint32_t not_used = 0;
734 uint32_t module_video_rate = 0;
735 uint32_t module_fec_rate = 0;
736 uint32_t module_nack_rate = 0;
737 rtp_rtcp->SetFecParameters(delta_params, key_params);
738 rtp_rtcp->BitrateSent(&not_used, &module_video_rate, &module_fec_rate,
739 &module_nack_rate);
740 *sent_video_rate_bps += module_video_rate;
741 *sent_nack_rate_bps += module_nack_rate;
742 *sent_fec_rate_bps += module_fec_rate;
743 }
744 return 0;
745 }
746
637 } // namespace internal 747 } // namespace internal
638 } // namespace webrtc 748 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698