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