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.Debug;
26 
27 private import glib.ListSG;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gstreamer.Bin;
31 private import gstreamer.DebugCategory;
32 private import gstreamer.c.functions;
33 public  import gstreamer.c.types;
34 public  import gstreamerc.gstreamertypes;
35 
36 
37 /** */
38 public struct Debug
39 {
40 
41 	/**
42 	 * Adds the logging function to the list of logging functions.
43 	 * Be sure to use #G_GNUC_NO_INSTRUMENT on that function, it is needed.
44 	 *
45 	 * Params:
46 	 *     func = the function to use
47 	 *     userData = user data
48 	 *     notify = called when @user_data is not used anymore
49 	 */
50 	public static void addLogFunction(GstLogFunction func, void* userData, GDestroyNotify notify)
51 	{
52 		gst_debug_add_log_function(func, userData, notify);
53 	}
54 
55 	/**
56 	 * To aid debugging applications one can use this method to obtain the whole
57 	 * network of gstreamer elements that form the pipeline into an dot file.
58 	 * This data can be processed with graphviz to get an image.
59 	 *
60 	 * Params:
61 	 *     bin = the top-level pipeline that should be analyzed
62 	 *     details = type of #GstDebugGraphDetails to use
63 	 *
64 	 * Returns: a string containing the pipeline in graphviz
65 	 *     dot format.
66 	 */
67 	public static string binToDotData(Bin bin, GstDebugGraphDetails details)
68 	{
69 		auto retStr = gst_debug_bin_to_dot_data((bin is null) ? null : bin.getBinStruct(), details);
70 
71 		scope(exit) Str.freeString(retStr);
72 		return Str.toString(retStr);
73 	}
74 
75 	/**
76 	 * To aid debugging applications one can use this method to write out the whole
77 	 * network of gstreamer elements that form the pipeline into an dot file.
78 	 * This file can be processed with graphviz to get an image.
79 	 * <informalexample><programlisting>
80 	 * dot -Tpng -oimage.png graph_lowlevel.dot
81 	 * </programlisting></informalexample>
82 	 *
83 	 * Params:
84 	 *     bin = the top-level pipeline that should be analyzed
85 	 *     details = type of #GstDebugGraphDetails to use
86 	 *     fileName = output base filename (e.g. "myplayer")
87 	 */
88 	public static void binToDotFile(Bin bin, GstDebugGraphDetails details, string fileName)
89 	{
90 		gst_debug_bin_to_dot_file((bin is null) ? null : bin.getBinStruct(), details, Str.toStringz(fileName));
91 	}
92 
93 	/**
94 	 * This works like gst_debug_bin_to_dot_file(), but adds the current timestamp
95 	 * to the filename, so that it can be used to take multiple snapshots.
96 	 *
97 	 * Params:
98 	 *     bin = the top-level pipeline that should be analyzed
99 	 *     details = type of #GstDebugGraphDetails to use
100 	 *     fileName = output base filename (e.g. "myplayer")
101 	 */
102 	public static void binToDotFileWithTs(Bin bin, GstDebugGraphDetails details, string fileName)
103 	{
104 		gst_debug_bin_to_dot_file_with_ts((bin is null) ? null : bin.getBinStruct(), details, Str.toStringz(fileName));
105 	}
106 
107 	/**
108 	 * Constructs a string that can be used for getting the desired color in color
109 	 * terminals.
110 	 * You need to free the string after use.
111 	 *
112 	 * Params:
113 	 *     colorinfo = the color info
114 	 *
115 	 * Returns: a string containing the color
116 	 *     definition
117 	 */
118 	public static string constructTermColor(uint colorinfo)
119 	{
120 		auto retStr = gst_debug_construct_term_color(colorinfo);
121 
122 		scope(exit) Str.freeString(retStr);
123 		return Str.toString(retStr);
124 	}
125 
126 	/**
127 	 * Constructs an integer that can be used for getting the desired color in
128 	 * windows' terminals (cmd.exe). As there is no mean to underline, we simply
129 	 * ignore this attribute.
130 	 *
131 	 * This function returns 0 on non-windows machines.
132 	 *
133 	 * Params:
134 	 *     colorinfo = the color info
135 	 *
136 	 * Returns: an integer containing the color definition
137 	 */
138 	public static int constructWinColor(uint colorinfo)
139 	{
140 		return gst_debug_construct_win_color(colorinfo);
141 	}
142 
143 	/**
144 	 * Returns a snapshot of a all categories that are currently in use . This list
145 	 * may change anytime.
146 	 * The caller has to free the list after use.
147 	 *
148 	 * Returns: the list of
149 	 *     debug categories
150 	 */
151 	public static ListSG getAllCategories()
152 	{
153 		auto p = gst_debug_get_all_categories();
154 
155 		if(p is null)
156 		{
157 			return null;
158 		}
159 
160 		return new ListSG(cast(GSList*) p);
161 	}
162 
163 	/**
164 	 * Changes the coloring mode for debug output.
165 	 *
166 	 * Returns: see @GstDebugColorMode for possible values.
167 	 *
168 	 * Since: 1.2
169 	 */
170 	public static GstDebugColorMode getColorMode()
171 	{
172 		return gst_debug_get_color_mode();
173 	}
174 
175 	/**
176 	 * Returns the default threshold that is used for new categories.
177 	 *
178 	 * Returns: the default threshold level
179 	 */
180 	public static GstDebugLevel getDefaultThreshold()
181 	{
182 		return gst_debug_get_default_threshold();
183 	}
184 
185 	/**
186 	 * Checks if debugging output is activated.
187 	 *
188 	 * Returns: %TRUE, if debugging is activated
189 	 */
190 	public static bool isActive()
191 	{
192 		return gst_debug_is_active() != 0;
193 	}
194 
195 	/**
196 	 * Checks if the debugging output should be colored.
197 	 *
198 	 * Returns: %TRUE, if the debug output should be colored.
199 	 */
200 	public static bool isColored()
201 	{
202 		return gst_debug_is_colored() != 0;
203 	}
204 
205 	/**
206 	 * Get the string representation of a debugging level
207 	 *
208 	 * Params:
209 	 *     level = the level to get the name for
210 	 *
211 	 * Returns: the name
212 	 */
213 	public static string levelGetName(GstDebugLevel level)
214 	{
215 		return Str.toString(gst_debug_level_get_name(level));
216 	}
217 
218 	/**
219 	 * The default logging handler used by GStreamer. Logging functions get called
220 	 * whenever a macro like GST_DEBUG or similar is used. By default this function
221 	 * is setup to output the message and additional info to stderr (or the log file
222 	 * specified via the GST_DEBUG_FILE environment variable) as received via
223 	 * @user_data.
224 	 *
225 	 * You can add other handlers by using gst_debug_add_log_function().
226 	 * And you can remove this handler by calling
227 	 * gst_debug_remove_log_function(gst_debug_log_default);
228 	 *
229 	 * Params:
230 	 *     category = category to log
231 	 *     level = level of the message
232 	 *     file = the file that emitted the message, usually the __FILE__ identifier
233 	 *     function_ = the function that emitted the message
234 	 *     line = the line from that the message was emitted, usually __LINE__
235 	 *     object = the object this message relates to,
236 	 *         or %NULL if none
237 	 *     message = the actual message
238 	 *     userData = the FILE* to log to
239 	 */
240 	public static void logDefault(DebugCategory category, GstDebugLevel level, string file, string function_, int line, ObjectG object, GstDebugMessage* message, void* userData)
241 	{
242 		gst_debug_log_default((category is null) ? null : category.getDebugCategoryStruct(), level, Str.toStringz(file), Str.toStringz(function_), line, (object is null) ? null : object.getObjectGStruct(), message, userData);
243 	}
244 
245 	/**
246 	 * Logs the given message using the currently registered debugging handlers.
247 	 *
248 	 * Params:
249 	 *     category = category to log
250 	 *     level = level of the message is in
251 	 *     file = the file that emitted the message, usually the __FILE__ identifier
252 	 *     function_ = the function that emitted the message
253 	 *     line = the line from that the message was emitted, usually __LINE__
254 	 *     object = the object this message relates to,
255 	 *         or %NULL if none
256 	 *     format = a printf style format string
257 	 *     args = optional arguments for the format
258 	 */
259 	public static void logValist(DebugCategory category, GstDebugLevel level, string file, string function_, int line, ObjectG object, string format, void* args)
260 	{
261 		gst_debug_log_valist((category is null) ? null : category.getDebugCategoryStruct(), level, Str.toStringz(file), Str.toStringz(function_), line, (object is null) ? null : object.getObjectGStruct(), Str.toStringz(format), args);
262 	}
263 
264 	/**
265 	 * If libunwind, glibc backtrace or DbgHelp are present
266 	 * a stack trace is printed.
267 	 */
268 	public static void printStackTrace()
269 	{
270 		gst_debug_print_stack_trace();
271 	}
272 
273 	/**
274 	 * Removes all registered instances of the given logging functions.
275 	 *
276 	 * Params:
277 	 *     func = the log function to remove, or %NULL to
278 	 *         remove the default log function
279 	 *
280 	 * Returns: How many instances of the function were removed
281 	 */
282 	public static uint removeLogFunction(GstLogFunction func)
283 	{
284 		return gst_debug_remove_log_function(func);
285 	}
286 
287 	/**
288 	 * Removes all registered instances of log functions with the given user data.
289 	 *
290 	 * Params:
291 	 *     data = user data of the log function to remove
292 	 *
293 	 * Returns: How many instances of the function were removed
294 	 */
295 	public static uint removeLogFunctionByData(void* data)
296 	{
297 		return gst_debug_remove_log_function_by_data(data);
298 	}
299 
300 	/**
301 	 * If activated, debugging messages are sent to the debugging
302 	 * handlers.
303 	 * It makes sense to deactivate it for speed issues.
304 	 * > This function is not threadsafe. It makes sense to only call it
305 	 * during initialization.
306 	 *
307 	 * Params:
308 	 *     active = Whether to use debugging output or not
309 	 */
310 	public static void setActive(bool active)
311 	{
312 		gst_debug_set_active(active);
313 	}
314 
315 	/**
316 	 * Changes the coloring mode for debug output.
317 	 *
318 	 * This function may be called before gst_init().
319 	 *
320 	 * Params:
321 	 *     mode = The coloring mode for debug output. See @GstDebugColorMode.
322 	 *
323 	 * Since: 1.2
324 	 */
325 	public static void setColorMode(GstDebugColorMode mode)
326 	{
327 		gst_debug_set_color_mode(mode);
328 	}
329 
330 	/**
331 	 * Changes the coloring mode for debug output.
332 	 *
333 	 * This function may be called before gst_init().
334 	 *
335 	 * Params:
336 	 *     mode = The coloring mode for debug output. One of the following:
337 	 *         "on", "auto", "off", "disable", "unix".
338 	 *
339 	 * Since: 1.2
340 	 */
341 	public static void setColorModeFromString(string mode)
342 	{
343 		gst_debug_set_color_mode_from_string(Str.toStringz(mode));
344 	}
345 
346 	/**
347 	 * Sets or unsets the use of coloured debugging output.
348 	 * Same as gst_debug_set_color_mode () with the argument being
349 	 * being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF.
350 	 *
351 	 * This function may be called before gst_init().
352 	 *
353 	 * Params:
354 	 *     colored = Whether to use colored output or not
355 	 */
356 	public static void setColored(bool colored)
357 	{
358 		gst_debug_set_colored(colored);
359 	}
360 
361 	/**
362 	 * Sets the default threshold to the given level and updates all categories to
363 	 * use this threshold.
364 	 *
365 	 * This function may be called before gst_init().
366 	 *
367 	 * Params:
368 	 *     level = level to set
369 	 */
370 	public static void setDefaultThreshold(GstDebugLevel level)
371 	{
372 		gst_debug_set_default_threshold(level);
373 	}
374 
375 	/**
376 	 * Sets all categories which match the given glob style pattern to the given
377 	 * level.
378 	 *
379 	 * Params:
380 	 *     name = name of the categories to set
381 	 *     level = level to set them to
382 	 */
383 	public static void setThresholdForName(string name, GstDebugLevel level)
384 	{
385 		gst_debug_set_threshold_for_name(Str.toStringz(name), level);
386 	}
387 
388 	/**
389 	 * Sets the debug logging wanted in the same form as with the GST_DEBUG
390 	 * environment variable. You can use wildcards such as '*', but note that
391 	 * the order matters when you use wild cards, e.g. "foosrc:6,*src:3,*:2" sets
392 	 * everything to log level 2.
393 	 *
394 	 * Params:
395 	 *     list = comma-separated list of "category:level" pairs to be used
396 	 *         as debug logging levels
397 	 *     reset = %TRUE to clear all previously-set debug levels before setting
398 	 *         new thresholds
399 	 *         %FALSE if adding the threshold described by @list to the one already set.
400 	 *
401 	 * Since: 1.2
402 	 */
403 	public static void setThresholdFromString(string list, bool reset)
404 	{
405 		gst_debug_set_threshold_from_string(Str.toStringz(list), reset);
406 	}
407 
408 	/**
409 	 * Resets all categories with the given name back to the default level.
410 	 *
411 	 * Params:
412 	 *     name = name of the categories to set
413 	 */
414 	public static void unsetThresholdForName(string name)
415 	{
416 		gst_debug_unset_threshold_for_name(Str.toStringz(name));
417 	}
418 }