webrtcsrc: expose MSID property on source pad

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1789>
This commit is contained in:
Mathieu Duponchelle 2024-09-19 15:19:45 +02:00 committed by Sebastian Dröge
parent c9b370a6e4
commit a85b0cb72e
3 changed files with 51 additions and 2 deletions

View file

@ -11261,7 +11261,21 @@
"GInitiallyUnowned", "GInitiallyUnowned",
"GObject" "GObject"
], ],
"kind": "object" "kind": "object",
"properties": {
"msid": {
"blurb": "Remote MediaStream ID in use for this pad",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "NULL",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": false
}
}
} }
}, },
"package": "gst-plugin-webrtc", "package": "gst-plugin-webrtc",

View file

@ -491,6 +491,8 @@ impl Session {
self.id self.id
); );
webrtcbin_pad.store_sticky_event(&builder.build()).ok(); webrtcbin_pad.store_sticky_event(&builder.build()).ok();
srcpad.imp().set_webrtc_pad(webrtcbin_pad.downgrade());
} }
let ghostpad = gst::GhostPad::builder(gst::PadDirection::Src) let ghostpad = gst::GhostPad::builder(gst::PadDirection::Src)

View file

@ -1,7 +1,9 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use gst::glib; use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*; use gst::subclass::prelude::*;
use once_cell::sync::Lazy;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::sync::Mutex; use std::sync::Mutex;
@ -10,6 +12,7 @@ use std::sync::Mutex;
pub struct WebRTCSrcPad { pub struct WebRTCSrcPad {
needs_raw: AtomicBool, needs_raw: AtomicBool,
stream_id: Mutex<Option<String>>, stream_id: Mutex<Option<String>>,
webrtcbin_pad: Mutex<Option<gst::glib::WeakRef<gst::Pad>>>,
} }
impl WebRTCSrcPad { impl WebRTCSrcPad {
@ -29,6 +32,10 @@ impl WebRTCSrcPad {
let stream_id = self.stream_id.lock().unwrap(); let stream_id = self.stream_id.lock().unwrap();
stream_id.as_ref().unwrap().clone() stream_id.as_ref().unwrap().clone()
} }
pub fn set_webrtc_pad(&self, pad: glib::object::WeakRef<gst::Pad>) {
*self.webrtcbin_pad.lock().unwrap() = Some(pad);
}
} }
#[glib::object_subclass] #[glib::object_subclass]
@ -38,7 +45,33 @@ impl ObjectSubclass for WebRTCSrcPad {
type ParentType = gst::GhostPad; type ParentType = gst::GhostPad;
} }
impl ObjectImpl for WebRTCSrcPad {} impl ObjectImpl for WebRTCSrcPad {
fn properties() -> &'static [glib::ParamSpec] {
static PROPS: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![glib::ParamSpecString::builder("msid")
.flags(glib::ParamFlags::READABLE)
.blurb("Remote MediaStream ID in use for this pad")
.build()]
});
PROPS.as_ref()
}
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() {
"msid" => {
let msid = self
.webrtcbin_pad
.lock()
.unwrap()
.as_ref()
.and_then(|p| p.upgrade())
.map(|p| p.property::<String>("msid"));
msid.to_value()
}
name => panic!("no readable property {name:?}"),
}
}
}
impl GstObjectImpl for WebRTCSrcPad {} impl GstObjectImpl for WebRTCSrcPad {}
impl PadImpl for WebRTCSrcPad {} impl PadImpl for WebRTCSrcPad {}
impl ProxyPadImpl for WebRTCSrcPad {} impl ProxyPadImpl for WebRTCSrcPad {}