Provide Environment for ReceiveSideConfestionController construction

Environment includes propagated field trials that can be later passed to
RemoteBitrateEstimators member, and would allow not to rely on the global field trial string

Bug: webrtc:42220378
Change-Id: Icf75a433c20352b2c22829c2148c92f69a2517aa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349645
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42242}
This commit is contained in:
Danil Chapovalov 2024-05-06 19:51:23 +02:00 committed by WebRTC LUCI CQ
parent f5e9f11994
commit 2ee83c1784
9 changed files with 47 additions and 12 deletions

View file

@ -666,7 +666,7 @@ Call::Call(const CallConfig& config,
aggregate_network_up_(false),
receive_stats_(&env_.clock()),
send_stats_(&env_.clock()),
receive_side_cc_(&env_.clock(),
receive_side_cc_(env_,
absl::bind_front(&PacketRouter::SendCombinedRtcpPacket,
transport_send->packet_router()),
absl::bind_front(&PacketRouter::SendRemb,

View file

@ -28,6 +28,7 @@ rtc_library("congestion_controller") {
deps = [
"../../api:rtp_parameters",
"../../api/environment",
"../../api/transport:network_control",
"../../api/units:data_rate",
"../../api/units:time_delta",
@ -39,6 +40,7 @@ rtc_library("congestion_controller") {
"../remote_bitrate_estimator",
"../rtp_rtcp:rtp_rtcp_format",
]
absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ]
}
if (rtc_include_tests && !build_with_chromium) {
@ -51,6 +53,7 @@ if (rtc_include_tests && !build_with_chromium) {
]
deps = [
":congestion_controller",
"../../api/environment:environment_factory",
"../../api/test/network_emulation",
"../../api/test/network_emulation:create_cross_traffic",
"../../api/units:data_rate",

View file

@ -14,6 +14,8 @@
#include <memory>
#include <vector>
#include "absl/base/nullability.h"
#include "api/environment/environment.h"
#include "api/transport/network_control.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
@ -35,12 +37,18 @@ class RemoteBitrateEstimator;
class ReceiveSideCongestionController : public CallStatsObserver {
public:
ReceiveSideCongestionController(
const Environment& env,
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,
RembThrottler::RembSender remb_sender,
absl::Nullable<NetworkStateEstimator*> network_state_estimator);
[[deprecated]] ReceiveSideCongestionController(
Clock* clock,
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,
RembThrottler::RembSender remb_sender,
NetworkStateEstimator* network_state_estimator);
~ReceiveSideCongestionController() override {}
~ReceiveSideCongestionController() override = default;
void OnReceivedPacket(const RtpPacketReceived& packet, MediaType media_type);

View file

@ -10,6 +10,8 @@
#include "modules/congestion_controller/include/receive_side_congestion_controller.h"
#include "absl/base/nullability.h"
#include "api/environment/environment.h"
#include "api/media_types.h"
#include "api/units/data_rate.h"
#include "modules/pacing/packet_router.h"
@ -68,6 +70,21 @@ void ReceiveSideCongestionController::PickEstimator(
}
}
ReceiveSideCongestionController::ReceiveSideCongestionController(
const Environment& env,
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,
RembThrottler::RembSender remb_sender,
absl::Nullable<NetworkStateEstimator*> network_state_estimator)
: clock_(env.clock()),
remb_throttler_(std::move(remb_sender), &clock_),
remote_estimator_proxy_(std::move(feedback_sender),
network_state_estimator),
rbe_(
std::make_unique<RemoteBitrateEstimatorSingleStream>(&remb_throttler_,
&clock_)),
using_absolute_send_time_(false),
packets_since_absolute_send_time_(0) {}
ReceiveSideCongestionController::ReceiveSideCongestionController(
Clock* clock,
RemoteEstimatorProxy::TransportFeedbackSender feedback_sender,

View file

@ -10,6 +10,7 @@
#include "modules/congestion_controller/include/receive_side_congestion_controller.h"
#include "api/environment/environment_factory.h"
#include "api/test/network_emulation/create_cross_traffic.h"
#include "api/test/network_emulation/cross_traffic.h"
#include "api/units/data_rate.h"
@ -41,11 +42,11 @@ TEST(ReceiveSideCongestionControllerTest, SendsRembWithAbsSendTime) {
MockFunction<void(std::vector<std::unique_ptr<rtcp::RtcpPacket>>)>
feedback_sender;
MockFunction<void(uint64_t, std::vector<uint32_t>)> remb_sender;
SimulatedClock clock_(123456);
SimulatedClock clock(123456);
ReceiveSideCongestionController controller(
&clock_, feedback_sender.AsStdFunction(), remb_sender.AsStdFunction(),
nullptr);
CreateEnvironment(&clock), feedback_sender.AsStdFunction(),
remb_sender.AsStdFunction(), nullptr);
RtpHeaderExtensionMap extensions;
extensions.Register<AbsoluteSendTime>(1);
@ -58,8 +59,8 @@ TEST(ReceiveSideCongestionControllerTest, SendsRembWithAbsSendTime) {
.Times(AtLeast(1));
for (int i = 0; i < 10; ++i) {
clock_.AdvanceTime(kPayloadSize / kInitialBitrate);
Timestamp now = clock_.CurrentTime();
clock.AdvanceTime(kPayloadSize / kInitialBitrate);
Timestamp now = clock.CurrentTime();
packet.SetExtension<AbsoluteSendTime>(AbsoluteSendTime::To24Bits(now));
packet.set_arrival_time(now);
controller.OnReceivedPacket(packet, MediaType::VIDEO);
@ -71,11 +72,11 @@ TEST(ReceiveSideCongestionControllerTest,
MockFunction<void(std::vector<std::unique_ptr<rtcp::RtcpPacket>>)>
feedback_sender;
MockFunction<void(uint64_t, std::vector<uint32_t>)> remb_sender;
SimulatedClock clock_(123456);
SimulatedClock clock(123456);
ReceiveSideCongestionController controller(
&clock_, feedback_sender.AsStdFunction(), remb_sender.AsStdFunction(),
nullptr);
CreateEnvironment(&clock), feedback_sender.AsStdFunction(),
remb_sender.AsStdFunction(), nullptr);
EXPECT_CALL(remb_sender, Call(123, _));
controller.SetMaxDesiredReceiveBitrate(DataRate::BitsPerSec(123));
}

View file

@ -359,6 +359,7 @@ if (!build_with_chromium) {
rtc_library("event_log_visualizer_utils") {
visibility = [ "*" ]
allow_poison = [ "environment_construction" ]
sources = [
"rtc_event_log_visualizer/alerts.cc",
"rtc_event_log_visualizer/alerts.h",
@ -384,6 +385,7 @@ if (!build_with_chromium) {
"../api:scoped_refptr",
"../api/audio_codecs:audio_codecs_api", # TODO(kwiberg): Remove this
# dependency.
"../api/environment:environment_factory",
"../api/neteq:neteq_api",
"../api/rtc_event_log:rtc_event_log",
"../api/transport:field_trial_based_config",
@ -437,6 +439,7 @@ if (!build_with_chromium) {
rtc_library("event_log_visualizer_bindings") {
visibility = [ "*" ]
allow_poison = [ "environment_construction" ]
sources = [
"rtc_event_log_visualizer/analyzer_bindings.cc",
"rtc_event_log_visualizer/analyzer_bindings.h",

View file

@ -28,6 +28,7 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/dtls_transport_interface.h"
#include "api/environment/environment_factory.h"
#include "api/function_view.h"
#include "api/media_types.h"
#include "api/network_state_predictor.h"
@ -1851,7 +1852,7 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) {
SimulatedClock clock(0);
RembInterceptor remb_interceptor;
ReceiveSideCongestionController rscc(
&clock, [](auto...) {},
CreateEnvironment(&clock), [](auto...) {},
absl::bind_front(&RembInterceptor::SendRemb, &remb_interceptor), nullptr);
// TODO(holmer): Log the call config and use that here instead.
// static const uint32_t kDefaultStartBitrateBps = 300000;

View file

@ -278,6 +278,7 @@ webrtc_fuzzer_test("receive_side_congestion_controller_fuzzer") {
sources = [ "receive_side_congestion_controller_fuzzer.cc" ]
deps = [
"../../api:array_view",
"../../api/environment:environment_factory",
"../../api/units:time_delta",
"../../api/units:timestamp",
"../../modules/congestion_controller",

View file

@ -13,6 +13,7 @@
#include <cstdint>
#include "api/array_view.h"
#include "api/environment/environment_factory.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/congestion_controller/include/receive_side_congestion_controller.h"
@ -28,7 +29,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
Timestamp arrival_time = Timestamp::Micros(123'456'789);
SimulatedClock clock(arrival_time);
ReceiveSideCongestionController cc(
&clock,
CreateEnvironment(&clock),
/*feedback_sender=*/[](auto...) {},
/*remb_sender=*/[](auto...) {},
/*network_state_estimator=*/nullptr);