gst/gstinfo.h: Add missing inline function.
[platform/upstream/gstreamer.git] / gst / gstinfo.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
5  *
6  * gstinfo.h: debugging functions
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #ifndef __GSTINFO_H__
25 #define __GSTINFO_H__
26
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <gst/gstatomic.h>
30 #include <gst/gstconfig.h>
31
32 G_BEGIN_DECLS
33
34 /*
35  * GStreamer's debugging subsystem is an easy way to get information about what
36  * the application is doing.
37  * It is not meant for programming errors. Use GLibs methods (g_warning and so
38  * on for that.
39  */
40
41 /* log levels */
42 typedef enum {
43   GST_LEVEL_NONE = 0,
44   GST_LEVEL_ERROR,
45   GST_LEVEL_WARNING,
46   GST_LEVEL_INFO,
47   GST_LEVEL_DEBUG,
48   GST_LEVEL_LOG,
49   /* add more */
50   GST_LEVEL_COUNT
51 } GstDebugLevel;
52
53 /* we can now override this to be more general in maintainer builds or cvs checkouts */
54 #ifndef GST_LEVEL_DEFAULT
55 #define GST_LEVEL_DEFAULT GST_LEVEL_NONE
56 #endif
57
58 /* defines for format (colors etc) - don't change them around, it uses terminal layout 
59  * Terminal color strings:
60  * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
61  * Text color codes:
62  * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
63  * Background color codes:
64  * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
65  */
66 typedef enum {
67   /* colors */
68   GST_DEBUG_FG_BLACK            = 0x0000,
69   GST_DEBUG_FG_RED              = 0x0001,
70   GST_DEBUG_FG_GREEN            = 0x0002,
71   GST_DEBUG_FG_YELLOW           = 0x0003,
72   GST_DEBUG_FG_BLUE             = 0x0004,
73   GST_DEBUG_FG_MAGENTA          = 0x0005,
74   GST_DEBUG_FG_CYAN             = 0x0006,
75   GST_DEBUG_FG_WHITE            = 0x0007,
76   /* background colors */
77   GST_DEBUG_BG_BLACK            = 0x0000,
78   GST_DEBUG_BG_RED              = 0x0010,
79   GST_DEBUG_BG_GREEN            = 0x0020,
80   GST_DEBUG_BG_YELLOW           = 0x0030,
81   GST_DEBUG_BG_BLUE             = 0x0040,
82   GST_DEBUG_BG_MAGENTA          = 0x0050,
83   GST_DEBUG_BG_CYAN             = 0x0060,
84   GST_DEBUG_BG_WHITE            = 0x0070,
85   /* other formats */
86   GST_DEBUG_BOLD                = 0x0100,
87   GST_DEBUG_UNDERLINE           = 0x0200
88 } GstDebugColorFlags;
89
90 #define GST_DEBUG_FG_MASK       (0x000F)
91 #define GST_DEBUG_BG_MASK       (0x00F0)
92 #define GST_DEBUG_FORMAT_MASK   (0xFF00)
93
94 typedef struct _GstDebugCategory GstDebugCategory;
95 struct _GstDebugCategory {
96   /*< private >*/
97   GstAtomicInt *        threshold;
98   guint                 color;          /* see defines above */
99
100   const gchar *         name;
101   const gchar *         description;
102 };
103
104 /********** some convenience macros for debugging **********/
105
106 /* This is needed in printf's if a char* might be NULL. Solaris crashes then */
107 #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
108
109 /* easier debugging for pad names */
110 #define GST_DEBUG_PAD_NAME(pad) \
111   (GST_OBJECT_PARENT(pad) != NULL) ? \
112   GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
113   "''", GST_OBJECT_NAME (pad)
114
115 /* You might want to define GST_FUNCTION in apps' configure script */
116
117 #ifndef GST_FUNCTION
118 #if defined (__GNUC__)
119 #  define GST_FUNCTION     ((const char*) (__PRETTY_FUNCTION__))
120 #elif defined (G_HAVE_ISO_VARARGS)
121 #  define GST_FUNCTION     ((const char*) (__func__))
122 #else
123 #  define GST_FUNCTION     ((const char*) ("???"))
124 #endif
125 #endif /* ifndef GST_FUNCTION */
126
127
128 typedef struct _GstDebugMessage GstDebugMessage;
129 typedef void (*GstLogFunction)  (GstDebugCategory *     category,
130                                  GstDebugLevel          level,
131                                  const gchar *          file,
132                                  const gchar *          function,
133                                  gint                   line,
134                                  GObject *              object,
135                                  GstDebugMessage *      message,
136                                  gpointer               data);
137
138 #ifndef GST_DISABLE_GST_DEBUG
139
140 void            _gst_debug_init                 (void);
141
142 /* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which
143  * we use for GST_PTR_FORMAT. */
144 void            gst_debug_log                   (GstDebugCategory *     category,
145                                                  GstDebugLevel          level,
146                                                  const gchar *          file,
147                                                  const gchar *          function,
148                                                  gint                   line,
149                                                  GObject *              object,
150                                                  const gchar *          format,
151                                                  ...) G_GNUC_NO_INSTRUMENT;
152 void            gst_debug_log_valist            (GstDebugCategory *     category,
153                                                  GstDebugLevel          level,
154                                                  const gchar *          file,
155                                                  const gchar *          function,
156                                                  gint                   line,
157                                                  GObject *              object,
158                                                  const gchar *          format,
159                                                  va_list                args) G_GNUC_NO_INSTRUMENT;
160
161 const gchar *   gst_debug_message_get           (GstDebugMessage *      message);
162
163 void            gst_debug_log_default           (GstDebugCategory *     category,
164                                                  GstDebugLevel          level,
165                                                  const gchar *          file,
166                                                  const gchar *          function,
167                                                  gint                   line,
168                                                  GObject *              object,
169                                                  GstDebugMessage *      message,
170                                                  gpointer               unused) G_GNUC_NO_INSTRUMENT;
171
172 G_CONST_RETURN gchar *
173                 gst_debug_level_get_name        (GstDebugLevel          level);
174
175 void            gst_debug_add_log_function      (GstLogFunction         func,
176                                                  gpointer data);
177 guint           gst_debug_remove_log_function   (GstLogFunction         func);
178 guint           gst_debug_remove_log_function_by_data (gpointer         data);
179
180 void            gst_debug_set_active            (gboolean active);
181 gboolean        gst_debug_is_active             (void);
182
183 void            gst_debug_set_colored           (gboolean colored);
184 gboolean        gst_debug_is_colored            (void);
185
186 void            gst_debug_set_default_threshold (GstDebugLevel          level);
187 GstDebugLevel   gst_debug_get_default_threshold (void);
188 void            gst_debug_set_threshold_for_name (const gchar *         name,
189                                                  GstDebugLevel          level);
190 void            gst_debug_unset_threshold_for_name (const gchar *       name);
191
192 /**
193  * GST_DEBUG_CATEGORY:
194  * @cat: the category
195  *
196  * Defines a GstDebugCategory variable.
197  * This macro expands to nothing if debugging is disabled.
198  */
199 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
200 /**
201  * GST_DEBUG_CATEGORY_EXTERN:
202  * @cat: the category
203  *
204  * Declares a GstDebugCategory variable as extern. Use in header files.
205  * This macro expands to nothing if debugging is disabled.
206  */
207 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
208 /**
209  * GST_DEBUG_CATEGORY_STATIC:
210  * @cat: the category
211  *
212  * Defines a static GstDebugCategory variable.
213  * This macro expands to nothing if debugging is disabled.
214  */
215 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
216 /* do not use this function, use the macros below */
217 GstDebugCategory *_gst_debug_category_new       (gchar *                name,
218                                                  guint                  color,
219                                                  gchar *                description);
220 /**
221  * GST_DEBUG_CATEGORY_INIT:
222  * @cat: the category to initialize.
223  * @name: the name of the category.
224  * @color: the colors to use for a color representation or 0 for no color.
225  * @description: optional description of the category.
226  *
227  * Initializes a new #GstDebugCategory with the given properties and set to
228  * the default threshold.
229  *
230  * <note>
231  * <para>
232  * This macro expands to nothing if debugging is disabled.
233  * </para>
234  * <para>
235  * When naming your category, please follow the following conventions to ensure
236  * that the pattern matching for categories works as expected. It is not
237  * earth-shattering if you don't follow these conventions, but it would be nice
238  * for everyone.
239  * </para>
240  * <para>
241  * If you define a category for a plugin or a feature of it, name the category
242  * like the feature. So if you wanted to write a "filesrc" element, you would
243  * name the category "filesrc". Use lowercase letters only.
244  * If you define more than one category for the same element, append an
245  * underscore and an identifier to your categories, like this: "filesrc_cache"
246  * </para>
247  * <para>
248  * If you create a library or an application using debugging categories, use a
249  * common prefix followed by an underscore for all your categories. GStreamer
250  * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
251  * to include uppercase letters.
252  * </para>
253  * </note>
254  */
255 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{       \
256   if (cat == NULL)                                                              \
257     cat = _gst_debug_category_new (name,color,description);                     \
258 }G_STMT_END
259
260 void            gst_debug_category_free         (GstDebugCategory *     category);
261 void            gst_debug_category_set_threshold (GstDebugCategory *    category,
262                                                  GstDebugLevel          level);
263 void            gst_debug_category_reset_threshold (GstDebugCategory *  category);
264 GstDebugLevel   gst_debug_category_get_threshold (GstDebugCategory *    category);
265 G_CONST_RETURN gchar *
266                 gst_debug_category_get_name     (GstDebugCategory *     category);
267 guint           gst_debug_category_get_color    (GstDebugCategory *     category);
268 G_CONST_RETURN gchar *
269                 gst_debug_category_get_description (GstDebugCategory *  category);
270 GSList *        gst_debug_get_all_categories    (void);
271
272 gchar *         gst_debug_construct_term_color  (guint colorinfo);
273
274
275 extern GstDebugCategory *       GST_CAT_DEFAULT;
276 /* this symbol may not be used */
277 extern gboolean                 __gst_debug_enabled;
278
279 #ifdef G_HAVE_ISO_VARARGS
280 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{                   \
281   if (__gst_debug_enabled) {                            \
282     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, (GObject *) (object), __VA_ARGS__); \
283   }                                                                             \
284 }G_STMT_END
285 #else /* G_HAVE_GNUC_VARARGS */
286 #ifdef G_HAVE_GNUC_VARARGS
287 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{                       \
288   if (__gst_debug_enabled) {                            \
289     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, (GObject *) (object), ##args ); \
290   }                                                                             \
291 }G_STMT_END
292 #else /* no variadic macros, use inline */
293 static inline void
294 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
295     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
296 {
297   gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
298       varargs);
299 }
300
301 static inline void
302 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
303     gpointer object, const char *format, ...)
304 {
305   if (__gst_debug_enabled) {
306     va_list varargs;
307
308     va_start (varargs, format);
309     GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
310     va_end (varargs);
311   }
312 }
313 #endif
314 #endif /* G_HAVE_ISO_VARARGS */
315
316 #ifdef G_HAVE_ISO_VARARGS
317
318 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
319 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
320 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
321 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
322 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
323
324 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
325 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
326 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
327 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
328 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
329
330 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
331 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
332 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
333 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
334 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
335
336 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
337 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
338 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
339 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
340 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
341
342 #else
343 #ifdef G_HAVE_GNUC_VARARGS
344
345 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
346 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
347 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
348 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
349 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
350
351 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
352 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
353 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
354 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
355 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
356
357 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
358 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
359 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
360 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
361 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
362
363 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
364 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
365 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
366 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
367 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
368
369 #else
370 /* no variadic macros, use inline */
371 static inline void
372 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
373     ...)
374 {
375   va_list varargs;
376
377   va_start (varargs, format);
378   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
379   va_end (varargs);
380 }
381
382 static inline void
383 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
384     const char *format, ...)
385 {
386   va_list varargs;
387
388   va_start (varargs, format);
389   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
390   va_end (varargs);
391 }
392
393 static inline void
394 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
395     ...)
396 {
397   va_list varargs;
398
399   va_start (varargs, format);
400   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
401   va_end (varargs);
402 }
403
404 static inline void
405 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
406     ...)
407 {
408   va_list varargs;
409
410   va_start (varargs, format);
411   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
412   va_end (varargs);
413 }
414
415 static inline void
416 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
417     ...)
418 {
419   va_list varargs;
420
421   va_start (varargs, format);
422   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
423   va_end (varargs);
424 }
425
426 static inline void
427 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
428 {
429   va_list varargs;
430
431   va_start (varargs, format);
432   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
433   va_end (varargs);
434 }
435
436 static inline void
437 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
438 {
439   va_list varargs;
440
441   va_start (varargs, format);
442   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
443   va_end (varargs);
444 }
445
446 static inline void
447 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
448 {
449   va_list varargs;
450
451   va_start (varargs, format);
452   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
453   va_end (varargs);
454 }
455
456 static inline void
457 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
458 {
459   va_list varargs;
460
461   va_start (varargs, format);
462   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
463   va_end (varargs);
464 }
465
466 static inline void
467 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
468 {
469   va_list varargs;
470
471   va_start (varargs, format);
472   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
473   va_end (varargs);
474 }
475
476 static inline void
477 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
478 {
479   va_list varargs;
480
481   va_start (varargs, format);
482   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
483       varargs);
484   va_end (varargs);
485 }
486
487 static inline void
488 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
489 {
490   va_list varargs;
491
492   va_start (varargs, format);
493   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
494       varargs);
495   va_end (varargs);
496 }
497
498 static inline void
499 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
500 {
501   va_list varargs;
502
503   va_start (varargs, format);
504   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
505       varargs);
506   va_end (varargs);
507 }
508
509 static inline void
510 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
511 {
512   va_list varargs;
513
514   va_start (varargs, format);
515   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
516       varargs);
517   va_end (varargs);
518 }
519
520 static inline void
521 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
522 {
523   va_list varargs;
524
525   va_start (varargs, format);
526   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
527       varargs);
528   va_end (varargs);
529 }
530
531 static inline void
532 GST_ERROR (const char *format, ...)
533 {
534   va_list varargs;
535
536   va_start (varargs, format);
537   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
538       varargs);
539   va_end (varargs);
540 }
541
542 static inline void
543 GST_WARNING (const char *format, ...)
544 {
545   va_list varargs;
546
547   va_start (varargs, format);
548   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
549       varargs);
550   va_end (varargs);
551 }
552
553 static inline void
554 GST_INFO (const char *format, ...)
555 {
556   va_list varargs;
557
558   va_start (varargs, format);
559   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
560       varargs);
561   va_end (varargs);
562 }
563
564 static inline void
565 GST_DEBUG (const char *format, ...)
566 {
567   va_list varargs;
568
569   va_start (varargs, format);
570   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
571       varargs);
572   va_end (varargs);
573 }
574
575 static inline void
576 GST_LOG (const char *format, ...)
577 {
578   va_list varargs;
579
580   va_start (varargs, format);
581   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
582       format, varargs);
583   va_end (varargs);
584 }
585 #endif
586 #endif
587
588
589 /********** function pointer stuff **********/
590 void*           _gst_debug_register_funcptr     (void *                 ptr,
591                                                  gchar *                ptrname);
592 G_CONST_RETURN gchar*
593                 _gst_debug_nameof_funcptr       (void *                 ptr);
594
595 #define GST_DEBUG_FUNCPTR(ptr) (_gst_debug_register_funcptr((void *)(ptr), #ptr) , ptr)
596 #define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr)
597
598 #else /* GST_DISABLE_GST_DEBUG */
599
600 #ifdef __GNUC__
601 #  pragma GCC poison gst_debug_log
602 #  pragma GCC poison gst_debug_log_valist
603 #  pragma GCC poison _gst_debug_category_new
604 #endif
605
606 #define _gst_debug_init()                               /* NOP */
607
608 #define gst_debug_set_log_function(func,data)           /* NOP */
609 #define gst_debug_reset_log_function(void)              /* NOP */
610 #define gst_debug_set_default_threshold(level)          /* NOP */
611 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
612 #define gst_debug_category_set_threshold_for_name(name, level) /* NOP */
613 #define gst_debug_category_unset_threshold_for_name(name) /* NOP */
614
615 #define gst_debug_level_get_name(level)                 ("NONE")
616 #define gst_debug_add_log_function(func,data)           (FALSE)
617 #define gst_debug_remove_log_function(func)             (0)
618 #define gst_debug_remove_log_function_by_data(data)     (0)
619 #define gst_debug_set_active(active)                    /* NOP */
620 #define gst_debug_is_active()                           (FALSE)
621 #define gst_debug_set_colored(colored)                  /* NOP */
622 #define gst_debug_is_colored()                          (FALSE)
623 #define gst_debug_set_default_threshold(level)          /* NOP */
624 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
625 #define gst_debug_set_threshold_for_name(name,level)    /* NOP */
626 #define gst_debug_unset_threshold_for_name(name)        /* NOP */
627
628 #define GST_DEBUG_CATEGORY(var)                         /* NOP */
629 #define GST_DEBUG_CATEGORY_EXTERN(var)                  /* NOP */
630 #define GST_DEBUG_CATEGORY_STATIC(var)                  /* NOP */
631 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    /* NOP */
632 #define gst_debug_category_free(category)               /* NOP */
633 #define gst_debug_category_set_threshold(category,level) /* NOP */
634 #define gst_debug_category_reset_threshold(category)    /* NOP */
635 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
636 #define gst_debug_category_get_name(cat)                ("")
637 #define gst_debug_category_get_color(cat)               (0)
638 #define gst_debug_category_get_description(cat)         ("")
639 #define gst_debug_get_all_categories()                  (NULL)
640 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
641
642 #ifdef G_HAVE_ISO_VARARGS
643
644 #define GST_CAT_LEVEL_LOG(cat,level,...)                /* NOP */
645
646 #define GST_CAT_ERROR_OBJECT(...)                       /* NOP */
647 #define GST_CAT_WARNING_OBJECT(...)                     /* NOP */
648 #define GST_CAT_INFO_OBJECT(...)                        /* NOP */
649 #define GST_CAT_DEBUG_OBJECT(...)                       /* NOP */
650 #define GST_CAT_LOG_OBJECT(...)                         /* NOP */
651
652 #define GST_CAT_ERROR(...)                              /* NOP */
653 #define GST_CAT_WARNING(...)                            /* NOP */
654 #define GST_CAT_INFO(...)                               /* NOP */
655 #define GST_CAT_DEBUG(...)                              /* NOP */
656 #define GST_CAT_LOG(...)                                /* NOP */
657
658 #define GST_ERROR_OBJECT(...)                           /* NOP */
659 #define GST_WARNING_OBJECT(...)                         /* NOP */
660 #define GST_INFO_OBJECT(...)                            /* NOP */
661 #define GST_DEBUG_OBJECT(...)                           /* NOP */
662 #define GST_LOG_OBJECT(...)                             /* NOP */
663
664 #define GST_ERROR(...)                                  /* NOP */
665 #define GST_WARNING(...)                                /* NOP */
666 #define GST_INFO(...)                                   /* NOP */
667 #define GST_DEBUG(...)                                  /* NOP */
668 #define GST_LOG(...)                                    /* NOP */
669
670 #else
671 #ifdef G_HAVE_GNUC_VARARGS
672
673 #define GST_CAT_LEVEL_LOG(cat,level,args...)            /* NOP */
674
675 #define GST_CAT_ERROR_OBJECT(args...)                   /* NOP */
676 #define GST_CAT_WARNING_OBJECT(args...)                 /* NOP */
677 #define GST_CAT_INFO_OBJECT(args...)                    /* NOP */
678 #define GST_CAT_DEBUG_OBJECT(args...)                   /* NOP */
679 #define GST_CAT_LOG_OBJECT(args...)                     /* NOP */
680
681 #define GST_CAT_ERROR(args...)                          /* NOP */
682 #define GST_CAT_WARNING(args...)                        /* NOP */
683 #define GST_CAT_INFO(args...)                           /* NOP */
684 #define GST_CAT_DEBUG(args...)                          /* NOP */
685 #define GST_CAT_LOG(args...)                            /* NOP */
686
687 #define GST_ERROR_OBJECT(args...)                       /* NOP */
688 #define GST_WARNING_OBJECT(args...)                     /* NOP */
689 #define GST_INFO_OBJECT(args...)                        /* NOP */
690 #define GST_DEBUG_OBJECT(args...)                       /* NOP */
691 #define GST_LOG_OBJECT(args...)                         /* NOP */
692
693 #define GST_ERROR(args...)                              /* NOP */
694 #define GST_WARNING(args...)                            /* NOP */
695 #define GST_INFO(args...)                               /* NOP */
696 #define GST_DEBUG(args...)                              /* NOP */
697 #define GST_LOG(args...)                                /* NOP */
698
699 #else
700 static inline void
701 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
702     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
703 {
704 }
705
706 static inline void
707 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
708     ...)
709 {
710 }
711
712 static inline void
713 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
714     const char *format, ...)
715 {
716 }
717
718 static inline void
719 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
720     ...)
721 {
722 }
723
724 static inline void
725 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
726     ...)
727 {
728 }
729
730 static inline void
731 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
732     ...)
733 {
734 }
735
736 static inline void
737 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
738 {
739 }
740
741 static inline void
742 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
743 {
744 }
745
746 static inline void
747 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
748 {
749 }
750
751 static inline void
752 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
753 {
754 }
755
756 static inline void
757 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
758 {
759 }
760
761 static inline void
762 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
763 {
764 }
765
766 static inline void
767 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
768 {
769 }
770
771 static inline void
772 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
773 {
774 }
775
776 static inline void
777 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
778 {
779 }
780
781 static inline void
782 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
783 {
784 }
785
786 static inline void
787 GST_ERROR (const char *format, ...)
788 {
789 }
790
791 static inline void
792 GST_WARNING (const char *format, ...)
793 {
794 }
795
796 static inline void
797 GST_INFO (const char *format, ...)
798 {
799 }
800
801 static inline void
802 GST_DEBUG (const char *format, ...)
803 {
804 }
805
806 static inline void
807 GST_LOG (const char *format, ...)
808 {
809 }
810 #endif
811 #endif
812
813 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
814 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
815
816 #endif /* GST_DISABLE_GST_DEBUG */
817
818 void gst_debug_print_stack_trace (void);
819
820 /* timestamp debugging macros */
821 #define GST_TIME_FORMAT "u:%02u:%02u.%09u"
822 #define GST_TIME_ARGS(t) \
823         (guint) (t / (GST_SECOND * 60 * 60)), \
824         (guint) ((t / (GST_SECOND * 60)) % 60), \
825         (guint) ((t / GST_SECOND) % 60), \
826         (guint) (t % GST_SECOND)
827
828 G_END_DECLS
829
830 #endif /* __GSTINFO_H__ */