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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 static_cast<internal::AudioState*>(config_.audio_state.get()); | 139 static_cast<internal::AudioState*>(config_.audio_state.get()); |
140 if (audio_state) | 140 if (audio_state) |
141 return audio_state->voice_engine(); | 141 return audio_state->voice_engine(); |
142 else | 142 else |
143 return nullptr; | 143 return nullptr; |
144 } | 144 } |
145 | 145 |
146 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); | 146 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); |
147 void UpdateReceiveHistograms(); | 147 void UpdateReceiveHistograms(); |
148 void UpdateHistograms(); | 148 void UpdateHistograms(); |
149 void UpdateAggregateNetworkState(); | |
150 | 149 |
151 Clock* const clock_; | 150 Clock* const clock_; |
152 | 151 |
153 const int num_cpu_cores_; | 152 const int num_cpu_cores_; |
154 const std::unique_ptr<ProcessThread> module_process_thread_; | 153 const std::unique_ptr<ProcessThread> module_process_thread_; |
155 const std::unique_ptr<ProcessThread> pacer_thread_; | 154 const std::unique_ptr<ProcessThread> pacer_thread_; |
156 const std::unique_ptr<CallStats> call_stats_; | 155 const std::unique_ptr<CallStats> call_stats_; |
157 const std::unique_ptr<BitrateAllocator> bitrate_allocator_; | 156 const std::unique_ptr<BitrateAllocator> bitrate_allocator_; |
158 Call::Config config_; | 157 Call::Config config_; |
159 rtc::ThreadChecker configuration_thread_checker_; | 158 rtc::ThreadChecker configuration_thread_checker_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 274 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
276 config.bitrate_config.min_bitrate_bps); | 275 config.bitrate_config.min_bitrate_bps); |
277 if (config.bitrate_config.max_bitrate_bps != -1) { | 276 if (config.bitrate_config.max_bitrate_bps != -1) { |
278 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 277 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
279 config.bitrate_config.start_bitrate_bps); | 278 config.bitrate_config.start_bitrate_bps); |
280 } | 279 } |
281 Trace::CreateTrace(); | 280 Trace::CreateTrace(); |
282 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 281 call_stats_->RegisterStatsObserver(congestion_controller_.get()); |
283 | 282 |
284 congestion_controller_->SetBweBitrates( | 283 congestion_controller_->SetBweBitrates( |
284 config_.bitrate_config.start_bitrate_bps, | |
285 config_.bitrate_config.min_bitrate_bps, | 285 config_.bitrate_config.min_bitrate_bps, |
286 config_.bitrate_config.start_bitrate_bps, | |
287 config_.bitrate_config.max_bitrate_bps); | 286 config_.bitrate_config.max_bitrate_bps); |
288 | 287 |
289 module_process_thread_->Start(); | 288 module_process_thread_->Start(); |
290 module_process_thread_->RegisterModule(call_stats_.get()); | 289 module_process_thread_->RegisterModule(call_stats_.get()); |
291 module_process_thread_->RegisterModule(congestion_controller_.get()); | 290 module_process_thread_->RegisterModule(congestion_controller_.get()); |
292 pacer_thread_->RegisterModule(congestion_controller_->pacer()); | 291 pacer_thread_->RegisterModule(congestion_controller_->pacer()); |
293 pacer_thread_->RegisterModule( | 292 pacer_thread_->RegisterModule( |
294 congestion_controller_->GetRemoteBitrateEstimator(true)); | 293 congestion_controller_->GetRemoteBitrateEstimator(true)); |
295 pacer_thread_->Start(); | 294 pacer_thread_->Start(); |
296 } | 295 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 AudioSendStream* send_stream = new AudioSendStream( | 397 AudioSendStream* send_stream = new AudioSendStream( |
399 config, config_.audio_state, &worker_queue_, congestion_controller_.get(), | 398 config, config_.audio_state, &worker_queue_, congestion_controller_.get(), |
400 bitrate_allocator_.get(), event_log_); | 399 bitrate_allocator_.get(), event_log_); |
401 { | 400 { |
402 WriteLockScoped write_lock(*send_crit_); | 401 WriteLockScoped write_lock(*send_crit_); |
403 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == | 402 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == |
404 audio_send_ssrcs_.end()); | 403 audio_send_ssrcs_.end()); |
405 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; | 404 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; |
406 } | 405 } |
407 send_stream->SignalNetworkState(audio_network_state_); | 406 send_stream->SignalNetworkState(audio_network_state_); |
408 UpdateAggregateNetworkState(); | |
409 return send_stream; | 407 return send_stream; |
410 } | 408 } |
411 | 409 |
412 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { | 410 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { |
413 TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream"); | 411 TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream"); |
414 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 412 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
415 RTC_DCHECK(send_stream != nullptr); | 413 RTC_DCHECK(send_stream != nullptr); |
416 | 414 |
417 send_stream->Stop(); | 415 send_stream->Stop(); |
418 | 416 |
419 webrtc::internal::AudioSendStream* audio_send_stream = | 417 webrtc::internal::AudioSendStream* audio_send_stream = |
420 static_cast<webrtc::internal::AudioSendStream*>(send_stream); | 418 static_cast<webrtc::internal::AudioSendStream*>(send_stream); |
421 { | 419 { |
422 WriteLockScoped write_lock(*send_crit_); | 420 WriteLockScoped write_lock(*send_crit_); |
423 size_t num_deleted = audio_send_ssrcs_.erase( | 421 size_t num_deleted = audio_send_ssrcs_.erase( |
424 audio_send_stream->config().rtp.ssrc); | 422 audio_send_stream->config().rtp.ssrc); |
425 RTC_DCHECK(num_deleted == 1); | 423 RTC_DCHECK(num_deleted == 1); |
426 } | 424 } |
427 UpdateAggregateNetworkState(); | |
428 delete audio_send_stream; | 425 delete audio_send_stream; |
429 } | 426 } |
430 | 427 |
431 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 428 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
432 const webrtc::AudioReceiveStream::Config& config) { | 429 const webrtc::AudioReceiveStream::Config& config) { |
433 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 430 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
434 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 431 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
435 event_log_->LogAudioReceiveStreamConfig(config); | 432 event_log_->LogAudioReceiveStreamConfig(config); |
436 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 433 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
437 congestion_controller_.get(), config, config_.audio_state, event_log_); | 434 congestion_controller_.get(), config, config_.audio_state, event_log_); |
438 { | 435 { |
439 WriteLockScoped write_lock(*receive_crit_); | 436 WriteLockScoped write_lock(*receive_crit_); |
440 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 437 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
441 audio_receive_ssrcs_.end()); | 438 audio_receive_ssrcs_.end()); |
442 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 439 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
443 ConfigureSync(config.sync_group); | 440 ConfigureSync(config.sync_group); |
444 } | 441 } |
445 receive_stream->SignalNetworkState(audio_network_state_); | 442 receive_stream->SignalNetworkState(audio_network_state_); |
446 UpdateAggregateNetworkState(); | |
447 return receive_stream; | 443 return receive_stream; |
448 } | 444 } |
449 | 445 |
450 void Call::DestroyAudioReceiveStream( | 446 void Call::DestroyAudioReceiveStream( |
451 webrtc::AudioReceiveStream* receive_stream) { | 447 webrtc::AudioReceiveStream* receive_stream) { |
452 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 448 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
453 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 449 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
454 RTC_DCHECK(receive_stream != nullptr); | 450 RTC_DCHECK(receive_stream != nullptr); |
455 webrtc::internal::AudioReceiveStream* audio_receive_stream = | 451 webrtc::internal::AudioReceiveStream* audio_receive_stream = |
456 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); | 452 static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
457 { | 453 { |
458 WriteLockScoped write_lock(*receive_crit_); | 454 WriteLockScoped write_lock(*receive_crit_); |
459 size_t num_deleted = audio_receive_ssrcs_.erase( | 455 size_t num_deleted = audio_receive_ssrcs_.erase( |
460 audio_receive_stream->config().rtp.remote_ssrc); | 456 audio_receive_stream->config().rtp.remote_ssrc); |
461 RTC_DCHECK(num_deleted == 1); | 457 RTC_DCHECK(num_deleted == 1); |
462 const std::string& sync_group = audio_receive_stream->config().sync_group; | 458 const std::string& sync_group = audio_receive_stream->config().sync_group; |
463 const auto it = sync_stream_mapping_.find(sync_group); | 459 const auto it = sync_stream_mapping_.find(sync_group); |
464 if (it != sync_stream_mapping_.end() && | 460 if (it != sync_stream_mapping_.end() && |
465 it->second == audio_receive_stream) { | 461 it->second == audio_receive_stream) { |
466 sync_stream_mapping_.erase(it); | 462 sync_stream_mapping_.erase(it); |
467 ConfigureSync(sync_group); | 463 ConfigureSync(sync_group); |
468 } | 464 } |
469 } | 465 } |
470 UpdateAggregateNetworkState(); | |
471 delete audio_receive_stream; | 466 delete audio_receive_stream; |
472 } | 467 } |
473 | 468 |
474 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 469 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
475 webrtc::VideoSendStream::Config config, | 470 webrtc::VideoSendStream::Config config, |
476 VideoEncoderConfig encoder_config) { | 471 VideoEncoderConfig encoder_config) { |
477 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 472 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
478 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 473 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
479 | 474 |
480 video_send_delay_stats_->AddSsrcs(config); | 475 video_send_delay_stats_->AddSsrcs(config); |
(...skipping 11 matching lines...) Expand all Loading... | |
492 | 487 |
493 { | 488 { |
494 WriteLockScoped write_lock(*send_crit_); | 489 WriteLockScoped write_lock(*send_crit_); |
495 for (uint32_t ssrc : ssrcs) { | 490 for (uint32_t ssrc : ssrcs) { |
496 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 491 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
497 video_send_ssrcs_[ssrc] = send_stream; | 492 video_send_ssrcs_[ssrc] = send_stream; |
498 } | 493 } |
499 video_send_streams_.insert(send_stream); | 494 video_send_streams_.insert(send_stream); |
500 } | 495 } |
501 send_stream->SignalNetworkState(video_network_state_); | 496 send_stream->SignalNetworkState(video_network_state_); |
502 UpdateAggregateNetworkState(); | |
503 | 497 |
504 return send_stream; | 498 return send_stream; |
505 } | 499 } |
506 | 500 |
507 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { | 501 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
508 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); | 502 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); |
509 RTC_DCHECK(send_stream != nullptr); | 503 RTC_DCHECK(send_stream != nullptr); |
510 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 504 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
511 | 505 |
512 send_stream->Stop(); | 506 send_stream->Stop(); |
(...skipping 15 matching lines...) Expand all Loading... | |
528 RTC_CHECK(send_stream_impl != nullptr); | 522 RTC_CHECK(send_stream_impl != nullptr); |
529 | 523 |
530 VideoSendStream::RtpStateMap rtp_state = | 524 VideoSendStream::RtpStateMap rtp_state = |
531 send_stream_impl->StopPermanentlyAndGetRtpStates(); | 525 send_stream_impl->StopPermanentlyAndGetRtpStates(); |
532 | 526 |
533 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin(); | 527 for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin(); |
534 it != rtp_state.end(); ++it) { | 528 it != rtp_state.end(); ++it) { |
535 suspended_video_send_ssrcs_[it->first] = it->second; | 529 suspended_video_send_ssrcs_[it->first] = it->second; |
536 } | 530 } |
537 | 531 |
538 UpdateAggregateNetworkState(); | |
539 delete send_stream_impl; | 532 delete send_stream_impl; |
540 } | 533 } |
541 | 534 |
542 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 535 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
543 webrtc::VideoReceiveStream::Config configuration) { | 536 webrtc::VideoReceiveStream::Config configuration) { |
544 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 537 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
545 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 538 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
546 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 539 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
547 num_cpu_cores_, congestion_controller_.get(), std::move(configuration), | 540 num_cpu_cores_, congestion_controller_.get(), std::move(configuration), |
548 voice_engine(), module_process_thread_.get(), call_stats_.get(), &remb_); | 541 voice_engine(), module_process_thread_.get(), call_stats_.get(), &remb_); |
549 | 542 |
550 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); | 543 const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
551 { | 544 { |
552 WriteLockScoped write_lock(*receive_crit_); | 545 WriteLockScoped write_lock(*receive_crit_); |
553 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 546 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
554 video_receive_ssrcs_.end()); | 547 video_receive_ssrcs_.end()); |
555 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 548 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
556 // TODO(pbos): Configure different RTX payloads per receive payload. | 549 // TODO(pbos): Configure different RTX payloads per receive payload. |
557 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 550 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
558 config.rtp.rtx.begin(); | 551 config.rtp.rtx.begin(); |
559 if (it != config.rtp.rtx.end()) | 552 if (it != config.rtp.rtx.end()) |
560 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 553 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
561 video_receive_streams_.insert(receive_stream); | 554 video_receive_streams_.insert(receive_stream); |
562 ConfigureSync(config.sync_group); | 555 ConfigureSync(config.sync_group); |
563 } | 556 } |
564 receive_stream->SignalNetworkState(video_network_state_); | 557 receive_stream->SignalNetworkState(video_network_state_); |
565 UpdateAggregateNetworkState(); | |
566 event_log_->LogVideoReceiveStreamConfig(config); | 558 event_log_->LogVideoReceiveStreamConfig(config); |
567 return receive_stream; | 559 return receive_stream; |
568 } | 560 } |
569 | 561 |
570 void Call::DestroyVideoReceiveStream( | 562 void Call::DestroyVideoReceiveStream( |
571 webrtc::VideoReceiveStream* receive_stream) { | 563 webrtc::VideoReceiveStream* receive_stream) { |
572 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 564 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
573 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 565 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
574 RTC_DCHECK(receive_stream != nullptr); | 566 RTC_DCHECK(receive_stream != nullptr); |
575 VideoReceiveStream* receive_stream_impl = nullptr; | 567 VideoReceiveStream* receive_stream_impl = nullptr; |
576 { | 568 { |
577 WriteLockScoped write_lock(*receive_crit_); | 569 WriteLockScoped write_lock(*receive_crit_); |
578 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 570 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
579 // separate SSRC there can be either one or two. | 571 // separate SSRC there can be either one or two. |
580 auto it = video_receive_ssrcs_.begin(); | 572 auto it = video_receive_ssrcs_.begin(); |
581 while (it != video_receive_ssrcs_.end()) { | 573 while (it != video_receive_ssrcs_.end()) { |
582 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 574 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
583 if (receive_stream_impl != nullptr) | 575 if (receive_stream_impl != nullptr) |
584 RTC_DCHECK(receive_stream_impl == it->second); | 576 RTC_DCHECK(receive_stream_impl == it->second); |
585 receive_stream_impl = it->second; | 577 receive_stream_impl = it->second; |
586 video_receive_ssrcs_.erase(it++); | 578 video_receive_ssrcs_.erase(it++); |
587 } else { | 579 } else { |
588 ++it; | 580 ++it; |
589 } | 581 } |
590 } | 582 } |
591 video_receive_streams_.erase(receive_stream_impl); | 583 video_receive_streams_.erase(receive_stream_impl); |
592 RTC_CHECK(receive_stream_impl != nullptr); | 584 RTC_CHECK(receive_stream_impl != nullptr); |
593 ConfigureSync(receive_stream_impl->config().sync_group); | 585 ConfigureSync(receive_stream_impl->config().sync_group); |
594 } | 586 } |
595 UpdateAggregateNetworkState(); | |
596 delete receive_stream_impl; | 587 delete receive_stream_impl; |
597 } | 588 } |
598 | 589 |
599 webrtc::FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( | 590 webrtc::FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( |
600 webrtc::FlexfecReceiveStream::Config configuration) { | 591 webrtc::FlexfecReceiveStream::Config configuration) { |
601 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); | 592 TRACE_EVENT0("webrtc", "Call::CreateFlexfecReceiveStream"); |
602 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 593 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
603 FlexfecReceiveStream* receive_stream = | 594 FlexfecReceiveStream* receive_stream = |
604 new FlexfecReceiveStream(std::move(configuration), this); | 595 new FlexfecReceiveStream(std::move(configuration), this); |
605 | 596 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 bitrate_config.max_bitrate_bps) { | 679 bitrate_config.max_bitrate_bps) { |
689 // Nothing new to set, early abort to avoid encoder reconfigurations. | 680 // Nothing new to set, early abort to avoid encoder reconfigurations. |
690 return; | 681 return; |
691 } | 682 } |
692 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; | 683 config_.bitrate_config.min_bitrate_bps = bitrate_config.min_bitrate_bps; |
693 // Start bitrate of -1 means we should keep the old bitrate, which there is | 684 // Start bitrate of -1 means we should keep the old bitrate, which there is |
694 // no point in remembering for the future. | 685 // no point in remembering for the future. |
695 if (bitrate_config.start_bitrate_bps > 0) | 686 if (bitrate_config.start_bitrate_bps > 0) |
696 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; | 687 config_.bitrate_config.start_bitrate_bps = bitrate_config.start_bitrate_bps; |
697 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; | 688 config_.bitrate_config.max_bitrate_bps = bitrate_config.max_bitrate_bps; |
698 congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps, | 689 congestion_controller_->SetBweBitrates( |
699 bitrate_config.start_bitrate_bps, | 690 config_.bitrate_config.start_bitrate_bps, |
700 bitrate_config.max_bitrate_bps); | 691 config_.bitrate_config.min_bitrate_bps, |
692 config_.bitrate_config.max_bitrate_bps); | |
701 } | 693 } |
702 | 694 |
703 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { | 695 void Call::SignalChannelNetworkState(MediaType media, NetworkState state) { |
704 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 696 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
705 switch (media) { | 697 switch (media) { |
706 case MediaType::AUDIO: | 698 case MediaType::AUDIO: |
707 audio_network_state_ = state; | 699 audio_network_state_ = state; |
708 break; | 700 break; |
709 case MediaType::VIDEO: | 701 case MediaType::VIDEO: |
710 video_network_state_ = state; | 702 video_network_state_ = state; |
711 break; | 703 break; |
712 case MediaType::ANY: | 704 case MediaType::ANY: |
713 case MediaType::DATA: | 705 case MediaType::DATA: |
714 RTC_NOTREACHED(); | 706 RTC_NOTREACHED(); |
715 break; | 707 break; |
716 } | 708 } |
717 | 709 |
718 UpdateAggregateNetworkState(); | |
honghaiz3
2016/11/03 06:10:20
I don't think it is appropriate to remove this her
| |
719 { | 710 { |
720 ReadLockScoped read_lock(*send_crit_); | 711 ReadLockScoped read_lock(*send_crit_); |
721 for (auto& kv : audio_send_ssrcs_) { | 712 for (auto& kv : audio_send_ssrcs_) { |
722 kv.second->SignalNetworkState(audio_network_state_); | 713 kv.second->SignalNetworkState(audio_network_state_); |
723 } | 714 } |
724 for (auto& kv : video_send_ssrcs_) { | 715 for (auto& kv : video_send_ssrcs_) { |
725 kv.second->SignalNetworkState(video_network_state_); | 716 kv.second->SignalNetworkState(video_network_state_); |
726 } | 717 } |
727 } | 718 } |
728 { | 719 { |
(...skipping 13 matching lines...) Expand all Loading... | |
742 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 733 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
743 // Check if the network route is connected. | 734 // Check if the network route is connected. |
744 if (!network_route.connected) { | 735 if (!network_route.connected) { |
745 LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; | 736 LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; |
746 // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and | 737 // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and |
747 // consider merging these two methods. | 738 // consider merging these two methods. |
748 return; | 739 return; |
749 } | 740 } |
750 | 741 |
751 // Check whether the network route has changed on each transport. | 742 // Check whether the network route has changed on each transport. |
752 auto result = | 743 auto& old_route = network_routes_[transport_name]; |
753 network_routes_.insert(std::make_pair(transport_name, network_route)); | 744 if (old_route != network_route) { |
754 auto kv = result.first; | 745 old_route = network_route; |
755 bool inserted = result.second; | |
756 if (inserted) { | |
757 // No need to reset BWE if this is the first time the network connects. | |
758 return; | |
759 } | |
760 if (kv->second != network_route) { | |
761 kv->second = network_route; | |
762 LOG(LS_INFO) << "Network route changed on transport " << transport_name | 746 LOG(LS_INFO) << "Network route changed on transport " << transport_name |
763 << ": new local network id " << network_route.local_network_id | 747 << ": new local network id " << network_route.local_network_id |
764 << " new remote network id " << network_route.remote_network_id | 748 << " new remote network id " |
765 << " Reset bitrates to min: " | 749 << network_route.remote_network_id; |
766 << config_.bitrate_config.min_bitrate_bps | 750 congestion_controller_->OnNetworkRouteChanged(network_route); |
767 << " bps, start: " << config_.bitrate_config.start_bitrate_bps | |
768 << " bps, max: " << config_.bitrate_config.start_bitrate_bps | |
769 << " bps."; | |
770 congestion_controller_->ResetBweAndBitrates( | |
771 config_.bitrate_config.start_bitrate_bps, | |
772 config_.bitrate_config.min_bitrate_bps, | |
773 config_.bitrate_config.max_bitrate_bps); | |
774 } | 751 } |
775 } | 752 } |
776 | 753 |
777 void Call::UpdateAggregateNetworkState() { | |
778 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | |
779 | |
780 bool have_audio = false; | |
781 bool have_video = false; | |
782 { | |
783 ReadLockScoped read_lock(*send_crit_); | |
784 if (audio_send_ssrcs_.size() > 0) | |
785 have_audio = true; | |
786 if (video_send_ssrcs_.size() > 0) | |
787 have_video = true; | |
788 } | |
789 { | |
790 ReadLockScoped read_lock(*receive_crit_); | |
791 if (audio_receive_ssrcs_.size() > 0) | |
792 have_audio = true; | |
793 if (video_receive_ssrcs_.size() > 0) | |
794 have_video = true; | |
795 } | |
796 | |
797 NetworkState aggregate_state = kNetworkDown; | |
798 if ((have_video && video_network_state_ == kNetworkUp) || | |
799 (have_audio && audio_network_state_ == kNetworkUp)) { | |
800 aggregate_state = kNetworkUp; | |
801 } | |
802 | |
803 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" | |
804 << (aggregate_state == kNetworkUp ? "up" : "down"); | |
805 | |
806 congestion_controller_->SignalNetworkState(aggregate_state); | |
807 } | |
808 | |
809 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 754 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
810 if (first_packet_sent_ms_ == -1) | 755 if (first_packet_sent_ms_ == -1) |
811 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 756 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
812 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, | 757 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, |
813 clock_->TimeInMilliseconds()); | 758 clock_->TimeInMilliseconds()); |
814 congestion_controller_->OnSentPacket(sent_packet); | 759 congestion_controller_->OnSentPacket(sent_packet); |
815 } | 760 } |
816 | 761 |
817 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, | 762 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, |
818 int64_t rtt_ms) { | 763 int64_t rtt_ms) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 982 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
1038 ReadLockScoped read_lock(*receive_crit_); | 983 ReadLockScoped read_lock(*receive_crit_); |
1039 auto it = video_receive_ssrcs_.find(ssrc); | 984 auto it = video_receive_ssrcs_.find(ssrc); |
1040 if (it == video_receive_ssrcs_.end()) | 985 if (it == video_receive_ssrcs_.end()) |
1041 return false; | 986 return false; |
1042 return it->second->OnRecoveredPacket(packet, length); | 987 return it->second->OnRecoveredPacket(packet, length); |
1043 } | 988 } |
1044 | 989 |
1045 } // namespace internal | 990 } // namespace internal |
1046 } // namespace webrtc | 991 } // namespace webrtc |
OLD | NEW |