From 2915bfa2991f1d099119b70a4c77aaba57772e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 29 Jul 2017 16:09:14 +0100 Subject: [PATCH] Add support for queries in pad probes --- gstreamer/src/pad.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index c4b45d558..d84ab090f 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -12,6 +12,7 @@ use PadProbeReturn; use Buffer; use BufferList; use FlowReturn; +use Query; use QueryRef; use miniobject::MiniObject; @@ -47,18 +48,18 @@ impl FromGlib for PadProbeId { } } -pub struct PadProbeInfo { +pub struct PadProbeInfo<'a> { pub mask: PadProbeType, pub id: PadProbeId, pub offset: u64, pub size: u32, - pub data: Option, + pub data: Option>, } -pub enum PadProbeData { +pub enum PadProbeData<'a> { Buffer(Buffer), BufferList(BufferList), - // Query(&Query), + Query(&'a mut QueryRef), // Event(&Event), Unknown, } @@ -211,6 +212,11 @@ unsafe extern "C" fn trampoline_pad_probe( Some(PadProbeData::BufferList( from_glib_none(data as *const ffi::GstBufferList), )) + } else if (*data).type_ == Query::static_type().to_glib() { + data_type = Some(Query::static_type()); + Some(PadProbeData::Query( + QueryRef::from_mut_ptr(data as *mut ffi::GstQuery), + )) } else { Some(PadProbeData::Unknown) } @@ -235,6 +241,7 @@ unsafe extern "C" fn trampoline_pad_probe( } } None => { + assert_ne!(data_type, Some(Query::static_type())); if !(*info).data.is_null() { ffi::gst_mini_object_unref((*info).data as *mut _); (*info).data = ptr::null_mut();