1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::Element;
use crate::Object;
use crate::TagList;
use crate::TagMergeMode;
use glib::object::IsA;
use glib::translate::*;

glib::wrapper! {
    /// Element interface that allows setting of media metadata.
    ///
    /// Elements that support changing a stream's metadata will implement this
    /// interface. Examples of such elements are 'vorbisenc', 'theoraenc' and
    /// 'id3v2mux'.
    ///
    /// If you just want to retrieve metadata in your application then all you
    /// need to do is watch for tag messages on your pipeline's bus. This
    /// interface is only for setting metadata, not for extracting it. To set tags
    /// from the application, find tagsetter elements and set tags using e.g.
    /// [`TagSetterExt::merge_tags()`][crate::prelude::TagSetterExt::merge_tags()] or `gst_tag_setter_add_tags()`. Also consider
    /// setting the [`TagMergeMode`][crate::TagMergeMode] that is used for tag events that arrive at the
    /// tagsetter element (default mode is to keep existing tags).
    /// The application should do that before the element goes to [`State::Paused`][crate::State::Paused].
    ///
    /// Elements implementing the [`TagSetter`][crate::TagSetter] interface often have to merge
    /// any tags received from upstream and the tags set by the application via
    /// the interface. This can be done like this:
    ///
    ///
    /// ```C
    /// GstTagMergeMode merge_mode;
    /// const GstTagList *application_tags;
    /// const GstTagList *event_tags;
    /// GstTagSetter *tagsetter;
    /// GstTagList *result;
    ///
    /// tagsetter = GST_TAG_SETTER (element);
    ///
    /// merge_mode = gst_tag_setter_get_tag_merge_mode (tagsetter);
    /// application_tags = gst_tag_setter_get_tag_list (tagsetter);
    /// event_tags = (const GstTagList *) element->event_tags;
    ///
    /// GST_LOG_OBJECT (tagsetter, "merging tags, merge mode = %d", merge_mode);
    /// GST_LOG_OBJECT (tagsetter, "event tags: %" GST_PTR_FORMAT, event_tags);
    /// GST_LOG_OBJECT (tagsetter, "set   tags: %" GST_PTR_FORMAT, application_tags);
    ///
    /// result = gst_tag_list_merge (application_tags, event_tags, merge_mode);
    ///
    /// GST_LOG_OBJECT (tagsetter, "final tags: %" GST_PTR_FORMAT, result);
    /// ```
    ///
    /// # Implements
    ///
    /// [`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]
    #[doc(alias = "GstTagSetter")]
    pub struct TagSetter(Interface<ffi::GstTagSetter, ffi::GstTagSetterInterface>) @requires Element, Object;

    match fn {
        type_ => || ffi::gst_tag_setter_get_type(),
    }
}

unsafe impl Send for TagSetter {}
unsafe impl Sync for TagSetter {}

pub const NONE_TAG_SETTER: Option<&TagSetter> = None;

/// Trait containing all [`struct@TagSetter`] methods.
///
/// # Implementors
///
/// [`TagSetter`][struct@crate::TagSetter]
pub trait TagSetterExt: 'static {
    //#[doc(alias = "gst_tag_setter_add_tag_valist")]
    //fn add_tag_valist(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    //#[doc(alias = "gst_tag_setter_add_tag_valist_values")]
    //fn add_tag_valist_values(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);

    //#[doc(alias = "gst_tag_setter_add_tag_values")]
    //fn add_tag_values(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    /// Returns the current list of tags the setter uses. The list should not be
    /// modified or freed.
    ///
    /// This function is not thread-safe.
    ///
    /// # Returns
    ///
    /// a current snapshot of the
    ///  taglist used in the setter or [`None`] if none is used.
    #[doc(alias = "gst_tag_setter_get_tag_list")]
    #[doc(alias = "get_tag_list")]
    fn tag_list(&self) -> Option<TagList>;

    /// Queries the mode by which tags inside the setter are overwritten by tags
    /// from events
    ///
    /// # Returns
    ///
    /// the merge mode used inside the element.
    #[doc(alias = "gst_tag_setter_get_tag_merge_mode")]
    #[doc(alias = "get_tag_merge_mode")]
    fn tag_merge_mode(&self) -> TagMergeMode;

    /// Merges the given list into the setter's list using the given mode.
    /// ## `list`
    /// a tag list to merge from
    /// ## `mode`
    /// the mode to merge with
    #[doc(alias = "gst_tag_setter_merge_tags")]
    fn merge_tags(&self, list: &TagList, mode: TagMergeMode);

    /// Reset the internal taglist. Elements should call this from within the
    /// state-change handler.
    #[doc(alias = "gst_tag_setter_reset_tags")]
    fn reset_tags(&self);

    /// Sets the given merge mode that is used for adding tags from events to tags
    /// specified by this interface. The default is [`TagMergeMode::Keep`][crate::TagMergeMode::Keep], which keeps
    /// the tags set with this interface and discards tags from events.
    /// ## `mode`
    /// The mode with which tags are added
    #[doc(alias = "gst_tag_setter_set_tag_merge_mode")]
    fn set_tag_merge_mode(&self, mode: TagMergeMode);
}

impl<O: IsA<TagSetter>> TagSetterExt for O {
    //fn add_tag_valist(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_valist() }
    //}

    //fn add_tag_valist_values(&self, mode: TagMergeMode, tag: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_valist_values() }
    //}

    //fn add_tag_values(&self, mode: TagMergeMode, tag: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi:gst_tag_setter_add_tag_values() }
    //}

    fn tag_list(&self) -> Option<TagList> {
        unsafe {
            from_glib_none(ffi::gst_tag_setter_get_tag_list(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn tag_merge_mode(&self) -> TagMergeMode {
        unsafe {
            from_glib(ffi::gst_tag_setter_get_tag_merge_mode(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn merge_tags(&self, list: &TagList, mode: TagMergeMode) {
        unsafe {
            ffi::gst_tag_setter_merge_tags(
                self.as_ref().to_glib_none().0,
                list.to_glib_none().0,
                mode.into_glib(),
            );
        }
    }

    fn reset_tags(&self) {
        unsafe {
            ffi::gst_tag_setter_reset_tags(self.as_ref().to_glib_none().0);
        }
    }

    fn set_tag_merge_mode(&self, mode: TagMergeMode) {
        unsafe {
            ffi::gst_tag_setter_set_tag_merge_mode(
                self.as_ref().to_glib_none().0,
                mode.into_glib(),
            );
        }
    }
}