Event/Message::get_structure() can return None

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

View file

@ -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))
}
}
}

View file

@ -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))
}
}
}