From 236608f48e9c3cbbe1cb9fae8afd8e799e464b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 14 May 2025 08:40:39 +0300 Subject: [PATCH] webrtc: Stop using deprecated API and require GStreamer 1.22 or newer Part-of: --- net/webrtc/Cargo.toml | 19 +++++++++---------- net/webrtc/src/webrtcsink/imp.rs | 25 ++++++++++++------------- net/webrtc/src/webrtcsrc/imp.rs | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/net/webrtc/Cargo.toml b/net/webrtc/Cargo.toml index 466eaac21..370d23a14 100644 --- a/net/webrtc/Cargo.toml +++ b/net/webrtc/Cargo.toml @@ -9,14 +9,14 @@ repository.workspace = true rust-version.workspace = true [dependencies] -gst = { workspace = true, features = ["v1_20", "serde"] } -gst-app = { workspace = true, features = ["v1_20"] } -gst-audio = { workspace = true, features = ["v1_20", "serde"] } -gst-video = { workspace = true, features = ["v1_20", "serde"] } -gst-net = { workspace = true, features = ["v1_20"] } -gst-webrtc = { workspace = true, features = ["v1_20"] } -gst-sdp = { workspace = true, features = ["v1_20"] } -gst-rtp = { workspace = true, features = ["v1_20"] } +gst = { workspace = true, features = ["v1_22", "serde"] } +gst-app = { workspace = true, features = ["v1_22"] } +gst-audio = { workspace = true, features = ["v1_22", "serde"] } +gst-video = { workspace = true, features = ["v1_22", "serde"] } +gst-net = { workspace = true, features = ["v1_22"] } +gst-webrtc = { workspace = true, features = ["v1_22"] } +gst-sdp = { workspace = true, features = ["v1_22"] } +gst-rtp = { workspace = true, features = ["v1_22"] } gst-utils.workspace = true gst-base.workspace = true uuid = { version = "1", features = ["v4"] } @@ -82,10 +82,9 @@ path = "src/lib.rs" gst-plugin-version-helper.workspace = true [features] -default = ["v1_22", "janus", "whip", "web_server"] +default = ["janus", "whip", "web_server"] static = [] capi = [] -v1_22 = ["gst/v1_22", "gst-app/v1_22", "gst-video/v1_22", "gst-webrtc/v1_22", "gst-sdp/v1_22", "gst-rtp/v1_22"] doc = [] aws = ["dep:aws-config", "dep:aws-smithy-runtime", "dep:aws-smithy-runtime-api", "dep:aws-types", "dep:aws-credential-types", diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index 4a63ead2c..7242c0ecd 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -63,11 +63,8 @@ const DEFAULT_MIN_BITRATE: u32 = 1000; * my local network, possibly related to chrome's pretty low UDP * buffer sizes */ const DEFAULT_MAX_BITRATE: u32 = 8192000; -const DEFAULT_CONGESTION_CONTROL: WebRTCSinkCongestionControl = if cfg!(feature = "v1_22") { - WebRTCSinkCongestionControl::GoogleCongestionControl -} else { - WebRTCSinkCongestionControl::Disabled -}; +const DEFAULT_CONGESTION_CONTROL: WebRTCSinkCongestionControl = + WebRTCSinkCongestionControl::GoogleCongestionControl; const DEFAULT_DO_FEC: bool = true; const DEFAULT_DO_RETRANSMISSION: bool = true; const DEFAULT_DO_CLOCK_SIGNALLING: bool = false; @@ -90,7 +87,6 @@ const DEFAULT_WEB_SERVER_HOST_ADDR: &str = "http://127.0.0.1:8080"; const DEFAULT_FORWARD_METAS: &str = ""; /* Start adding some FEC when the bitrate > 2Mbps as we found experimentally * that it is not worth it below that threshold */ -#[cfg(feature = "v1_22")] const DO_FEC_THRESHOLD: u32 = 2000000; #[derive(Debug, Clone, Copy)] @@ -302,7 +298,6 @@ struct SessionInner { pipeline: gst::Pipeline, webrtcbin: gst::Element, - #[cfg(feature = "v1_22")] rtprtxsend: Option, webrtc_pads: HashMap, peer_id: String, @@ -1292,7 +1287,6 @@ impl SessionInner { webrtcbin, peer_id, cc_info, - #[cfg(feature = "v1_22")] rtprtxsend: None, congestion_controller, rtpgccbwe, @@ -1596,7 +1590,13 @@ impl ControlRequestHandler { } Ok(msg) => match serde_json::to_string(&msg).ok() { Some(s) => { - channel.send_string(Some(s.as_str())); + if let Err(err) = channel.send_string_full(Some(s.as_str())) { + gst::error!( + CAT, + obj = element, + "Failed sending control request to peer: {err}", + ); + } } None => { gst::error!( @@ -2740,7 +2740,9 @@ impl BaseWebRTCSink { info: utils::Info::Meta(meta), }) { Ok(msg) => { - handler.0 .1.send_string(Some(msg.as_str())); + if let Err(err) = handler.0 .1.send_string_full(Some(msg.as_str())) { + gst::error!(CAT, imp = self, "Failed sending meta to peer: {err}",); + } } Err(err) => { gst::warning!(CAT, imp = self, "Failed to serialize info message: {err:?}",); @@ -2801,7 +2803,6 @@ impl BaseWebRTCSink { } let rtpgccbwe = match settings.cc_info.heuristic { - #[cfg(feature = "v1_22")] WebRTCSinkCongestionControl::GoogleCongestionControl => { let rtpgccbwe = match gst::ElementFactory::make("rtpgccbwe").build() { Err(err) => { @@ -3459,7 +3460,6 @@ impl BaseWebRTCSink { webrtcbin.emit_by_name::<()>("get-stats", &[&None::, &promise]); } - #[cfg(feature = "v1_22")] fn set_rtptrxsend(&self, session_id: &str, rtprtxsend: gst::Element) { let mut state = self.state.lock().unwrap(); @@ -3468,7 +3468,6 @@ impl BaseWebRTCSink { } } - #[cfg(feature = "v1_22")] fn set_bitrate(&self, session_id: &str, bitrate: u32) { let settings = self.settings.lock().unwrap(); let mut state = self.state.lock().unwrap(); diff --git a/net/webrtc/src/webrtcsrc/imp.rs b/net/webrtc/src/webrtcsrc/imp.rs index a70ac1396..a4502a448 100644 --- a/net/webrtc/src/webrtcsrc/imp.rs +++ b/net/webrtc/src/webrtcsrc/imp.rs @@ -426,7 +426,14 @@ impl Session { "Sending navigation event to peer for session {}", self.id ); - data_channel.send_string(Some(str.as_str())); + if let Err(err) = data_channel.send_string_full(Some(str.as_str())) { + gst::error!( + CAT, + obj = element, + "Failed sending navigation event to peer for session {}: {err}", + self.id, + ); + } } None => { gst::error!( @@ -460,7 +467,14 @@ impl Session { "Sending control request to peer for session {}", self.id ); - data_channel.send_string(Some(str.as_str())); + if let Err(err) = data_channel.send_string_full(Some(str.as_str())) { + gst::error!( + CAT, + obj = element, + "Failed sending control request to peer for session {}: {err}", + self.id, + ); + } } None => { gst::error!(