diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 0c7a83f27..60392cf2c 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -281,6 +281,15 @@ name = "Gst.TagList" status = "manual" ref_mode = "ref" +[[object]] +name = "Gst.TagScope" +status = "generate" + [[object.derive]] + name = "Serialize, Deserialize" + cfg_condition = "feature = \"ser_de\"" + [[object.derive]] + name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash" + [[object]] name = "Gst.Query" status = "manual" diff --git a/gstreamer/src/auto/enums.rs b/gstreamer/src/auto/enums.rs index 83b2f9dda..2aa23a267 100644 --- a/gstreamer/src/auto/enums.rs +++ b/gstreamer/src/auto/enums.rs @@ -2530,6 +2530,65 @@ impl SetValue for TagMergeMode { } } + #[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))] + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy)] +pub enum TagScope { + Stream, + Global, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for TagScope { + type GlibType = ffi::GstTagScope; + + fn to_glib(&self) -> ffi::GstTagScope { + match *self { + TagScope::Stream => ffi::GST_TAG_SCOPE_STREAM, + TagScope::Global => ffi::GST_TAG_SCOPE_GLOBAL, + TagScope::__Unknown(value) => value + } + } +} + +#[doc(hidden)] +impl FromGlib for TagScope { + fn from_glib(value: ffi::GstTagScope) -> Self { + skip_assert_initialized!(); + match value { + 0 => TagScope::Stream, + 1 => TagScope::Global, + value => TagScope::__Unknown(value), + } + } +} + +impl StaticType for TagScope { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_tag_scope_get_type()) } + } +} + +impl<'a> FromValueOptional<'a> for TagScope { + unsafe fn from_value_optional(value: &Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +impl<'a> FromValue<'a> for TagScope { + unsafe fn from_value(value: &Value) -> Self { + from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl SetValue for TagScope { + unsafe fn set_value(value: &mut Value, this: &Self) { + gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) + } +} + #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum TaskState { diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 5319e158b..697c5e033 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -146,6 +146,7 @@ pub use self::enums::StreamStatusType; pub use self::enums::StructureChangeType; pub use self::enums::TagFlag; pub use self::enums::TagMergeMode; +pub use self::enums::TagScope; pub use self::enums::TaskState; pub use self::enums::TocEntryType; pub use self::enums::TocLoopType; diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 2e95edaa5..742a70efc 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -23,6 +23,7 @@ use miniobject::*; use Sample; use TagError; use TagMergeMode; +use TagScope; pub trait Tag<'a> { type TagType: FromValueOptional<'a> + SetValue + Send; @@ -498,6 +499,14 @@ impl TagListRef { )) } } + + pub fn get_scope(&self) -> TagScope { + unsafe { from_glib(ffi::gst_tag_list_get_scope(self.as_ptr())) } + } + + pub fn set_scope(&mut self, scope: TagScope) { + unsafe { ffi::gst_tag_list_set_scope(self.as_mut_ptr(), scope.to_glib()) } + } } impl fmt::Debug for TagListRef { @@ -904,6 +913,19 @@ mod tests { ); } + #[test] + fn test_scope() { + ::init().unwrap(); + + let mut tags = TagList::new(); + assert_eq!(tags.get_scope(), TagScope::Stream); + { + let tags = tags.get_mut().unwrap(); + tags.set_scope(TagScope::Global); + } + assert_eq!(tags.get_scope(), TagScope::Global); + } + #[test] fn test_generic() { ::init().unwrap();