gstreamer/auto/
tag_setter.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, Element, Object, TagList, TagMergeMode};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// Element interface that allows setting of media metadata.
11    ///
12    /// Elements that support changing a stream's metadata will implement this
13    /// interface. Examples of such elements are 'vorbisenc', 'theoraenc' and
14    /// 'id3v2mux'.
15    ///
16    /// If you just want to retrieve metadata in your application then all you
17    /// need to do is watch for tag messages on your pipeline's bus. This
18    /// interface is only for setting metadata, not for extracting it. To set tags
19    /// from the application, find tagsetter elements and set tags using e.g.
20    /// [`TagSetterExt::merge_tags()`][crate::prelude::TagSetterExt::merge_tags()] or `gst_tag_setter_add_tags()`. Also consider
21    /// setting the [`TagMergeMode`][crate::TagMergeMode] that is used for tag events that arrive at the
22    /// tagsetter element (default mode is to keep existing tags).
23    /// The application should do that before the element goes to [`State::Paused`][crate::State::Paused].
24    ///
25    /// Elements implementing the [`TagSetter`][crate::TagSetter] interface often have to merge
26    /// any tags received from upstream and the tags set by the application via
27    /// the interface. This can be done like this:
28    ///
29    ///
30    ///
31    /// **⚠️ The following code is in C ⚠️**
32    ///
33    /// ```C
34    /// GstTagMergeMode merge_mode;
35    /// const GstTagList *application_tags;
36    /// const GstTagList *event_tags;
37    /// GstTagSetter *tagsetter;
38    /// GstTagList *result;
39    ///
40    /// tagsetter = GST_TAG_SETTER (element);
41    ///
42    /// merge_mode = gst_tag_setter_get_tag_merge_mode (tagsetter);
43    /// application_tags = gst_tag_setter_get_tag_list (tagsetter);
44    /// event_tags = (const GstTagList *) element->event_tags;
45    ///
46    /// GST_LOG_OBJECT (tagsetter, "merging tags, merge mode = %d", merge_mode);
47    /// GST_LOG_OBJECT (tagsetter, "event tags: %" GST_PTR_FORMAT, event_tags);
48    /// GST_LOG_OBJECT (tagsetter, "set   tags: %" GST_PTR_FORMAT, application_tags);
49    ///
50    /// result = gst_tag_list_merge (application_tags, event_tags, merge_mode);
51    ///
52    /// GST_LOG_OBJECT (tagsetter, "final tags: %" GST_PTR_FORMAT, result);
53    /// ```
54    ///
55    /// # Implements
56    ///
57    /// [`TagSetterExt`][trait@crate::prelude::TagSetterExt], [`ElementExt`][trait@crate::prelude::ElementExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`TagSetterExtManual`][trait@crate::prelude::TagSetterExtManual], [`ElementExtManual`][trait@crate::prelude::ElementExtManual]
58    #[doc(alias = "GstTagSetter")]
59    pub struct TagSetter(Interface<ffi::GstTagSetter, ffi::GstTagSetterInterface>) @requires Element, Object;
60
61    match fn {
62        type_ => || ffi::gst_tag_setter_get_type(),
63    }
64}
65
66impl TagSetter {
67    pub const NONE: Option<&'static TagSetter> = None;
68}
69
70unsafe impl Send for TagSetter {}
71unsafe impl Sync for TagSetter {}
72
73/// Trait containing all [`struct@TagSetter`] methods.
74///
75/// # Implementors
76///
77/// [`TagSetter`][struct@crate::TagSetter]
78pub trait TagSetterExt: IsA<TagSetter> + 'static {
79    //#[doc(alias = "gst_tag_setter_add_tag_valist")]
80    //fn add_tag_valist(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
81    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_valist() }
82    //}
83
84    //#[doc(alias = "gst_tag_setter_add_tag_valist_values")]
85    //fn add_tag_valist_values(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
86    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_valist_values() }
87    //}
88
89    //#[doc(alias = "gst_tag_setter_add_tag_values")]
90    //fn add_tag_values(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
91    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_values() }
92    //}
93
94    /// Returns the current list of tags the setter uses. The list should not be
95    /// modified or freed.
96    ///
97    /// This function is not thread-safe.
98    ///
99    /// # Returns
100    ///
101    /// a current snapshot of the
102    ///  taglist used in the setter or [`None`] if none is used.
103    #[doc(alias = "gst_tag_setter_get_tag_list")]
104    #[doc(alias = "get_tag_list")]
105    fn tag_list(&self) -> Option<TagList> {
106        unsafe {
107            from_glib_none(ffi::gst_tag_setter_get_tag_list(
108                self.as_ref().to_glib_none().0,
109            ))
110        }
111    }
112
113    /// Queries the mode by which tags inside the setter are overwritten by tags
114    /// from events
115    ///
116    /// # Returns
117    ///
118    /// the merge mode used inside the element.
119    #[doc(alias = "gst_tag_setter_get_tag_merge_mode")]
120    #[doc(alias = "get_tag_merge_mode")]
121    fn tag_merge_mode(&self) -> TagMergeMode {
122        unsafe {
123            from_glib(ffi::gst_tag_setter_get_tag_merge_mode(
124                self.as_ref().to_glib_none().0,
125            ))
126        }
127    }
128
129    /// Merges the given list into the setter's list using the given mode.
130    /// ## `list`
131    /// a tag list to merge from
132    /// ## `mode`
133    /// the mode to merge with
134    #[doc(alias = "gst_tag_setter_merge_tags")]
135    fn merge_tags(&self, list: &TagList, mode: TagMergeMode) {
136        unsafe {
137            ffi::gst_tag_setter_merge_tags(
138                self.as_ref().to_glib_none().0,
139                list.to_glib_none().0,
140                mode.into_glib(),
141            );
142        }
143    }
144
145    /// Reset the internal taglist. Elements should call this from within the
146    /// state-change handler.
147    #[doc(alias = "gst_tag_setter_reset_tags")]
148    fn reset_tags(&self) {
149        unsafe {
150            ffi::gst_tag_setter_reset_tags(self.as_ref().to_glib_none().0);
151        }
152    }
153
154    /// Sets the given merge mode that is used for adding tags from events to tags
155    /// specified by this interface. The default is [`TagMergeMode::Keep`][crate::TagMergeMode::Keep], which keeps
156    /// the tags set with this interface and discards tags from events.
157    /// ## `mode`
158    /// The mode with which tags are added
159    #[doc(alias = "gst_tag_setter_set_tag_merge_mode")]
160    fn set_tag_merge_mode(&self, mode: TagMergeMode) {
161        unsafe {
162            ffi::gst_tag_setter_set_tag_merge_mode(
163                self.as_ref().to_glib_none().0,
164                mode.into_glib(),
165            );
166        }
167    }
168}
169
170impl<O: IsA<TagSetter>> TagSetterExt for O {}