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