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

Side by Side Diff: webrtc/call/call.cc

Issue 2685673003: Define RtpTransportControllerSendInterface. (Closed)
Patch Set: Minor comment update. Created 3 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/call/BUILD.gn ('k') | webrtc/call/rtp_transport_controller_send.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) 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 15 matching lines...) Expand all
26 #include "webrtc/base/location.h" 26 #include "webrtc/base/location.h"
27 #include "webrtc/base/logging.h" 27 #include "webrtc/base/logging.h"
28 #include "webrtc/base/optional.h" 28 #include "webrtc/base/optional.h"
29 #include "webrtc/base/task_queue.h" 29 #include "webrtc/base/task_queue.h"
30 #include "webrtc/base/thread_annotations.h" 30 #include "webrtc/base/thread_annotations.h"
31 #include "webrtc/base/thread_checker.h" 31 #include "webrtc/base/thread_checker.h"
32 #include "webrtc/base/trace_event.h" 32 #include "webrtc/base/trace_event.h"
33 #include "webrtc/call/bitrate_allocator.h" 33 #include "webrtc/call/bitrate_allocator.h"
34 #include "webrtc/call/call.h" 34 #include "webrtc/call/call.h"
35 #include "webrtc/call/flexfec_receive_stream_impl.h" 35 #include "webrtc/call/flexfec_receive_stream_impl.h"
36 #include "webrtc/call/rtp_transport_controller_send.h"
36 #include "webrtc/config.h" 37 #include "webrtc/config.h"
37 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
38 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 39 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
39 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h" 40 #include "webrtc/modules/congestion_controller/include/receive_side_congestion_c ontroller.h"
40 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 41 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
41 #include "webrtc/modules/pacing/paced_sender.h" 42 #include "webrtc/modules/pacing/paced_sender.h"
42 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" 43 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h"
43 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 44 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
44 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 45 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
45 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" 46 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 82 }
82 83
83 bool UseSendSideBwe(const AudioReceiveStream::Config& config) { 84 bool UseSendSideBwe(const AudioReceiveStream::Config& config) {
84 return UseSendSideBwe(config.rtp.extensions, config.rtp.transport_cc); 85 return UseSendSideBwe(config.rtp.extensions, config.rtp.transport_cc);
85 } 86 }
86 87
87 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) { 88 bool UseSendSideBwe(const FlexfecReceiveStream::Config& config) {
88 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc); 89 return UseSendSideBwe(config.rtp_header_extensions, config.transport_cc);
89 } 90 }
90 91
92 class RtpTransportControllerSend : public RtpTransportControllerSendInterface {
93 public:
94 RtpTransportControllerSend(Clock* clock, webrtc::RtcEventLog* event_log);
stefan-webrtc 2017/03/27 11:14:11 Empty line below
nisse-webrtc 2017/03/27 11:41:22 Done.
95 void InitCongestionControl(SendSideCongestionController::Observer* observer);
96 PacketRouter* packet_router() override { return &packet_router_; }
97 SendSideCongestionController* send_side_cc() override {
98 return send_side_cc_.get();
99 }
100 TransportFeedbackObserver* transport_feedback_observer() override {
101 return send_side_cc_.get();
102 }
103 RtpPacketSender* packet_sender() override { return send_side_cc_->pacer(); }
104
105 private:
106 Clock* const clock_;
107 webrtc::RtcEventLog* const event_log_;
108 PacketRouter packet_router_;
109 // Construction delayed until InitCongestionControl, since the
110 // CongestionController wants its observer as a construction time
111 // argument, and setting it later seems no-trivial.
stefan-webrtc 2017/03/27 11:14:11 nit: non-trivial? I think we later will want to b
nisse-webrtc 2017/03/27 11:41:22 Done.
112 std::unique_ptr<SendSideCongestionController> send_side_cc_;
113 };
114
115 RtpTransportControllerSend::RtpTransportControllerSend(
116 Clock* clock,
117 webrtc::RtcEventLog* event_log)
118 : clock_(clock), event_log_(event_log) {}
119
120 void RtpTransportControllerSend::InitCongestionControl(
121 SendSideCongestionController::Observer* observer) {
122 // Must be called only once.
123 RTC_CHECK(!send_side_cc_);
124 send_side_cc_.reset(new SendSideCongestionController(
125 clock_, observer, event_log_, &packet_router_));
126 }
127
91 } // namespace 128 } // namespace
92 129
93 namespace internal { 130 namespace internal {
94 131
95 class Call : public webrtc::Call, 132 class Call : public webrtc::Call,
96 public PacketReceiver, 133 public PacketReceiver,
97 public RecoveredPacketReceiver, 134 public RecoveredPacketReceiver,
98 public SendSideCongestionController::Observer, 135 public SendSideCongestionController::Observer,
99 public BitrateAllocator::LimitObserver { 136 public BitrateAllocator::LimitObserver {
100 public: 137 public:
101 explicit Call(const Call::Config& config); 138 Call(const Call::Config& config,
139 std::unique_ptr<RtpTransportControllerSend> transport_send);
102 virtual ~Call(); 140 virtual ~Call();
103 141
104 // Implements webrtc::Call. 142 // Implements webrtc::Call.
105 PacketReceiver* Receiver() override; 143 PacketReceiver* Receiver() override;
106 144
107 webrtc::AudioSendStream* CreateAudioSendStream( 145 webrtc::AudioSendStream* CreateAudioSendStream(
108 const webrtc::AudioSendStream::Config& config) override; 146 const webrtc::AudioSendStream::Config& config) override;
109 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; 147 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
110 148
111 webrtc::AudioReceiveStream* CreateAudioReceiveStream( 149 webrtc::AudioReceiveStream* CreateAudioReceiveStream(
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // TODO(holmer): Remove this lock once BitrateController no longer calls 303 // TODO(holmer): Remove this lock once BitrateController no longer calls
266 // OnNetworkChanged from multiple threads. 304 // OnNetworkChanged from multiple threads.
267 rtc::CriticalSection bitrate_crit_; 305 rtc::CriticalSection bitrate_crit_;
268 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 306 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
269 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 307 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
270 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 308 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
271 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); 309 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
272 310
273 std::map<std::string, rtc::NetworkRoute> network_routes_; 311 std::map<std::string, rtc::NetworkRoute> network_routes_;
274 312
313 std::unique_ptr<RtpTransportControllerSend> transport_send_;
275 VieRemb remb_; 314 VieRemb remb_;
276 PacketRouter packet_router_;
277 SendSideCongestionController send_side_cc_;
278 ReceiveSideCongestionController receive_side_cc_; 315 ReceiveSideCongestionController receive_side_cc_;
279 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; 316 const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
280 const int64_t start_ms_; 317 const int64_t start_ms_;
281 // TODO(perkj): |worker_queue_| is supposed to replace 318 // TODO(perkj): |worker_queue_| is supposed to replace
282 // |module_process_thread_|. 319 // |module_process_thread_|.
283 // |worker_queue| is defined last to ensure all pending tasks are cancelled 320 // |worker_queue| is defined last to ensure all pending tasks are cancelled
284 // and deleted before any other members. 321 // and deleted before any other members.
285 rtc::TaskQueue worker_queue_; 322 rtc::TaskQueue worker_queue_;
286 323
287 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 324 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
288 }; 325 };
289 } // namespace internal 326 } // namespace internal
290 327
291 std::string Call::Stats::ToString(int64_t time_ms) const { 328 std::string Call::Stats::ToString(int64_t time_ms) const {
292 std::stringstream ss; 329 std::stringstream ss;
293 ss << "Call stats: " << time_ms << ", {"; 330 ss << "Call stats: " << time_ms << ", {";
294 ss << "send_bw_bps: " << send_bandwidth_bps << ", "; 331 ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
295 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", "; 332 ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
296 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", "; 333 ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
297 ss << "pacer_delay_ms: " << pacer_delay_ms << ", "; 334 ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
298 ss << "rtt_ms: " << rtt_ms; 335 ss << "rtt_ms: " << rtt_ms;
299 ss << '}'; 336 ss << '}';
300 return ss.str(); 337 return ss.str();
301 } 338 }
302 339
303 Call* Call::Create(const Call::Config& config) { 340 Call* Call::Create(const Call::Config& config) {
304 return new internal::Call(config); 341 return new internal::Call(
342 config, std::unique_ptr<RtpTransportControllerSend>(
343 new RtpTransportControllerSend(Clock::GetRealTimeClock(),
344 config.event_log)));
305 } 345 }
306 346
307 namespace internal { 347 namespace internal {
308 348
309 Call::Call(const Call::Config& config) 349 Call::Call(const Call::Config& config,
350 std::unique_ptr<RtpTransportControllerSend> transport_send)
310 : clock_(Clock::GetRealTimeClock()), 351 : clock_(Clock::GetRealTimeClock()),
311 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 352 num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
312 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 353 module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
313 pacer_thread_(ProcessThread::Create("PacerThread")), 354 pacer_thread_(ProcessThread::Create("PacerThread")),
314 call_stats_(new CallStats(clock_)), 355 call_stats_(new CallStats(clock_)),
315 bitrate_allocator_(new BitrateAllocator(this)), 356 bitrate_allocator_(new BitrateAllocator(this)),
316 config_(config), 357 config_(config),
317 audio_network_state_(kNetworkDown), 358 audio_network_state_(kNetworkDown),
318 video_network_state_(kNetworkDown), 359 video_network_state_(kNetworkDown),
319 receive_crit_(RWLockWrapper::CreateRWLock()), 360 receive_crit_(RWLockWrapper::CreateRWLock()),
320 send_crit_(RWLockWrapper::CreateRWLock()), 361 send_crit_(RWLockWrapper::CreateRWLock()),
321 event_log_(config.event_log), 362 event_log_(config.event_log),
322 first_packet_sent_ms_(-1), 363 first_packet_sent_ms_(-1),
323 received_bytes_per_second_counter_(clock_, nullptr, true), 364 received_bytes_per_second_counter_(clock_, nullptr, true),
324 received_audio_bytes_per_second_counter_(clock_, nullptr, true), 365 received_audio_bytes_per_second_counter_(clock_, nullptr, true),
325 received_video_bytes_per_second_counter_(clock_, nullptr, true), 366 received_video_bytes_per_second_counter_(clock_, nullptr, true),
326 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 367 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
327 min_allocated_send_bitrate_bps_(0), 368 min_allocated_send_bitrate_bps_(0),
328 configured_max_padding_bitrate_bps_(0), 369 configured_max_padding_bitrate_bps_(0),
329 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 370 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
330 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 371 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
372 transport_send_(std::move(transport_send)),
331 remb_(clock_), 373 remb_(clock_),
332 send_side_cc_(clock_, this, event_log_, &packet_router_), 374 receive_side_cc_(clock_, &remb_, transport_send_->packet_router()),
333 receive_side_cc_(clock_, &remb_, &packet_router_),
334 video_send_delay_stats_(new SendDelayStats(clock_)), 375 video_send_delay_stats_(new SendDelayStats(clock_)),
335 start_ms_(clock_->TimeInMilliseconds()), 376 start_ms_(clock_->TimeInMilliseconds()),
336 worker_queue_("call_worker_queue") { 377 worker_queue_("call_worker_queue") {
337 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 378 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
338 RTC_DCHECK(config.event_log != nullptr); 379 RTC_DCHECK(config.event_log != nullptr);
339 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 380 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
340 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps, 381 RTC_DCHECK_GT(config.bitrate_config.start_bitrate_bps,
341 config.bitrate_config.min_bitrate_bps); 382 config.bitrate_config.min_bitrate_bps);
342 if (config.bitrate_config.max_bitrate_bps != -1) { 383 if (config.bitrate_config.max_bitrate_bps != -1) {
343 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 384 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
344 config.bitrate_config.start_bitrate_bps); 385 config.bitrate_config.start_bitrate_bps);
345 } 386 }
346 Trace::CreateTrace(); 387 Trace::CreateTrace();
347 call_stats_->RegisterStatsObserver(&send_side_cc_); 388 transport_send_->InitCongestionControl(this);
348 389 transport_send_->send_side_cc()->SignalNetworkState(kNetworkDown);
349 send_side_cc_.SignalNetworkState(kNetworkDown); 390 transport_send_->send_side_cc()->SetBweBitrates(
350 send_side_cc_.SetBweBitrates(config_.bitrate_config.min_bitrate_bps, 391 config_.bitrate_config.min_bitrate_bps,
351 config_.bitrate_config.start_bitrate_bps, 392 config_.bitrate_config.start_bitrate_bps,
352 config_.bitrate_config.max_bitrate_bps); 393 config_.bitrate_config.max_bitrate_bps);
394 call_stats_->RegisterStatsObserver(transport_send_->send_side_cc());
353 395
354 module_process_thread_->Start(); 396 module_process_thread_->Start();
355 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); 397 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE);
356 module_process_thread_->RegisterModule(&send_side_cc_, RTC_FROM_HERE);
357 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE); 398 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE);
358 pacer_thread_->RegisterModule(send_side_cc_.pacer(), RTC_FROM_HERE); 399 module_process_thread_->RegisterModule(transport_send_->send_side_cc(),
400 RTC_FROM_HERE);
401 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(),
402 RTC_FROM_HERE);
359 pacer_thread_->RegisterModule( 403 pacer_thread_->RegisterModule(
360 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE); 404 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE);
405
361 pacer_thread_->Start(); 406 pacer_thread_->Start();
362 } 407 }
363 408
364 Call::~Call() { 409 Call::~Call() {
365 RTC_DCHECK(!remb_.InUse()); 410 RTC_DCHECK(!remb_.InUse());
366 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 411 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
367 412
368 RTC_CHECK(audio_send_ssrcs_.empty()); 413 RTC_CHECK(audio_send_ssrcs_.empty());
369 RTC_CHECK(video_send_ssrcs_.empty()); 414 RTC_CHECK(video_send_ssrcs_.empty());
370 RTC_CHECK(video_send_streams_.empty()); 415 RTC_CHECK(video_send_streams_.empty());
371 RTC_CHECK(audio_receive_ssrcs_.empty()); 416 RTC_CHECK(audio_receive_ssrcs_.empty());
372 RTC_CHECK(video_receive_ssrcs_.empty()); 417 RTC_CHECK(video_receive_ssrcs_.empty());
373 RTC_CHECK(video_receive_streams_.empty()); 418 RTC_CHECK(video_receive_streams_.empty());
374 419
375 pacer_thread_->Stop(); 420 pacer_thread_->Stop();
376 pacer_thread_->DeRegisterModule(send_side_cc_.pacer()); 421 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer());
377 pacer_thread_->DeRegisterModule( 422 pacer_thread_->DeRegisterModule(
378 receive_side_cc_.GetRemoteBitrateEstimator(true)); 423 receive_side_cc_.GetRemoteBitrateEstimator(true));
379 module_process_thread_->DeRegisterModule(&send_side_cc_); 424 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc());
380 module_process_thread_->DeRegisterModule(&receive_side_cc_); 425 module_process_thread_->DeRegisterModule(&receive_side_cc_);
381 module_process_thread_->DeRegisterModule(call_stats_.get()); 426 module_process_thread_->DeRegisterModule(call_stats_.get());
382 module_process_thread_->Stop(); 427 module_process_thread_->Stop();
383 call_stats_->DeregisterStatsObserver(&send_side_cc_); 428 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc());
384 429
385 // Only update histograms after process threads have been shut down, so that 430 // Only update histograms after process threads have been shut down, so that
386 // they won't try to concurrently update stats. 431 // they won't try to concurrently update stats.
387 { 432 {
388 rtc::CritScope lock(&bitrate_crit_); 433 rtc::CritScope lock(&bitrate_crit_);
389 UpdateSendHistograms(); 434 UpdateSendHistograms();
390 } 435 }
391 UpdateReceiveHistograms(); 436 UpdateReceiveHistograms();
392 UpdateHistograms(); 437 UpdateHistograms();
393 438
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 536 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
492 return this; 537 return this;
493 } 538 }
494 539
495 webrtc::AudioSendStream* Call::CreateAudioSendStream( 540 webrtc::AudioSendStream* Call::CreateAudioSendStream(
496 const webrtc::AudioSendStream::Config& config) { 541 const webrtc::AudioSendStream::Config& config) {
497 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); 542 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
498 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 543 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
499 event_log_->LogAudioSendStreamConfig(config); 544 event_log_->LogAudioSendStreamConfig(config);
500 AudioSendStream* send_stream = new AudioSendStream( 545 AudioSendStream* send_stream = new AudioSendStream(
501 config, config_.audio_state, &worker_queue_, &packet_router_, 546 config, config_.audio_state, &worker_queue_, transport_send_.get(),
502 &send_side_cc_, bitrate_allocator_.get(), event_log_, 547 bitrate_allocator_.get(), event_log_, call_stats_->rtcp_rtt_stats());
503 call_stats_->rtcp_rtt_stats());
504 { 548 {
505 WriteLockScoped write_lock(*send_crit_); 549 WriteLockScoped write_lock(*send_crit_);
506 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == 550 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
507 audio_send_ssrcs_.end()); 551 audio_send_ssrcs_.end());
508 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; 552 audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
509 } 553 }
510 { 554 {
511 ReadLockScoped read_lock(*receive_crit_); 555 ReadLockScoped read_lock(*receive_crit_);
512 for (const auto& kv : audio_receive_ssrcs_) { 556 for (const auto& kv : audio_receive_ssrcs_) {
513 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) { 557 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 589 }
546 UpdateAggregateNetworkState(); 590 UpdateAggregateNetworkState();
547 delete audio_send_stream; 591 delete audio_send_stream;
548 } 592 }
549 593
550 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 594 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
551 const webrtc::AudioReceiveStream::Config& config) { 595 const webrtc::AudioReceiveStream::Config& config) {
552 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 596 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
553 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 597 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
554 event_log_->LogAudioReceiveStreamConfig(config); 598 event_log_->LogAudioReceiveStreamConfig(config);
555 AudioReceiveStream* receive_stream = new AudioReceiveStream( 599 AudioReceiveStream* receive_stream =
556 &packet_router_, config, 600 new AudioReceiveStream(transport_send_->packet_router(), config,
557 config_.audio_state, event_log_); 601 config_.audio_state, event_log_);
558 { 602 {
559 WriteLockScoped write_lock(*receive_crit_); 603 WriteLockScoped write_lock(*receive_crit_);
560 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == 604 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
561 audio_receive_ssrcs_.end()); 605 audio_receive_ssrcs_.end());
562 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 606 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
563 receive_rtp_config_[config.rtp.remote_ssrc] = 607 receive_rtp_config_[config.rtp.remote_ssrc] =
564 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config)); 608 ReceiveRtpConfig(config.rtp.extensions, UseSendSideBwe(config));
565 609
566 ConfigureSync(config.sync_group); 610 ConfigureSync(config.sync_group);
567 } 611 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 657
614 video_send_delay_stats_->AddSsrcs(config); 658 video_send_delay_stats_->AddSsrcs(config);
615 event_log_->LogVideoSendStreamConfig(config); 659 event_log_->LogVideoSendStreamConfig(config);
616 660
617 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 661 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
618 // the call has already started. 662 // the call has already started.
619 // Copy ssrcs from |config| since |config| is moved. 663 // Copy ssrcs from |config| since |config| is moved.
620 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; 664 std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
621 VideoSendStream* send_stream = new VideoSendStream( 665 VideoSendStream* send_stream = new VideoSendStream(
622 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, 666 num_cpu_cores_, module_process_thread_.get(), &worker_queue_,
623 call_stats_.get(), &send_side_cc_, &packet_router_, 667 call_stats_.get(), transport_send_.get(), bitrate_allocator_.get(),
624 bitrate_allocator_.get(), video_send_delay_stats_.get(), &remb_, 668 video_send_delay_stats_.get(), &remb_, event_log_, std::move(config),
625 event_log_, std::move(config), std::move(encoder_config), 669 std::move(encoder_config), suspended_video_send_ssrcs_);
626 suspended_video_send_ssrcs_);
627 670
628 { 671 {
629 WriteLockScoped write_lock(*send_crit_); 672 WriteLockScoped write_lock(*send_crit_);
630 for (uint32_t ssrc : ssrcs) { 673 for (uint32_t ssrc : ssrcs) {
631 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 674 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
632 video_send_ssrcs_[ssrc] = send_stream; 675 video_send_ssrcs_[ssrc] = send_stream;
633 } 676 }
634 video_send_streams_.insert(send_stream); 677 video_send_streams_.insert(send_stream);
635 } 678 }
636 send_stream->SignalNetworkState(video_network_state_); 679 send_stream->SignalNetworkState(video_network_state_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 UpdateAggregateNetworkState(); 716 UpdateAggregateNetworkState();
674 delete send_stream_impl; 717 delete send_stream_impl;
675 } 718 }
676 719
677 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( 720 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
678 webrtc::VideoReceiveStream::Config configuration) { 721 webrtc::VideoReceiveStream::Config configuration) {
679 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); 722 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
680 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 723 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
681 724
682 VideoReceiveStream* receive_stream = new VideoReceiveStream( 725 VideoReceiveStream* receive_stream = new VideoReceiveStream(
683 num_cpu_cores_, &packet_router_, std::move(configuration), 726 num_cpu_cores_, transport_send_->packet_router(),
684 module_process_thread_.get(), call_stats_.get(), &remb_); 727 std::move(configuration), module_process_thread_.get(), call_stats_.get(),
728 &remb_);
685 729
686 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); 730 const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
687 ReceiveRtpConfig receive_config(config.rtp.extensions, 731 ReceiveRtpConfig receive_config(config.rtp.extensions,
688 UseSendSideBwe(config)); 732 UseSendSideBwe(config));
689 { 733 {
690 WriteLockScoped write_lock(*receive_crit_); 734 WriteLockScoped write_lock(*receive_crit_);
691 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == 735 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
692 video_receive_ssrcs_.end()); 736 video_receive_ssrcs_.end());
693 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 737 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
694 if (config.rtp.rtx_ssrc) { 738 if (config.rtp.rtx_ssrc) {
695 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; 739 video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream;
696 // We record identical config for the rtx stream as for the main 740 // We record identical config for the rtx stream as for the main
697 // stream. Since the transport_cc negotiation is per payload 741 // stream. Since the transport_send_cc negotiation is per payload
698 // type, we may get an incorrect value for the rtx stream, but 742 // type, we may get an incorrect value for the rtx stream, but
699 // that is unlikely to matter in practice. 743 // that is unlikely to matter in practice.
700 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; 744 receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config;
701 } 745 }
702 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; 746 receive_rtp_config_[config.rtp.remote_ssrc] = receive_config;
703 video_receive_streams_.insert(receive_stream); 747 video_receive_streams_.insert(receive_stream);
704 ConfigureSync(config.sync_group); 748 ConfigureSync(config.sync_group);
705 } 749 }
706 receive_stream->SignalNetworkState(video_network_state_); 750 receive_stream->SignalNetworkState(video_network_state_);
707 UpdateAggregateNetworkState(); 751 UpdateAggregateNetworkState();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 delete receive_stream_impl; 866 delete receive_stream_impl;
823 } 867 }
824 868
825 Call::Stats Call::GetStats() const { 869 Call::Stats Call::GetStats() const {
826 // TODO(solenberg): Some test cases in EndToEndTest use this from a different 870 // TODO(solenberg): Some test cases in EndToEndTest use this from a different
827 // thread. Re-enable once that is fixed. 871 // thread. Re-enable once that is fixed.
828 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 872 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
829 Stats stats; 873 Stats stats;
830 // Fetch available send/receive bitrates. 874 // Fetch available send/receive bitrates.
831 uint32_t send_bandwidth = 0; 875 uint32_t send_bandwidth = 0;
832 send_side_cc_.GetBitrateController()->AvailableBandwidth(&send_bandwidth); 876 transport_send_->send_side_cc()->GetBitrateController()->AvailableBandwidth(
877 &send_bandwidth);
833 std::vector<unsigned int> ssrcs; 878 std::vector<unsigned int> ssrcs;
834 uint32_t recv_bandwidth = 0; 879 uint32_t recv_bandwidth = 0;
835 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate( 880 receive_side_cc_.GetRemoteBitrateEstimator(false)->LatestEstimate(
836 &ssrcs, &recv_bandwidth); 881 &ssrcs, &recv_bandwidth);
837 stats.send_bandwidth_bps = send_bandwidth; 882 stats.send_bandwidth_bps = send_bandwidth;
838 stats.recv_bandwidth_bps = recv_bandwidth; 883 stats.recv_bandwidth_bps = recv_bandwidth;
839 stats.pacer_delay_ms = send_side_cc_.GetPacerQueuingDelayMs(); 884 stats.pacer_delay_ms =
885 transport_send_->send_side_cc()->GetPacerQueuingDelayMs();
840 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt(); 886 stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt();
841 { 887 {
842 rtc::CritScope cs(&bitrate_crit_); 888 rtc::CritScope cs(&bitrate_crit_);
843 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_; 889 stats.max_padding_bitrate_bps = configured_max_padding_bitrate_bps_;
844 } 890 }
845 return stats; 891 return stats;
846 } 892 }
847 893
848 void Call::SetBitrateConfig( 894 void Call::SetBitrateConfig(
849 const webrtc::Call::Config::BitrateConfig& bitrate_config) { 895 const webrtc::Call::Config::BitrateConfig& bitrate_config) {
(...skipping 12 matching lines...) Expand all
862 // Nothing new to set, early abort to avoid encoder reconfigurations. 908 // Nothing new to set, early abort to avoid encoder reconfigurations.
863 return; 909 return;
864 } 910 }
865 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; 911 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps;
866 // Start bitrate of -1 means we should keep the old bitrate, which there is 912 // Start bitrate of -1 means we should keep the old bitrate, which there is
867 // no point in remembering for the future. 913 // no point in remembering for the future.
868 if (bitrate_config.start_bitrate_bps > 0) 914 if (bitrate_config.start_bitrate_bps > 0)
869 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; 915 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps;
870 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; 916 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps;
871 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0); 917 RTC_DCHECK_NE(bitrate_config.start_bitrate_bps, 0);
872 send_side_cc_.SetBweBitrates(bitrate_config.min_bitrate_bps, 918 transport_send_->send_side_cc()->SetBweBitrates(
873 bitrate_config.start_bitrate_bps, 919 bitrate_config.min_bitrate_bps, bitrate_config.start_bitrate_bps,
874 bitrate_config.max_bitrate_bps); 920 bitrate_config.max_bitrate_bps);
875 } 921 }
876 922
877 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { 923 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) {
878 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 924 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
879 switch (media) { 925 switch (media) {
880 case MediaType::AUDIO: 926 case MediaType::AUDIO:
881 audio_network_state_ = state; 927 audio_network_state_ = state;
882 break; 928 break;
883 case MediaType::VIDEO: 929 case MediaType::VIDEO:
884 video_network_state_ = state; 930 video_network_state_ = state;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 kv->second = network_route; 1005 kv->second = network_route;
960 LOG(LS_INFO) << "Network route changed on transport " << transport_name 1006 LOG(LS_INFO) << "Network route changed on transport " << transport_name
961 << ": new local network id " << network_route.local_network_id 1007 << ": new local network id " << network_route.local_network_id
962 << " new remote network id " << network_route.remote_network_id 1008 << " new remote network id " << network_route.remote_network_id
963 << " Reset bitrates to min: " 1009 << " Reset bitrates to min: "
964 << config_.bitrate_config.min_bitrate_bps 1010 << config_.bitrate_config.min_bitrate_bps
965 << " bps, start: " << config_.bitrate_config.start_bitrate_bps 1011 << " bps, start: " << config_.bitrate_config.start_bitrate_bps
966 << " bps, max: " << config_.bitrate_config.start_bitrate_bps 1012 << " bps, max: " << config_.bitrate_config.start_bitrate_bps
967 << " bps."; 1013 << " bps.";
968 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0); 1014 RTC_DCHECK_GT(config_.bitrate_config.start_bitrate_bps, 0);
969 send_side_cc_.OnNetworkRouteChanged( 1015 transport_send_->send_side_cc()->OnNetworkRouteChanged(
970 network_route, config_.bitrate_config.start_bitrate_bps, 1016 network_route, config_.bitrate_config.start_bitrate_bps,
971 config_.bitrate_config.min_bitrate_bps, 1017 config_.bitrate_config.min_bitrate_bps,
972 config_.bitrate_config.max_bitrate_bps); 1018 config_.bitrate_config.max_bitrate_bps);
973 } 1019 }
974 } 1020 }
975 1021
976 void Call::UpdateAggregateNetworkState() { 1022 void Call::UpdateAggregateNetworkState() {
977 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 1023 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
978 1024
979 bool have_audio = false; 1025 bool have_audio = false;
(...skipping 15 matching lines...) Expand all
995 1041
996 NetworkState aggregate_state = kNetworkDown; 1042 NetworkState aggregate_state = kNetworkDown;
997 if ((have_video && video_network_state_ == kNetworkUp) || 1043 if ((have_video && video_network_state_ == kNetworkUp) ||
998 (have_audio && audio_network_state_ == kNetworkUp)) { 1044 (have_audio && audio_network_state_ == kNetworkUp)) {
999 aggregate_state = kNetworkUp; 1045 aggregate_state = kNetworkUp;
1000 } 1046 }
1001 1047
1002 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" 1048 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state="
1003 << (aggregate_state == kNetworkUp ? "up" : "down"); 1049 << (aggregate_state == kNetworkUp ? "up" : "down");
1004 1050
1005 send_side_cc_.SignalNetworkState(aggregate_state); 1051 transport_send_->send_side_cc()->SignalNetworkState(aggregate_state);
1006 } 1052 }
1007 1053
1008 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { 1054 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
1009 if (first_packet_sent_ms_ == -1) 1055 if (first_packet_sent_ms_ == -1)
1010 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); 1056 first_packet_sent_ms_ = clock_->TimeInMilliseconds();
1011 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, 1057 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
1012 clock_->TimeInMilliseconds()); 1058 clock_->TimeInMilliseconds());
1013 send_side_cc_.OnSentPacket(sent_packet); 1059 transport_send_->send_side_cc()->OnSentPacket(sent_packet);
1014 } 1060 }
1015 1061
1016 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, 1062 void Call::OnNetworkChanged(uint32_t target_bitrate_bps,
1017 uint8_t fraction_loss, 1063 uint8_t fraction_loss,
1018 int64_t rtt_ms, 1064 int64_t rtt_ms,
1019 int64_t probing_interval_ms) { 1065 int64_t probing_interval_ms) {
1020 // TODO(perkj): Consider making sure CongestionController operates on 1066 // TODO(perkj): Consider making sure CongestionController operates on
1021 // |worker_queue_|. 1067 // |worker_queue_|.
1022 if (!worker_queue_.IsCurrent()) { 1068 if (!worker_queue_.IsCurrent()) {
1023 worker_queue_.PostTask( 1069 worker_queue_.PostTask(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1102 }
1057 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000); 1103 estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000);
1058 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate. 1104 // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate.
1059 uint32_t pacer_bitrate_bps = 1105 uint32_t pacer_bitrate_bps =
1060 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_); 1106 std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_);
1061 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000); 1107 pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000);
1062 } 1108 }
1063 1109
1064 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, 1110 void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
1065 uint32_t max_padding_bitrate_bps) { 1111 uint32_t max_padding_bitrate_bps) {
1066 send_side_cc_.SetAllocatedSendBitrateLimits(min_send_bitrate_bps, 1112 transport_send_->send_side_cc()->SetAllocatedSendBitrateLimits(
1067 max_padding_bitrate_bps); 1113 min_send_bitrate_bps, max_padding_bitrate_bps);
1068 rtc::CritScope lock(&bitrate_crit_); 1114 rtc::CritScope lock(&bitrate_crit_);
1069 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps; 1115 min_allocated_send_bitrate_bps_ = min_send_bitrate_bps;
1070 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps; 1116 configured_max_padding_bitrate_bps_ = max_padding_bitrate_bps;
1071 } 1117 }
1072 1118
1073 void Call::ConfigureSync(const std::string& sync_group) { 1119 void Call::ConfigureSync(const std::string& sync_group) {
1074 // Set sync only if there was no previous one. 1120 // Set sync only if there was no previous one.
1075 if (sync_group.empty()) 1121 if (sync_group.empty())
1076 return; 1122 return;
1077 1123
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // should be fixed to use the same MediaType as the production code. 1322 // should be fixed to use the same MediaType as the production code.
1277 if (media_type != MediaType::AUDIO || 1323 if (media_type != MediaType::AUDIO ||
1278 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1324 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1279 receive_side_cc_.OnReceivedPacket( 1325 receive_side_cc_.OnReceivedPacket(
1280 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1326 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1281 header); 1327 header);
1282 } 1328 }
1283 } 1329 }
1284 1330
1285 } // namespace internal 1331 } // namespace internal
1332
1286 } // namespace webrtc 1333 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/BUILD.gn ('k') | webrtc/call/rtp_transport_controller_send.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698