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