gst-plugins-rs/net/webrtc/src/janusvr_signaller/mod.rs
Guillaume Desmottes 612f863ee9 webrtc: janusvrwebrtcsink: add 'use-string-ids' property
Instead of exposing all ids properties as strings, we now have two
signaller implementations exposing those properties using their actual
type. This API is more natural and save the element and application
conversions when using numerical ids (Janus's default).

I also removed the 'joined-id' property as it's actually the same id as
'feed-id'. I think it would be better to have a 'janus-state' property or
something like that for applications willing to know when the room has
been joined.
This id is also no longer generated by the element by default, as Janus
will take care of generating one if not provided.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1486>
2024-03-07 09:34:58 +01:00

65 lines
1.6 KiB
Rust

// SPDX-License-Identifier: MPL-2.0
use crate::signaller::Signallable;
use gst::{glib, glib::subclass::prelude::*};
mod imp;
// base class
glib::wrapper! {
pub struct JanusVRSignaller(ObjectSubclass<imp::Signaller>) @implements Signallable;
}
trait JanusVRSignallerImpl: ObjectImpl {}
#[repr(C)]
pub struct JanusVRSignallerClass {
parent: glib::object::ObjectClass,
}
unsafe impl ClassStruct for JanusVRSignallerClass {
type Type = imp::Signaller;
}
impl std::ops::Deref for JanusVRSignallerClass {
type Target = glib::Class<<<Self as ClassStruct>::Type as ObjectSubclass>::ParentType>;
fn deref(&self) -> &Self::Target {
unsafe { &*(&self.parent as *const _ as *const _) }
}
}
unsafe impl<T: JanusVRSignallerImpl> IsSubclassable<T> for JanusVRSignaller {
fn class_init(class: &mut glib::Class<Self>) {
Self::parent_class_init::<T>(class);
}
}
impl Default for JanusVRSignaller {
fn default() -> Self {
glib::Object::new()
}
}
// default signaller using `u64` ids
glib::wrapper! {
pub struct JanusVRSignallerU64(ObjectSubclass<imp::signaller_u64::SignallerU64>) @extends JanusVRSignaller, @implements Signallable;
}
impl Default for JanusVRSignallerU64 {
fn default() -> Self {
glib::Object::new()
}
}
// signaller using strings ids, used when `use-string-ids=true` is set on `janusvrwebrtcsink`
glib::wrapper! {
pub struct JanusVRSignallerStr(ObjectSubclass<imp::signaller_str::SignallerStr>) @extends JanusVRSignaller, @implements Signallable;
}
impl Default for JanusVRSignallerStr {
fn default() -> Self {
glib::Object::new()
}
}