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