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