Field Trials
Core API
This page uses the core API in dev.onvoid.webrtc, which leaves negotiation, threads and cleanup to you. For the client API, see The Runtime.
WebRTC uses field trials to gate experimental features and tune internal behavior (e.g. congestion control, codec selection, message interleaving) without changing the public API. This guide explains how to enable them when creating a PeerConnectionFactory.
Field trials are applied once, at PeerConnectionFactory creation, and take effect for everything created by that factory (peer connections, tracks, sources). Different PeerConnectionFactory instances in the same process may use different field trials.
Basic Usage
Pass a Map<String, String> of trial names to their assigned group to one of the PeerConnectionFactory constructors that accept fieldTrials:
Map<String, String> fieldTrials = Map.of(
"WebRTC-Bar", "Enabled"
);
PeerConnectionFactory factory = new PeerConnectionFactory(fieldTrials);Field trials can be combined with a custom audio device module and/or audio processing module:
PeerConnectionFactory factory = new PeerConnectionFactory(fieldTrials, audioModule);
PeerConnectionFactory factory = new PeerConnectionFactory(fieldTrials, audioProcessing);
PeerConnectionFactory factory = new PeerConnectionFactory(fieldTrials, audioModule, audioProcessing);PeerConnectionFactory.builder() sets them too, next to anything else a factory is created with, such as its video codecs:
PeerConnectionFactory factory = PeerConnectionFactory.builder()
.setFieldTrials(fieldTrials)
.setAudioDeviceModule(audioModule)
.build();Constraints
Each key and value must be non-null and non-empty. Passing a map that violates this constraint throws an exception when the PeerConnectionFactory is created.
Tips and Troubleshooting
- Field trial names and accepted groups (e.g.
Enabled,Disabled) are defined by the underlying WebRTC native code, and change between WebRTC releases. To find the trials available now, consult the WebRTC source of the branch this library is built against. - Since field trials configure experimental or internal behavior, prefer enabling only the trials you specifically need, and re-verify them after upgrading to a new release of this library.
Related API
PeerConnectionFactory— the constructors acceptingfieldTrialsapply them for the lifetime of that factory.
For the full API, see the JavaDoc for PeerConnectionFactory.
