Event/Message::get_structure() can return None

This commit is contained in:
Sebastian Dröge 2017-12-01 11:21:20 +02:00
parent 7342a0fb98
commit 1576ff6c32
2 changed files with 12 additions and 4 deletions

View file

@ -100,10 +100,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))
}
}
}

View file

@ -43,10 +43,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))
}
}
}