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
// 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::Caps;
use crate::Object;
use crate::PluginFeature;
use glib::translate::*;

glib::wrapper! {
    /// These functions allow querying information about registered typefind
    /// functions. How to create and register these functions is described in
    /// the section <link linkend="gstreamer-Writing-typefind-functions">
    /// "Writing typefind functions"`</link>`.
    ///
    /// The following example shows how to write a very simple typefinder that
    /// identifies the given data. You can get quite a bit more complicated than
    /// that though.
    ///
    /// ```C
    ///   typedef struct {
    ///     guint8 *data;
    ///     guint size;
    ///     guint probability;
    ///     GstCaps *data;
    ///   } MyTypeFind;
    ///   static void
    ///   my_peek (gpointer data, gint64 offset, guint size)
    ///   {
    ///     MyTypeFind *find = (MyTypeFind *) data;
    ///     if (offset &gt;= 0 &amp;&amp; offset + size &lt;= find->size) {
    ///       return find->data + offset;
    ///     }
    ///     return NULL;
    ///   }
    ///   static void
    ///   my_suggest (gpointer data, guint probability, GstCaps *caps)
    ///   {
    ///     MyTypeFind *find = (MyTypeFind *) data;
    ///     if (probability &gt; find->probability) {
    ///       find->probability = probability;
    ///       gst_caps_replace (&amp;find->caps, caps);
    ///     }
    ///   }
    ///   static GstCaps *
    ///   find_type (guint8 *data, guint size)
    ///   {
    ///     GList *walk, *type_list;
    ///     MyTypeFind find = {data, size, 0, NULL};
    ///     GstTypeFind gst_find = {my_peek, my_suggest, &amp;find, };
    ///     walk = type_list = gst_type_find_factory_get_list ();
    ///     while (walk) {
    ///       GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
    ///       walk = g_list_next (walk)
    ///       gst_type_find_factory_call_function (factory, &amp;gst_find);
    ///     }
    ///     g_list_free (type_list);
    ///     return find.caps;
    ///   };
    /// ```
    ///
    /// # Implements
    ///
    /// [`trait@crate::prelude::PluginFeatureExt`], [`trait@crate::prelude::GstObjectExt`], [`trait@glib::object::ObjectExt`], [`trait@crate::prelude::PluginFeatureExtManual`]
    pub struct TypeFindFactory(Object<ffi::GstTypeFindFactory, ffi::GstTypeFindFactoryClass>) @extends PluginFeature, Object;

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

impl TypeFindFactory {
    //#[doc(alias = "gst_type_find_factory_call_function")]
    //pub fn call_function(&self, find: /*Ignored*/&mut TypeFind) {
    //    unsafe { TODO: call ffi:gst_type_find_factory_call_function() }
    //}

    /// Gets the [`crate::Caps`] associated with a typefind factory.
    ///
    /// # Returns
    ///
    /// the [`crate::Caps`] associated with this factory
    #[doc(alias = "gst_type_find_factory_get_caps")]
    #[doc(alias = "get_caps")]
    pub fn caps(&self) -> Option<Caps> {
        unsafe { from_glib_none(ffi::gst_type_find_factory_get_caps(self.to_glib_none().0)) }
    }

    /// Gets the extensions associated with a [`crate::TypeFindFactory`]. The returned
    /// array should not be changed. If you need to change stuff in it, you should
    /// copy it using `g_strdupv()`. This function may return [`None`] to indicate
    /// a 0-length list.
    ///
    /// # Returns
    ///
    ///
    ///  a [`None`]-terminated array of extensions associated with this factory
    #[doc(alias = "gst_type_find_factory_get_extensions")]
    #[doc(alias = "get_extensions")]
    pub fn extensions(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gst_type_find_factory_get_extensions(
                self.to_glib_none().0,
            ))
        }
    }

    /// Check whether the factory has a typefind function. Typefind factories
    /// without typefind functions are a last-effort fallback mechanism to
    /// e.g. assume a certain media type based on the file extension.
    ///
    /// # Returns
    ///
    /// [`true`] if the factory has a typefind functions set, otherwise [`false`]
    #[doc(alias = "gst_type_find_factory_has_function")]
    pub fn has_function(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_type_find_factory_has_function(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the list of all registered typefind factories. You must free the
    /// list using [`crate::PluginFeature::list_free()`].
    ///
    /// The returned factories are sorted by highest rank first, and then by
    /// factory name.
    ///
    /// Free-function: gst_plugin_feature_list_free
    ///
    /// # Returns
    ///
    /// the list of all
    ///  registered [`crate::TypeFindFactory`].
    #[doc(alias = "gst_type_find_factory_get_list")]
    #[doc(alias = "get_list")]
    pub fn list() -> Vec<TypeFindFactory> {
        assert_initialized_main_thread!();
        unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_type_find_factory_get_list()) }
    }
}

unsafe impl Send for TypeFindFactory {}
unsafe impl Sync for TypeFindFactory {}