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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use Caps;
use Object;
use PluginFeature;
use ffi;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
    /// These functions allow querying informations 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
    ///
    /// [`PluginFeatureExt`](trait.PluginFeatureExt.html), [`GstObjectExt`](trait.GstObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct TypeFindFactory(Object<ffi::GstTypeFindFactory, ffi::GstTypeFindFactoryClass>): PluginFeature, Object;

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

impl TypeFindFactory {
    //pub fn call_function(&self, find: /*Ignored*/&mut TypeFind) {
    //    unsafe { TODO: call ffi::gst_type_find_factory_call_function() }
    //}

    /// Gets the `Caps` associated with a typefind factory.
    ///
    /// # Returns
    ///
    /// the `Caps` associated with this factory
    pub fn get_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 `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
    pub fn get_extensions(&self) -> Vec<String> {
        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`
    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 `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 `TypeFindFactory`.
    pub fn get_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 {}