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