webrtc: add features for specific signallers

When swapping between several development branches, compilation times can be
frustrating. This commit proposes adding features to control which signaller
to include when building the webrtc plugin. By default, all signallers are
included, just like before.

Compiling the `webrtc-precise-sync` examples with `--no-default-features`
reduces compilation to 267 crates instead of 429 when all signallers are
compiled in.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1539>
This commit is contained in:
François Laignel 2024-04-12 19:10:42 +02:00
parent 83d70d3471
commit 168af88eda
7 changed files with 352 additions and 282 deletions

View file

@ -22,6 +22,7 @@ gst-base.workspace = true
uuid = { version = "1", features = ["v4"] } uuid = { version = "1", features = ["v4"] }
anyhow = "1" anyhow = "1"
chrono = "0.4"
thiserror = "1" thiserror = "1"
futures = "0.3" futures = "0.3"
tokio = { version = "1", features = ["fs", "macros", "rt-multi-thread", "time"] } tokio = { version = "1", features = ["fs", "macros", "rt-multi-thread", "time"] }
@ -33,33 +34,31 @@ serde_json = "1"
fastrand = "2.0" fastrand = "2.0"
gst_plugin_webrtc_protocol = { path="protocol", package = "gst-plugin-webrtc-signalling-protocol" } gst_plugin_webrtc_protocol = { path="protocol", package = "gst-plugin-webrtc-signalling-protocol" }
human_bytes = "0.4" human_bytes = "0.4"
once_cell.workspace = true
rand = "0.8"
url = "2" url = "2"
aws-config = "1.0" aws-config = { version = "1.0", optional = true }
aws-types = "1.0" aws-types = { version = "1.0", optional = true }
aws-credential-types = "1.0" aws-credential-types = { version = "1.0", optional = true }
aws-sigv4 = "1.0" aws-sigv4 = { version = "1.0", optional = true }
aws-smithy-http = { version = "0.60", features = [ "rt-tokio" ] } aws-smithy-http = { version = "0.60", features = [ "rt-tokio" ], optional = true }
aws-smithy-types = "1.0" aws-smithy-types = { version = "1.0", optional = true }
aws-sdk-kinesisvideo = "1.0" aws-sdk-kinesisvideo = { version = "1.0", optional = true }
aws-sdk-kinesisvideosignaling = "1.0" aws-sdk-kinesisvideosignaling = { version = "1.0", optional = true }
http = "1.0" http = { version = "1.0", optional = true }
chrono = "0.4" data-encoding = {version = "2.3.3", optional = true }
data-encoding = "2.3.3" url-escape = { version = "0.1.1", optional = true }
url-escape = "0.1.1"
regex = "1"
reqwest = { version = "0.11", features = ["default-tls"] } reqwest = { version = "0.11", features = ["default-tls"], optional = true }
parse_link_header = {version = "0.3", features = ["url"]} parse_link_header = {version = "0.3", features = ["url"]}
async-recursion = "1.0.0" async-recursion = { version = "1.0.0", optional = true }
livekit-protocol = { version = "0.3" } livekit-protocol = { version = "0.3", optional = true }
livekit-api = { version = "0.3", default-features = false, features = ["signal-client", "access-token", "native-tls"] } livekit-api = { version = "0.3", default-features = false, features = ["signal-client", "access-token", "native-tls"], optional = true }
warp = "0.3" warp = {version = "0.3", optional = true }
crossbeam-channel = "0.5" crossbeam-channel = { version = "0.5", optional = true }
rand = "0.8"
once_cell.workspace = true
[dev-dependencies] [dev-dependencies]
gst-plugin-rtp = { path = "../rtp" } gst-plugin-rtp = { path = "../rtp" }
@ -67,6 +66,7 @@ tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] } tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-log = "0.2" tracing-log = "0.2"
clap = { version = "4", features = ["derive"] } clap = { version = "4", features = ["derive"] }
regex = "1"
[lib] [lib]
name = "gstrswebrtc" name = "gstrswebrtc"
@ -77,12 +77,19 @@ path = "src/lib.rs"
gst-plugin-version-helper.workspace = true gst-plugin-version-helper.workspace = true
[features] [features]
default = ["v1_22"] default = ["v1_22", "aws", "janus", "livekit", "whip"]
static = [] static = []
capi = [] 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"] 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 = [] doc = []
aws = ["dep:aws-config", "dep:aws-types", "dep:aws-credential-types", "dep:aws-sigv4",
"dep:aws-smithy-http", "dep:aws-smithy-types", "dep:aws-sdk-kinesisvideo",
"dep:aws-sdk-kinesisvideosignaling", "dep:data-encoding", "dep:http", "dep:url-escape"]
janus = ["dep:http"]
livekit = ["dep:livekit-protocol", "dep:livekit-api"]
whip = ["dep:async-recursion", "dep:crossbeam-channel", "dep:reqwest", "dep:warp"]
[package.metadata.capi] [package.metadata.capi]
min_version = "0.9.21" min_version = "0.9.21"

View file

@ -14,13 +14,17 @@ use gst::glib;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use tokio::runtime; use tokio::runtime;
#[cfg(feature = "aws")]
mod aws_kvs_signaller; mod aws_kvs_signaller;
#[cfg(feature = "janus")]
mod janusvr_signaller; mod janusvr_signaller;
#[cfg(feature = "livekit")]
mod livekit_signaller; mod livekit_signaller;
pub mod signaller; pub mod signaller;
pub mod utils; pub mod utils;
pub mod webrtcsink; pub mod webrtcsink;
pub mod webrtcsrc; pub mod webrtcsrc;
#[cfg(feature = "whip")]
mod whip_signaller; mod whip_signaller;
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {

View file

@ -104,7 +104,9 @@ use crate::RUNTIME;
use futures::future; use futures::future;
use futures::prelude::*; use futures::prelude::*;
use gst::ErrorMessage; use gst::ErrorMessage;
#[cfg(feature = "whip")]
use reqwest::header::HeaderMap; use reqwest::header::HeaderMap;
#[cfg(feature = "whip")]
use reqwest::redirect::Policy; use reqwest::redirect::Policy;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
@ -237,6 +239,7 @@ where
res res
} }
#[cfg(feature = "whip")]
pub fn parse_redirect_location( pub fn parse_redirect_location(
headermap: &HeaderMap, headermap: &HeaderMap,
old_url: &reqwest::Url, old_url: &reqwest::Url,
@ -277,11 +280,13 @@ pub fn parse_redirect_location(
} }
} }
#[cfg(feature = "whip")]
pub fn build_reqwest_client(pol: Policy) -> reqwest::Client { pub fn build_reqwest_client(pol: Policy) -> reqwest::Client {
let client_builder = reqwest::Client::builder(); let client_builder = reqwest::Client::builder();
client_builder.redirect(pol).build().unwrap() client_builder.redirect(pol).build().unwrap()
} }
#[cfg(feature = "whip")]
pub fn set_ice_servers( pub fn set_ice_servers(
webrtcbin: &gst::Element, webrtcbin: &gst::Element,
headermap: &HeaderMap, headermap: &HeaderMap,

View file

@ -23,11 +23,7 @@ use super::homegrown_cc::CongestionController;
use super::{ use super::{
WebRTCSinkCongestionControl, WebRTCSinkError, WebRTCSinkMitigationMode, WebRTCSinkPad, WebRTCSinkCongestionControl, WebRTCSinkError, WebRTCSinkMitigationMode, WebRTCSinkPad,
}; };
use crate::aws_kvs_signaller::AwsKvsSignaller;
use crate::janusvr_signaller::{JanusVRSignallerStr, JanusVRSignallerU64};
use crate::livekit_signaller::LiveKitSignaller;
use crate::signaller::{prelude::*, Signallable, Signaller, WebRTCSignallerRole}; use crate::signaller::{prelude::*, Signallable, Signaller, WebRTCSignallerRole};
use crate::whip_signaller::WhipClientSignaller;
use crate::{utils, RUNTIME}; use crate::{utils, RUNTIME};
use std::collections::{BTreeMap, HashSet}; use std::collections::{BTreeMap, HashSet};
@ -4521,187 +4517,219 @@ impl ObjectSubclass for WebRTCSink {
type ParentType = super::BaseWebRTCSink; type ParentType = super::BaseWebRTCSink;
} }
#[derive(Default)] #[cfg(feature = "aws")]
pub struct AwsKvsWebRTCSink {} pub(super) mod aws {
use super::*;
use crate::aws_kvs_signaller::AwsKvsSignaller;
impl ObjectImpl for AwsKvsWebRTCSink { #[derive(Default)]
fn constructed(&self) { pub struct AwsKvsWebRTCSink {}
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSink>().imp();
let _ = ws.set_signaller(AwsKvsSignaller::default().upcast()); impl ObjectImpl for AwsKvsWebRTCSink {
} fn constructed(&self) {
} let element = self.obj();
let ws = element
.upcast_ref::<crate::webrtcsink::BaseWebRTCSink>()
.imp();
impl GstObjectImpl for AwsKvsWebRTCSink {} let _ = ws.set_signaller(AwsKvsSignaller::default().upcast());
impl ElementImpl for AwsKvsWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"AwsKvsWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with kinesis video streams signaller",
"Mathieu Duponchelle <mathieu@centricular.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for AwsKvsWebRTCSink {}
impl BaseWebRTCSinkImpl for AwsKvsWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for AwsKvsWebRTCSink {
const NAME: &'static str = "GstAwsKvsWebRTCSink";
type Type = super::AwsKvsWebRTCSink;
type ParentType = super::BaseWebRTCSink;
}
#[derive(Default)]
pub struct WhipWebRTCSink {}
impl ObjectImpl for WhipWebRTCSink {
fn constructed(&self) {
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSink>().imp();
let _ = ws.set_signaller(WhipClientSignaller::default().upcast());
}
}
impl GstObjectImpl for WhipWebRTCSink {}
impl ElementImpl for WhipWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"WhipWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with WHIP client signaller",
"Taruntej Kanakamalla <taruntej@asymptotic.io>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for WhipWebRTCSink {}
impl BaseWebRTCSinkImpl for WhipWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for WhipWebRTCSink {
const NAME: &'static str = "GstWhipWebRTCSink";
type Type = super::WhipWebRTCSink;
type ParentType = super::BaseWebRTCSink;
}
#[derive(Default)]
pub struct LiveKitWebRTCSink {}
impl ObjectImpl for LiveKitWebRTCSink {
fn constructed(&self) {
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSink>().imp();
let _ = ws.set_signaller(LiveKitSignaller::new_producer().upcast());
}
}
impl GstObjectImpl for LiveKitWebRTCSink {}
impl ElementImpl for LiveKitWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"LiveKitWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with LiveKit signaller",
"Olivier Crête <olivier.crete@collabora.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for LiveKitWebRTCSink {}
impl BaseWebRTCSinkImpl for LiveKitWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for LiveKitWebRTCSink {
const NAME: &'static str = "GstLiveKitWebRTCSink";
type Type = super::LiveKitWebRTCSink;
type ParentType = super::BaseWebRTCSink;
}
#[derive(Debug, Clone, Default)]
struct JanusSettings {
use_string_ids: bool,
}
#[derive(Default, glib::Properties)]
#[properties(wrapper_type = super::JanusVRWebRTCSink)]
pub struct JanusVRWebRTCSink {
/**
* GstJanusVRWebRTCSink:use-string-ids:
*
* By default Janus uses `u64` ids to identitify the room, the feed, etc.
* But it can be changed to strings using the `strings_ids` option in `janus.plugin.videoroom.jcfg`.
* In such case, `janusvrwebrtcsink` has to be created using `use-string-ids=true` so its signaller
* uses the right types for such ids and properties.
*
* Since: plugins-rs-0.13.0
*/
#[property(name="use-string-ids", get, construct_only, type = bool, member = use_string_ids, blurb = "Use strings instead of u64 for Janus IDs, see strings_ids config option in janus.plugin.videoroom.jcfg")]
settings: Mutex<JanusSettings>,
}
#[glib::derived_properties]
impl ObjectImpl for JanusVRWebRTCSink {
fn constructed(&self) {
let settings = self.settings.lock().unwrap();
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSink>().imp();
if settings.use_string_ids {
let _ = ws.set_signaller(JanusVRSignallerStr::default().upcast());
} else {
let _ = ws.set_signaller(JanusVRSignallerU64::default().upcast());
} }
} }
}
impl GstObjectImpl for JanusVRWebRTCSink {} impl GstObjectImpl for AwsKvsWebRTCSink {}
impl ElementImpl for JanusVRWebRTCSink { impl ElementImpl for AwsKvsWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new( gst::subclass::ElementMetadata::new(
"JanusVRWebRTCSink", "AwsKvsWebRTCSink",
"Sink/Network/WebRTC", "Sink/Network/WebRTC",
"WebRTC sink with Janus Video Room signaller", "WebRTC sink with kinesis video streams signaller",
"Eva Pace <epace@igalia.com>", "Mathieu Duponchelle <mathieu@centricular.com>",
) )
}); });
Some(&*ELEMENT_METADATA) Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for AwsKvsWebRTCSink {}
impl BaseWebRTCSinkImpl for AwsKvsWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for AwsKvsWebRTCSink {
const NAME: &'static str = "GstAwsKvsWebRTCSink";
type Type = crate::webrtcsink::AwsKvsWebRTCSink;
type ParentType = crate::webrtcsink::BaseWebRTCSink;
} }
} }
impl BinImpl for JanusVRWebRTCSink {} #[cfg(feature = "whip")]
pub(super) mod whip {
use super::*;
use crate::whip_signaller::WhipClientSignaller;
impl BaseWebRTCSinkImpl for JanusVRWebRTCSink {} #[derive(Default)]
pub struct WhipWebRTCSink {}
#[glib::object_subclass] impl ObjectImpl for WhipWebRTCSink {
impl ObjectSubclass for JanusVRWebRTCSink { fn constructed(&self) {
const NAME: &'static str = "GstJanusVRWebRTCSink"; let element = self.obj();
type Type = super::JanusVRWebRTCSink; let ws = element
type ParentType = super::BaseWebRTCSink; .upcast_ref::<crate::webrtcsink::BaseWebRTCSink>()
.imp();
let _ = ws.set_signaller(WhipClientSignaller::default().upcast());
}
}
impl GstObjectImpl for WhipWebRTCSink {}
impl ElementImpl for WhipWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"WhipWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with WHIP client signaller",
"Taruntej Kanakamalla <taruntej@asymptotic.io>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for WhipWebRTCSink {}
impl BaseWebRTCSinkImpl for WhipWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for WhipWebRTCSink {
const NAME: &'static str = "GstWhipWebRTCSink";
type Type = crate::webrtcsink::WhipWebRTCSink;
type ParentType = crate::webrtcsink::BaseWebRTCSink;
}
}
#[cfg(feature = "livekit")]
pub(super) mod livekit {
use super::*;
use crate::livekit_signaller::LiveKitSignaller;
#[derive(Default)]
pub struct LiveKitWebRTCSink {}
impl ObjectImpl for LiveKitWebRTCSink {
fn constructed(&self) {
let element = self.obj();
let ws = element
.upcast_ref::<crate::webrtcsink::BaseWebRTCSink>()
.imp();
let _ = ws.set_signaller(LiveKitSignaller::new_producer().upcast());
}
}
impl GstObjectImpl for LiveKitWebRTCSink {}
impl ElementImpl for LiveKitWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"LiveKitWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with LiveKit signaller",
"Olivier Crête <olivier.crete@collabora.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for LiveKitWebRTCSink {}
impl BaseWebRTCSinkImpl for LiveKitWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for LiveKitWebRTCSink {
const NAME: &'static str = "GstLiveKitWebRTCSink";
type Type = crate::webrtcsink::LiveKitWebRTCSink;
type ParentType = crate::webrtcsink::BaseWebRTCSink;
}
}
#[cfg(feature = "janus")]
pub(super) mod janus {
use super::*;
use crate::janusvr_signaller::{JanusVRSignallerStr, JanusVRSignallerU64};
#[derive(Debug, Clone, Default)]
struct JanusSettings {
use_string_ids: bool,
}
#[derive(Default, glib::Properties)]
#[properties(wrapper_type = crate::webrtcsink::JanusVRWebRTCSink)]
pub struct JanusVRWebRTCSink {
/**
* GstJanusVRWebRTCSink:use-string-ids:
*
* By default Janus uses `u64` ids to identitify the room, the feed, etc.
* But it can be changed to strings using the `strings_ids` option in `janus.plugin.videoroom.jcfg`.
* In such case, `janusvrwebrtcsink` has to be created using `use-string-ids=true` so its signaller
* uses the right types for such ids and properties.
*
* Since: plugins-rs-0.13.0
*/
#[property(name="use-string-ids", get, construct_only, type = bool, member = use_string_ids, blurb = "Use strings instead of u64 for Janus IDs, see strings_ids config option in janus.plugin.videoroom.jcfg")]
settings: Mutex<JanusSettings>,
}
#[glib::derived_properties]
impl ObjectImpl for JanusVRWebRTCSink {
fn constructed(&self) {
let settings = self.settings.lock().unwrap();
let element = self.obj();
let ws = element
.upcast_ref::<crate::webrtcsink::BaseWebRTCSink>()
.imp();
if settings.use_string_ids {
let _ = ws.set_signaller(JanusVRSignallerStr::default().upcast());
} else {
let _ = ws.set_signaller(JanusVRSignallerU64::default().upcast());
}
}
}
impl GstObjectImpl for JanusVRWebRTCSink {}
impl ElementImpl for JanusVRWebRTCSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"JanusVRWebRTCSink",
"Sink/Network/WebRTC",
"WebRTC sink with Janus Video Room signaller",
"Eva Pace <epace@igalia.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BinImpl for JanusVRWebRTCSink {}
impl BaseWebRTCSinkImpl for JanusVRWebRTCSink {}
#[glib::object_subclass]
impl ObjectSubclass for JanusVRWebRTCSink {
const NAME: &'static str = "GstJanusVRWebRTCSink";
type Type = crate::webrtcsink::JanusVRWebRTCSink;
type ParentType = crate::webrtcsink::BaseWebRTCSink;
}
} }

View file

@ -53,20 +53,24 @@ glib::wrapper! {
pub struct WebRTCSink(ObjectSubclass<imp::WebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation; pub struct WebRTCSink(ObjectSubclass<imp::WebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation;
} }
#[cfg(feature = "aws")]
glib::wrapper! { glib::wrapper! {
pub struct AwsKvsWebRTCSink(ObjectSubclass<imp::AwsKvsWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation; pub struct AwsKvsWebRTCSink(ObjectSubclass<imp::aws::AwsKvsWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation;
} }
#[cfg(feature = "whip")]
glib::wrapper! { glib::wrapper! {
pub struct WhipWebRTCSink(ObjectSubclass<imp::WhipWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation; pub struct WhipWebRTCSink(ObjectSubclass<imp::whip::WhipWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation;
} }
#[cfg(feature = "livekit")]
glib::wrapper! { glib::wrapper! {
pub struct LiveKitWebRTCSink(ObjectSubclass<imp::LiveKitWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation; pub struct LiveKitWebRTCSink(ObjectSubclass<imp::livekit::LiveKitWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation;
} }
#[cfg(feature = "janus")]
glib::wrapper! { glib::wrapper! {
pub struct JanusVRWebRTCSink(ObjectSubclass<imp::JanusVRWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation; pub struct JanusVRWebRTCSink(ObjectSubclass<imp::janus::JanusVRWebRTCSink>) @extends BaseWebRTCSink, gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, gst_video::Navigation;
} }
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
@ -140,24 +144,28 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Rank::NONE, gst::Rank::NONE,
WebRTCSink::static_type(), WebRTCSink::static_type(),
)?; )?;
#[cfg(feature = "aws")]
gst::Element::register( gst::Element::register(
Some(plugin), Some(plugin),
"awskvswebrtcsink", "awskvswebrtcsink",
gst::Rank::NONE, gst::Rank::NONE,
AwsKvsWebRTCSink::static_type(), AwsKvsWebRTCSink::static_type(),
)?; )?;
#[cfg(feature = "whip")]
gst::Element::register( gst::Element::register(
Some(plugin), Some(plugin),
"whipclientsink", "whipclientsink",
gst::Rank::NONE, gst::Rank::NONE,
WhipWebRTCSink::static_type(), WhipWebRTCSink::static_type(),
)?; )?;
#[cfg(feature = "livekit")]
gst::Element::register( gst::Element::register(
Some(plugin), Some(plugin),
"livekitwebrtcsink", "livekitwebrtcsink",
gst::Rank::NONE, gst::Rank::NONE,
LiveKitWebRTCSink::static_type(), LiveKitWebRTCSink::static_type(),
)?; )?;
#[cfg(feature = "janus")]
/** /**
* element-janusvrwebrtcsink: * element-janusvrwebrtcsink:
* *

View file

@ -2,11 +2,9 @@
use gst::prelude::*; use gst::prelude::*;
use crate::livekit_signaller::LiveKitSignaller;
use crate::signaller::{prelude::*, Signallable, Signaller}; use crate::signaller::{prelude::*, Signallable, Signaller};
use crate::utils::{Codec, Codecs, NavigationEvent, AUDIO_CAPS, RTP_CAPS, VIDEO_CAPS}; use crate::utils::{Codec, Codecs, NavigationEvent, AUDIO_CAPS, RTP_CAPS, VIDEO_CAPS};
use crate::webrtcsrc::WebRTCSrcPad; use crate::webrtcsrc::WebRTCSrcPad;
use crate::whip_signaller::WhipServerSignaller;
use anyhow::{Context, Error}; use anyhow::{Context, Error};
use gst::glib; use gst::glib;
use gst::subclass::prelude::*; use gst::subclass::prelude::*;
@ -1255,92 +1253,108 @@ impl ObjectSubclass for WebRTCSrc {
type Interfaces = (gst::URIHandler,); type Interfaces = (gst::URIHandler,);
} }
#[derive(Default)] #[cfg(feature = "whip")]
pub struct WhipServerSrc {} pub(super) mod whip {
use super::*;
use crate::whip_signaller::WhipServerSignaller;
impl ObjectImpl for WhipServerSrc { #[derive(Default)]
fn constructed(&self) { pub struct WhipServerSrc {}
self.parent_constructed();
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSrc>().imp();
let _ = ws.set_signaller(WhipServerSignaller::default().upcast()); impl ObjectImpl for WhipServerSrc {
fn constructed(&self) {
self.parent_constructed();
let element = self.obj();
let ws = element
.upcast_ref::<crate::webrtcsrc::BaseWebRTCSrc>()
.imp();
let settings = ws.settings.lock().unwrap(); let _ = ws.set_signaller(WhipServerSignaller::default().upcast());
element
.bind_property("stun-server", &settings.signaller, "stun-server") let settings = ws.settings.lock().unwrap();
.build(); element
element .bind_property("stun-server", &settings.signaller, "stun-server")
.bind_property("turn-servers", &settings.signaller, "turn-servers") .build();
.build(); element
.bind_property("turn-servers", &settings.signaller, "turn-servers")
.build();
}
}
impl GstObjectImpl for WhipServerSrc {}
impl BinImpl for WhipServerSrc {}
impl ElementImpl for WhipServerSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"WhipServerSrc",
"Source/Network/WebRTC",
"WebRTC source element using WHIP Server as the signaller",
"Taruntej Kanakamalla <taruntej@asymptotic.io>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BaseWebRTCSrcImpl for WhipServerSrc {}
#[glib::object_subclass]
impl ObjectSubclass for WhipServerSrc {
const NAME: &'static str = "GstWhipServerSrc";
type Type = crate::webrtcsrc::WhipServerSrc;
type ParentType = crate::webrtcsrc::BaseWebRTCSrc;
} }
} }
impl GstObjectImpl for WhipServerSrc {} #[cfg(feature = "livekit")]
pub(super) mod livekit {
use super::*;
use crate::livekit_signaller::LiveKitSignaller;
impl BinImpl for WhipServerSrc {} #[derive(Default)]
pub struct LiveKitWebRTCSrc;
impl ElementImpl for WhipServerSrc { impl ObjectImpl for LiveKitWebRTCSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn constructed(&self) {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { self.parent_constructed();
gst::subclass::ElementMetadata::new( let element = self.obj();
"WhipServerSrc", let ws = element
"Source/Network/WebRTC", .upcast_ref::<crate::webrtcsrc::BaseWebRTCSrc>()
"WebRTC source element using WHIP Server as the signaller", .imp();
"Taruntej Kanakamalla <taruntej@asymptotic.io>",
)
});
Some(&*ELEMENT_METADATA) let _ = ws.set_signaller(LiveKitSignaller::new_consumer().upcast());
}
}
impl GstObjectImpl for LiveKitWebRTCSrc {}
impl BinImpl for LiveKitWebRTCSrc {}
impl ElementImpl for LiveKitWebRTCSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"LiveKitWebRTCSrc",
"Source/Network/WebRTC",
"WebRTC source with LiveKit signaller",
"Jordan Yelloz <jordan.yelloz@collabora.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BaseWebRTCSrcImpl for LiveKitWebRTCSrc {}
#[glib::object_subclass]
impl ObjectSubclass for LiveKitWebRTCSrc {
const NAME: &'static str = "GstLiveKitWebRTCSrc";
type Type = crate::webrtcsrc::LiveKitWebRTCSrc;
type ParentType = crate::webrtcsrc::BaseWebRTCSrc;
} }
} }
impl BaseWebRTCSrcImpl for WhipServerSrc {}
#[glib::object_subclass]
impl ObjectSubclass for WhipServerSrc {
const NAME: &'static str = "GstWhipServerSrc";
type Type = super::WhipServerSrc;
type ParentType = super::BaseWebRTCSrc;
}
#[derive(Default)]
pub struct LiveKitWebRTCSrc;
impl ObjectImpl for LiveKitWebRTCSrc {
fn constructed(&self) {
self.parent_constructed();
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSrc>().imp();
let _ = ws.set_signaller(LiveKitSignaller::new_consumer().upcast());
}
}
impl GstObjectImpl for LiveKitWebRTCSrc {}
impl BinImpl for LiveKitWebRTCSrc {}
impl ElementImpl for LiveKitWebRTCSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"LiveKitWebRTCSrc",
"Source/Network/WebRTC",
"WebRTC source with LiveKit signaller",
"Jordan Yelloz <jordan.yelloz@collabora.com>",
)
});
Some(&*ELEMENT_METADATA)
}
}
impl BaseWebRTCSrcImpl for LiveKitWebRTCSrc {}
#[glib::object_subclass]
impl ObjectSubclass for LiveKitWebRTCSrc {
const NAME: &'static str = "GstLiveKitWebRTCSrc";
type Type = super::LiveKitWebRTCSrc;
type ParentType = super::BaseWebRTCSrc;
}

View file

@ -49,12 +49,14 @@ glib::wrapper! {
pub struct WebRTCSrc(ObjectSubclass<imp::WebRTCSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, @implements gst::URIHandler, gst::ChildProxy; pub struct WebRTCSrc(ObjectSubclass<imp::WebRTCSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, @implements gst::URIHandler, gst::ChildProxy;
} }
#[cfg(feature = "whip")]
glib::wrapper! { glib::wrapper! {
pub struct WhipServerSrc(ObjectSubclass<imp::WhipServerSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, @implements gst::URIHandler, gst::ChildProxy; pub struct WhipServerSrc(ObjectSubclass<imp::whip::WhipServerSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, @implements gst::URIHandler, gst::ChildProxy;
} }
#[cfg(feature = "livekit")]
glib::wrapper! { glib::wrapper! {
pub struct LiveKitWebRTCSrc(ObjectSubclass<imp::LiveKitWebRTCSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, gst::ChildProxy; pub struct LiveKitWebRTCSrc(ObjectSubclass<imp::livekit::LiveKitWebRTCSrc>) @extends BaseWebRTCSrc, gst::Bin, gst::Element, gst::Object, gst::ChildProxy;
} }
glib::wrapper! { glib::wrapper! {
@ -73,6 +75,7 @@ pub fn register(plugin: Option<&gst::Plugin>) -> Result<(), glib::BoolError> {
WebRTCSrc::static_type(), WebRTCSrc::static_type(),
)?; )?;
#[cfg(feature = "whip")]
gst::Element::register( gst::Element::register(
plugin, plugin,
"whipserversrc", "whipserversrc",
@ -80,6 +83,7 @@ pub fn register(plugin: Option<&gst::Plugin>) -> Result<(), glib::BoolError> {
WhipServerSrc::static_type(), WhipServerSrc::static_type(),
)?; )?;
#[cfg(feature = "livekit")]
/** /**
* element-livekitwebrtcsrc: * element-livekitwebrtcsrc:
* *