| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // OnNetworkChanged from multiple threads. | 206 // OnNetworkChanged from multiple threads. |
| 207 rtc::CriticalSection bitrate_crit_; | 207 rtc::CriticalSection bitrate_crit_; |
| 208 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 208 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 209 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); | 209 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); |
| 210 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 210 AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 211 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); | 211 AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_); |
| 212 | 212 |
| 213 std::map<std::string, rtc::NetworkRoute> network_routes_; | 213 std::map<std::string, rtc::NetworkRoute> network_routes_; |
| 214 | 214 |
| 215 VieRemb remb_; | 215 VieRemb remb_; |
| 216 PacketRouter packet_router_; |
| 217 // TODO(nisse): Could be a direct member, except for constness |
| 218 // issues with GetRemoteBitrateEstimator (and maybe others). |
| 216 const std::unique_ptr<CongestionController> congestion_controller_; | 219 const std::unique_ptr<CongestionController> congestion_controller_; |
| 217 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; | 220 const std::unique_ptr<SendDelayStats> video_send_delay_stats_; |
| 218 const int64_t start_ms_; | 221 const int64_t start_ms_; |
| 219 // TODO(perkj): |worker_queue_| is supposed to replace | 222 // TODO(perkj): |worker_queue_| is supposed to replace |
| 220 // |module_process_thread_|. | 223 // |module_process_thread_|. |
| 221 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 224 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
| 222 // and deleted before any other members. | 225 // and deleted before any other members. |
| 223 rtc::TaskQueue worker_queue_; | 226 rtc::TaskQueue worker_queue_; |
| 224 | 227 |
| 225 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 228 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 first_packet_sent_ms_(-1), | 263 first_packet_sent_ms_(-1), |
| 261 received_bytes_per_second_counter_(clock_, nullptr, true), | 264 received_bytes_per_second_counter_(clock_, nullptr, true), |
| 262 received_audio_bytes_per_second_counter_(clock_, nullptr, true), | 265 received_audio_bytes_per_second_counter_(clock_, nullptr, true), |
| 263 received_video_bytes_per_second_counter_(clock_, nullptr, true), | 266 received_video_bytes_per_second_counter_(clock_, nullptr, true), |
| 264 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), | 267 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), |
| 265 min_allocated_send_bitrate_bps_(0), | 268 min_allocated_send_bitrate_bps_(0), |
| 266 configured_max_padding_bitrate_bps_(0), | 269 configured_max_padding_bitrate_bps_(0), |
| 267 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), | 270 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), |
| 268 pacer_bitrate_kbps_counter_(clock_, nullptr, true), | 271 pacer_bitrate_kbps_counter_(clock_, nullptr, true), |
| 269 remb_(clock_), | 272 remb_(clock_), |
| 270 congestion_controller_( | 273 congestion_controller_(new CongestionController(clock_, |
| 271 new CongestionController(clock_, this, &remb_, event_log_)), | 274 this, |
| 275 &remb_, |
| 276 event_log_, |
| 277 &packet_router_)), |
| 272 video_send_delay_stats_(new SendDelayStats(clock_)), | 278 video_send_delay_stats_(new SendDelayStats(clock_)), |
| 273 start_ms_(clock_->TimeInMilliseconds()), | 279 start_ms_(clock_->TimeInMilliseconds()), |
| 274 worker_queue_("call_worker_queue") { | 280 worker_queue_("call_worker_queue") { |
| 275 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 281 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 276 RTC_DCHECK(config.event_log != nullptr); | 282 RTC_DCHECK(config.event_log != nullptr); |
| 277 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 283 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 278 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 284 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
| 279 config.bitrate_config.min_bitrate_bps); | 285 config.bitrate_config.min_bitrate_bps); |
| 280 if (config.bitrate_config.max_bitrate_bps != -1) { | 286 if (config.bitrate_config.max_bitrate_bps != -1) { |
| 281 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 287 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 411 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 406 return this; | 412 return this; |
| 407 } | 413 } |
| 408 | 414 |
| 409 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 415 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
| 410 const webrtc::AudioSendStream::Config& config) { | 416 const webrtc::AudioSendStream::Config& config) { |
| 411 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); | 417 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); |
| 412 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 418 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 413 event_log_->LogAudioSendStreamConfig(config); | 419 event_log_->LogAudioSendStreamConfig(config); |
| 414 AudioSendStream* send_stream = new AudioSendStream( | 420 AudioSendStream* send_stream = new AudioSendStream( |
| 415 config, config_.audio_state, &worker_queue_, congestion_controller_.get(), | 421 config, config_.audio_state, &worker_queue_, &packet_router_, |
| 416 bitrate_allocator_.get(), event_log_); | 422 congestion_controller_.get(), bitrate_allocator_.get(), event_log_); |
| 417 { | 423 { |
| 418 WriteLockScoped write_lock(*send_crit_); | 424 WriteLockScoped write_lock(*send_crit_); |
| 419 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == | 425 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == |
| 420 audio_send_ssrcs_.end()); | 426 audio_send_ssrcs_.end()); |
| 421 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; | 427 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; |
| 422 } | 428 } |
| 423 { | 429 { |
| 424 ReadLockScoped read_lock(*receive_crit_); | 430 ReadLockScoped read_lock(*receive_crit_); |
| 425 for (const auto& kv : audio_receive_ssrcs_) { | 431 for (const auto& kv : audio_receive_ssrcs_) { |
| 426 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) { | 432 if (kv.second->config().rtp.local_ssrc == config.rtp.ssrc) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 UpdateAggregateNetworkState(); | 465 UpdateAggregateNetworkState(); |
| 460 delete audio_send_stream; | 466 delete audio_send_stream; |
| 461 } | 467 } |
| 462 | 468 |
| 463 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 469 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
| 464 const webrtc::AudioReceiveStream::Config& config) { | 470 const webrtc::AudioReceiveStream::Config& config) { |
| 465 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 471 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
| 466 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 472 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 467 event_log_->LogAudioReceiveStreamConfig(config); | 473 event_log_->LogAudioReceiveStreamConfig(config); |
| 468 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 474 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
| 469 congestion_controller_.get(), config, config_.audio_state, event_log_); | 475 &packet_router_, |
| 476 // TODO(nisse): Used only when UseSendSideBwe(config) is true. |
| 477 congestion_controller_->GetRemoteBitrateEstimator(true), config, |
| 478 config_.audio_state, event_log_); |
| 470 { | 479 { |
| 471 WriteLockScoped write_lock(*receive_crit_); | 480 WriteLockScoped write_lock(*receive_crit_); |
| 472 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 481 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 473 audio_receive_ssrcs_.end()); | 482 audio_receive_ssrcs_.end()); |
| 474 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 483 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 475 ConfigureSync(config.sync_group); | 484 ConfigureSync(config.sync_group); |
| 476 } | 485 } |
| 477 { | 486 { |
| 478 ReadLockScoped read_lock(*send_crit_); | 487 ReadLockScoped read_lock(*send_crit_); |
| 479 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); | 488 auto it = audio_send_ssrcs_.find(config.rtp.local_ssrc); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 527 |
| 519 video_send_delay_stats_->AddSsrcs(config); | 528 video_send_delay_stats_->AddSsrcs(config); |
| 520 event_log_->LogVideoSendStreamConfig(config); | 529 event_log_->LogVideoSendStreamConfig(config); |
| 521 | 530 |
| 522 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 531 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
| 523 // the call has already started. | 532 // the call has already started. |
| 524 // Copy ssrcs from |config| since |config| is moved. | 533 // Copy ssrcs from |config| since |config| is moved. |
| 525 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; | 534 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; |
| 526 VideoSendStream* send_stream = new VideoSendStream( | 535 VideoSendStream* send_stream = new VideoSendStream( |
| 527 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, | 536 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, |
| 528 call_stats_.get(), congestion_controller_.get(), bitrate_allocator_.get(), | 537 call_stats_.get(), congestion_controller_.get(), &packet_router_, |
| 529 video_send_delay_stats_.get(), &remb_, event_log_, std::move(config), | 538 bitrate_allocator_.get(), video_send_delay_stats_.get(), &remb_, |
| 530 std::move(encoder_config), suspended_video_send_ssrcs_); | 539 event_log_, std::move(config), std::move(encoder_config), |
| 540 suspended_video_send_ssrcs_); |
| 531 | 541 |
| 532 { | 542 { |
| 533 WriteLockScoped write_lock(*send_crit_); | 543 WriteLockScoped write_lock(*send_crit_); |
| 534 for (uint32_t ssrc : ssrcs) { | 544 for (uint32_t ssrc : ssrcs) { |
| 535 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 545 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
| 536 video_send_ssrcs_[ssrc] = send_stream; | 546 video_send_ssrcs_[ssrc] = send_stream; |
| 537 } | 547 } |
| 538 video_send_streams_.insert(send_stream); | 548 video_send_streams_.insert(send_stream); |
| 539 } | 549 } |
| 540 send_stream->SignalNetworkState(video_network_state_); | 550 send_stream->SignalNetworkState(video_network_state_); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 586 |
| 577 UpdateAggregateNetworkState(); | 587 UpdateAggregateNetworkState(); |
| 578 delete send_stream_impl; | 588 delete send_stream_impl; |
| 579 } | 589 } |
| 580 | 590 |
| 581 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 591 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
| 582 webrtc::VideoReceiveStream::Config configuration) { | 592 webrtc::VideoReceiveStream::Config configuration) { |
| 583 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 593 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
| 584 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 594 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 585 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 595 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
| 586 num_cpu_cores_, congestion_controller_.get(), std::move(configuration), | 596 num_cpu_cores_, congestion_controller_.get(), &packet_router_, |
| 587 voice_engine(), module_process_thread_.get(), call_stats_.get(), &remb_); | 597 std::move(configuration), voice_engine(), module_process_thread_.get(), |
| 598 call_stats_.get(), &remb_); |
| 588 | 599 |
| 589 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 600 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
| 590 { | 601 { |
| 591 WriteLockScoped write_lock(*receive_crit_); | 602 WriteLockScoped write_lock(*receive_crit_); |
| 592 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 603 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 593 video_receive_ssrcs_.end()); | 604 video_receive_ssrcs_.end()); |
| 594 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 605 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 595 // TODO(pbos): Configure different RTX payloads per receive payload. | 606 // TODO(pbos): Configure different RTX payloads per receive payload. |
| 596 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 607 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
| 597 config.rtp.rtx.begin(); | 608 config.rtp.rtx.begin(); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 1111 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
| 1101 ReadLockScoped read_lock(*receive_crit_); | 1112 ReadLockScoped read_lock(*receive_crit_); |
| 1102 auto it = video_receive_ssrcs_.find(ssrc); | 1113 auto it = video_receive_ssrcs_.find(ssrc); |
| 1103 if (it == video_receive_ssrcs_.end()) | 1114 if (it == video_receive_ssrcs_.end()) |
| 1104 return false; | 1115 return false; |
| 1105 return it->second->OnRecoveredPacket(packet, length); | 1116 return it->second->OnRecoveredPacket(packet, length); |
| 1106 } | 1117 } |
| 1107 | 1118 |
| 1108 } // namespace internal | 1119 } // namespace internal |
| 1109 } // namespace webrtc | 1120 } // namespace webrtc |
| OLD | NEW |