configure.ac: comment about refining the xml deps
[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   (pad != NULL) ?  \
189   ((GST_OBJECT_PARENT(pad) != NULL) ? \
190   GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
191   "''" ) : "''", \
192   (pad != NULL) ? GST_STR_NULL (GST_OBJECT_NAME (pad)) : "''"
193
194 /**
195  * GST_FUNCTION:
196  *
197  * This macro should evaluate to the name of the current function and be should
198  * be defined when configuring your project, as it is compiler dependant. If it
199  * is not defined, some default value is used. It is used to provide debugging
200  * output with the function name of the message.
201  */
202 #ifndef GST_FUNCTION
203 #if defined (__GNUC__)
204 #  define GST_FUNCTION     ((const char*) (__PRETTY_FUNCTION__))
205 #elif defined (G_HAVE_ISO_VARARGS)
206 #  define GST_FUNCTION     ((const char*) (__func__))
207 #else
208 #  define GST_FUNCTION     ((const char*) ("???"))
209 #endif
210 #endif /* ifndef GST_FUNCTION */
211
212
213 typedef struct _GstDebugMessage GstDebugMessage;
214
215 /**
216  * GstLogFunction:
217  * @category: a #GstDebugCategory
218  * @level: a #GstDebugLevel
219  * @file: file name
220  * @function: function name
221  * @line: line number
222  * @object: a #GObject
223  * @message: the message
224  * @data: user data for the log function
225  *
226  * Function prototype for a logging function that can be registered with
227  * gst_debug_add_log_function().
228  * Use G_GNUC_NO_INSTRUMENT on that function.
229  */
230 typedef void (*GstLogFunction)  (GstDebugCategory * category,
231                                  GstDebugLevel      level,
232                                  const gchar      * file,
233                                  const gchar      * function,
234                                  gint               line,
235                                  GObject          * object,
236                                  GstDebugMessage  * message,
237                                  gpointer           data);
238
239 #ifndef GST_DISABLE_GST_DEBUG
240
241 void            _gst_debug_init (void);
242
243
244 #ifdef GST_USING_PRINTF_EXTENSION
245
246 /* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */
247 void                gst_debug_log            (GstDebugCategory * category,
248                                           GstDebugLevel      level,
249                                           const gchar      * file,
250                                           const gchar      * function,
251                                           gint               line,
252                                           GObject          * object,
253                                           const gchar      * format,
254                                           ...) G_GNUC_NO_INSTRUMENT;
255
256 #else /* GST_USING_PRINTF_EXTENSION */
257
258 void                gst_debug_log            (GstDebugCategory * category,
259                                           GstDebugLevel      level,
260                                           const gchar      * file,
261                                           const gchar      * function,
262                                           gint               line,
263                                           GObject          * object,
264                                           const gchar      * format,
265                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
266
267 #endif /* GST_USING_PRINTF_EXTENSION */
268
269 void            gst_debug_log_valist     (GstDebugCategory * category,
270                                           GstDebugLevel      level,
271                                           const gchar      * file,
272                                           const gchar      * function,
273                                           gint                line,
274                                           GObject          * object,
275                                           const gchar      * format,
276                                           va_list            args) G_GNUC_NO_INSTRUMENT;
277
278 const gchar   * gst_debug_message_get    (GstDebugMessage  * message);
279
280 void            gst_debug_log_default    (GstDebugCategory * category,
281                                           GstDebugLevel      level,
282                                           const gchar      * file,
283                                           const gchar      * function,
284                                           gint               line,
285                                           GObject          * object,
286                                           GstDebugMessage  * message,
287                                           gpointer           unused) G_GNUC_NO_INSTRUMENT;
288
289 G_CONST_RETURN gchar *
290                 gst_debug_level_get_name (GstDebugLevel level);
291
292 void            gst_debug_add_log_function            (GstLogFunction func,
293                                                        gpointer       data);
294 guint           gst_debug_remove_log_function         (GstLogFunction func);
295 guint           gst_debug_remove_log_function_by_data (gpointer       data);
296
297 void            gst_debug_set_active  (gboolean active);
298 gboolean        gst_debug_is_active   (void);
299
300 void            gst_debug_set_colored (gboolean colored);
301 gboolean        gst_debug_is_colored  (void);
302
303 void            gst_debug_set_default_threshold     (GstDebugLevel level);
304 GstDebugLevel   gst_debug_get_default_threshold     (void);
305 void            gst_debug_set_threshold_for_name    (const gchar * name,
306                                                      GstDebugLevel level);
307 void            gst_debug_unset_threshold_for_name  (const gchar * name);
308
309 /**
310  * GST_DEBUG_CATEGORY:
311  * @cat: the category
312  *
313  * Defines a GstDebugCategory variable.
314  * This macro expands to nothing if debugging is disabled.
315  */
316 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
317 /**
318  * GST_DEBUG_CATEGORY_EXTERN:
319  * @cat: the category
320  *
321  * Declares a GstDebugCategory variable as extern. Use in header files.
322  * This macro expands to nothing if debugging is disabled.
323  */
324 #ifndef _MSC_VER
325 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
326 #else /* _MSC_VER */
327 #define GST_DEBUG_CATEGORY_EXTERN(cat) \
328   extern __declspec (dllimport) GstDebugCategory *cat;
329 #endif
330
331 /**
332  * GST_DEBUG_CATEGORY_STATIC:
333  * @cat: the category
334  *
335  * Defines a static GstDebugCategory variable.
336  * This macro expands to nothing if debugging is disabled.
337  */
338 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
339 /* do not use this function, use the macros below */
340 GstDebugCategory *_gst_debug_category_new       (gchar *        name,
341                                                  guint          color,
342                                                  gchar *        description);
343 /**
344  * GST_DEBUG_CATEGORY_INIT:
345  * @cat: the category to initialize.
346  * @name: the name of the category.
347  * @color: the colors to use for a color representation or 0 for no color.
348  * @description: optional description of the category.
349  *
350  * Initializes a new #GstDebugCategory with the given properties and set to
351  * the default threshold.
352  *
353  * <note>
354  * <para>
355  * This macro expands to nothing if debugging is disabled.
356  * </para>
357  * <para>
358  * When naming your category, please follow the following conventions to ensure
359  * that the pattern matching for categories works as expected. It is not
360  * earth-shattering if you don't follow these conventions, but it would be nice
361  * for everyone.
362  * </para>
363  * <para>
364  * If you define a category for a plugin or a feature of it, name the category
365  * like the feature. So if you wanted to write a "filesrc" element, you would
366  * name the category "filesrc". Use lowercase letters only.
367  * If you define more than one category for the same element, append an
368  * underscore and an identifier to your categories, like this: "filesrc_cache"
369  * </para>
370  * <para>
371  * If you create a library or an application using debugging categories, use a
372  * common prefix followed by an underscore for all your categories. GStreamer
373  * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
374  * to include uppercase letters.
375  * </para>
376  * </note>
377  */
378 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
379   if (cat == NULL)                                                      \
380     cat = _gst_debug_category_new (name,color,description);             \
381 }G_STMT_END
382
383 void    gst_debug_category_free         (GstDebugCategory *     category);
384 void    gst_debug_category_set_threshold (GstDebugCategory *    category,
385                                          GstDebugLevel          level);
386 void    gst_debug_category_reset_threshold(GstDebugCategory *   category);
387 GstDebugLevel
388         gst_debug_category_get_threshold (GstDebugCategory *    category);
389 G_CONST_RETURN gchar *
390         gst_debug_category_get_name     (GstDebugCategory *     category);
391 guint   gst_debug_category_get_color    (GstDebugCategory *     category);
392 G_CONST_RETURN gchar *
393         gst_debug_category_get_description (GstDebugCategory *  category);
394 GSList *
395         gst_debug_get_all_categories    (void);
396
397 gchar * gst_debug_construct_term_color  (guint colorinfo);
398
399
400 /**
401  * GST_CAT_DEFAULT:
402  *
403  * Default gstreamer core debug log category. Please define your own.
404  */
405 GST_EXPORT GstDebugCategory *   GST_CAT_DEFAULT;
406 /* this symbol may not be used */
407 extern gboolean                 __gst_debug_enabled;
408
409 /* since 0.10.7, the min debug level, used for quickly discarding debug
410  * messages that fall under the threshold. */
411 extern GstDebugLevel            __gst_debug_min; 
412
413 /**
414  * GST_CAT_LEVEL_LOG:
415  * @cat: category to use
416  * @level: the severity of the message
417  * @object: the #GObject the message belongs to or NULL if none
418  * @...: A printf-style message to output
419  *
420  * Outputs a debugging message. This is the most general macro for outputting
421  * debugging messages. You will probably want to use one of the ones described
422  * below.
423  */
424 #ifdef G_HAVE_ISO_VARARGS
425 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{           \
426   if (G_UNLIKELY (level <= __gst_debug_min)) {                                          \
427     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
428         (GObject *) (object), __VA_ARGS__);                             \
429   }                                                                     \
430 }G_STMT_END
431 #else /* G_HAVE_GNUC_VARARGS */
432 #ifdef G_HAVE_GNUC_VARARGS
433 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{       \
434   if (G_UNLIKELY (level <= __gst_debug_min)) {                                          \
435     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
436         (GObject *) (object), ##args );                                 \
437   }                                                                     \
438 }G_STMT_END
439 #else /* no variadic macros, use inline */
440 static inline void
441 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
442     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
443 {
444   gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
445       varargs);
446 }
447
448 static inline void
449 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
450     gpointer object, const char *format, ...)
451 {
452   if (G_UNLIKELY (level <= __gst_debug_min)) {
453     va_list varargs;
454
455     va_start (varargs, format);
456     GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
457     va_end (varargs);
458   }
459 }
460 #endif
461 #endif /* G_HAVE_ISO_VARARGS */
462
463 /**
464  * GST_CAT_ERROR_OBJECT:
465  * @cat: category to use
466  * @obj: the #GObject the message belongs to
467  * @...: printf-style message to output
468  *
469  * Output an error message belonging to the given object in the given category.
470  */
471 /**
472  * GST_CAT_WARNING_OBJECT:
473  * @cat: category to use
474  * @obj: the #GObject the message belongs to
475  * @...: printf-style message to output
476  *
477  * Output a warning message belonging to the given object in the given category.
478  */
479 /**
480  * GST_CAT_INFO_OBJECT:
481  * @cat: category to use
482  * @obj: the #GObject the message belongs to
483  * @...: printf-style message to output
484  *
485  * Output an informational message belonging to the given object in the given
486  * category.
487  */
488 /**
489  * GST_CAT_DEBUG_OBJECT:
490  * @cat: category to use
491  * @obj: the #GObject the message belongs to
492  * @...: printf-style message to output
493  *
494  * Output an debugging message belonging to the given object in the given category.
495  */
496 /**
497  * GST_CAT_LOG_OBJECT:
498  * @cat: category to use
499  * @obj: the #GObject the message belongs to
500  * @...: printf-style message to output
501  *
502  * Output an logging message belonging to the given object in the given category.
503  */
504
505
506 /**
507  * GST_CAT_ERROR:
508  * @cat: category to use
509  * @...: printf-style message to output
510  *
511  * Output an error message in the given category.
512  */
513 /**
514  * GST_CAT_WARNING:
515  * @cat: category to use
516  * @...: printf-style message to output
517  *
518  * Output an warning message in the given category.
519  */
520 /**
521  * GST_CAT_INFO:
522  * @cat: category to use
523  * @...: printf-style message to output
524  *
525  * Output an informational message in the given category.
526  */
527 /**
528  * GST_CAT_DEBUG:
529  * @cat: category to use
530  * @...: printf-style message to output
531  *
532  * Output an debugging message in the given category.
533  */
534 /**
535  * GST_CAT_LOG:
536  * @cat: category to use
537  * @...: printf-style message to output
538  *
539  * Output an logging message in the given category.
540  */
541
542
543 /**
544  * GST_ERROR_OBJECT:
545  * @obj: the #GObject the message belongs to
546  * @...: printf-style message to output
547  *
548  * Output an error message belonging to the given object in the default category.
549  */
550 /**
551  * GST_WARNING_OBJECT:
552  * @obj: the #GObject the message belongs to
553  * @...: printf-style message to output
554  *
555  * Output a warning message belonging to the given object in the default category.
556  */
557 /**
558  * GST_INFO_OBJECT:
559  * @obj: the #GObject the message belongs to
560  * @...: printf-style message to output
561  *
562  * Output an informational message belonging to the given object in the default
563  * category.
564  */
565 /**
566  * GST_DEBUG_OBJECT:
567  * @obj: the #GObject the message belongs to
568  * @...: printf-style message to output
569  *
570  * Output a debugging message belonging to the given object in the default
571  * category.
572  */
573 /**
574  * GST_LOG_OBJECT:
575  * @obj: the #GObject the message belongs to
576  * @...: printf-style message to output
577  *
578  * Output a logging message belonging to the given object in the default category.
579  */
580
581
582 /**
583  * GST_ERROR:
584  * @...: printf-style message to output
585  *
586  * Output an error message in the default category.
587  */
588 /**
589  * GST_WARNING:
590  * @...: printf-style message to output
591  *
592  * Output a warning message in the default category.
593  */
594 /**
595  * GST_INFO:
596  * @...: printf-style message to output
597  *
598  * Output an informational message in the default category.
599  */
600 /**
601  * GST_DEBUG:
602  * @...: printf-style message to output
603  *
604  * Output a debugging message in the default category.
605  */
606 /**
607  * GST_LOG:
608  * @...: printf-style message to output
609  *
610  * Output a logging message in the default category.
611  */
612
613 #ifdef G_HAVE_ISO_VARARGS
614
615 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
616 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
617 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
618 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
619 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
620
621 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
622 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
623 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
624 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
625 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
626
627 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
628 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
629 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
630 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
631 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
632
633 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
634 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
635 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
636 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
637 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
638
639 #else
640 #ifdef G_HAVE_GNUC_VARARGS
641
642 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
643 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
644 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
645 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
646 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
647
648 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
649 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
650 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
651 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
652 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
653
654 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
655 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
656 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
657 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
658 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
659
660 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
661 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
662 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
663 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
664 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
665
666 #else
667 /* no variadic macros, use inline */
668 static inline void
669 GST_CAT_ERROR_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_ERROR, obj, format, varargs);
676   va_end (varargs);
677 }
678
679 static inline void
680 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
681     const char *format, ...)
682 {
683   va_list varargs;
684
685   va_start (varargs, format);
686   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
687   va_end (varargs);
688 }
689
690 static inline void
691 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
692     ...)
693 {
694   va_list varargs;
695
696   va_start (varargs, format);
697   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
698   va_end (varargs);
699 }
700
701 static inline void
702 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
703     ...)
704 {
705   va_list varargs;
706
707   va_start (varargs, format);
708   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
709   va_end (varargs);
710 }
711
712 static inline void
713 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
714     ...)
715 {
716   va_list varargs;
717
718   va_start (varargs, format);
719   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
720   va_end (varargs);
721 }
722
723 static inline void
724 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
725 {
726   va_list varargs;
727
728   va_start (varargs, format);
729   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
730   va_end (varargs);
731 }
732
733 static inline void
734 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
735 {
736   va_list varargs;
737
738   va_start (varargs, format);
739   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
740   va_end (varargs);
741 }
742
743 static inline void
744 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
745 {
746   va_list varargs;
747
748   va_start (varargs, format);
749   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
750   va_end (varargs);
751 }
752
753 static inline void
754 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
755 {
756   va_list varargs;
757
758   va_start (varargs, format);
759   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
760   va_end (varargs);
761 }
762
763 static inline void
764 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
765 {
766   va_list varargs;
767
768   va_start (varargs, format);
769   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
770   va_end (varargs);
771 }
772
773 static inline void
774 GST_ERROR_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_ERROR, obj, format,
780       varargs);
781   va_end (varargs);
782 }
783
784 static inline void
785 GST_WARNING_OBJECT (gpointer obj, 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_WARNING, obj, format,
791       varargs);
792   va_end (varargs);
793 }
794
795 static inline void
796 GST_INFO_OBJECT (gpointer obj, 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_INFO, obj, format,
802       varargs);
803   va_end (varargs);
804 }
805
806 static inline void
807 GST_DEBUG_OBJECT (gpointer obj, 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_DEBUG, obj, format,
813       varargs);
814   va_end (varargs);
815 }
816
817 static inline void
818 GST_LOG_OBJECT (gpointer obj, 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_LOG, obj, format,
824       varargs);
825   va_end (varargs);
826 }
827
828 static inline void
829 GST_ERROR (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_ERROR, NULL, format,
835       varargs);
836   va_end (varargs);
837 }
838
839 static inline void
840 GST_WARNING (const char *format, ...)
841 {
842   va_list varargs;
843
844   va_start (varargs, format);
845   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
846       varargs);
847   va_end (varargs);
848 }
849
850 static inline void
851 GST_INFO (const char *format, ...)
852 {
853   va_list varargs;
854
855   va_start (varargs, format);
856   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
857       varargs);
858   va_end (varargs);
859 }
860
861 static inline void
862 GST_DEBUG (const char *format, ...)
863 {
864   va_list varargs;
865
866   va_start (varargs, format);
867   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
868       varargs);
869   va_end (varargs);
870 }
871
872 static inline void
873 GST_LOG (const char *format, ...)
874 {
875   va_list varargs;
876
877   va_start (varargs, format);
878   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
879       format, varargs);
880   va_end (varargs);
881 }
882 #endif
883 #endif
884
885
886 /********** function pointer stuff **********/
887
888 typedef void (* GstDebugFuncPtr)        (void);
889 void    _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
890                                          const gchar *          ptrname);
891 G_CONST_RETURN gchar *
892         _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func);
893
894 /**
895  * GST_DEBUG_FUNCPTR:
896  * @ptr: pointer to the function to register
897  *
898  * Register a pointer to a function with its name, so it can later be used by
899  * GST_DEBUG_FUNCPTR_NAME().
900  */
901 #define GST_DEBUG_FUNCPTR(ptr) \
902   (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
903
904 /**
905  * GST_DEBUG_FUNCPTR_NAME:
906  * @ptr: address of the function of which to look up the name
907  *
908  * Retrieves the name of the function, if it was previously registered with
909  * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
910  *
911  * This macro returns a constant string which must not be modified or
912  * freed by the caller.
913  */
914 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
915   _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
916
917 #else /* GST_DISABLE_GST_DEBUG */
918
919 #if defined(__GNUC__) && __GNUC__ >= 3
920 #  pragma GCC poison gst_debug_log
921 #  pragma GCC poison gst_debug_log_valist
922 #  pragma GCC poison _gst_debug_category_new
923 #endif
924
925 #define _gst_debug_init()                               /* NOP */
926
927 #define gst_debug_set_default_threshold(level)          /* NOP */
928 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
929
930 #define gst_debug_level_get_name(level)                         ("NONE")
931 #define gst_debug_message_get(message)                          ("NONE")
932 #define gst_debug_add_log_function(func,data)           /* NOP */
933 guint gst_debug_remove_log_function (GstLogFunction func);
934 guint gst_debug_remove_log_function_by_data (gpointer data);
935 #define gst_debug_set_active(active)                    /* NOP */
936 #define gst_debug_is_active()                           (FALSE)
937 #define gst_debug_set_colored(colored)                  /* NOP */
938 #define gst_debug_is_colored()                          (FALSE)
939 #define gst_debug_set_default_threshold(level)          /* NOP */
940 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
941 #define gst_debug_set_threshold_for_name(name,level)    /* NOP */
942 #define gst_debug_unset_threshold_for_name(name)        /* NOP */
943
944 #define GST_DEBUG_CATEGORY(var)                         /* NOP */
945 #define GST_DEBUG_CATEGORY_EXTERN(var)                  /* NOP */
946 #if !defined(G_HAVE_GNUC_VARARGS) && !defined(G_HAVE_ISO_VARARGS)
947 #define GST_DEBUG_CATEGORY_STATIC(var)                  static GstDebugCategory *var = NULL
948 #else
949 #define GST_DEBUG_CATEGORY_STATIC(var)                  /* NOP */
950 #endif
951 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    /* NOP */
952 #define gst_debug_category_free(category)               /* NOP */
953 #define gst_debug_category_set_threshold(category,level) /* NOP */
954 #define gst_debug_category_reset_threshold(category)    /* NOP */
955 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
956 #define gst_debug_category_get_name(cat)                ("")
957 #define gst_debug_category_get_color(cat)               (0)
958 #define gst_debug_category_get_description(cat)         ("")
959 #define gst_debug_get_all_categories()                  (NULL)
960 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
961
962 #ifdef G_HAVE_ISO_VARARGS
963
964 #define GST_CAT_LEVEL_LOG(cat,level,...)                /* NOP */
965
966 #define GST_CAT_ERROR_OBJECT(...)                       /* NOP */
967 #define GST_CAT_WARNING_OBJECT(...)                     /* NOP */
968 #define GST_CAT_INFO_OBJECT(...)                        /* NOP */
969 #define GST_CAT_DEBUG_OBJECT(...)                       /* NOP */
970 #define GST_CAT_LOG_OBJECT(...)                         /* NOP */
971
972 #define GST_CAT_ERROR(...)                              /* NOP */
973 #define GST_CAT_WARNING(...)                            /* NOP */
974 #define GST_CAT_INFO(...)                               /* NOP */
975 #define GST_CAT_DEBUG(...)                              /* NOP */
976 #define GST_CAT_LOG(...)                                /* NOP */
977
978 #define GST_ERROR_OBJECT(...)                           /* NOP */
979 #define GST_WARNING_OBJECT(...)                         /* NOP */
980 #define GST_INFO_OBJECT(...)                            /* NOP */
981 #define GST_DEBUG_OBJECT(...)                           /* NOP */
982 #define GST_LOG_OBJECT(...)                             /* NOP */
983
984 #define GST_ERROR(...)                                  /* NOP */
985 #define GST_WARNING(...)                                /* NOP */
986 #define GST_INFO(...)                                   /* NOP */
987 #define GST_DEBUG(...)                                  /* NOP */
988 #define GST_LOG(...)                                    /* NOP */
989
990 #else
991 #ifdef G_HAVE_GNUC_VARARGS
992
993 #define GST_CAT_LEVEL_LOG(cat,level,args...)            /* NOP */
994
995 #define GST_CAT_ERROR_OBJECT(args...)                   /* NOP */
996 #define GST_CAT_WARNING_OBJECT(args...)                 /* NOP */
997 #define GST_CAT_INFO_OBJECT(args...)                    /* NOP */
998 #define GST_CAT_DEBUG_OBJECT(args...)                   /* NOP */
999 #define GST_CAT_LOG_OBJECT(args...)                     /* NOP */
1000
1001 #define GST_CAT_ERROR(args...)                          /* NOP */
1002 #define GST_CAT_WARNING(args...)                        /* NOP */
1003 #define GST_CAT_INFO(args...)                           /* NOP */
1004 #define GST_CAT_DEBUG(args...)                          /* NOP */
1005 #define GST_CAT_LOG(args...)                            /* NOP */
1006
1007 #define GST_ERROR_OBJECT(args...)                       /* NOP */
1008 #define GST_WARNING_OBJECT(args...)                     /* NOP */
1009 #define GST_INFO_OBJECT(args...)                        /* NOP */
1010 #define GST_DEBUG_OBJECT(args...)                       /* NOP */
1011 #define GST_LOG_OBJECT(args...)                         /* NOP */
1012
1013 #define GST_ERROR(args...)                              /* NOP */
1014 #define GST_WARNING(args...)                            /* NOP */
1015 #define GST_INFO(args...)                               /* NOP */
1016 #define GST_DEBUG(args...)                              /* NOP */
1017 #define GST_LOG(args...)                                /* NOP */
1018
1019 #else
1020 static inline void
1021 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
1022     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
1023 {
1024 }
1025
1026 static inline void
1027 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1028     ...)
1029 {
1030 }
1031
1032 static inline void
1033 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1034     const char *format, ...)
1035 {
1036 }
1037
1038 static inline void
1039 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1040     ...)
1041 {
1042 }
1043
1044 static inline void
1045 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1046     ...)
1047 {
1048 }
1049
1050 static inline void
1051 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1052     ...)
1053 {
1054 }
1055
1056 static inline void
1057 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1058 {
1059 }
1060
1061 static inline void
1062 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1063 {
1064 }
1065
1066 static inline void
1067 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1068 {
1069 }
1070
1071 static inline void
1072 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1073 {
1074 }
1075
1076 static inline void
1077 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1078 {
1079 }
1080
1081 static inline void
1082 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1083 {
1084 }
1085
1086 static inline void
1087 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1088 {
1089 }
1090
1091 static inline void
1092 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1093 {
1094 }
1095
1096 static inline void
1097 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1098 {
1099 }
1100
1101 static inline void
1102 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1103 {
1104 }
1105
1106 static inline void
1107 GST_ERROR (const char *format, ...)
1108 {
1109 }
1110
1111 static inline void
1112 GST_WARNING (const char *format, ...)
1113 {
1114 }
1115
1116 static inline void
1117 GST_INFO (const char *format, ...)
1118 {
1119 }
1120
1121 static inline void
1122 GST_DEBUG (const char *format, ...)
1123 {
1124 }
1125
1126 static inline void
1127 GST_LOG (const char *format, ...)
1128 {
1129 }
1130 #endif
1131 #endif
1132
1133 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
1134 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
1135
1136 #endif /* GST_DISABLE_GST_DEBUG */
1137
1138 void gst_debug_print_stack_trace (void);
1139
1140 G_END_DECLS
1141
1142 #endif /* __GSTINFO_H__ */