diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 5e8b9bbfe..f5a276610 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -101,10 +101,14 @@ impl EventRef { } - pub fn get_structure(&self) -> &StructureRef { + pub fn get_structure(&self) -> Option<&StructureRef> { unsafe { let structure = ffi::gst_event_get_structure(self.as_mut_ptr()); - StructureRef::from_glib_borrow(structure) + if structure.is_null() { + None + } else { + Some(StructureRef::from_glib_borrow(structure)) + } } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index d4aa4437a..37771c9d7 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -45,10 +45,14 @@ impl MessageRef { unsafe { ffi::gst_message_get_seqnum(self.as_mut_ptr()) } } - pub fn get_structure(&self) -> &StructureRef { + pub fn get_structure(&self) -> Option<&StructureRef> { unsafe { let structure = ffi::gst_message_get_structure(self.as_mut_ptr()); - StructureRef::from_glib_borrow(structure) + if structure.is_null() { + None + } else { + Some(StructureRef::from_glib_borrow(structure)) + } } }