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.GStreamer;
26 
27 private import glib.ErrorG;
28 private import glib.GException;
29 private import glib.OptionGroup;
30 private import glib.Str;
31 private import gstreamer.c.functions;
32 public  import gstreamer.c.types;
33 public  import gstreamerc.gstreamertypes;
34 
35 
36 /** */
37 public struct GStreamer
38 {
39 
40 	/**
41 	 * Clean up any resources created by GStreamer in gst_init().
42 	 *
43 	 * It is normally not needed to call this function in a normal application
44 	 * as the resources will automatically be freed when the program terminates.
45 	 * This function is therefore mostly used by testsuites and other memory
46 	 * profiling tools.
47 	 *
48 	 * After this call GStreamer (including this method) should not be used anymore.
49 	 */
50 	public static void deinit()
51 	{
52 		gst_deinit();
53 	}
54 
55 	/**
56 	 * Initializes the GStreamer library, setting up internal path lists,
57 	 * registering built-in elements, and loading standard plugins.
58 	 *
59 	 * Unless the plugin registry is disabled at compile time, the registry will be
60 	 * loaded. By default this will also check if the registry cache needs to be
61 	 * updated and rescan all plugins if needed. See gst_update_registry() for
62 	 * details and section
63 	 * <link linkend="gst-running">Running GStreamer Applications</link>
64 	 * for how to disable automatic registry updates.
65 	 *
66 	 * > This function will terminate your program if it was unable to initialize
67 	 * > GStreamer for some reason.  If you want your program to fall back,
68 	 * > use gst_init_check() instead.
69 	 *
70 	 * WARNING: This function does not work in the same way as corresponding
71 	 * functions in other glib-style libraries, such as gtk_init\(\). In
72 	 * particular, unknown command line options cause this function to
73 	 * abort program execution.
74 	 *
75 	 * Params:
76 	 *     argv = pointer to application's argv
77 	 */
78 	public static void init(ref string[] argv)
79 	{
80 		int argc = cast(int)argv.length;
81 		char** outargv = Str.toStringzArray(argv);
82 
83 		gst_init(&argc, &outargv);
84 
85 		argv = Str.toStringArray(outargv, argc);
86 	}
87 
88 	/**
89 	 * Initializes the GStreamer library, setting up internal path lists,
90 	 * registering built-in elements, and loading standard plugins.
91 	 *
92 	 * This function will return %FALSE if GStreamer could not be initialized
93 	 * for some reason.  If you want your program to fail fatally,
94 	 * use gst_init() instead.
95 	 *
96 	 * Params:
97 	 *     argv = pointer to application's argv
98 	 *
99 	 * Returns: %TRUE if GStreamer could be initialized.
100 	 *
101 	 * Throws: GException on failure.
102 	 */
103 	public static bool initCheck(ref string[] argv)
104 	{
105 		int argc = cast(int)argv.length;
106 		char** outargv = Str.toStringzArray(argv);
107 		GError* err = null;
108 
109 		auto p = gst_init_check(&argc, &outargv, &err) != 0;
110 
111 		if (err !is null)
112 		{
113 			throw new GException( new ErrorG(err) );
114 		}
115 
116 		argv = Str.toStringArray(outargv, argc);
117 
118 		return p;
119 	}
120 
121 	/**
122 	 * Returns a #GOptionGroup with GStreamer's argument specifications. The
123 	 * group is set up to use standard GOption callbacks, so when using this
124 	 * group in combination with GOption parsing methods, all argument parsing
125 	 * and initialization is automated.
126 	 *
127 	 * This function is useful if you want to integrate GStreamer with other
128 	 * libraries that use GOption (see g_option_context_add_group() ).
129 	 *
130 	 * If you use this function, you should make sure you initialise the GLib
131 	 * threading system as one of the very first things in your program
132 	 * (see the example at the beginning of this section).
133 	 *
134 	 * Returns: a pointer to GStreamer's option group.
135 	 */
136 	public static OptionGroup initGetOptionGroup()
137 	{
138 		auto p = gst_init_get_option_group();
139 
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 
145 		return new OptionGroup(cast(GOptionGroup*) p, true);
146 	}
147 
148 	/**
149 	 * Use this function to check if GStreamer has been initialized with gst_init()
150 	 * or gst_init_check().
151 	 *
152 	 * Returns: %TRUE if initialization has been done, %FALSE otherwise.
153 	 */
154 	public static bool isInitialized()
155 	{
156 		return gst_is_initialized() != 0;
157 	}
158 
159 	/**
160 	 * Some functions in the GStreamer core might install a custom SIGSEGV handler
161 	 * to better catch and report errors to the application. Currently this feature
162 	 * is enabled by default when loading plugins.
163 	 *
164 	 * Applications might want to disable this behaviour with the
165 	 * gst_segtrap_set_enabled() function. This is typically done if the application
166 	 * wants to install its own handler without GStreamer interfering.
167 	 *
168 	 * Returns: %TRUE if GStreamer is allowed to install a custom SIGSEGV handler.
169 	 */
170 	public static bool segtrapIsEnabled()
171 	{
172 		return gst_segtrap_is_enabled() != 0;
173 	}
174 
175 	/**
176 	 * Applications might want to disable/enable the SIGSEGV handling of
177 	 * the GStreamer core. See gst_segtrap_is_enabled() for more information.
178 	 *
179 	 * Params:
180 	 *     enabled = whether a custom SIGSEGV handler should be installed.
181 	 */
182 	public static void segtrapSetEnabled(bool enabled)
183 	{
184 		gst_segtrap_set_enabled(enabled);
185 	}
186 
187 	/**
188 	 * Forces GStreamer to re-scan its plugin paths and update the default
189 	 * plugin registry.
190 	 *
191 	 * Applications will almost never need to call this function, it is only
192 	 * useful if the application knows new plugins have been installed (or old
193 	 * ones removed) since the start of the application (or, to be precise, the
194 	 * first call to gst_init()) and the application wants to make use of any
195 	 * newly-installed plugins without restarting the application.
196 	 *
197 	 * Applications should assume that the registry update is neither atomic nor
198 	 * thread-safe and should therefore not have any dynamic pipelines running
199 	 * (including the playbin and decodebin elements) and should also not create
200 	 * any elements or access the GStreamer registry while the update is in
201 	 * progress.
202 	 *
203 	 * Note that this function may block for a significant amount of time.
204 	 *
205 	 * Returns: %TRUE if the registry has been updated successfully (does not
206 	 *     imply that there were changes), otherwise %FALSE.
207 	 */
208 	public static bool updateRegistry()
209 	{
210 		return gst_update_registry() != 0;
211 	}
212 
213 	/**
214 	 * Gets the version number of the GStreamer library.
215 	 *
216 	 * Params:
217 	 *     major = pointer to a guint to store the major version number
218 	 *     minor = pointer to a guint to store the minor version number
219 	 *     micro = pointer to a guint to store the micro version number
220 	 *     nano = pointer to a guint to store the nano version number
221 	 */
222 	public static void versio(out uint major, out uint minor, out uint micro, out uint nano)
223 	{
224 		gst_version(&major, &minor, &micro, &nano);
225 	}
226 
227 	/**
228 	 * This function returns a string that is useful for describing this version
229 	 * of GStreamer to the outside world: user agent strings, logging, ...
230 	 *
231 	 * Returns: a newly allocated string describing this version
232 	 *     of GStreamer.
233 	 */
234 	public static string versionString()
235 	{
236 		auto retStr = gst_version_string();
237 
238 		scope(exit) Str.freeString(retStr);
239 		return Str.toString(retStr);
240 	}
241 }