diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index 37077e9f04..0d314c2da3 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -26,8 +26,6 @@ rtc_static_library("congestion_controller") { "probe_controller.h", "receive_side_congestion_controller.cc", "send_side_congestion_controller.cc", - "transport_feedback_adapter.cc", - "transport_feedback_adapter.h", ] # TODO(jschuh): Bug 1348: fix this warning. @@ -41,6 +39,7 @@ rtc_static_library("congestion_controller") { deps = [ ":delay_based_bwe", ":estimators", + ":transport_feedback", "..:module_api", "../..:webrtc_common", "../../rtc_base:checks", @@ -60,6 +59,24 @@ rtc_static_library("congestion_controller") { } } +rtc_static_library("transport_feedback") { + visibility = [ "*" ] + sources = [ + "send_time_history.cc", + "send_time_history.h", + "transport_feedback_adapter.cc", + "transport_feedback_adapter.h", + ] + + deps = [ + "../../modules:module_api", + "../../rtc_base:checks", + "../../rtc_base:rtc_base_approved", + "../../system_wrappers:system_wrappers", + "../rtp_rtcp:rtp_rtcp_format", + ] +} + rtc_source_set("estimators") { configs += [ ":bwe_test_logging" ] sources = [ @@ -136,6 +153,7 @@ if (rtc_include_tests) { "probe_controller_unittest.cc", "receive_side_congestion_controller_unittest.cc", "send_side_congestion_controller_unittest.cc", + "send_time_history_unittest.cc", "transport_feedback_adapter_unittest.cc", "trendline_estimator_unittest.cc", ] @@ -144,6 +162,7 @@ if (rtc_include_tests) { ":delay_based_bwe", ":estimators", ":mock_congestion_controller", + ":transport_feedback", "../../logging:mocks", "../../rtc_base:checks", "../../rtc_base:rtc_base", diff --git a/modules/congestion_controller/include/send_side_congestion_controller.h b/modules/congestion_controller/include/send_side_congestion_controller.h index b33fad0d30..2707cc340d 100644 --- a/modules/congestion_controller/include/send_side_congestion_controller.h +++ b/modules/congestion_controller/include/send_side_congestion_controller.h @@ -152,6 +152,8 @@ class SendSideCongestionController : public CallStatsObserver, bool in_cwnd_experiment_; int64_t accepted_queue_ms_; bool was_in_alr_; + const bool send_side_bwe_with_overhead_; + size_t transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(bwe_lock_); rtc::RaceChecker worker_race_; diff --git a/modules/congestion_controller/send_side_congestion_controller.cc b/modules/congestion_controller/send_side_congestion_controller.cc index 4db1125cd5..2a67578658 100644 --- a/modules/congestion_controller/send_side_congestion_controller.cc +++ b/modules/congestion_controller/send_side_congestion_controller.cc @@ -132,8 +132,10 @@ SendSideCongestionController::SendSideCongestionController( in_cwnd_experiment_(CwndExperimentEnabled()), accepted_queue_ms_(kDefaultAcceptedQueueMs), was_in_alr_(false), - pacer_pushback_experiment_( - IsPacerPushbackExperimentEnabled()) { + send_side_bwe_with_overhead_( + webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), + transport_overhead_bytes_per_packet_(0), + pacer_pushback_experiment_(IsPacerPushbackExperimentEnabled()) { delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); if (in_cwnd_experiment_ && !ReadCwndExperimentParameter(&accepted_queue_ms_)) { @@ -267,8 +269,8 @@ void SendSideCongestionController::SignalNetworkState(NetworkState state) { void SendSideCongestionController::SetTransportOverhead( size_t transport_overhead_bytes_per_packet) { - transport_feedback_adapter_.SetTransportOverhead( - rtc::dchecked_cast(transport_overhead_bytes_per_packet)); + rtc::CritScope cs(&bwe_lock_); + transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; } void SendSideCongestionController::OnSentPacket( @@ -318,6 +320,10 @@ void SendSideCongestionController::AddPacket( uint16_t sequence_number, size_t length, const PacedPacketInfo& pacing_info) { + if (send_side_bwe_with_overhead_) { + rtc::CritScope cs(&bwe_lock_); + length += transport_overhead_bytes_per_packet_; + } transport_feedback_adapter_.AddPacket(ssrc, sequence_number, length, pacing_info); } diff --git a/modules/remote_bitrate_estimator/send_time_history.cc b/modules/congestion_controller/send_time_history.cc similarity index 96% rename from modules/remote_bitrate_estimator/send_time_history.cc rename to modules/congestion_controller/send_time_history.cc index 014080530a..e5bc416286 100644 --- a/modules/remote_bitrate_estimator/send_time_history.cc +++ b/modules/congestion_controller/send_time_history.cc @@ -8,7 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/remote_bitrate_estimator/include/send_time_history.h" +#include "modules/congestion_controller/send_time_history.h" + +#include +#include #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/checks.h" diff --git a/modules/remote_bitrate_estimator/include/send_time_history.h b/modules/congestion_controller/send_time_history.h similarity index 89% rename from modules/remote_bitrate_estimator/include/send_time_history.h rename to modules/congestion_controller/send_time_history.h index 3946c4effa..366fec9d2c 100644 --- a/modules/remote_bitrate_estimator/include/send_time_history.h +++ b/modules/congestion_controller/send_time_history.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_ -#define MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_ +#ifndef MODULES_CONGESTION_CONTROLLER_SEND_TIME_HISTORY_H_ +#define MODULES_CONGESTION_CONTROLLER_SEND_TIME_HISTORY_H_ #include @@ -52,4 +52,4 @@ class SendTimeHistory { }; } // namespace webrtc -#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_ +#endif // MODULES_CONGESTION_CONTROLLER_SEND_TIME_HISTORY_H_ diff --git a/modules/remote_bitrate_estimator/send_time_history_unittest.cc b/modules/congestion_controller/send_time_history_unittest.cc similarity index 99% rename from modules/remote_bitrate_estimator/send_time_history_unittest.cc rename to modules/congestion_controller/send_time_history_unittest.cc index 5e2ece6d60..64f30c0375 100644 --- a/modules/remote_bitrate_estimator/send_time_history_unittest.cc +++ b/modules/congestion_controller/send_time_history_unittest.cc @@ -13,7 +13,7 @@ #include #include -#include "modules/remote_bitrate_estimator/include/send_time_history.h" +#include "modules/congestion_controller/send_time_history.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "system_wrappers/include/clock.h" #include "test/gtest.h" diff --git a/modules/congestion_controller/transport_feedback_adapter.cc b/modules/congestion_controller/transport_feedback_adapter.cc index 0989875df9..7a5f7c4ee3 100644 --- a/modules/congestion_controller/transport_feedback_adapter.cc +++ b/modules/congestion_controller/transport_feedback_adapter.cc @@ -12,12 +12,11 @@ #include -#include "modules/congestion_controller/delay_based_bwe.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/mod_ops.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { @@ -28,10 +27,7 @@ const int64_t kBaseTimestampScaleFactor = const int64_t kBaseTimestampRangeSizeUs = kBaseTimestampScaleFactor * (1 << 24); TransportFeedbackAdapter::TransportFeedbackAdapter(const Clock* clock) - : send_side_bwe_with_overhead_( - webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), - transport_overhead_bytes_per_packet_(0), - send_time_history_(clock, kSendTimeHistoryWindowMs), + : send_time_history_(clock, kSendTimeHistoryWindowMs), clock_(clock), current_offset_ms_(kNoTimestamp), last_timestamp_us_(kNoTimestamp), @@ -66,9 +62,6 @@ void TransportFeedbackAdapter::AddPacket(uint32_t ssrc, const PacedPacketInfo& pacing_info) { { rtc::CritScope cs(&lock_); - if (send_side_bwe_with_overhead_) { - length += transport_overhead_bytes_per_packet_; - } const int64_t creation_time_ms = clock_->TimeInMilliseconds(); send_time_history_.AddAndRemoveOld( PacketFeedback(creation_time_ms, sequence_number, length, local_net_id_, @@ -77,7 +70,7 @@ void TransportFeedbackAdapter::AddPacket(uint32_t ssrc, { rtc::CritScope cs(&observers_lock_); - for (auto observer : observers_) { + for (auto* observer : observers_) { observer->OnPacketAdded(ssrc, sequence_number); } } @@ -89,12 +82,6 @@ void TransportFeedbackAdapter::OnSentPacket(uint16_t sequence_number, send_time_history_.OnSentPacket(sequence_number, send_time_ms); } -void TransportFeedbackAdapter::SetTransportOverhead( - int transport_overhead_bytes_per_packet) { - rtc::CritScope cs(&lock_); - transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; -} - void TransportFeedbackAdapter::SetNetworkIds(uint16_t local_id, uint16_t remote_id) { rtc::CritScope cs(&lock_); @@ -195,7 +182,7 @@ void TransportFeedbackAdapter::OnTransportFeedback( last_packet_feedback_vector_ = GetPacketFeedbackVector(feedback); { rtc::CritScope cs(&observers_lock_); - for (auto observer : observers_) { + for (auto* observer : observers_) { observer->OnPacketFeedbackVector(last_packet_feedback_vector_); } } diff --git a/modules/congestion_controller/transport_feedback_adapter.h b/modules/congestion_controller/transport_feedback_adapter.h index 008bab87f1..2e9bf7ced2 100644 --- a/modules/congestion_controller/transport_feedback_adapter.h +++ b/modules/congestion_controller/transport_feedback_adapter.h @@ -14,7 +14,7 @@ #include #include -#include "modules/remote_bitrate_estimator/include/send_time_history.h" +#include "modules/congestion_controller/send_time_history.h" #include "rtc_base/criticalsection.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/thread_checker.h" @@ -59,9 +59,7 @@ class TransportFeedbackAdapter { std::vector GetPacketFeedbackVector( const rtcp::TransportFeedback& feedback); - const bool send_side_bwe_with_overhead_; rtc::CriticalSection lock_; - int transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(&lock_); SendTimeHistory send_time_history_ RTC_GUARDED_BY(&lock_); const Clock* const clock_; int64_t current_offset_ms_; diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn index fe9833c789..1c9504387d 100644 --- a/modules/remote_bitrate_estimator/BUILD.gn +++ b/modules/remote_bitrate_estimator/BUILD.gn @@ -16,7 +16,6 @@ rtc_static_library("remote_bitrate_estimator") { "bwe_defines.cc", "include/bwe_defines.h", "include/remote_bitrate_estimator.h", - "include/send_time_history.h", "inter_arrival.cc", "inter_arrival.h", "overuse_detector.cc", @@ -29,7 +28,6 @@ rtc_static_library("remote_bitrate_estimator") { "remote_bitrate_estimator_single_stream.h", "remote_estimator_proxy.cc", "remote_estimator_proxy.h", - "send_time_history.cc", "test/bwe_test_logging.h", ] @@ -152,6 +150,7 @@ if (rtc_include_tests) { "../congestion_controller", "../congestion_controller:delay_based_bwe", "../congestion_controller:estimators", + "../congestion_controller:transport_feedback", "../pacing", "../rtp_rtcp", "../rtp_rtcp:rtp_rtcp_format", @@ -191,7 +190,6 @@ if (rtc_include_tests) { "remote_bitrate_estimator_unittest_helper.cc", "remote_bitrate_estimator_unittest_helper.h", "remote_estimator_proxy_unittest.cc", - "send_time_history_unittest.cc", "test/bwe_test_framework_unittest.cc", "test/bwe_unittest.cc", "test/estimators/congestion_window_unittest.cc", diff --git a/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h b/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h index 011934d9cf..489b47efe5 100644 --- a/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h +++ b/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h @@ -20,7 +20,6 @@ #include #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" -#include "modules/remote_bitrate_estimator/include/send_time_history.h" #include "modules/remote_bitrate_estimator/test/bwe.h" namespace webrtc { diff --git a/modules/remote_bitrate_estimator/test/estimators/send_side.h b/modules/remote_bitrate_estimator/test/estimators/send_side.h index 6816223cf3..1fa07200e6 100644 --- a/modules/remote_bitrate_estimator/test/estimators/send_side.h +++ b/modules/remote_bitrate_estimator/test/estimators/send_side.h @@ -16,7 +16,7 @@ #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "modules/congestion_controller/acknowledged_bitrate_estimator.h" -#include "modules/remote_bitrate_estimator/include/send_time_history.h" +#include "modules/congestion_controller/send_time_history.h" #include "modules/remote_bitrate_estimator/test/bwe.h" namespace webrtc {