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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: %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 * Return: %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 * Return: 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 GST_ENABLE_FUNC_INSTRUMENTATION is defined a stacktrace is available for 234 * gstreamer code, which can be printed with this function. 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 246 * 247 * Return: How many instances of the function were removed 248 */ 249 public static uint removeLogFunction(GstLogFunction func) 250 { 251 return gst_debug_remove_log_function(func); 252 } 253 254 /** 255 * Removes all registered instances of log functions with the given user data. 256 * 257 * Params: 258 * data = user data of the log function to remove 259 * 260 * Return: How many instances of the function were removed 261 */ 262 public static uint removeLogFunctionByData(void* data) 263 { 264 return gst_debug_remove_log_function_by_data(data); 265 } 266 267 /** 268 * If activated, debugging messages are sent to the debugging 269 * handlers. 270 * It makes sense to deactivate it for speed issues. 271 * <note><para>This function is not threadsafe. It makes sense to only call it 272 * during initialization.</para></note> 273 * 274 * Params: 275 * active = Whether to use debugging output or not 276 */ 277 public static void setActive(bool active) 278 { 279 gst_debug_set_active(active); 280 } 281 282 /** 283 * Changes the coloring mode for debug output. 284 * 285 * This function may be called before gst_init(). 286 * 287 * Params: 288 * mode = The coloring mode for debug output. See @GstDebugColorMode. 289 * 290 * Since: 1.2 291 */ 292 public static void setColorMode(GstDebugColorMode mode) 293 { 294 gst_debug_set_color_mode(mode); 295 } 296 297 /** 298 * Changes the coloring mode for debug output. 299 * 300 * This function may be called before gst_init(). 301 * 302 * Params: 303 * mode = The coloring mode for debug output. One of the following: 304 * "on", "auto", "off", "disable", "unix". 305 * 306 * Since: 1.2 307 */ 308 public static void setColorModeFromString(string mode) 309 { 310 gst_debug_set_color_mode_from_string(Str.toStringz(mode)); 311 } 312 313 /** 314 * Sets or unsets the use of coloured debugging output. 315 * Same as gst_debug_set_color_mode () with the argument being 316 * being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF. 317 * 318 * This function may be called before gst_init(). 319 * 320 * Params: 321 * colored = Whether to use colored output or not 322 */ 323 public static void setColored(bool colored) 324 { 325 gst_debug_set_colored(colored); 326 } 327 328 /** 329 * Sets the default threshold to the given level and updates all categories to 330 * use this threshold. 331 * 332 * This function may be called before gst_init(). 333 * 334 * Params: 335 * level = level to set 336 */ 337 public static void setDefaultThreshold(GstDebugLevel level) 338 { 339 gst_debug_set_default_threshold(level); 340 } 341 342 /** 343 * Sets all categories which match the given glob style pattern to the given 344 * level. 345 * 346 * Params: 347 * name = name of the categories to set 348 * level = level to set them to 349 */ 350 public static void setThresholdForName(string name, GstDebugLevel level) 351 { 352 gst_debug_set_threshold_for_name(Str.toStringz(name), level); 353 } 354 355 /** 356 * Sets the debug logging wanted in the same form as with the GST_DEBUG 357 * environment variable. You can use wildcards such as '*', but note that 358 * the order matters when you use wild cards, e.g. "foosrc:6,*src:3,*:2" sets 359 * everything to log level 2. 360 * 361 * Params: 362 * list = comma-separated list of "category:level" pairs to be used 363 * as debug logging levels 364 * reset = %TRUE to clear all previously-set debug levels before setting 365 * new thresholds 366 * %FALSE if adding the threshold described by @list to the one already set. 367 * 368 * Since: 1.2 369 */ 370 public static void setThresholdFromString(string list, bool reset) 371 { 372 gst_debug_set_threshold_from_string(Str.toStringz(list), reset); 373 } 374 375 /** 376 * Resets all categories with the given name back to the default level. 377 * 378 * Params: 379 * name = name of the categories to set 380 */ 381 public static void unsetThresholdForName(string name) 382 { 383 gst_debug_unset_threshold_for_name(Str.toStringz(name)); 384 } 385 }