mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-10 20:31:10 +00:00
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:
parent
c9b370a6e4
commit
a85b0cb72e
3 changed files with 51 additions and 2 deletions
|
@ -11261,7 +11261,21 @@
|
|||
"GInitiallyUnowned",
|
||||
"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",
|
||||
|
|
|
@ -491,6 +491,8 @@ impl Session {
|
|||
self.id
|
||||
);
|
||||
webrtcbin_pad.store_sticky_event(&builder.build()).ok();
|
||||
|
||||
srcpad.imp().set_webrtc_pad(webrtcbin_pad.downgrade());
|
||||
}
|
||||
|
||||
let ghostpad = gst::GhostPad::builder(gst::PadDirection::Src)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
use gst::subclass::prelude::*;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Mutex;
|
||||
|
@ -10,6 +12,7 @@ use std::sync::Mutex;
|
|||
pub struct WebRTCSrcPad {
|
||||
needs_raw: AtomicBool,
|
||||
stream_id: Mutex<Option<String>>,
|
||||
webrtcbin_pad: Mutex<Option<gst::glib::WeakRef<gst::Pad>>>,
|
||||
}
|
||||
|
||||
impl WebRTCSrcPad {
|
||||
|
@ -29,6 +32,10 @@ impl WebRTCSrcPad {
|
|||
let stream_id = self.stream_id.lock().unwrap();
|
||||
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]
|
||||
|
@ -38,7 +45,33 @@ impl ObjectSubclass for WebRTCSrcPad {
|
|||
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 PadImpl for WebRTCSrcPad {}
|
||||
impl ProxyPadImpl for WebRTCSrcPad {}
|
||||
|
|
Loading…
Reference in a new issue