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