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

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

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