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