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