mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
TagList: add TagScope {get, set}
This commit is contained in:
parent
d8554071b6
commit
bec3d84627
4 changed files with 91 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -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<ffi::GstTagScope> 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<Self> {
|
||||
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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue