From 6d30078c891da6c7a63b56cb726dc62cca775ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Thu, 19 Nov 2020 21:10:13 +0100 Subject: [PATCH] Event: impl structure_mut getter --- gstreamer/src/event.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 949a65c79..d8ade409e 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -168,6 +168,14 @@ impl EventRef { } } + pub fn structure_mut(&mut self) -> &mut StructureRef { + unsafe { + StructureRef::from_glib_borrow_mut(gst_sys::gst_event_writable_structure( + self.as_mut_ptr(), + )) + } + } + pub fn is_upstream(&self) -> bool { self.get_type().is_upstream() } @@ -2264,4 +2272,20 @@ mod tests { _ => panic!("flush_stop_evt.view() is not an EventView::FlushStop(_)"), } } + + #[test] + fn test_get_structure_mut() { + ::init().unwrap(); + + let mut flush_start_evt = FlushStart::new(); + + { + let flush_start_evt = flush_start_evt.get_mut().unwrap(); + let structure = flush_start_evt.structure_mut(); + structure.set("test", &42u32); + } + + let structure = flush_start_evt.get_structure().unwrap(); + assert_eq!(structure.get_some("test"), Ok(42u32)); + } }