| 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 15 matching lines...) Expand all Loading... |
| 26 #include "webrtc/call.h" | 26 #include "webrtc/call.h" |
| 27 #include "webrtc/call/bitrate_allocator.h" | 27 #include "webrtc/call/bitrate_allocator.h" |
| 28 #include "webrtc/call/rtc_event_log.h" | 28 #include "webrtc/call/rtc_event_log.h" |
| 29 #include "webrtc/config.h" | 29 #include "webrtc/config.h" |
| 30 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 30 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 31 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 31 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| 32 #include "webrtc/modules/pacing/paced_sender.h" | 32 #include "webrtc/modules/pacing/paced_sender.h" |
| 33 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 33 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 34 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 34 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 35 #include "webrtc/modules/utility/include/process_thread.h" | 35 #include "webrtc/modules/utility/include/process_thread.h" |
| 36 #include "webrtc/p2p/base/port.h" |
| 36 #include "webrtc/system_wrappers/include/cpu_info.h" | 37 #include "webrtc/system_wrappers/include/cpu_info.h" |
| 37 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 38 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 38 #include "webrtc/system_wrappers/include/metrics.h" | 39 #include "webrtc/system_wrappers/include/metrics.h" |
| 39 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 40 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
| 40 #include "webrtc/system_wrappers/include/trace.h" | 41 #include "webrtc/system_wrappers/include/trace.h" |
| 41 #include "webrtc/video/call_stats.h" | 42 #include "webrtc/video/call_stats.h" |
| 42 #include "webrtc/video/video_receive_stream.h" | 43 #include "webrtc/video/video_receive_stream.h" |
| 43 #include "webrtc/video/video_send_stream.h" | 44 #include "webrtc/video/video_send_stream.h" |
| 44 #include "webrtc/video/vie_remb.h" | 45 #include "webrtc/video/vie_remb.h" |
| 45 #include "webrtc/voice_engine/include/voe_codec.h" | 46 #include "webrtc/voice_engine/include/voe_codec.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 DeliveryStatus DeliverPacket(MediaType media_type, | 83 DeliveryStatus DeliverPacket(MediaType media_type, |
| 83 const uint8_t* packet, | 84 const uint8_t* packet, |
| 84 size_t length, | 85 size_t length, |
| 85 const PacketTime& packet_time) override; | 86 const PacketTime& packet_time) override; |
| 86 | 87 |
| 87 void SetBitrateConfig( | 88 void SetBitrateConfig( |
| 88 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 89 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
| 89 void SignalNetworkState(NetworkState state) override; | 90 void SignalNetworkState(NetworkState state) override; |
| 90 | 91 |
| 92 void OnBestConnectionChanged(cricket::Connection* best_connection) override; |
| 93 |
| 91 void OnSentPacket(const rtc::SentPacket& sent_packet) override; | 94 void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
| 92 | 95 |
| 93 // Implements BitrateObserver. | 96 // Implements BitrateObserver. |
| 94 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, | 97 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, |
| 95 int64_t rtt_ms) override; | 98 int64_t rtt_ms) override; |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 101 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
| 99 size_t length); | 102 size_t length); |
| 100 DeliveryStatus DeliverRtp(MediaType media_type, | 103 DeliveryStatus DeliverRtp(MediaType media_type, |
| 101 const uint8_t* packet, | 104 const uint8_t* packet, |
| 102 size_t length, | 105 size_t length, |
| 103 const PacketTime& packet_time); | 106 const PacketTime& packet_time); |
| 104 | |
| 105 void ConfigureSync(const std::string& sync_group) | 107 void ConfigureSync(const std::string& sync_group) |
| 106 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 108 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
| 107 | 109 |
| 108 VoiceEngine* voice_engine() { | 110 VoiceEngine* voice_engine() { |
| 109 internal::AudioState* audio_state = | 111 internal::AudioState* audio_state = |
| 110 static_cast<internal::AudioState*>(config_.audio_state.get()); | 112 static_cast<internal::AudioState*>(config_.audio_state.get()); |
| 111 if (audio_state) | 113 if (audio_state) |
| 112 return audio_state->voice_engine(); | 114 return audio_state->voice_engine(); |
| 113 else | 115 else |
| 114 return nullptr; | 116 return nullptr; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 int64_t last_rtp_packet_received_ms_; | 162 int64_t last_rtp_packet_received_ms_; |
| 161 int64_t first_packet_sent_ms_; | 163 int64_t first_packet_sent_ms_; |
| 162 | 164 |
| 163 // TODO(holmer): Remove this lock once BitrateController no longer calls | 165 // TODO(holmer): Remove this lock once BitrateController no longer calls |
| 164 // OnNetworkChanged from multiple threads. | 166 // OnNetworkChanged from multiple threads. |
| 165 rtc::CriticalSection bitrate_crit_; | 167 rtc::CriticalSection bitrate_crit_; |
| 166 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 168 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
| 167 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); | 169 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); |
| 168 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); | 170 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); |
| 169 | 171 |
| 172 int local_network_id_ = 0; |
| 173 int remote_network_id_ = 0; |
| 174 |
| 170 VieRemb remb_; | 175 VieRemb remb_; |
| 171 const std::unique_ptr<CongestionController> congestion_controller_; | 176 const std::unique_ptr<CongestionController> congestion_controller_; |
| 172 | 177 |
| 173 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 178 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
| 174 }; | 179 }; |
| 175 } // namespace internal | 180 } // namespace internal |
| 176 | 181 |
| 177 Call* Call::Create(const Call::Config& config) { | 182 Call* Call::Create(const Call::Config& config) { |
| 178 return new internal::Call(config); | 183 return new internal::Call(config); |
| 179 } | 184 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 568 } |
| 564 } | 569 } |
| 565 { | 570 { |
| 566 ReadLockScoped write_lock(*receive_crit_); | 571 ReadLockScoped write_lock(*receive_crit_); |
| 567 for (auto& kv : video_receive_ssrcs_) { | 572 for (auto& kv : video_receive_ssrcs_) { |
| 568 kv.second->SignalNetworkState(state); | 573 kv.second->SignalNetworkState(state); |
| 569 } | 574 } |
| 570 } | 575 } |
| 571 } | 576 } |
| 572 | 577 |
| 578 void Call::OnBestConnectionChanged(cricket::Connection* connection) { |
| 579 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
| 580 // Reset the BWE estimate when network changes. |
| 581 // Check if the network has actually changed. |
| 582 if (connection == nullptr) { |
| 583 LOG(LS_INFO) << "Transport channel is disconnected"; |
| 584 // TODO(honghaiz): stop sending when this happens. |
| 585 return; |
| 586 } |
| 587 uint16_t local_net_id = connection->local_candidate().network_id(); |
| 588 uint16_t remote_net_id = connection->local_candidate().network_id(); |
| 589 if (local_net_id == local_network_id_ && |
| 590 remote_net_id == remote_network_id_) { |
| 591 return; |
| 592 } |
| 593 LOG(LS_INFO) << "Network changed: new local network id " << local_net_id |
| 594 << " new remote network id " << remote_net_id; |
| 595 local_network_id_ = local_net_id; |
| 596 remote_network_id_ = remote_net_id; |
| 597 congestion_controller_->ResetBweBitrates( |
| 598 config_.bitrate_config.start_bitrate_bps); |
| 599 } |
| 600 |
| 573 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 601 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 574 if (first_packet_sent_ms_ == -1) | 602 if (first_packet_sent_ms_ == -1) |
| 575 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 603 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
| 576 congestion_controller_->OnSentPacket(sent_packet); | 604 congestion_controller_->OnSentPacket(sent_packet); |
| 577 } | 605 } |
| 578 | 606 |
| 579 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, | 607 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, |
| 580 int64_t rtt_ms) { | 608 int64_t rtt_ms) { |
| 581 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( | 609 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( |
| 582 target_bitrate_bps, fraction_loss, rtt_ms); | 610 target_bitrate_bps, fraction_loss, rtt_ms); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 // thread. Then this check can be enabled. | 773 // thread. Then this check can be enabled. |
| 746 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 774 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
| 747 if (RtpHeaderParser::IsRtcp(packet, length)) | 775 if (RtpHeaderParser::IsRtcp(packet, length)) |
| 748 return DeliverRtcp(media_type, packet, length); | 776 return DeliverRtcp(media_type, packet, length); |
| 749 | 777 |
| 750 return DeliverRtp(media_type, packet, length, packet_time); | 778 return DeliverRtp(media_type, packet, length, packet_time); |
| 751 } | 779 } |
| 752 | 780 |
| 753 } // namespace internal | 781 } // namespace internal |
| 754 } // namespace webrtc | 782 } // namespace webrtc |
| OLD | NEW |