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

View file

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

View file

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

View file

@ -23,11 +23,7 @@ use super::homegrown_cc::CongestionController;
use super::{
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::whip_signaller::WhipClientSignaller;
use crate::{utils, RUNTIME};
use std::collections::{BTreeMap, HashSet};
@ -4521,187 +4517,219 @@ impl ObjectSubclass for WebRTCSink {
type ParentType = super::BaseWebRTCSink;
}
#[derive(Default)]
pub struct AwsKvsWebRTCSink {}
#[cfg(feature = "aws")]
pub(super) mod aws {
use super::*;
use crate::aws_kvs_signaller::AwsKvsSignaller;
impl ObjectImpl for AwsKvsWebRTCSink {
fn constructed(&self) {
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSink>().imp();
#[derive(Default)]
pub struct AwsKvsWebRTCSink {}
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 {}
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());
let _ = ws.set_signaller(AwsKvsSignaller::default().upcast());
}
}
}
impl GstObjectImpl for JanusVRWebRTCSink {}
impl GstObjectImpl for AwsKvsWebRTCSink {}
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>",
)
});
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)
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 ObjectSubclass for JanusVRWebRTCSink {
const NAME: &'static str = "GstJanusVRWebRTCSink";
type Type = super::JanusVRWebRTCSink;
type ParentType = super::BaseWebRTCSink;
impl ObjectImpl for WhipWebRTCSink {
fn constructed(&self) {
let element = self.obj();
let ws = element
.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;
}
#[cfg(feature = "aws")]
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! {
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! {
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! {
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)]
@ -140,24 +144,28 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Rank::NONE,
WebRTCSink::static_type(),
)?;
#[cfg(feature = "aws")]
gst::Element::register(
Some(plugin),
"awskvswebrtcsink",
gst::Rank::NONE,
AwsKvsWebRTCSink::static_type(),
)?;
#[cfg(feature = "whip")]
gst::Element::register(
Some(plugin),
"whipclientsink",
gst::Rank::NONE,
WhipWebRTCSink::static_type(),
)?;
#[cfg(feature = "livekit")]
gst::Element::register(
Some(plugin),
"livekitwebrtcsink",
gst::Rank::NONE,
LiveKitWebRTCSink::static_type(),
)?;
#[cfg(feature = "janus")]
/**
* element-janusvrwebrtcsink:
*

View file

@ -2,11 +2,9 @@
use gst::prelude::*;
use crate::livekit_signaller::LiveKitSignaller;
use crate::signaller::{prelude::*, Signallable, Signaller};
use crate::utils::{Codec, Codecs, NavigationEvent, AUDIO_CAPS, RTP_CAPS, VIDEO_CAPS};
use crate::webrtcsrc::WebRTCSrcPad;
use crate::whip_signaller::WhipServerSignaller;
use anyhow::{Context, Error};
use gst::glib;
use gst::subclass::prelude::*;
@ -1255,92 +1253,108 @@ impl ObjectSubclass for WebRTCSrc {
type Interfaces = (gst::URIHandler,);
}
#[derive(Default)]
pub struct WhipServerSrc {}
#[cfg(feature = "whip")]
pub(super) mod whip {
use super::*;
use crate::whip_signaller::WhipServerSignaller;
impl ObjectImpl for WhipServerSrc {
fn constructed(&self) {
self.parent_constructed();
let element = self.obj();
let ws = element.upcast_ref::<super::BaseWebRTCSrc>().imp();
#[derive(Default)]
pub struct WhipServerSrc {}
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();
element
.bind_property("stun-server", &settings.signaller, "stun-server")
.build();
element
.bind_property("turn-servers", &settings.signaller, "turn-servers")
.build();
let _ = ws.set_signaller(WhipServerSignaller::default().upcast());
let settings = ws.settings.lock().unwrap();
element
.bind_property("stun-server", &settings.signaller, "stun-server")
.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 {
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>",
)
});
impl ObjectImpl for LiveKitWebRTCSrc {
fn constructed(&self) {
self.parent_constructed();
let element = self.obj();
let ws = element
.upcast_ref::<crate::webrtcsrc::BaseWebRTCSrc>()
.imp();
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;
}
#[cfg(feature = "whip")]
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! {
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! {
@ -73,6 +75,7 @@ pub fn register(plugin: Option<&gst::Plugin>) -> Result<(), glib::BoolError> {
WebRTCSrc::static_type(),
)?;
#[cfg(feature = "whip")]
gst::Element::register(
plugin,
"whipserversrc",
@ -80,6 +83,7 @@ pub fn register(plugin: Option<&gst::Plugin>) -> Result<(), glib::BoolError> {
WhipServerSrc::static_type(),
)?;
#[cfg(feature = "livekit")]
/**
* element-livekitwebrtcsrc:
*