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