forked from mirrors/gstreamer-rs
gstreamer: Add bindings for StreamCollection::stream-notify
signal
This commit is contained in:
parent
63f6d6a7d3
commit
2471150e72
1 changed files with 46 additions and 0 deletions
|
@ -2,8 +2,13 @@
|
||||||
|
|
||||||
use crate::Stream;
|
use crate::Stream;
|
||||||
use crate::StreamCollection;
|
use crate::StreamCollection;
|
||||||
|
use glib::object::ObjectType as ObjectType_;
|
||||||
|
use glib::signal::connect_raw;
|
||||||
|
use glib::signal::SignalHandlerId;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
use std::boxed::Box as Box_;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::mem::transmute;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Iter<'a> {
|
pub struct Iter<'a> {
|
||||||
|
@ -93,6 +98,7 @@ impl StreamCollectionBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StreamCollection {
|
impl StreamCollection {
|
||||||
|
#[doc(alias = "gst_stream_collection_new")]
|
||||||
pub fn builder(upstream_id: Option<&str>) -> StreamCollectionBuilder {
|
pub fn builder(upstream_id: Option<&str>) -> StreamCollectionBuilder {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
let upstream_id = upstream_id.to_glib_none();
|
let upstream_id = upstream_id.to_glib_none();
|
||||||
|
@ -107,6 +113,46 @@ impl StreamCollection {
|
||||||
StreamCollectionBuilder(collection)
|
StreamCollectionBuilder(collection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "stream-notify")]
|
||||||
|
pub fn connect_stream_notify<
|
||||||
|
F: Fn(&Self, &Stream, &glib::ParamSpec) + Send + Sync + 'static,
|
||||||
|
>(
|
||||||
|
&self,
|
||||||
|
detail: Option<&str>,
|
||||||
|
f: F,
|
||||||
|
) -> SignalHandlerId {
|
||||||
|
unsafe extern "C" fn stream_notify_trampoline<
|
||||||
|
F: Fn(&StreamCollection, &Stream, &glib::ParamSpec) + Send + Sync + 'static,
|
||||||
|
>(
|
||||||
|
this: *mut ffi::GstStreamCollection,
|
||||||
|
object: *mut ffi::GstStream,
|
||||||
|
p0: *mut glib::gobject_ffi::GParamSpec,
|
||||||
|
f: glib::ffi::gpointer,
|
||||||
|
) {
|
||||||
|
let f: &F = &*(f as *const F);
|
||||||
|
f(
|
||||||
|
&from_glib_borrow(this),
|
||||||
|
&from_glib_borrow(object),
|
||||||
|
&from_glib_borrow(p0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
let f: Box_<F> = Box_::new(f);
|
||||||
|
let detailed_signal_name = detail.map(|name| format!("stream-notify::{}\0", name));
|
||||||
|
let signal_name: &[u8] = detailed_signal_name
|
||||||
|
.as_ref()
|
||||||
|
.map_or(&b"stream-notify\0"[..], |n| n.as_bytes());
|
||||||
|
connect_raw(
|
||||||
|
self.as_ptr() as *mut _,
|
||||||
|
signal_name.as_ptr() as *const _,
|
||||||
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
||||||
|
stream_notify_trampoline::<F> as *const (),
|
||||||
|
)),
|
||||||
|
Box_::into_raw(f),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> Iter {
|
pub fn iter(&self) -> Iter {
|
||||||
Iter::new(self)
|
Iter::new(self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue