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