From 35160bedbc7ad359c5ba10adfcd8f4aa6aebc35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 30 Jul 2017 15:11:47 +0100 Subject: [PATCH] Add support for Events in pad probes --- gstreamer/src/event.rs | 1 - gstreamer/src/pad.rs | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 11053879a..a12769e00 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -7,7 +7,6 @@ // except according to those terms. use ffi; -use Object; use miniobject::*; use structure::*; diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index d84ab090f..f967cf17a 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -14,6 +14,7 @@ use BufferList; use FlowReturn; use Query; use QueryRef; +use Event; use miniobject::MiniObject; use std::cell::RefCell; @@ -60,7 +61,7 @@ pub enum PadProbeData<'a> { Buffer(Buffer), BufferList(BufferList), Query(&'a mut QueryRef), - // Event(&Event), + Event(Event), Unknown, } @@ -217,6 +218,11 @@ unsafe extern "C" fn trampoline_pad_probe( Some(PadProbeData::Query( QueryRef::from_mut_ptr(data as *mut ffi::GstQuery), )) + } else if (*data).type_ == Event::static_type().to_glib() { + data_type = Some(Event::static_type()); + Some(PadProbeData::Event( + from_glib_none(data as *const ffi::GstEvent), + )) } else { Some(PadProbeData::Unknown) } @@ -240,6 +246,13 @@ unsafe extern "C" fn trampoline_pad_probe( (*info).data = bufferlist.into_ptr() as *mut libc::c_void; } } + Some(PadProbeData::Event(event)) => { + assert_eq!(data_type, Some(Event::static_type())); + if (*info).data != event.as_mut_ptr() as *mut _ { + ffi::gst_mini_object_unref((*info).data as *mut _); + (*info).data = event.into_ptr() as *mut libc::c_void; + } + } None => { assert_ne!(data_type, Some(Query::static_type())); if !(*info).data.is_null() {