Field trials for DSCP
Add a field trial "WebRTC-DscpFieldTrial"
that allows user to set any int value to be
used as tagging. This tag value will be used
for all packets on the PeerConnection,
whether they are audio, video, data or ICE
e.g WebRTC-DscpFieldTrial/override_dscp:40/
see https://webrtc.googlesource.com/src/+/b477fc73cfd2f4c09bb9c416b170ba4b566cecaf/rtc_base/dscp.h
for names of popular ints.
Bug: webrtc:13622
Change-Id: Iedbedd0f918100259678eb5bc083c9bf89b343b1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249786
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35848}
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index 47f858e..18d921c 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -775,6 +775,16 @@
ice_controller_->SetIceConfig(config_);
+ // DSCP override, allow user to specify (any) int value
+ // that will be used for tagging all packets.
+ webrtc::StructParametersParser::Create("override_dscp",
+ &field_trials_.override_dscp)
+ ->Parse(webrtc::field_trial::FindFullName("WebRTC-DscpFieldTrial"));
+
+ if (field_trials_.override_dscp) {
+ SetOption(rtc::Socket::OPT_DSCP, *field_trials_.override_dscp);
+ }
+
RTC_DCHECK(ValidateIceConfig(config_).ok());
}
@@ -1529,6 +1539,10 @@
// port objects.
int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
RTC_DCHECK_RUN_ON(network_thread_);
+ if (field_trials_.override_dscp && opt == rtc::Socket::OPT_DSCP) {
+ value = *field_trials_.override_dscp;
+ }
+
OptionMap::iterator it = options_.find(opt);
if (it == options_.end()) {
options_.insert(std::make_pair(opt, value));
diff --git a/p2p/base/p2p_transport_channel_ice_field_trials.h b/p2p/base/p2p_transport_channel_ice_field_trials.h
index 4987f1c..f05623d 100644
--- a/p2p/base/p2p_transport_channel_ice_field_trials.h
+++ b/p2p/base/p2p_transport_channel_ice_field_trials.h
@@ -61,6 +61,9 @@
// Stop gathering when having a strong connection.
bool stop_gather_on_strongly_connected = true;
+
+ // DSCP taging.
+ absl::optional<int> override_dscp;
};
} // namespace cricket