forked from mirrors/gstreamer-rs
gstreamer: Implement pad sticky event getter by type
This allows the caller to directly use the specific event type API on the result instead of first having to match on it first. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/314
This commit is contained in:
parent
87e7a84a27
commit
aab0a45cfc
5 changed files with 367 additions and 230 deletions
|
@ -1424,6 +1424,11 @@ manual_traits = ["PadExtManual"]
|
|||
# Complex closure argument handling
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_sticky_event"
|
||||
# More convenient API
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "add_probe"
|
||||
# Complex closure argument handling
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
use crate::Caps;
|
||||
use crate::Element;
|
||||
use crate::Event;
|
||||
use crate::EventType;
|
||||
use crate::FlowError;
|
||||
use crate::FlowSuccess;
|
||||
use crate::Object;
|
||||
|
@ -117,10 +116,6 @@ pub trait PadExt: 'static {
|
|||
#[doc(alias = "get_single_internal_link")]
|
||||
fn single_internal_link(&self) -> Option<Pad>;
|
||||
|
||||
#[doc(alias = "gst_pad_get_sticky_event")]
|
||||
#[doc(alias = "get_sticky_event")]
|
||||
fn sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event>;
|
||||
|
||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
||||
#[doc(alias = "gst_pad_get_stream")]
|
||||
|
@ -389,16 +384,6 @@ impl<O: IsA<Pad>> PadExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event> {
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_pad_get_sticky_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
event_type.into_glib(),
|
||||
idx,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
||||
fn stream(&self) -> Option<Stream> {
|
||||
|
|
|
@ -123,7 +123,7 @@ pub trait ElementExtManual: 'static {
|
|||
fn query(&self, query: &mut QueryRef) -> bool;
|
||||
|
||||
#[doc(alias = "gst_element_send_event")]
|
||||
fn send_event(&self, event: Event) -> bool;
|
||||
fn send_event(&self, event: impl Into<Event>) -> bool;
|
||||
|
||||
#[doc(alias = "get_metadata")]
|
||||
fn metadata<'a>(&self, key: &str) -> Option<&'a str>;
|
||||
|
@ -303,11 +303,11 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn send_event(&self, event: Event) -> bool {
|
||||
fn send_event(&self, event: impl Into<Event>) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_element_send_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
event.into().into_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -140,11 +140,15 @@ pub trait PadExtManual: 'static {
|
|||
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool;
|
||||
|
||||
#[doc(alias = "gst_pad_event_default")]
|
||||
fn event_default<P: IsA<crate::Object>>(&self, parent: Option<&P>, event: Event) -> bool;
|
||||
fn event_default<P: IsA<crate::Object>>(
|
||||
&self,
|
||||
parent: Option<&P>,
|
||||
event: impl Into<Event>,
|
||||
) -> bool;
|
||||
#[doc(alias = "gst_pad_push_event")]
|
||||
fn push_event(&self, event: Event) -> bool;
|
||||
fn push_event(&self, event: impl Into<Event>) -> bool;
|
||||
#[doc(alias = "gst_pad_send_event")]
|
||||
fn send_event(&self, event: Event) -> bool;
|
||||
fn send_event(&self, event: impl Into<Event>) -> bool;
|
||||
|
||||
#[doc(alias = "gst_pad_iterate_internal_links")]
|
||||
fn iterate_internal_links(&self) -> crate::Iterator<Pad>;
|
||||
|
@ -278,6 +282,10 @@ pub trait PadExtManual: 'static {
|
|||
func: F,
|
||||
);
|
||||
|
||||
#[doc(alias = "gst_pad_get_sticky_event")]
|
||||
#[doc(alias = "get_sticky_event")]
|
||||
fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T>;
|
||||
|
||||
fn set_pad_flags(&self, flags: PadFlags);
|
||||
|
||||
fn unset_pad_flags(&self, flags: PadFlags);
|
||||
|
@ -482,31 +490,35 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn event_default<P: IsA<crate::Object>>(&self, parent: Option<&P>, event: Event) -> bool {
|
||||
fn event_default<P: IsA<crate::Object>>(
|
||||
&self,
|
||||
parent: Option<&P>,
|
||||
event: impl Into<Event>,
|
||||
) -> bool {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
from_glib(ffi::gst_pad_event_default(
|
||||
self.as_ref().to_glib_none().0,
|
||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
event.into().into_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn push_event(&self, event: Event) -> bool {
|
||||
fn push_event(&self, event: impl Into<Event>) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_pad_push_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
event.into().into_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn send_event(&self, event: Event) -> bool {
|
||||
fn send_event(&self, event: impl Into<Event>) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_pad_send_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
event.into().into_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -1006,6 +1018,22 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T> {
|
||||
unsafe {
|
||||
let ptr = ffi::gst_pad_get_sticky_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::TYPE.into_glib(),
|
||||
idx,
|
||||
);
|
||||
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(T::from_event(from_glib_full(ptr)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_pad_flags(&self, flags: PadFlags) {
|
||||
unsafe {
|
||||
let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _;
|
||||
|
|
Loading…
Reference in a new issue