webrtcsink: Add ice-transport-policy option

Can be used to force relay ICE candidates, ensuring TURN server is used.
Proxy to the corresponding setting in webrtcbin,

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1160>
This commit is contained in:
Vivia Nikolaidou 2023-03-23 12:27:43 +02:00 committed by GStreamer Marge Bot
parent 73dc6a8ef9
commit f15fd82f83
2 changed files with 32 additions and 1 deletions

View file

@ -5994,6 +5994,18 @@
"type": "gboolean",
"writable": true
},
"ice-transport-policy": {
"blurb": "The policy to apply for ICE transport",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "all (0)",
"mutable": "ready",
"readable": true,
"type": "GstWebRTCICETransportPolicy",
"writable": true
},
"max-bitrate": {
"blurb": "Minimal bitrate to use (in bit/sec) when computing it through the congestion control algorithm",
"conditionally-available": false,

View file

@ -7,7 +7,7 @@ use gst::subclass::prelude::*;
use gst_rtp::prelude::*;
use gst_utils::StreamProducer;
use gst_video::subclass::prelude::*;
use gst_webrtc::WebRTCDataChannel;
use gst_webrtc::{WebRTCDataChannel, WebRTCICETransportPolicy};
use futures::prelude::*;
@ -50,6 +50,7 @@ const DEFAULT_CONGESTION_CONTROL: WebRTCSinkCongestionControl =
const DEFAULT_DO_FEC: bool = true;
const DEFAULT_DO_RETRANSMISSION: bool = true;
const DEFAULT_ENABLE_DATA_CHANNEL_NAVIGATION: bool = false;
const DEFAULT_ICE_TRANSPORT_POLICY: WebRTCICETransportPolicy = WebRTCICETransportPolicy::All;
const DEFAULT_START_BITRATE: u32 = 2048000;
/* Start adding some FEC when the bitrate > 2Mbps as we found experimentally
* that it is not worth it below that threshold */
@ -74,6 +75,7 @@ struct Settings {
do_retransmission: bool,
enable_data_channel_navigation: bool,
meta: Option<gst::Structure>,
ice_transport_policy: WebRTCICETransportPolicy,
}
/// Represents a codec we can offer
@ -282,6 +284,7 @@ impl Default for Settings {
do_retransmission: DEFAULT_DO_RETRANSMISSION,
enable_data_channel_navigation: DEFAULT_ENABLE_DATA_CHANNEL_NAVIGATION,
meta: None,
ice_transport_policy: DEFAULT_ICE_TRANSPORT_POLICY,
}
}
}
@ -1417,6 +1420,7 @@ impl WebRTCSink {
})?;
webrtcbin.set_property_from_str("bundle-policy", "max-bundle");
webrtcbin.set_property("ice-transport-policy", settings.ice_transport_policy);
if let Some(stun_server) = settings.stun_server.as_ref() {
webrtcbin.set_property("stun-server", stun_server);
@ -2434,6 +2438,11 @@ impl ObjectImpl for WebRTCSink {
.nick("Meta")
.blurb("Free form metadata about the producer")
.build(),
glib::ParamSpecEnum::builder_with_default("ice-transport-policy", DEFAULT_ICE_TRANSPORT_POLICY)
.nick("ICE Transport Policy")
.blurb("The policy to apply for ICE transport")
.mutable_ready()
.build(),
]
});
@ -2503,6 +2512,12 @@ impl ObjectImpl for WebRTCSink {
.get::<Option<gst::Structure>>()
.expect("type checked upstream")
}
"ice-transport-policy" => {
let mut settings = self.settings.lock().unwrap();
settings.ice_transport_policy = value
.get::<WebRTCICETransportPolicy>()
.expect("type checked upstream");
}
_ => unimplemented!(),
}
}
@ -2558,6 +2573,10 @@ impl ObjectImpl for WebRTCSink {
let settings = self.settings.lock().unwrap();
settings.meta.to_value()
}
"ice-transport-policy" => {
let settings = self.settings.lock().unwrap();
settings.ice_transport_policy.to_value()
}
_ => unimplemented!(),
}
}