From 91bb6671eafbd6a957e2e1091965567bf23a05b4 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Wed, 21 Feb 2018 13:02:51 +0100 Subject: [PATCH] Moved routes tracking to rtp transport controller. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prepares for eliminating OnNetworkRouteChanged in the Call class. Bug: webrtc:8415 Change-Id: I62dc7226804e65c90b2a0a771dd6861f6760c8dd Reviewed-on: https://webrtc-review.googlesource.com/54363 Commit-Queue: Sebastian Jansson Reviewed-by: Stefan Holmer Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#22130} --- call/BUILD.gn | 1 + call/call.cc | 24 +------------ call/rtp_transport_controller_send.cc | 51 +++++++++++++++++++-------- call/rtp_transport_controller_send.h | 3 ++ 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/call/BUILD.gn b/call/BUILD.gn index b943221958..683f5282c1 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -97,6 +97,7 @@ rtc_source_set("rtp_sender") { "..:webrtc_common", "../modules/congestion_controller", "../modules/pacing", + "../rtc_base:rtc_base", "../rtc_base:rtc_base_approved", ] } diff --git a/call/call.cc b/call/call.cc index c21c24095f..9f526cc672 100644 --- a/call/call.cc +++ b/call/call.cc @@ -356,8 +356,6 @@ class Call : public webrtc::Call, RTC_GUARDED_BY(&bitrate_crit_); AvgCounter pacer_bitrate_kbps_counter_ RTC_GUARDED_BY(&bitrate_crit_); - std::map network_routes_; - std::unique_ptr transport_send_; ReceiveSideCongestionController receive_side_cc_; const std::unique_ptr video_send_delay_stats_; @@ -1026,27 +1024,7 @@ void Call::OnTransportOverheadChanged(MediaType media, void Call::OnNetworkRouteChanged(const std::string& transport_name, const rtc::NetworkRoute& network_route) { RTC_DCHECK_CALLED_SEQUENTIALLY(&configuration_sequence_checker_); - // Check if the network route is connected. - if (!network_route.connected) { - RTC_LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; - // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and - // consider merging these two methods. - return; - } - - // Check whether the network route has changed on each transport. - auto result = - network_routes_.insert(std::make_pair(transport_name, network_route)); - auto kv = result.first; - bool inserted = result.second; - if (inserted) { - // No need to reset BWE if this is the first time the network connects. - return; - } - if (kv->second != network_route) { - kv->second = network_route; - transport_send_->OnNetworkRouteChanged(transport_name, network_route); - } + transport_send_->OnNetworkRouteChanged(transport_name, network_route); } void Call::UpdateAggregateNetworkState() { diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index a48d84353e..71be5cbef8 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -7,6 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +#include #include "call/rtp_transport_controller_send.h" #include "rtc_base/logging.h" @@ -88,21 +89,41 @@ void RtpTransportControllerSend::DeRegisterNetworkObserver( void RtpTransportControllerSend::OnNetworkRouteChanged( const std::string& transport_name, const rtc::NetworkRoute& network_route) { - BitrateConstraints bitrate_config = bitrate_configurator_.GetConfig(); - RTC_LOG(LS_INFO) << "Network route changed on transport " << transport_name - << ": new local network id " - << network_route.local_network_id - << " new remote network id " - << network_route.remote_network_id - << " Reset bitrates to min: " - << bitrate_config.min_bitrate_bps - << " bps, start: " << bitrate_config.start_bitrate_bps - << " bps, max: " << bitrate_config.max_bitrate_bps - << " bps."; - RTC_DCHECK_GT(bitrate_config.start_bitrate_bps, 0); - send_side_cc_.OnNetworkRouteChanged( - network_route, bitrate_config.start_bitrate_bps, - bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps); + // Check if the network route is connected. + if (!network_route.connected) { + RTC_LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; + // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and + // consider merging these two methods. + return; + } + + // Check whether the network route has changed on each transport. + auto result = + network_routes_.insert(std::make_pair(transport_name, network_route)); + auto kv = result.first; + bool inserted = result.second; + if (inserted) { + // No need to reset BWE if this is the first time the network connects. + return; + } + if (kv->second != network_route) { + kv->second = network_route; + BitrateConstraints bitrate_config = bitrate_configurator_.GetConfig(); + RTC_LOG(LS_INFO) << "Network route changed on transport " << transport_name + << ": new local network id " + << network_route.local_network_id + << " new remote network id " + << network_route.remote_network_id + << " Reset bitrates to min: " + << bitrate_config.min_bitrate_bps + << " bps, start: " << bitrate_config.start_bitrate_bps + << " bps, max: " << bitrate_config.max_bitrate_bps + << " bps."; + RTC_DCHECK_GT(bitrate_config.start_bitrate_bps, 0); + send_side_cc_.OnNetworkRouteChanged( + network_route, bitrate_config.start_bitrate_bps, + bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps); + } } void RtpTransportControllerSend::OnNetworkAvailability(bool network_available) { send_side_cc_.SignalNetworkState(network_available ? kNetworkUp diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 30f059642e..ec71614464 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -11,6 +11,7 @@ #ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_ #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_ +#include #include #include "call/rtp_bitrate_configurator.h" @@ -19,6 +20,7 @@ #include "modules/congestion_controller/include/send_side_congestion_controller.h" #include "modules/pacing/packet_router.h" #include "rtc_base/constructormagic.h" +#include "rtc_base/networkroute.h" namespace webrtc { class Clock; @@ -78,6 +80,7 @@ class RtpTransportControllerSend : public RtpTransportControllerSendInterface { SendSideCongestionController send_side_cc_; RtpKeepAliveConfig keepalive_; RtpBitrateConfigurator bitrate_configurator_; + std::map network_routes_; RTC_DISALLOW_COPY_AND_ASSIGN(RtpTransportControllerSend); };