inlined 3 more biiiig doc files and added some missing docs on the fly
[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/gstconfig.h>
30
31 G_BEGIN_DECLS
32
33 /**
34  * GstDebugLevel:
35  * @GST_LEVEL_NONE: No debugging level specified or desired. Used to deactivate
36  *  debugging output.
37  * @GST_LEVEL_ERROR: Error messages are to be used only when an error occured 
38  *  that stops the application from keeping working correctly.
39  *  An examples is gst_element_error, which outputs a message with this priority.
40  *  It does not mean that the application is terminating as with g_errror.
41  * @GST_LEVEL_WARNING: Warning messages are to inform about abnormal behaviour
42  *  that could lead to problems or weird behaviour later on. An example of this 
43  *  would be clocking issues ("your computer is pretty slow") or broken input
44  *  data ("Can't synchronize to stream.")
45  * @GST_LEVEL_INFO: Informational messages should be used to keep the developer
46  *  updated about what is happening.
47  *  Examples where this should be used are when a typefind function has 
48  *  successfully determined the type of the stream or when an mp3 plugin detects
49  *  the format to be used. ("This file has mono sound.")
50  * @GST_LEVEL_DEBUG: Debugging messages should be used when something common
51  *  happens that is not the expected default behavior. 
52  *  An example would be notifications about state changes or receiving/sending of
53  *  events.
54  * @GST_LEVEL_LOG: Log messages are messages that are very common but might be 
55  *  useful to know. As a rule of thumb a pipeline that is iterating as expected
56  *  should never output anzthing else but LOG messages.
57  *  Examples for this are referencing/dereferencing of objects or cothread switches.
58  * @GST_LEVEL_COUNT: The number of defined debugging levels.
59  * 
60  * The level defines the importance of a debugging message. The more important a 
61  * message is, the greater the probability that the debugging system outputs it.
62  */
63 typedef enum {
64   GST_LEVEL_NONE = 0,
65   GST_LEVEL_ERROR,
66   GST_LEVEL_WARNING,
67   GST_LEVEL_INFO,
68   GST_LEVEL_DEBUG,
69   GST_LEVEL_LOG,
70   /* add more */
71   GST_LEVEL_COUNT
72 } GstDebugLevel;
73
74 /**
75  * GST_LEVEL_DEFAULT:
76  *
77  * Defines the default debugging level to be used with GStreamer. It is normally
78  * set to #GST_LEVEL_NONE so nothing get printed.
79  * As it can be configured at compile time, developer builds may chose to
80  * override that though.
81  * You can use this as an argument to gst_debug_set_default_threshold() to
82  * reset the debugging output to default behaviour.
83  */
84 #ifndef GST_LEVEL_DEFAULT
85 #define GST_LEVEL_DEFAULT GST_LEVEL_NONE
86 #endif
87
88 /* defines for format (colors etc)
89  * don't change them around, it uses terminal layout
90  * Terminal color strings:
91  * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
92  * Text color codes:
93  * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
94  * Background color codes:
95  * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
96  */
97 /**
98  * GstDebugColorFlags:
99  * @GST_DEBUG_FG_BLACK: Use black as foreground color.
100  * @GST_DEBUG_FG_RED: Use red as foreground color.
101  * @GST_DEBUG_FG_GREEN: Use green as foreground color.
102  * @GST_DEBUG_FG_YELLOW: Use yellow as foreground color.
103  * @GST_DEBUG_FG_BLUE: Use blue as foreground color.
104  * @GST_DEBUG_FG_MAGENTA: Use magenta as foreground color.
105  * @GST_DEBUG_FG_CYAN: Use cyan as foreground color.
106  * @GST_DEBUG_FG_WHITE: Use white as foreground color.
107  * @GST_DEBUG_BG_BLACK: Use black as background color.
108  * @GST_DEBUG_BG_RED: Use red as background color.
109  * @GST_DEBUG_BG_GREEN: Use green as background color.
110  * @GST_DEBUG_BG_YELLOW: Use yellow as background color.
111  * @GST_DEBUG_BG_BLUE: Use blue as background color.
112  * @GST_DEBUG_BG_MAGENTA: Use magenta as background color.
113  * @GST_DEBUG_BG_CYAN: Use cyan as background color.
114  * @GST_DEBUG_BG_WHITE: Use white as background color.
115  * @GST_DEBUG_BOLD: Make the output bold.
116  * @GST_DEBUG_UNDERLINE: Underline the output.
117  * 
118  * These are some terminal style flags you can use when creating your
119  * debugging categories to make them stand out in debugging output.
120  */
121 typedef enum {
122   /* colors */
123   GST_DEBUG_FG_BLACK            = 0x0000,
124   GST_DEBUG_FG_RED              = 0x0001,
125   GST_DEBUG_FG_GREEN            = 0x0002,
126   GST_DEBUG_FG_YELLOW           = 0x0003,
127   GST_DEBUG_FG_BLUE             = 0x0004,
128   GST_DEBUG_FG_MAGENTA          = 0x0005,
129   GST_DEBUG_FG_CYAN             = 0x0006,
130   GST_DEBUG_FG_WHITE            = 0x0007,
131   /* background colors */
132   GST_DEBUG_BG_BLACK            = 0x0000,
133   GST_DEBUG_BG_RED              = 0x0010,
134   GST_DEBUG_BG_GREEN            = 0x0020,
135   GST_DEBUG_BG_YELLOW           = 0x0030,
136   GST_DEBUG_BG_BLUE             = 0x0040,
137   GST_DEBUG_BG_MAGENTA          = 0x0050,
138   GST_DEBUG_BG_CYAN             = 0x0060,
139   GST_DEBUG_BG_WHITE            = 0x0070,
140   /* other formats */
141   GST_DEBUG_BOLD                = 0x0100,
142   GST_DEBUG_UNDERLINE           = 0x0200
143 } GstDebugColorFlags;
144
145 #define GST_DEBUG_FG_MASK       (0x000F)
146 #define GST_DEBUG_BG_MASK       (0x00F0)
147 #define GST_DEBUG_FORMAT_MASK   (0xFF00)
148
149 typedef struct _GstDebugCategory GstDebugCategory;
150 /**
151  * GstDebugCategory:
152  *
153  * This is the struct that describes the categories. Once initialized with
154  * #GST_DEBUG_CATEGORY_INIT, its values can't be changed anymore.
155  */
156 struct _GstDebugCategory {
157   /*< private >*/
158   gint                  threshold;
159   guint                 color;          /* see defines above */
160
161   const gchar *         name;
162   const gchar *         description;
163 };
164
165 /********** some convenience macros for debugging **********/
166
167 /**
168  * GST_STR_NULL:
169  * @str: The string to check.
170  *
171  * Macro to use when a string must not be NULL, but may be NULL. If the string
172  * is NULL, "(NULL)" is printed instead.
173  * In GStreamer printf string arguments may not be NULL, because on some
174  * platforms (ie Solaris) the libc crashes in that case. This includes debugging
175  * strings.
176  */
177 #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
178
179 /* FIXME, not MT safe */
180 /**
181  * GST_DEBUG_PAD_NAME:
182  * @pad: The pad to debug.
183  *
184  * Evaluates to 2 strings, that describe the pad. Often used in debugging
185  * statements.
186  */
187 #define GST_DEBUG_PAD_NAME(pad) \
188   (GST_OBJECT_PARENT(pad) != NULL) ? \
189   GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
190   "''", GST_OBJECT_NAME (pad)
191
192 /**
193  * GST_FUNCTION:
194  *
195  * This macro should evaluate to the name of the current function and be should
196  * be defined when configuring your project, as it is compiler dependant. If it
197  * is not defined, some default value is used. It is used to provide debugging
198  * output with the function name of the message.
199  */
200 #ifndef GST_FUNCTION
201 #if defined (__GNUC__)
202 #  define GST_FUNCTION     ((const char*) (__PRETTY_FUNCTION__))
203 #elif defined (G_HAVE_ISO_VARARGS)
204 #  define GST_FUNCTION     ((const char*) (__func__))
205 #else
206 #  define GST_FUNCTION     ((const char*) ("???"))
207 #endif
208 #endif /* ifndef GST_FUNCTION */
209
210
211 typedef struct _GstDebugMessage GstDebugMessage;
212 typedef void (*GstLogFunction)  (GstDebugCategory *     category,
213                                  GstDebugLevel          level,
214                                  const gchar *          file,
215                                  const gchar *          function,
216                                  gint                   line,
217                                  GObject *              object,
218                                  GstDebugMessage *      message,
219                                  gpointer               data);
220
221 #ifndef GST_DISABLE_GST_DEBUG
222
223 void            _gst_debug_init                 (void);
224
225 /* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which
226  * we use for GST_PTR_FORMAT. */
227 void            gst_debug_log           (GstDebugCategory *     category,
228                                          GstDebugLevel          level,
229                                          const gchar *          file,
230                                          const gchar *          function,
231                                          gint                   line,
232                                          GObject *              object,
233                                          const gchar *          format,
234                                          ...) G_GNUC_NO_INSTRUMENT;
235 void            gst_debug_log_valist    (GstDebugCategory *     category,
236                                          GstDebugLevel          level,
237                                          const gchar *          file,
238                                          const gchar *          function,
239                                          gint                   line,
240                                          GObject *              object,
241                                          const gchar *          format,
242                                          va_list                args) G_GNUC_NO_INSTRUMENT;
243
244 const gchar *   gst_debug_message_get   (GstDebugMessage *      message);
245
246 void            gst_debug_log_default   (GstDebugCategory *     category,
247                                          GstDebugLevel          level,
248                                          const gchar *          file,
249                                          const gchar *          function,
250                                          gint                   line,
251                                          GObject *              object,
252                                          GstDebugMessage *      message,
253                                          gpointer               unused) G_GNUC_NO_INSTRUMENT;
254
255 G_CONST_RETURN gchar *
256                 gst_debug_level_get_name        (GstDebugLevel          level);
257
258 void            gst_debug_add_log_function      (GstLogFunction         func,
259                                                  gpointer data);
260 guint           gst_debug_remove_log_function   (GstLogFunction         func);
261 guint           gst_debug_remove_log_function_by_data (gpointer         data);
262
263 void            gst_debug_set_active            (gboolean active);
264 gboolean        gst_debug_is_active             (void);
265
266 void            gst_debug_set_colored           (gboolean colored);
267 gboolean        gst_debug_is_colored            (void);
268
269 void            gst_debug_set_default_threshold (GstDebugLevel          level);
270 GstDebugLevel   gst_debug_get_default_threshold (void);
271 void            gst_debug_set_threshold_for_name (const gchar *         name,
272                                                  GstDebugLevel          level);
273 void            gst_debug_unset_threshold_for_name (const gchar *       name);
274
275 /**
276  * GST_DEBUG_CATEGORY:
277  * @cat: the category
278  *
279  * Defines a GstDebugCategory variable.
280  * This macro expands to nothing if debugging is disabled.
281  */
282 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
283 /**
284  * GST_DEBUG_CATEGORY_EXTERN:
285  * @cat: the category
286  *
287  * Declares a GstDebugCategory variable as extern. Use in header files.
288  * This macro expands to nothing if debugging is disabled.
289  */
290 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
291 /**
292  * GST_DEBUG_CATEGORY_STATIC:
293  * @cat: the category
294  *
295  * Defines a static GstDebugCategory variable.
296  * This macro expands to nothing if debugging is disabled.
297  */
298 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
299 /* do not use this function, use the macros below */
300 GstDebugCategory *_gst_debug_category_new       (gchar *        name,
301                                                  guint          color,
302                                                  gchar *        description);
303 /**
304  * GST_DEBUG_CATEGORY_INIT:
305  * @cat: the category to initialize.
306  * @name: the name of the category.
307  * @color: the colors to use for a color representation or 0 for no color.
308  * @description: optional description of the category.
309  *
310  * Initializes a new #GstDebugCategory with the given properties and set to
311  * the default threshold.
312  *
313  * <note>
314  * <para>
315  * This macro expands to nothing if debugging is disabled.
316  * </para>
317  * <para>
318  * When naming your category, please follow the following conventions to ensure
319  * that the pattern matching for categories works as expected. It is not
320  * earth-shattering if you don't follow these conventions, but it would be nice
321  * for everyone.
322  * </para>
323  * <para>
324  * If you define a category for a plugin or a feature of it, name the category
325  * like the feature. So if you wanted to write a "filesrc" element, you would
326  * name the category "filesrc". Use lowercase letters only.
327  * If you define more than one category for the same element, append an
328  * underscore and an identifier to your categories, like this: "filesrc_cache"
329  * </para>
330  * <para>
331  * If you create a library or an application using debugging categories, use a
332  * common prefix followed by an underscore for all your categories. GStreamer
333  * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
334  * to include uppercase letters.
335  * </para>
336  * </note>
337  */
338 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
339   if (cat == NULL)                                                      \
340     cat = _gst_debug_category_new (name,color,description);             \
341 }G_STMT_END
342
343 void    gst_debug_category_free         (GstDebugCategory *     category);
344 void    gst_debug_category_set_threshold (GstDebugCategory *    category,
345                                          GstDebugLevel          level);
346 void    gst_debug_category_reset_threshold(GstDebugCategory *   category);
347 GstDebugLevel
348         gst_debug_category_get_threshold (GstDebugCategory *    category);
349 G_CONST_RETURN gchar *
350         gst_debug_category_get_name     (GstDebugCategory *     category);
351 guint   gst_debug_category_get_color    (GstDebugCategory *     category);
352 G_CONST_RETURN gchar *
353         gst_debug_category_get_description (GstDebugCategory *  category);
354 GSList *
355         gst_debug_get_all_categories    (void);
356
357 gchar * gst_debug_construct_term_color  (guint colorinfo);
358
359
360 /**
361  * GST_CAT_DEFAULT:
362  *
363  * Default gstreamer core debug log category. Please define your own.
364  */
365 GST_EXPORT GstDebugCategory *   GST_CAT_DEFAULT;
366 /* this symbol may not be used */
367 extern gboolean                 __gst_debug_enabled;
368
369 /**
370  * GST_CAT_LEVEL_LOG:
371  * @cat: category to use
372  * @level: the severity of the message
373  * @object: the #GObject the message belongs to or NULL if none
374  * @...: A printf-style message to output
375  *
376  * Outputs a debugging message. This is the most general macro for outputting
377  * debugging messages. You will probably want to use one of the ones described
378  * below.
379  */
380 #ifdef G_HAVE_ISO_VARARGS
381 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{           \
382   if (__gst_debug_enabled) {                                            \
383     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
384         (GObject *) (object), __VA_ARGS__);                             \
385   }                                                                     \
386 }G_STMT_END
387 #else /* G_HAVE_GNUC_VARARGS */
388 #ifdef G_HAVE_GNUC_VARARGS
389 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{       \
390   if (__gst_debug_enabled) {                                            \
391     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
392         (GObject *) (object), ##args );                                 \
393   }                                                                     \
394 }G_STMT_END
395 #else /* no variadic macros, use inline */
396 static inline void
397 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
398     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
399 {
400   gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
401       varargs);
402 }
403
404 static inline void
405 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
406     gpointer object, const char *format, ...)
407 {
408   if (__gst_debug_enabled) {
409     va_list varargs;
410
411     va_start (varargs, format);
412     GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
413     va_end (varargs);
414   }
415 }
416 #endif
417 #endif /* G_HAVE_ISO_VARARGS */
418
419 /**
420  * GST_CAT_ERROR_OBJECT:
421  * @cat: category to use
422  * @obj: the #GObject the message belongs to
423  * @...: printf-style message to output
424  *
425  * Output an error message belonging to the given object in the given category.
426  */
427 /**
428  * GST_CAT_WARNING_OBJECT:
429  * @cat: category to use
430  * @obj: the #GObject the message belongs to
431  * @...: printf-style message to output
432  *
433  * Output a warning message belonging to the given object in the given category.
434  */
435 /**
436  * GST_CAT_INFO_OBJECT:
437  * @cat: category to use
438  * @obj: the #GObject the message belongs to
439  * @...: printf-style message to output
440  *
441  * Output an informational message belonging to the given object in the given
442  * category.
443  */
444 /**
445  * GST_CAT_DEBUG_OBJECT:
446  * @cat: category to use
447  * @obj: the #GObject the message belongs to
448  * @...: printf-style message to output
449  *
450  * Output an debugging message belonging to the given object in the given category.
451  */
452 /**
453  * GST_CAT_LOG_OBJECT:
454  * @cat: category to use
455  * @obj: the #GObject the message belongs to
456  * @...: printf-style message to output
457  *
458  * Output an logging message belonging to the given object in the given category.
459  */
460
461
462 /**
463  * GST_CAT_ERROR:
464  * @cat: category to use
465  * @...: printf-style message to output
466  *
467  * Output an error message in the given category.
468  */
469 /**
470  * GST_CAT_WARNING:
471  * @cat: category to use
472  * @...: printf-style message to output
473  *
474  * Output an warning message in the given category.
475  */
476 /**
477  * GST_CAT_INFO:
478  * @cat: category to use
479  * @...: printf-style message to output
480  *
481  * Output an informational message in the given category.
482  */
483 /**
484  * GST_CAT_DEBUG:
485  * @cat: category to use
486  * @...: printf-style message to output
487  *
488  * Output an debugging message in the given category.
489  */
490 /**
491  * GST_CAT_LOG:
492  * @cat: category to use
493  * @...: printf-style message to output
494  *
495  * Output an logging message in the given category.
496  */
497
498
499 /**
500  * GST_ERROR_OBJECT:
501  * @obj: the #GObject the message belongs to
502  * @...: printf-style message to output
503  *
504  * Output an error message belonging to the given object in the default category.
505  */
506 /**
507  * GST_WARNING_OBJECT:
508  * @obj: the #GObject the message belongs to
509  * @...: printf-style message to output
510  *
511  * Output a warning message belonging to the given object in the default category.
512  */
513 /**
514  * GST_INFO_OBJECT:
515  * @obj: the #GObject the message belongs to
516  * @...: printf-style message to output
517  *
518  * Output an informational message belonging to the given object in the default 
519  * category.
520  */
521 /**
522  * GST_DEBUG_OBJECT:
523  * @obj: the #GObject the message belongs to
524  * @...: printf-style message to output
525  *
526  * Output a debugging message belonging to the given object in the default 
527  * category.
528  */
529 /**
530  * GST_LOG_OBJECT:
531  * @obj: the #GObject the message belongs to
532  * @...: printf-style message to output
533  *
534  * Output a logging message belonging to the given object in the default category.
535  */
536
537  
538 /**
539  * GST_ERROR:
540  * @...: printf-style message to output
541  *
542  * Output an error message in the default category.
543  */
544 /**
545  * GST_WARNING:
546  * @...: printf-style message to output
547  *
548  * Output a warning message in the default category.
549  */
550 /**
551  * GST_INFO:
552  * @...: printf-style message to output
553  *
554  * Output an informational message in the default category.
555  */
556 /**
557  * GST_DEBUG:
558  * @...: printf-style message to output
559  *
560  * Output a debugging message in the default category.
561  */
562 /**
563  * GST_LOG:
564  * @...: printf-style message to output
565  *
566  * Output a logging message in the default category.
567  */
568
569 #ifdef G_HAVE_ISO_VARARGS
570
571 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
572 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
573 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
574 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
575 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
576
577 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
578 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
579 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
580 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
581 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
582
583 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
584 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
585 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
586 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
587 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
588
589 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
590 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
591 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
592 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
593 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
594
595 #else
596 #ifdef G_HAVE_GNUC_VARARGS
597
598 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
599 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
600 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
601 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
602 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
603
604 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
605 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
606 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
607 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
608 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
609
610 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
611 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
612 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
613 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
614 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
615
616 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
617 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
618 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
619 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
620 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
621
622 #else
623 /* no variadic macros, use inline */
624 static inline void
625 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
626     ...)
627 {
628   va_list varargs;
629
630   va_start (varargs, format);
631   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
632   va_end (varargs);
633 }
634
635 static inline void
636 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
637     const char *format, ...)
638 {
639   va_list varargs;
640
641   va_start (varargs, format);
642   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
643   va_end (varargs);
644 }
645
646 static inline void
647 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
648     ...)
649 {
650   va_list varargs;
651
652   va_start (varargs, format);
653   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
654   va_end (varargs);
655 }
656
657 static inline void
658 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
659     ...)
660 {
661   va_list varargs;
662
663   va_start (varargs, format);
664   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
665   va_end (varargs);
666 }
667
668 static inline void
669 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
670     ...)
671 {
672   va_list varargs;
673
674   va_start (varargs, format);
675   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
676   va_end (varargs);
677 }
678
679 static inline void
680 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
681 {
682   va_list varargs;
683
684   va_start (varargs, format);
685   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
686   va_end (varargs);
687 }
688
689 static inline void
690 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
691 {
692   va_list varargs;
693
694   va_start (varargs, format);
695   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
696   va_end (varargs);
697 }
698
699 static inline void
700 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
701 {
702   va_list varargs;
703
704   va_start (varargs, format);
705   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
706   va_end (varargs);
707 }
708
709 static inline void
710 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
711 {
712   va_list varargs;
713
714   va_start (varargs, format);
715   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
716   va_end (varargs);
717 }
718
719 static inline void
720 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
721 {
722   va_list varargs;
723
724   va_start (varargs, format);
725   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
726   va_end (varargs);
727 }
728
729 static inline void
730 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
731 {
732   va_list varargs;
733
734   va_start (varargs, format);
735   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
736       varargs);
737   va_end (varargs);
738 }
739
740 static inline void
741 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
742 {
743   va_list varargs;
744
745   va_start (varargs, format);
746   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
747       varargs);
748   va_end (varargs);
749 }
750
751 static inline void
752 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
753 {
754   va_list varargs;
755
756   va_start (varargs, format);
757   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
758       varargs);
759   va_end (varargs);
760 }
761
762 static inline void
763 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
764 {
765   va_list varargs;
766
767   va_start (varargs, format);
768   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
769       varargs);
770   va_end (varargs);
771 }
772
773 static inline void
774 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
775 {
776   va_list varargs;
777
778   va_start (varargs, format);
779   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
780       varargs);
781   va_end (varargs);
782 }
783
784 static inline void
785 GST_ERROR (const char *format, ...)
786 {
787   va_list varargs;
788
789   va_start (varargs, format);
790   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
791       varargs);
792   va_end (varargs);
793 }
794
795 static inline void
796 GST_WARNING (const char *format, ...)
797 {
798   va_list varargs;
799
800   va_start (varargs, format);
801   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
802       varargs);
803   va_end (varargs);
804 }
805
806 static inline void
807 GST_INFO (const char *format, ...)
808 {
809   va_list varargs;
810
811   va_start (varargs, format);
812   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
813       varargs);
814   va_end (varargs);
815 }
816
817 static inline void
818 GST_DEBUG (const char *format, ...)
819 {
820   va_list varargs;
821
822   va_start (varargs, format);
823   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
824       varargs);
825   va_end (varargs);
826 }
827
828 static inline void
829 GST_LOG (const char *format, ...)
830 {
831   va_list varargs;
832
833   va_start (varargs, format);
834   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
835       format, varargs);
836   va_end (varargs);
837 }
838 #endif
839 #endif
840
841
842 /********** function pointer stuff **********/
843
844 typedef void (* GstDebugFuncPtr)        (void);
845 void    _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
846                                          gchar *                ptrname);
847 G_CONST_RETURN gchar *
848         _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func);
849
850 /**
851  * GST_DEBUG_FUNCPTR:
852  * @ptr: pointer to the function to register
853  *
854  * Register a pointer to a function with its name, so it can later be used by
855  * GST_DEBUG_FUNCPTR_NAME().
856  *
857  * Returns: The ptr to the function
858  */
859 #define GST_DEBUG_FUNCPTR(ptr) \
860   (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
861
862 /**
863  * GST_DEBUG_FUNCPTR_NAME:
864  * @ptr: pointer to the function to look up the name
865  *
866  * Retrieves the name of the function, if it was previously registered with
867  * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
868  *
869  * Make sure you free the string after use.
870  *
871  * Returns: The name of the function
872  */
873 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
874   _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
875
876 #else /* GST_DISABLE_GST_DEBUG */
877
878 #if defined(__GNUC__) && __GNUC__ >= 3
879 #  pragma GCC poison gst_debug_log
880 #  pragma GCC poison gst_debug_log_valist
881 #  pragma GCC poison _gst_debug_category_new
882 #endif
883
884 #define _gst_debug_init()                               /* NOP */
885
886 #define gst_debug_set_log_function(func,data)           /* NOP */
887 #define gst_debug_reset_log_function(void)              /* NOP */
888 #define gst_debug_set_default_threshold(level)          /* NOP */
889 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
890
891 #define gst_debug_level_get_name(level)                 ("NONE")
892 #define gst_debug_add_log_function(func,data)           /* NOP */
893 guint           gst_debug_remove_log_function   (GstLogFunction         func);
894 guint           gst_debug_remove_log_function_by_data (gpointer         data);
895 #define gst_debug_set_active(active)                    /* NOP */
896 #define gst_debug_is_active()                           (FALSE)
897 #define gst_debug_set_colored(colored)                  /* NOP */
898 #define gst_debug_is_colored()                          (FALSE)
899 #define gst_debug_set_default_threshold(level)          /* NOP */
900 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
901 #define gst_debug_set_threshold_for_name(name,level)    /* NOP */
902 #define gst_debug_unset_threshold_for_name(name)        /* NOP */
903
904 #define GST_DEBUG_CATEGORY(var)                         /* NOP */
905 #define GST_DEBUG_CATEGORY_EXTERN(var)                  /* NOP */
906 #if !defined(G_HAVE_GNUC_VARARGS) && !defined(G_HAVE_ISO_VARARGS)
907 #define GST_DEBUG_CATEGORY_STATIC(var)                  static GstDebugCategory *var = NULL
908 #else
909 #define GST_DEBUG_CATEGORY_STATIC(var)                  /* NOP */
910 #endif
911 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    /* NOP */
912 #define gst_debug_category_free(category)               /* NOP */
913 #define gst_debug_category_set_threshold(category,level) /* NOP */
914 #define gst_debug_category_reset_threshold(category)    /* NOP */
915 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
916 #define gst_debug_category_get_name(cat)                ("")
917 #define gst_debug_category_get_color(cat)               (0)
918 #define gst_debug_category_get_description(cat)         ("")
919 #define gst_debug_get_all_categories()                  (NULL)
920 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
921
922 #ifdef G_HAVE_ISO_VARARGS
923
924 #define GST_CAT_LEVEL_LOG(cat,level,...)                /* NOP */
925
926 #define GST_CAT_ERROR_OBJECT(...)                       /* NOP */
927 #define GST_CAT_WARNING_OBJECT(...)                     /* NOP */
928 #define GST_CAT_INFO_OBJECT(...)                        /* NOP */
929 #define GST_CAT_DEBUG_OBJECT(...)                       /* NOP */
930 #define GST_CAT_LOG_OBJECT(...)                         /* NOP */
931
932 #define GST_CAT_ERROR(...)                              /* NOP */
933 #define GST_CAT_WARNING(...)                            /* NOP */
934 #define GST_CAT_INFO(...)                               /* NOP */
935 #define GST_CAT_DEBUG(...)                              /* NOP */
936 #define GST_CAT_LOG(...)                                /* NOP */
937
938 #define GST_ERROR_OBJECT(...)                           /* NOP */
939 #define GST_WARNING_OBJECT(...)                         /* NOP */
940 #define GST_INFO_OBJECT(...)                            /* NOP */
941 #define GST_DEBUG_OBJECT(...)                           /* NOP */
942 #define GST_LOG_OBJECT(...)                             /* NOP */
943
944 #define GST_ERROR(...)                                  /* NOP */
945 #define GST_WARNING(...)                                /* NOP */
946 #define GST_INFO(...)                                   /* NOP */
947 #define GST_DEBUG(...)                                  /* NOP */
948 #define GST_LOG(...)                                    /* NOP */
949
950 #else
951 #ifdef G_HAVE_GNUC_VARARGS
952
953 #define GST_CAT_LEVEL_LOG(cat,level,args...)            /* NOP */
954
955 #define GST_CAT_ERROR_OBJECT(args...)                   /* NOP */
956 #define GST_CAT_WARNING_OBJECT(args...)                 /* NOP */
957 #define GST_CAT_INFO_OBJECT(args...)                    /* NOP */
958 #define GST_CAT_DEBUG_OBJECT(args...)                   /* NOP */
959 #define GST_CAT_LOG_OBJECT(args...)                     /* NOP */
960
961 #define GST_CAT_ERROR(args...)                          /* NOP */
962 #define GST_CAT_WARNING(args...)                        /* NOP */
963 #define GST_CAT_INFO(args...)                           /* NOP */
964 #define GST_CAT_DEBUG(args...)                          /* NOP */
965 #define GST_CAT_LOG(args...)                            /* NOP */
966
967 #define GST_ERROR_OBJECT(args...)                       /* NOP */
968 #define GST_WARNING_OBJECT(args...)                     /* NOP */
969 #define GST_INFO_OBJECT(args...)                        /* NOP */
970 #define GST_DEBUG_OBJECT(args...)                       /* NOP */
971 #define GST_LOG_OBJECT(args...)                         /* NOP */
972
973 #define GST_ERROR(args...)                              /* NOP */
974 #define GST_WARNING(args...)                            /* NOP */
975 #define GST_INFO(args...)                               /* NOP */
976 #define GST_DEBUG(args...)                              /* NOP */
977 #define GST_LOG(args...)                                /* NOP */
978
979 #else
980 static inline void
981 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
982     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
983 {
984 }
985
986 static inline void
987 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
988     ...)
989 {
990 }
991
992 static inline void
993 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
994     const char *format, ...)
995 {
996 }
997
998 static inline void
999 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1000     ...)
1001 {
1002 }
1003
1004 static inline void
1005 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1006     ...)
1007 {
1008 }
1009
1010 static inline void
1011 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1012     ...)
1013 {
1014 }
1015
1016 static inline void
1017 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1018 {
1019 }
1020
1021 static inline void
1022 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1023 {
1024 }
1025
1026 static inline void
1027 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1028 {
1029 }
1030
1031 static inline void
1032 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1033 {
1034 }
1035
1036 static inline void
1037 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1038 {
1039 }
1040
1041 static inline void
1042 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1043 {
1044 }
1045
1046 static inline void
1047 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1048 {
1049 }
1050
1051 static inline void
1052 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1053 {
1054 }
1055
1056 static inline void
1057 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1058 {
1059 }
1060
1061 static inline void
1062 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1063 {
1064 }
1065
1066 static inline void
1067 GST_ERROR (const char *format, ...)
1068 {
1069 }
1070
1071 static inline void
1072 GST_WARNING (const char *format, ...)
1073 {
1074 }
1075
1076 static inline void
1077 GST_INFO (const char *format, ...)
1078 {
1079 }
1080
1081 static inline void
1082 GST_DEBUG (const char *format, ...)
1083 {
1084 }
1085
1086 static inline void
1087 GST_LOG (const char *format, ...)
1088 {
1089 }
1090 #endif
1091 #endif
1092
1093 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
1094 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
1095
1096 #endif /* GST_DISABLE_GST_DEBUG */
1097
1098 void gst_debug_print_stack_trace (void);
1099
1100 G_END_DECLS
1101
1102 #endif /* __GSTINFO_H__ */