OLD | NEW |
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 transport_send->send_side_cc()->RegisterNetworkObserver(this); | 429 transport_send->send_side_cc()->RegisterNetworkObserver(this); |
430 transport_send_ = std::move(transport_send); | 430 transport_send_ = std::move(transport_send); |
431 transport_send_->send_side_cc()->SignalNetworkState(kNetworkDown); | 431 transport_send_->send_side_cc()->SignalNetworkState(kNetworkDown); |
432 transport_send_->send_side_cc()->SetBweBitrates( | 432 transport_send_->send_side_cc()->SetBweBitrates( |
433 config_.bitrate_config.min_bitrate_bps, | 433 config_.bitrate_config.min_bitrate_bps, |
434 config_.bitrate_config.start_bitrate_bps, | 434 config_.bitrate_config.start_bitrate_bps, |
435 config_.bitrate_config.max_bitrate_bps); | 435 config_.bitrate_config.max_bitrate_bps); |
436 call_stats_->RegisterStatsObserver(&receive_side_cc_); | 436 call_stats_->RegisterStatsObserver(&receive_side_cc_); |
437 call_stats_->RegisterStatsObserver(transport_send_->send_side_cc()); | 437 call_stats_->RegisterStatsObserver(transport_send_->send_side_cc()); |
438 | 438 |
439 module_process_thread_->Start(); | 439 // We have to attach the pacer to the pacer thread before starting the |
| 440 // module process thread to avoid a race accessing the process thread |
| 441 // both from the process thread and the pacer thread. |
| 442 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(), |
| 443 RTC_FROM_HERE); |
| 444 pacer_thread_->RegisterModule( |
| 445 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE); |
| 446 pacer_thread_->Start(); |
| 447 |
440 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); | 448 module_process_thread_->RegisterModule(call_stats_.get(), RTC_FROM_HERE); |
441 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE); | 449 module_process_thread_->RegisterModule(&receive_side_cc_, RTC_FROM_HERE); |
442 module_process_thread_->RegisterModule(transport_send_->send_side_cc(), | 450 module_process_thread_->RegisterModule(transport_send_->send_side_cc(), |
443 RTC_FROM_HERE); | 451 RTC_FROM_HERE); |
444 pacer_thread_->RegisterModule(transport_send_->send_side_cc()->pacer(), | 452 module_process_thread_->Start(); |
445 RTC_FROM_HERE); | |
446 pacer_thread_->RegisterModule( | |
447 receive_side_cc_.GetRemoteBitrateEstimator(true), RTC_FROM_HERE); | |
448 | |
449 pacer_thread_->Start(); | |
450 } | 453 } |
451 | 454 |
452 Call::~Call() { | 455 Call::~Call() { |
453 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); | 456 RTC_DCHECK_RUN_ON(&configuration_thread_checker_); |
454 | 457 |
455 RTC_CHECK(audio_send_ssrcs_.empty()); | 458 RTC_CHECK(audio_send_ssrcs_.empty()); |
456 RTC_CHECK(video_send_ssrcs_.empty()); | 459 RTC_CHECK(video_send_ssrcs_.empty()); |
457 RTC_CHECK(video_send_streams_.empty()); | 460 RTC_CHECK(video_send_streams_.empty()); |
458 RTC_CHECK(audio_receive_streams_.empty()); | 461 RTC_CHECK(audio_receive_streams_.empty()); |
459 RTC_CHECK(video_receive_streams_.empty()); | 462 RTC_CHECK(video_receive_streams_.empty()); |
460 | 463 |
| 464 // The send-side congestion controller must be de-registered prior to |
| 465 // the pacer thread being stopped to avoid a race when accessing the |
| 466 // pacer thread object on the module process thread at the same time as |
| 467 // the pacer thread is stopped. |
| 468 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); |
461 pacer_thread_->Stop(); | 469 pacer_thread_->Stop(); |
462 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); | 470 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); |
463 pacer_thread_->DeRegisterModule( | 471 pacer_thread_->DeRegisterModule( |
464 receive_side_cc_.GetRemoteBitrateEstimator(true)); | 472 receive_side_cc_.GetRemoteBitrateEstimator(true)); |
465 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); | |
466 module_process_thread_->DeRegisterModule(&receive_side_cc_); | 473 module_process_thread_->DeRegisterModule(&receive_side_cc_); |
467 module_process_thread_->DeRegisterModule(call_stats_.get()); | 474 module_process_thread_->DeRegisterModule(call_stats_.get()); |
468 module_process_thread_->Stop(); | 475 module_process_thread_->Stop(); |
469 call_stats_->DeregisterStatsObserver(&receive_side_cc_); | 476 call_stats_->DeregisterStatsObserver(&receive_side_cc_); |
470 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); | 477 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); |
471 | 478 |
472 int64_t first_sent_packet_ms = | 479 int64_t first_sent_packet_ms = |
473 transport_send_->send_side_cc()->GetFirstPacketTimeMs(); | 480 transport_send_->send_side_cc()->GetFirstPacketTimeMs(); |
474 // Only update histograms after process threads have been shut down, so that | 481 // Only update histograms after process threads have been shut down, so that |
475 // they won't try to concurrently update stats. | 482 // they won't try to concurrently update stats. |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { | 1424 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { |
1418 receive_side_cc_.OnReceivedPacket( | 1425 receive_side_cc_.OnReceivedPacket( |
1419 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), | 1426 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), |
1420 header); | 1427 header); |
1421 } | 1428 } |
1422 } | 1429 } |
1423 | 1430 |
1424 } // namespace internal | 1431 } // namespace internal |
1425 | 1432 |
1426 } // namespace webrtc | 1433 } // namespace webrtc |
OLD | NEW |