Propagate FieldTrialsView through FEC protection method helpers
And thus in those helpers query RateControlSettings field trials via propagated FieldTrialView instead of the via global field trial string
Bug: webrtc:42220378
Change-Id: I84f4bf42037d864519c4d2031d25cf909fd5010f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350305
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42286}
diff --git a/modules/video_coding/fec_controller_default.cc b/modules/video_coding/fec_controller_default.cc
index d548d65..9933782 100644
--- a/modules/video_coding/fec_controller_default.cc
+++ b/modules/video_coding/fec_controller_default.cc
@@ -30,8 +30,7 @@
VCMProtectionCallback* protection_callback)
: env_(env),
protection_callback_(protection_callback),
- loss_prot_logic_(new media_optimization::VCMLossProtectionLogic(
- env_.clock().TimeInMilliseconds())),
+ loss_prot_logic_(new media_optimization::VCMLossProtectionLogic(env_)),
max_payload_size_(1460),
overhead_threshold_(GetProtectionOverheadRateThreshold()) {}
diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc
index 7580c95..cdcc6e7 100644
--- a/modules/video_coding/media_opt_util.cc
+++ b/modules/video_coding/media_opt_util.cc
@@ -13,13 +13,16 @@
#include <math.h>
#include <algorithm>
+#include <memory>
+#include "api/field_trials_view.h"
#include "modules/video_coding/fec_rate_table.h"
#include "modules/video_coding/internal_defines.h"
#include "modules/video_coding/utility/simulcast_rate_allocator.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/rate_control_settings.h"
#include "rtc_base/numerics/safe_conversions.h"
+#include "system_wrappers/include/clock.h"
namespace webrtc {
// Max value of loss rates in off-line model
@@ -80,9 +83,10 @@
return 1;
}
-VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs,
+VCMNackFecMethod::VCMNackFecMethod(const FieldTrialsView& field_trials,
+ int64_t lowRttNackThresholdMs,
int64_t highRttNackThresholdMs)
- : VCMFecMethod(),
+ : VCMFecMethod(field_trials),
_lowRttNackMs(lowRttNackThresholdMs),
_highRttNackMs(highRttNackThresholdMs),
_maxFramesFec(1) {
@@ -244,9 +248,8 @@
return true;
}
-VCMFecMethod::VCMFecMethod()
- : VCMProtectionMethod(),
- rate_control_settings_(RateControlSettings::ParseFromFieldTrials()) {
+VCMFecMethod::VCMFecMethod(const FieldTrialsView& field_trials)
+ : rate_control_settings_(field_trials) {
_type = kFec;
}
@@ -489,8 +492,9 @@
return true;
}
-VCMLossProtectionLogic::VCMLossProtectionLogic(int64_t nowMs)
- : _currentParameters(),
+VCMLossProtectionLogic::VCMLossProtectionLogic(const Environment& env)
+ : env_(env),
+ _currentParameters(),
_rtt(0),
_lossPr(0.0f),
_bitRate(0.0f),
@@ -507,7 +511,7 @@
_codecWidth(704),
_codecHeight(576),
_numLayers(1) {
- Reset(nowMs);
+ Reset(env_.clock().CurrentTime().ms());
}
VCMLossProtectionLogic::~VCMLossProtectionLogic() {
@@ -524,10 +528,11 @@
_selectedMethod.reset(new VCMNackMethod());
break;
case kFec:
- _selectedMethod.reset(new VCMFecMethod());
+ _selectedMethod = std::make_unique<VCMFecMethod>(env_.field_trials());
break;
case kNackFec:
- _selectedMethod.reset(new VCMNackFecMethod(kLowRttNackMs, -1));
+ _selectedMethod = std::make_unique<VCMNackFecMethod>(env_.field_trials(),
+ kLowRttNackMs, -1);
break;
case kNone:
_selectedMethod.reset();
diff --git a/modules/video_coding/media_opt_util.h b/modules/video_coding/media_opt_util.h
index a74d1af..ad77f52 100644
--- a/modules/video_coding/media_opt_util.h
+++ b/modules/video_coding/media_opt_util.h
@@ -16,6 +16,8 @@
#include <memory>
+#include "api/environment/environment.h"
+#include "api/field_trials_view.h"
#include "modules/video_coding/internal_defines.h"
#include "rtc_base/experiments/rate_control_settings.h"
#include "rtc_base/numerics/exp_filter.h"
@@ -153,7 +155,7 @@
class VCMFecMethod : public VCMProtectionMethod {
public:
- VCMFecMethod();
+ explicit VCMFecMethod(const FieldTrialsView& field_trials);
~VCMFecMethod() override;
bool UpdateParameters(const VCMProtectionParameters* parameters) override;
// Get the effective packet loss for ER
@@ -190,7 +192,8 @@
class VCMNackFecMethod : public VCMFecMethod {
public:
- VCMNackFecMethod(int64_t lowRttNackThresholdMs,
+ VCMNackFecMethod(const FieldTrialsView& field_trials,
+ int64_t lowRttNackThresholdMs,
int64_t highRttNackThresholdMs);
~VCMNackFecMethod() override;
bool UpdateParameters(const VCMProtectionParameters* parameters) override;
@@ -213,7 +216,7 @@
class VCMLossProtectionLogic {
public:
- explicit VCMLossProtectionLogic(int64_t nowMs);
+ explicit VCMLossProtectionLogic(const Environment& env);
~VCMLossProtectionLogic();
// Set the protection method to be used
@@ -322,6 +325,8 @@
// Sets the available loss protection methods.
void UpdateMaxLossHistory(uint8_t lossPr255, int64_t now);
uint8_t MaxFilteredLossPr(int64_t nowMs) const;
+
+ const Environment env_;
std::unique_ptr<VCMProtectionMethod> _selectedMethod;
VCMProtectionParameters _currentParameters;
int64_t _rtt;