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  * Conversion parameters:
26  * inFile  = GstPlugin.html
27  * outPack = gstreamer
28  * outFile = Plugin
29  * strct   = GstPlugin
30  * realStrct=
31  * ctorStrct=
32  * clss    = Plugin
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_plugin_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- glib.ListG
50  * 	- gstreamer.Structure
51  * structWrap:
52  * 	- GList* -> ListG
53  * 	- GstPlugin* -> Plugin
54  * 	- GstStructure* -> Structure
55  * module aliases:
56  * local aliases:
57  * overrides:
58  * 	- getName
59  */
60 
61 module gstreamer.Plugin;
62 
63 public  import gstreamerc.gstreamertypes;
64 
65 private import gstreamerc.gstreamer;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 private import glib.Str;
70 private import glib.ErrorG;
71 private import glib.GException;
72 private import glib.ListG;
73 private import gstreamer.Structure;
74 
75 
76 private import gstreamer.ObjectGst;
77 
78 /**
79  * GStreamer is extensible, so GstElement instances can be loaded at runtime.
80  * A plugin system can provide one or more of the basic
81  * GStreamer GstPluginFeature subclasses.
82  *
83  * A plugin should export a symbol gst_plugin_desc that is a
84  * struct of type GstPluginDesc.
85  * the plugin loader will check the version of the core library the plugin was
86  * linked against and will create a new GstPlugin. It will then call the
87  * GstPluginInitFunc function that was provided in the
88  * gst_plugin_desc.
89  *
90  * Once you have a handle to a GstPlugin (e.g. from the GstRegistry), you
91  * can add any object that subclasses GstPluginFeature.
92  *
93  * Usually plugins are always automaticlly loaded so you don't need to call
94  * gst_plugin_load() explicitly to bring it into memory. There are options to
95  * statically link plugins to an app or even use GStreamer without a plugin
96  * repository in which case gst_plugin_load() can be needed to bring the plugin
97  * into memory.
98  */
99 public class Plugin : ObjectGst
100 {
101 	
102 	/** the main Gtk struct */
103 	protected GstPlugin* gstPlugin;
104 	
105 	
106 	/** Get the main Gtk struct */
107 	public GstPlugin* getPluginStruct()
108 	{
109 		return gstPlugin;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gstPlugin;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GstPlugin* gstPlugin)
123 	{
124 		super(cast(GstObject*)gstPlugin);
125 		this.gstPlugin = gstPlugin;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gstPlugin = cast(GstPlugin*)obj;
132 	}
133 	
134 	/**
135 	 */
136 	
137 	/**
138 	 * Get the error quark.
139 	 * Returns: The error quark used in GError messages
140 	 */
141 	public static GQuark errorQuark()
142 	{
143 		// GQuark gst_plugin_error_quark (void);
144 		return gst_plugin_error_quark();
145 	}
146 	
147 	/**
148 	 * Get the short name of the plugin
149 	 * Returns: the name of the plugin
150 	 */
151 	public override string getName()
152 	{
153 		// const gchar * gst_plugin_get_name (GstPlugin *plugin);
154 		return Str.toString(gst_plugin_get_name(gstPlugin));
155 	}
156 	
157 	/**
158 	 * Get the long descriptive name of the plugin
159 	 * Returns: the long name of the plugin
160 	 */
161 	public string getDescription()
162 	{
163 		// const gchar * gst_plugin_get_description (GstPlugin *plugin);
164 		return Str.toString(gst_plugin_get_description(gstPlugin));
165 	}
166 	
167 	/**
168 	 * get the filename of the plugin
169 	 * Returns: the filename of the plugin
170 	 */
171 	public string getFilename()
172 	{
173 		// const gchar * gst_plugin_get_filename (GstPlugin *plugin);
174 		return Str.toString(gst_plugin_get_filename(gstPlugin));
175 	}
176 	
177 	/**
178 	 * get the license of the plugin
179 	 * Returns: the license of the plugin
180 	 */
181 	public string getLicense()
182 	{
183 		// const gchar * gst_plugin_get_license (GstPlugin *plugin);
184 		return Str.toString(gst_plugin_get_license(gstPlugin));
185 	}
186 	
187 	/**
188 	 * get the package the plugin belongs to.
189 	 * Returns: the package of the plugin
190 	 */
191 	public string getPackage()
192 	{
193 		// const gchar * gst_plugin_get_package (GstPlugin *plugin);
194 		return Str.toString(gst_plugin_get_package(gstPlugin));
195 	}
196 	
197 	/**
198 	 * get the URL where the plugin comes from
199 	 * Returns: the origin of the plugin
200 	 */
201 	public string getOrigin()
202 	{
203 		// const gchar * gst_plugin_get_origin (GstPlugin *plugin);
204 		return Str.toString(gst_plugin_get_origin(gstPlugin));
205 	}
206 	
207 	/**
208 	 * get the source module the plugin belongs to.
209 	 * Returns: the source of the plugin
210 	 */
211 	public string getSource()
212 	{
213 		// const gchar * gst_plugin_get_source (GstPlugin *plugin);
214 		return Str.toString(gst_plugin_get_source(gstPlugin));
215 	}
216 	
217 	/**
218 	 * get the version of the plugin
219 	 * Returns: the version of the plugin
220 	 */
221 	public string getVersion()
222 	{
223 		// const gchar * gst_plugin_get_version (GstPlugin *plugin);
224 		return Str.toString(gst_plugin_get_version(gstPlugin));
225 	}
226 	
227 	/**
228 	 * Get the release date (and possibly time) in form of a string, if available.
229 	 * For normal GStreamer plugin releases this will usually just be a date in
230 	 * the form of "YYYY-MM-DD", while pre-releases and builds from git may contain
231 	 * a time component after the date as well, in which case the string will be
232 	 * formatted like "YYYY-MM-DDTHH:MMZ" (e.g. "2012-04-30T09:30Z").
233 	 * There may be plugins that do not have a valid release date set on them.
234 	 * Returns: the date string of the plugin, or NULL if not available.
235 	 */
236 	public string getReleaseDateString()
237 	{
238 		// const gchar * gst_plugin_get_release_date_string (GstPlugin *plugin);
239 		return Str.toString(gst_plugin_get_release_date_string(gstPlugin));
240 	}
241 	
242 	/**
243 	 * queries if the plugin is loaded into memory
244 	 * Returns: TRUE is loaded, FALSE otherwise
245 	 */
246 	public int isLoaded()
247 	{
248 		// gboolean gst_plugin_is_loaded (GstPlugin *plugin);
249 		return gst_plugin_is_loaded(gstPlugin);
250 	}
251 	
252 	/**
253 	 * Gets the plugin specific data cache. If it is NULL there is no cached data
254 	 * stored. This is the case when the registry is getting rebuilt.
255 	 * Returns: The cached data as a GstStructure or NULL. [transfer none]
256 	 */
257 	public Structure getCacheData()
258 	{
259 		// const GstStructure * gst_plugin_get_cache_data (GstPlugin *plugin);
260 		auto p = gst_plugin_get_cache_data(gstPlugin);
261 		
262 		if(p is null)
263 		{
264 			return null;
265 		}
266 		
267 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
268 	}
269 	
270 	/**
271 	 * Adds plugin specific data to cache. Passes the ownership of the structure to
272 	 * the plugin.
273 	 * The cache is flushed every time the registry is rebuilt.
274 	 * Params:
275 	 * cacheData = a structure containing the data to cache. [transfer full]
276 	 */
277 	public void setCacheData(Structure cacheData)
278 	{
279 		// void gst_plugin_set_cache_data (GstPlugin *plugin,  GstStructure *cache_data);
280 		gst_plugin_set_cache_data(gstPlugin, (cacheData is null) ? null : cacheData.getStructureStruct());
281 	}
282 	
283 	/**
284 	 * Loads the given plugin and refs it. Caller needs to unref after use.
285 	 * Params:
286 	 * filename = the plugin filename to load
287 	 * Returns: a reference to the existing loaded GstPlugin, a reference to the newly-loaded GstPlugin, or NULL if an error occurred. [transfer full]
288 	 * Throws: GException on failure.
289 	 */
290 	public static Plugin loadFile(string filename)
291 	{
292 		// GstPlugin * gst_plugin_load_file (const gchar *filename,  GError **error);
293 		GError* err = null;
294 		
295 		auto p = gst_plugin_load_file(Str.toStringz(filename), &err);
296 		
297 		if (err !is null)
298 		{
299 			throw new GException( new ErrorG(err) );
300 		}
301 		
302 		
303 		if(p is null)
304 		{
305 			return null;
306 		}
307 		
308 		return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p);
309 	}
310 	
311 	/**
312 	 * Loads plugin. Note that the *return value* is the loaded plugin; plugin is
313 	 * Returns: a reference to a loaded plugin, or NULL on error. [transfer full]
314 	 */
315 	public Plugin load()
316 	{
317 		// GstPlugin * gst_plugin_load (GstPlugin *plugin);
318 		auto p = gst_plugin_load(gstPlugin);
319 		
320 		if(p is null)
321 		{
322 			return null;
323 		}
324 		
325 		return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p);
326 	}
327 	
328 	/**
329 	 * Load the named plugin. Refs the plugin.
330 	 * Params:
331 	 * name = name of plugin to load
332 	 * Returns: a reference to a loaded plugin, or NULL on error. [transfer full]
333 	 */
334 	public static Plugin loadByName(string name)
335 	{
336 		// GstPlugin * gst_plugin_load_by_name (const gchar *name);
337 		auto p = gst_plugin_load_by_name(Str.toStringz(name));
338 		
339 		if(p is null)
340 		{
341 			return null;
342 		}
343 		
344 		return ObjectG.getDObject!(Plugin)(cast(GstPlugin*) p);
345 	}
346 	
347 	/**
348 	 * Unrefs each member of list, then frees the list.
349 	 * Params:
350 	 * list = list of GstPlugin. [transfer full][element-type Gst.Plugin]
351 	 */
352 	public static void listFree(ListG list)
353 	{
354 		// void gst_plugin_list_free (GList *list);
355 		gst_plugin_list_free((list is null) ? null : list.getListGStruct());
356 	}
357 	
358 	/**
359 	 * Registers a static plugin, ie. a plugin which is private to an application
360 	 * or library and contained within the application or library (as opposed to
361 	 * being shipped as a separate module file).
362 	 * You must make sure that GStreamer has been initialised (with gst_init() or
363 	 * via gst_init_get_option_group()) before calling this function.
364 	 * Params:
365 	 * majorVersion = the major version number of the GStreamer core that the
366 	 * plugin was compiled for, you can just use GST_VERSION_MAJOR here
367 	 * minorVersion = the minor version number of the GStreamer core that the
368 	 * plugin was compiled for, you can just use GST_VERSION_MINOR here
369 	 * name = a unique name of the plugin (ideally prefixed with an application- or
370 	 * library-specific namespace prefix in order to avoid name conflicts in
371 	 * case a similar plugin with the same name ever gets added to GStreamer)
372 	 * description = description of the plugin
373 	 * initFunc = pointer to the init function of this plugin. [scope call]
374 	 * license = effective license of plugin. Must be one of the approved licenses
375 	 * (see GstPluginDesc above) or the plugin will not be registered.
376 	 * source = source module plugin belongs to
377 	 * origin = URL to provider of plugin
378 	 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE.
379 	 */
380 	public static int registerStatic(int majorVersion, int minorVersion, string name, string description, GstPluginInitFunc initFunc, string versio, string license, string source, string p, string origin)
381 	{
382 		// gboolean gst_plugin_register_static (gint major_version,  gint minor_version,  const gchar *name,  const gchar *description,  GstPluginInitFunc init_func,  const gchar *version,  const gchar *license,  const gchar *source,  const gchar *package,  const gchar *origin);
383 		return gst_plugin_register_static(majorVersion, minorVersion, Str.toStringz(name), Str.toStringz(description), initFunc, Str.toStringz(versio), Str.toStringz(license), Str.toStringz(source), Str.toStringz(p), Str.toStringz(origin));
384 	}
385 	
386 	/**
387 	 * Registers a static plugin, ie. a plugin which is private to an application
388 	 * or library and contained within the application or library (as opposed to
389 	 * being shipped as a separate module file) with a GstPluginInitFullFunc
390 	 * which allows user data to be passed to the callback function (useful
391 	 * for bindings).
392 	 * You must make sure that GStreamer has been initialised (with gst_init() or
393 	 * via gst_init_get_option_group()) before calling this function.
394 	 * Params:
395 	 * majorVersion = the major version number of the GStreamer core that the
396 	 * plugin was compiled for, you can just use GST_VERSION_MAJOR here
397 	 * minorVersion = the minor version number of the GStreamer core that the
398 	 * plugin was compiled for, you can just use GST_VERSION_MINOR here
399 	 * name = a unique name of the plugin (ideally prefixed with an application- or
400 	 * library-specific namespace prefix in order to avoid name conflicts in
401 	 * case a similar plugin with the same name ever gets added to GStreamer)
402 	 * description = description of the plugin
403 	 * initFullFunc = pointer to the init function with user data
404 	 * of this plugin. [scope call]
405 	 * license = effective license of plugin. Must be one of the approved licenses
406 	 * (see GstPluginDesc above) or the plugin will not be registered.
407 	 * source = source module plugin belongs to
408 	 * origin = URL to provider of plugin
409 	 * userData = gpointer to user data
410 	 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE.
411 	 */
412 	public static int registerStaticFull(int majorVersion, int minorVersion, string name, string description, GstPluginInitFullFunc initFullFunc, string versio, string license, string source, string p, string origin, void* userData)
413 	{
414 		// gboolean gst_plugin_register_static_full (gint major_version,  gint minor_version,  const gchar *name,  const gchar *description,  GstPluginInitFullFunc init_full_func,  const gchar *version,  const gchar *license,  const gchar *source,  const gchar *package,  const gchar *origin,  gpointer user_data);
415 		return gst_plugin_register_static_full(majorVersion, minorVersion, Str.toStringz(name), Str.toStringz(description), initFullFunc, Str.toStringz(versio), Str.toStringz(license), Str.toStringz(source), Str.toStringz(p), Str.toStringz(origin), userData);
416 	}
417 	
418 	/**
419 	 * Make GStreamer aware of external dependencies which affect the feature
420 	 * set of this plugin (ie. the elements or typefinders associated with it).
421 	 * GStreamer will re-inspect plugins with external dependencies whenever any
422 	 * of the external dependencies change. This is useful for plugins which wrap
423 	 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
424 	 * library and makes visualisations available as GStreamer elements, or a
425 	 * codec loader which exposes elements and/or caps dependent on what external
426 	 * codec libraries are currently installed.
427 	 * Params:
428 	 * envVars = NULL-terminated array of environment variables affecting the
429 	 * feature set of the plugin (e.g. an environment variable containing
430 	 * paths where to look for additional modules/plugins of a library),
431 	 * or NULL. Environment variable names may be followed by a path component
432 	 * which will be added to the content of the environment variable, e.g.
433 	 * "HOME/.mystuff/plugins". [allow-none]
434 	 * paths = NULL-terminated array of directories/paths where dependent files
435 	 * may be, or NULL. [allow-none]
436 	 * names = NULL-terminated array of file names (or file name suffixes,
437 	 * depending on flags) to be used in combination with the paths from
438 	 * paths and/or the paths extracted from the environment variables in
439 	 * env_vars, or NULL. [allow-none]
440 	 * flags = optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE
441 	 */
442 	public void addDependency(string[] envVars, string[] paths, string[] names, GstPluginDependencyFlags flags)
443 	{
444 		// void gst_plugin_add_dependency (GstPlugin *plugin,  const gchar **env_vars,  const gchar **paths,  const gchar **names,  GstPluginDependencyFlags flags);
445 		gst_plugin_add_dependency(gstPlugin, Str.toStringzArray(envVars), Str.toStringzArray(paths), Str.toStringzArray(names), flags);
446 	}
447 	
448 	/**
449 	 * Make GStreamer aware of external dependencies which affect the feature
450 	 * set of this plugin (ie. the elements or typefinders associated with it).
451 	 * GStreamer will re-inspect plugins with external dependencies whenever any
452 	 * of the external dependencies change. This is useful for plugins which wrap
453 	 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
454 	 * library and makes visualisations available as GStreamer elements, or a
455 	 * codec loader which exposes elements and/or caps dependent on what external
456 	 * codec libraries are currently installed.
457 	 * Convenience wrapper function for gst_plugin_add_dependency() which
458 	 * takes simple strings as arguments instead of string arrays, with multiple
459 	 * arguments separated by predefined delimiters (see above).
460 	 * Params:
461 	 * envVars = one or more environment variables (separated by ':', ';' or ','),
462 	 * or NULL. Environment variable names may be followed by a path component
463 	 * which will be added to the content of the environment variable, e.g.
464 	 * "HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH". [allow-none]
465 	 * paths = one ore more directory paths (separated by ':' or ';' or ','),
466 	 * or NULL. Example: "/usr/lib/mystuff/plugins". [allow-none]
467 	 * names = one or more file names or file name suffixes (separated by commas),
468 	 * or NULL. [allow-none]
469 	 * flags = optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE
470 	 */
471 	public void addDependencySimple(string envVars, string paths, string names, GstPluginDependencyFlags flags)
472 	{
473 		// void gst_plugin_add_dependency_simple (GstPlugin *plugin,  const gchar *env_vars,  const gchar *paths,  const gchar *names,  GstPluginDependencyFlags flags);
474 		gst_plugin_add_dependency_simple(gstPlugin, Str.toStringz(envVars), Str.toStringz(paths), Str.toStringz(names), flags);
475 	}
476 }