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