1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gstreamer.TypeFindFactory; 26 27 private import glib.ListG; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gstreamer.Caps; 31 private import gstreamer.PluginFeature; 32 private import gstreamer.TypeFind; 33 private import gstreamer.c.functions; 34 public import gstreamer.c.types; 35 public import gstreamerc.gstreamertypes; 36 37 38 /** 39 * These functions allow querying information about registered typefind 40 * functions. How to create and register these functions is described in 41 * the section <link linkend="gstreamer-Writing-typefind-functions"> 42 * "Writing typefind functions"</link>. 43 * 44 * The following example shows how to write a very simple typefinder that 45 * identifies the given data. You can get quite a bit more complicated than 46 * that though. 47 * |[<!-- language="C" --> 48 * typedef struct { 49 * guint8 *data; 50 * guint size; 51 * guint probability; 52 * GstCaps *data; 53 * } MyTypeFind; 54 * static void 55 * my_peek (gpointer data, gint64 offset, guint size) 56 * { 57 * MyTypeFind *find = (MyTypeFind *) data; 58 * if (offset >= 0 && offset + size <= find->size) { 59 * return find->data + offset; 60 * } 61 * return NULL; 62 * } 63 * static void 64 * my_suggest (gpointer data, guint probability, GstCaps *caps) 65 * { 66 * MyTypeFind *find = (MyTypeFind *) data; 67 * if (probability > find->probability) { 68 * find->probability = probability; 69 * gst_caps_replace (&find->caps, caps); 70 * } 71 * } 72 * static GstCaps * 73 * find_type (guint8 *data, guint size) 74 * { 75 * GList *walk, *type_list; 76 * MyTypeFind find = {data, size, 0, NULL}; 77 * GstTypeFind gst_find = {my_peek, my_suggest, &find, }; 78 * walk = type_list = gst_type_find_factory_get_list (); 79 * while (walk) { 80 * GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data); 81 * walk = g_list_next (walk) 82 * gst_type_find_factory_call_function (factory, &gst_find); 83 * } 84 * g_list_free (type_list); 85 * return find.caps; 86 * }; 87 * ]| 88 */ 89 public class TypeFindFactory : PluginFeature 90 { 91 /** the main Gtk struct */ 92 protected GstTypeFindFactory* gstTypeFindFactory; 93 94 /** Get the main Gtk struct */ 95 public GstTypeFindFactory* getTypeFindFactoryStruct(bool transferOwnership = false) 96 { 97 if (transferOwnership) 98 ownedRef = false; 99 return gstTypeFindFactory; 100 } 101 102 /** the main Gtk struct as a void* */ 103 protected override void* getStruct() 104 { 105 return cast(void*)gstTypeFindFactory; 106 } 107 108 /** 109 * Sets our main struct and passes it to the parent class. 110 */ 111 public this (GstTypeFindFactory* gstTypeFindFactory, bool ownedRef = false) 112 { 113 this.gstTypeFindFactory = gstTypeFindFactory; 114 super(cast(GstPluginFeature*)gstTypeFindFactory, ownedRef); 115 } 116 117 118 /** */ 119 public static GType getType() 120 { 121 return gst_type_find_factory_get_type(); 122 } 123 124 /** 125 * Gets the list of all registered typefind factories. You must free the 126 * list using gst_plugin_feature_list_free(). 127 * 128 * The returned factories are sorted by highest rank first, and then by 129 * factory name. 130 * 131 * Free-function: gst_plugin_feature_list_free 132 * 133 * Returns: the list of all 134 * registered #GstTypeFindFactory. 135 */ 136 public static ListG getList() 137 { 138 auto p = gst_type_find_factory_get_list(); 139 140 if(p is null) 141 { 142 return null; 143 } 144 145 return new ListG(cast(GList*) p, true); 146 } 147 148 /** 149 * Calls the #GstTypeFindFunction associated with this factory. 150 * 151 * Params: 152 * find = a properly setup #GstTypeFind entry. The get_data 153 * and suggest_type members must be set. 154 */ 155 public void callFunction(TypeFind find) 156 { 157 gst_type_find_factory_call_function(gstTypeFindFactory, (find is null) ? null : find.getTypeFindStruct()); 158 } 159 160 /** 161 * Gets the #GstCaps associated with a typefind factory. 162 * 163 * Returns: the #GstCaps associated with this factory 164 */ 165 public Caps getCaps() 166 { 167 auto p = gst_type_find_factory_get_caps(gstTypeFindFactory); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 175 } 176 177 /** 178 * Gets the extensions associated with a #GstTypeFindFactory. The returned 179 * array should not be changed. If you need to change stuff in it, you should 180 * copy it using g_strdupv(). This function may return %NULL to indicate 181 * a 0-length list. 182 * 183 * Returns: a %NULL-terminated array of extensions associated with this factory 184 */ 185 public string[] getExtensions() 186 { 187 return Str.toStringArray(gst_type_find_factory_get_extensions(gstTypeFindFactory)); 188 } 189 190 /** 191 * Check whether the factory has a typefind function. Typefind factories 192 * without typefind functions are a last-effort fallback mechanism to 193 * e.g. assume a certain media type based on the file extension. 194 * 195 * Returns: %TRUE if the factory has a typefind functions set, otherwise %FALSE 196 */ 197 public bool hasFunction() 198 { 199 return gst_type_find_factory_has_function(gstTypeFindFactory) != 0; 200 } 201 }