mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 02:51:10 +00:00
analytics: Allow empty object type
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1407>
This commit is contained in:
parent
82f6accc31
commit
3246f4fb5b
2 changed files with 11 additions and 7 deletions
|
@ -82,11 +82,15 @@ unsafe fn from(t: ffi::GstAnalyticsMtd) -> ffi::GstAnalyticsODMtd {
|
|||
|
||||
impl<'a> AnalyticsMtdRef<'a, AnalyticsODMtd> {
|
||||
#[doc(alias = "gst_analytics_od_mtd_get_obj_type")]
|
||||
pub fn obj_type(&self) -> glib::Quark {
|
||||
pub fn obj_type(&self) -> Option<glib::Quark> {
|
||||
unsafe {
|
||||
let mut mtd = from(ffi::GstAnalyticsMtd::unsafe_from(self));
|
||||
let type_ = ffi::gst_analytics_od_mtd_get_obj_type(&mut mtd);
|
||||
glib::Quark::from_glib(type_)
|
||||
if type_ == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(glib::Quark::from_glib(type_))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +147,7 @@ mod tests {
|
|||
.add_od_mtd(glib::Quark::from_str("blb"), 0, 1, 10, 20, 0.8)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(od.obj_type(), glib::Quark::from_str("blb"));
|
||||
assert_eq!(od.obj_type().unwrap(), glib::Quark::from_str("blb"));
|
||||
|
||||
let loc = od.location().unwrap();
|
||||
|
||||
|
@ -159,7 +163,7 @@ mod tests {
|
|||
let meta2 = buf.meta::<AnalyticsRelationMeta>().unwrap();
|
||||
let od2 = meta2.mtd::<AnalyticsODMtd>(0).unwrap();
|
||||
|
||||
assert_eq!(od2.obj_type(), glib::Quark::from_str("blb"));
|
||||
assert_eq!(od2.obj_type().unwrap(), glib::Quark::from_str("blb"));
|
||||
let loc = od2.location().unwrap();
|
||||
|
||||
assert_eq!(loc.x, 0);
|
||||
|
|
|
@ -652,13 +652,13 @@ mod tests {
|
|||
assert_eq!(meta.len(), meta.iter::<AnalyticsAnyMtd>().count());
|
||||
assert_eq!(meta.len(), meta.iter::<AnalyticsODMtd>().count());
|
||||
for mtd in meta.iter::<AnalyticsODMtd>() {
|
||||
assert_eq!(mtd.obj_type(), glib::Quark::from_str("blb"))
|
||||
assert_eq!(mtd.obj_type().unwrap(), glib::Quark::from_str("blb"))
|
||||
}
|
||||
|
||||
assert_eq!(meta.len(), meta.iter::<AnalyticsAnyMtd>().count());
|
||||
for mtd in meta.iter::<AnalyticsAnyMtd>() {
|
||||
if let Ok(mtd) = mtd.downcast::<AnalyticsODMtd>() {
|
||||
assert_eq!(mtd.obj_type(), glib::Quark::from_str("blb"))
|
||||
assert_eq!(mtd.obj_type().unwrap(), glib::Quark::from_str("blb"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,7 +689,7 @@ mod tests {
|
|||
0
|
||||
);
|
||||
for mtd in meta.iter_direct_related::<AnalyticsODMtd>(od1_id, crate::RelTypes::IS_PART_OF) {
|
||||
assert_eq!(mtd.obj_type(), glib::Quark::from_str("blb"))
|
||||
assert_eq!(mtd.obj_type().unwrap(), glib::Quark::from_str("blb"))
|
||||
}
|
||||
|
||||
let mut meta = buf.make_mut().meta_mut::<AnalyticsRelationMeta>().unwrap();
|
||||
|
|
Loading…
Reference in a new issue