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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 81 |
82 DeliveryStatus DeliverPacket(MediaType media_type, | 82 DeliveryStatus DeliverPacket(MediaType media_type, |
83 const uint8_t* packet, | 83 const uint8_t* packet, |
84 size_t length, | 84 size_t length, |
85 const PacketTime& packet_time) override; | 85 const PacketTime& packet_time) override; |
86 | 86 |
87 void SetBitrateConfig( | 87 void SetBitrateConfig( |
88 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 88 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
89 void SignalNetworkState(NetworkState state) override; | 89 void SignalNetworkState(NetworkState state) override; |
90 | 90 |
91 void OnNetworkChanged(int local_net_id, int remote_net_id) override; | |
92 | |
91 void OnSentPacket(const rtc::SentPacket& sent_packet) override; | 93 void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
92 | 94 |
93 // Implements BitrateObserver. | 95 // Implements BitrateObserver. |
94 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, | 96 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, |
95 int64_t rtt_ms) override; | 97 int64_t rtt_ms) override; |
96 | 98 |
97 private: | 99 private: |
98 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 100 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
99 size_t length); | 101 size_t length); |
100 DeliveryStatus DeliverRtp(MediaType media_type, | 102 DeliveryStatus DeliverRtp(MediaType media_type, |
101 const uint8_t* packet, | 103 const uint8_t* packet, |
102 size_t length, | 104 size_t length, |
103 const PacketTime& packet_time); | 105 const PacketTime& packet_time); |
104 | 106 void ResetBweBitrates(); |
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; | |
pthatcher1
2016/03/16 21:22:03
If the signal has both old and new route infos, we
honghaiz3
2016/03/17 03:38:27
Keep this as we have discussed.
| |
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::OnNetworkChanged(int local_net_id, int remote_net_id) { | |
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 (local_net_id == local_network_id_ && | |
583 remote_net_id == remote_network_id_) { | |
pthatcher1
2016/03/16 21:22:03
If we use NetworkRoute structs, we should also che
honghaiz3
2016/03/17 03:38:27
We can now use the null pointer for best connectio
| |
584 return; | |
585 } | |
586 LOG(LS_INFO) << "Network changed: new local network id " << local_net_id | |
587 << " new remote network id " << remote_net_id; | |
588 local_network_id_ = local_net_id; | |
589 remote_network_id_ = remote_net_id; | |
590 ResetBweBitrates(); | |
591 } | |
592 | |
593 void Call::ResetBweBitrates() { | |
pthatcher1
2016/03/16 21:22:03
If !new_route.connected, we probably want to do so
honghaiz3
2016/03/17 03:38:27
Done. Add TODO.
| |
594 LOG(LS_INFO) << "Reset BWE estimate to " | |
595 << config_.bitrate_config.start_bitrate_bps << "bps"; | |
596 congestion_controller_->SetBweBitrates( | |
597 config_.bitrate_config.min_bitrate_bps, | |
598 config_.bitrate_config.start_bitrate_bps, | |
599 config_.bitrate_config.max_bitrate_bps); | |
pthatcher1
2016/03/16 21:22:03
Does this really restart the BWE?
honghaiz3
2016/03/17 03:38:27
Actually It may not. Maybe we can leave this to BW
| |
600 } | |
601 | |
573 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { | 602 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { |
574 if (first_packet_sent_ms_ == -1) | 603 if (first_packet_sent_ms_ == -1) |
575 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); | 604 first_packet_sent_ms_ = clock_->TimeInMilliseconds(); |
576 congestion_controller_->OnSentPacket(sent_packet); | 605 congestion_controller_->OnSentPacket(sent_packet); |
577 } | 606 } |
578 | 607 |
579 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, | 608 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss, |
580 int64_t rtt_ms) { | 609 int64_t rtt_ms) { |
581 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( | 610 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( |
582 target_bitrate_bps, fraction_loss, rtt_ms); | 611 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. | 774 // thread. Then this check can be enabled. |
746 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 775 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
747 if (RtpHeaderParser::IsRtcp(packet, length)) | 776 if (RtpHeaderParser::IsRtcp(packet, length)) |
748 return DeliverRtcp(media_type, packet, length); | 777 return DeliverRtcp(media_type, packet, length); |
749 | 778 |
750 return DeliverRtp(media_type, packet, length, packet_time); | 779 return DeliverRtp(media_type, packet, length, packet_time); |
751 } | 780 } |
752 | 781 |
753 } // namespace internal | 782 } // namespace internal |
754 } // namespace webrtc | 783 } // namespace webrtc |
OLD | NEW |