Field trials allow WebRTC users to turn on feature code in binaries out in the field.
If you don’t use field trials, you can stop reading now.
Historically field trials were set per process and queried using static functions. Such api is now deprecated. Instead custom field trials can be provided as an injected component to PeerConnectionFactory and other WebRTC classes.
Please migrate away from using
system_wrappers/include/field_trial.h
api/transport/field_trial_based_config.h
static field trials functions in objc and android sdks
See https://webrtc-review.googlesource.com/c/src/+/398701 for details on what apis are deprecated.
To inject field trials, create a FieldTrials class from ‘api/field_trials.h’.
It can use the same format of the field trial string that `InitFieldTrialsFromString` uses.
Alternatively you may provide a custom implementation of the FieldTrialsView interface from the `api/field_trials_view.h`.
PeerConnectionFactory, or any other WebRTC class that relies on the field trials, takes either Environment or FieldTrialsView as an argument to query field trials.
for example, instead of
InitFieldTrialsFromString(field_trials.c_str());
PeerConnectionFactoryDependencies pcf_deps;
pcf_ = CreateModularPeerConnectionFactory(std::move(pcf_deps));
use
PeerConnectionFactoryDependencies pcf_deps;
pcf_deps.env = CreateEnvironment(std::make_unique<FieldTrials>(field_trials));
pcf_ = CreateModularPeerConnectionFactory(std::move(pcf_deps));