info: fix compiler warning with -Wpedantic and gcc 5
[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., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, 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 occurred
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_error.
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_FIXME: Fixme messages are messages that indicate that something
46  *  in the executed code path is not fully implemented or handled yet. Note
47  *  that this does not replace proper error handling in any way, the purpose
48  *  of this message is to make it easier to spot incomplete/unfinished pieces
49  *  of code when reading the debug log.
50  * @GST_LEVEL_INFO: Informational messages should be used to keep the developer
51  *  updated about what is happening.
52  *  Examples where this should be used are when a typefind function has
53  *  successfully determined the type of the stream or when an mp3 plugin detects
54  *  the format to be used. ("This file has mono sound.")
55  * @GST_LEVEL_DEBUG: Debugging messages should be used when something common
56  *  happens that is not the expected default behavior, or something that's
57  *  useful to know but doesn't happen all the time (ie. per loop iteration or
58  *  buffer processed or event handled).
59  *  An example would be notifications about state changes or receiving/sending
60  *  of events.
61  * @GST_LEVEL_LOG: Log messages are messages that are very common but might be
62  *  useful to know. As a rule of thumb a pipeline that is running as expected
63  *  should never output anything else but LOG messages whilst processing data.
64  *  Use this log level to log recurring information in chain functions and
65  *  loop functions, for example.
66  * @GST_LEVEL_TRACE: Tracing-related messages.
67  *  Examples for this are referencing/dereferencing of objects.
68  * @GST_LEVEL_MEMDUMP: memory dump messages are used to log (small) chunks of
69  *  data as memory dumps in the log. They will be displayed as hexdump with
70  *  ASCII characters.
71  * @GST_LEVEL_COUNT: The number of defined debugging levels.
72  *
73  * The level defines the importance of a debugging message. The more important a
74  * message is, the greater the probability that the debugging system outputs it.
75  */
76 typedef enum {
77   GST_LEVEL_NONE = 0,
78   GST_LEVEL_ERROR = 1,
79   GST_LEVEL_WARNING = 2,
80   GST_LEVEL_FIXME = 3,
81   GST_LEVEL_INFO = 4,
82   GST_LEVEL_DEBUG = 5,
83   GST_LEVEL_LOG = 6,
84   GST_LEVEL_TRACE = 7,
85   /* add more */
86   GST_LEVEL_MEMDUMP = 9,
87   /* add more */
88   GST_LEVEL_COUNT
89 } GstDebugLevel;
90
91 /**
92  * GST_LEVEL_DEFAULT:
93  *
94  * Defines the default debugging level to be used with GStreamer. It is normally
95  * set to #GST_LEVEL_NONE so nothing get printed.
96  * As it can be configured at compile time, developer builds may chose to
97  * override that though.
98  * You can use this as an argument to gst_debug_set_default_threshold() to
99  * reset the debugging output to default behaviour.
100  */
101 #ifndef GST_LEVEL_DEFAULT
102 #define GST_LEVEL_DEFAULT GST_LEVEL_NONE
103 #endif
104
105 /**
106  * GST_LEVEL_MAX:
107  *
108  * Defines the maximum debugging level to be enabled at compilation time. By default
109  * it is set such that all debugging statements will be enabled.
110  *
111  * If you wish to compile GStreamer and plugins with only some debugging statements
112  * (Such as just warnings and errors), you can define it at compile time to the
113  * maximum debug level. Any debug statements above that level will be compiled out.
114  *
115  * Since: 1.6
116  */
117 #ifndef GST_LEVEL_MAX
118 #define GST_LEVEL_MAX GST_LEVEL_COUNT
119 #endif
120
121 /* defines for format (colors etc)
122  * don't change them around, it uses terminal layout
123  * Terminal color strings:
124  * 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
125  * Text color codes:
126  * 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
127  * Background color codes:
128  * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
129  */
130 /**
131  * GstDebugColorFlags:
132  * @GST_DEBUG_FG_BLACK: Use black as foreground color.
133  * @GST_DEBUG_FG_RED: Use red as foreground color.
134  * @GST_DEBUG_FG_GREEN: Use green as foreground color.
135  * @GST_DEBUG_FG_YELLOW: Use yellow as foreground color.
136  * @GST_DEBUG_FG_BLUE: Use blue as foreground color.
137  * @GST_DEBUG_FG_MAGENTA: Use magenta as foreground color.
138  * @GST_DEBUG_FG_CYAN: Use cyan as foreground color.
139  * @GST_DEBUG_FG_WHITE: Use white as foreground color.
140  * @GST_DEBUG_BG_BLACK: Use black as background color.
141  * @GST_DEBUG_BG_RED: Use red as background color.
142  * @GST_DEBUG_BG_GREEN: Use green as background color.
143  * @GST_DEBUG_BG_YELLOW: Use yellow as background color.
144  * @GST_DEBUG_BG_BLUE: Use blue as background color.
145  * @GST_DEBUG_BG_MAGENTA: Use magenta as background color.
146  * @GST_DEBUG_BG_CYAN: Use cyan as background color.
147  * @GST_DEBUG_BG_WHITE: Use white as background color.
148  * @GST_DEBUG_BOLD: Make the output bold.
149  * @GST_DEBUG_UNDERLINE: Underline the output.
150  *
151  * These are some terminal style flags you can use when creating your
152  * debugging categories to make them stand out in debugging output.
153  */
154 typedef enum {
155   /* colors */
156   GST_DEBUG_FG_BLACK            = 0x0000,
157   GST_DEBUG_FG_RED              = 0x0001,
158   GST_DEBUG_FG_GREEN            = 0x0002,
159   GST_DEBUG_FG_YELLOW           = 0x0003,
160   GST_DEBUG_FG_BLUE             = 0x0004,
161   GST_DEBUG_FG_MAGENTA          = 0x0005,
162   GST_DEBUG_FG_CYAN             = 0x0006,
163   GST_DEBUG_FG_WHITE            = 0x0007,
164   /* background colors */
165   GST_DEBUG_BG_BLACK            = 0x0000,
166   GST_DEBUG_BG_RED              = 0x0010,
167   GST_DEBUG_BG_GREEN            = 0x0020,
168   GST_DEBUG_BG_YELLOW           = 0x0030,
169   GST_DEBUG_BG_BLUE             = 0x0040,
170   GST_DEBUG_BG_MAGENTA          = 0x0050,
171   GST_DEBUG_BG_CYAN             = 0x0060,
172   GST_DEBUG_BG_WHITE            = 0x0070,
173   /* other formats */
174   GST_DEBUG_BOLD                = 0x0100,
175   GST_DEBUG_UNDERLINE           = 0x0200
176 } GstDebugColorFlags;
177
178 /**
179  * GstDebugColorMode:
180  * @GST_DEBUG_COLOR_MODE_OFF: Do not use colors in logs.
181  * @GST_DEBUG_COLOR_MODE_ON: Paint logs in a platform-specific way.
182  * @GST_DEBUG_COLOR_MODE_UNIX: Paint logs with UNIX terminal color codes
183  *                             no matter what platform GStreamer is running on.
184  */
185 typedef enum {
186   GST_DEBUG_COLOR_MODE_OFF  = 0,
187   GST_DEBUG_COLOR_MODE_ON   = 1,
188   GST_DEBUG_COLOR_MODE_UNIX = 2
189 } GstDebugColorMode;
190
191
192 #define GST_DEBUG_FG_MASK       (0x000F)
193 #define GST_DEBUG_BG_MASK       (0x00F0)
194 #define GST_DEBUG_FORMAT_MASK   (0xFF00)
195
196 typedef struct _GstDebugCategory GstDebugCategory;
197 /**
198  * GstDebugCategory:
199  *
200  * This is the struct that describes the categories. Once initialized with
201  * #GST_DEBUG_CATEGORY_INIT, its values can't be changed anymore.
202  */
203 struct _GstDebugCategory {
204   /*< private >*/
205   gint                  threshold;
206   guint                 color;          /* see defines above */
207
208   const gchar *         name;
209   const gchar *         description;
210 };
211
212 /********** some convenience macros for debugging **********/
213
214 /**
215  * GST_STR_NULL:
216  * @str: (allow-none): The string to check.
217  *
218  * Macro to use when a string must not be %NULL, but may be %NULL. If the string
219  * is %NULL, "(NULL)" is printed instead.
220  * In GStreamer printf string arguments may not be %NULL, because on some
221  * platforms (ie Solaris) the libc crashes in that case. This includes debugging
222  * strings.
223  */
224 #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
225
226 /* FIXME, not MT safe */
227 /**
228  * GST_DEBUG_PAD_NAME:
229  * @pad: The pad to debug.
230  *
231  * Evaluates to 2 strings, that describe the pad. Often used in debugging
232  * statements.
233  */
234 #define GST_DEBUG_PAD_NAME(pad) \
235   (pad != NULL) ?  \
236   ((GST_OBJECT_PARENT(pad) != NULL) ? \
237   GST_STR_NULL (GST_OBJECT_NAME (GST_OBJECT_PARENT(pad))) : \
238   "''" ) : "''", \
239   (pad != NULL) ? GST_STR_NULL (GST_OBJECT_NAME (pad)) : "''"
240
241 /**
242  * GST_FUNCTION:
243  *
244  * This macro should evaluate to the name of the current function and be should
245  * be defined when configuring your project, as it is compiler dependant. If it
246  * is not defined, some default value is used. It is used to provide debugging
247  * output with the function name of the message.
248  *
249  * Note that this is different from G_STRFUNC as we do not want the full
250  * function signature in C++ code.
251  */
252 #ifndef GST_FUNCTION
253 #if defined (__STDC__) && defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
254 #  define GST_FUNCTION     ((const char*) (__func__))
255 #elif defined (__GNUC__) || (defined (_MSC_VER) && _MSC_VER >= 1300)
256 #  define GST_FUNCTION     ((const char*) (__FUNCTION__))
257 #else
258 #  define GST_FUNCTION     ((const char*) ("???"))
259 #endif
260 #endif /* ifndef GST_FUNCTION */
261
262 /**
263  * GST_PTR_FORMAT:
264  *
265  * printf format type used to debug GStreamer types.
266  * This can only be used on types whose size is >= sizeof(gpointer).
267  */
268 #define GST_PTR_FORMAT     "p\aA"
269
270 /**
271  * GST_SEGMENT_FORMAT:
272  *
273  * printf format type used to debug GStreamer segments.
274  * This can only be used on pointers to GstSegment structures.
275  */
276 #define GST_SEGMENT_FORMAT "p\aB"
277
278 typedef struct _GstDebugMessage GstDebugMessage;
279
280 /**
281  * GstLogFunction:
282  * @category: a #GstDebugCategory
283  * @level: a #GstDebugLevel
284  * @file: file name
285  * @function: function name
286  * @line: line number
287  * @object: a #GObject
288  * @message: the message
289  * @user_data: user data for the log function
290  *
291  * Function prototype for a logging function that can be registered with
292  * gst_debug_add_log_function().
293  * Use G_GNUC_NO_INSTRUMENT on that function.
294  */
295 typedef void (*GstLogFunction)  (GstDebugCategory * category,
296                                  GstDebugLevel      level,
297                                  const gchar      * file,
298                                  const gchar      * function,
299                                  gint               line,
300                                  GObject          * object,
301                                  GstDebugMessage  * message,
302                                  gpointer           user_data);
303
304 void                gst_debug_log            (GstDebugCategory * category,
305                                           GstDebugLevel      level,
306                                           const gchar      * file,
307                                           const gchar      * function,
308                                           gint               line,
309                                           GObject          * object,
310                                           const gchar      * format,
311                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
312
313 void            gst_debug_log_valist     (GstDebugCategory * category,
314                                           GstDebugLevel      level,
315                                           const gchar      * file,
316                                           const gchar      * function,
317                                           gint                line,
318                                           GObject          * object,
319                                           const gchar      * format,
320                                           va_list            args) G_GNUC_NO_INSTRUMENT;
321
322 /* do not use this function, use the GST_DEBUG_CATEGORY_INIT macro */
323 GstDebugCategory *_gst_debug_category_new (const gchar * name,
324                                            guint         color,
325                                            const gchar * description);
326 /* do not use this function, use the GST_DEBUG_CATEGORY_GET macro */
327 GstDebugCategory *_gst_debug_get_category (const gchar *name);
328
329
330 /* do not use this function, use the GST_CAT_MEMDUMP_* macros */
331 void _gst_debug_dump_mem (GstDebugCategory * cat, const gchar * file,
332     const gchar * func, gint line, GObject * obj, const gchar * msg,
333     const guint8 * data, guint length);
334
335 /* we define this to avoid a compiler warning regarding a cast from a function
336  * pointer to a void pointer
337  * (see https://bugzilla.gnome.org/show_bug.cgi?id=309253)
338  */
339 typedef void (* GstDebugFuncPtr)        (void);
340
341 /* do no use these functions, use the GST_DEBUG*_FUNCPTR macros */
342 void    _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
343                                          const gchar *          ptrname);
344 const gchar *
345         _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func) G_GNUC_NO_INSTRUMENT;
346
347
348 const gchar   * gst_debug_message_get    (GstDebugMessage  * message);
349
350 void            gst_debug_log_default    (GstDebugCategory * category,
351                                           GstDebugLevel      level,
352                                           const gchar      * file,
353                                           const gchar      * function,
354                                           gint               line,
355                                           GObject          * object,
356                                           GstDebugMessage  * message,
357                                           gpointer           user_data) G_GNUC_NO_INSTRUMENT;
358
359 const gchar *   gst_debug_level_get_name (GstDebugLevel level);
360
361 void            gst_debug_add_log_function            (GstLogFunction func,
362                                                        gpointer       user_data,
363                                                        GDestroyNotify notify);
364
365 guint           gst_debug_remove_log_function         (GstLogFunction func);
366 guint           gst_debug_remove_log_function_by_data (gpointer       data);
367
368 void            gst_debug_set_active  (gboolean active);
369 gboolean        gst_debug_is_active   (void);
370
371 void            gst_debug_set_colored (gboolean colored);
372 void            gst_debug_set_color_mode   (GstDebugColorMode mode);
373 void            gst_debug_set_color_mode_from_string (const gchar * mode);
374 gboolean        gst_debug_is_colored  (void);
375 GstDebugColorMode gst_debug_get_color_mode (void);
376
377 void            gst_debug_set_default_threshold      (GstDebugLevel level);
378 GstDebugLevel   gst_debug_get_default_threshold      (void);
379 void            gst_debug_set_threshold_for_name     (const gchar * name,
380                                                       GstDebugLevel level);
381 void            gst_debug_set_threshold_from_string  (const gchar * list, gboolean reset);
382 void            gst_debug_unset_threshold_for_name   (const gchar * name);
383
384
385 void            gst_debug_category_free              (GstDebugCategory *        category);
386 void                gst_debug_category_set_threshold     (GstDebugCategory *    category,
387                                                       GstDebugLevel             level);
388 void            gst_debug_category_reset_threshold   (GstDebugCategory *        category);
389 GstDebugLevel   gst_debug_category_get_threshold     (GstDebugCategory *        category);
390 const gchar *   gst_debug_category_get_name          (GstDebugCategory *        category);
391 guint           gst_debug_category_get_color         (GstDebugCategory *        category);
392 const gchar *   gst_debug_category_get_description   (GstDebugCategory *        category);
393 GSList *        gst_debug_get_all_categories    (void);
394
395
396 gchar * gst_debug_construct_term_color (guint colorinfo);
397 gint    gst_debug_construct_win_color  (guint colorinfo);
398
399
400 #ifndef GST_DISABLE_GST_DEBUG
401
402 #define gst_debug_add_log_function(func,data,notify) \
403 G_STMT_START{                                        \
404   if (func == gst_debug_log_default) {               \
405     gst_debug_add_log_function(NULL,data,notify);    \
406   } else {                                           \
407     gst_debug_add_log_function(func,data,notify);    \
408   }                                                  \
409 }G_STMT_END
410
411 #define gst_debug_remove_log_function(func)   \
412     (func == gst_debug_log_default) ?         \
413         gst_debug_remove_log_function(NULL) : \
414         gst_debug_remove_log_function(func)
415
416 /**
417  * GST_DEBUG_CATEGORY:
418  * @cat: the category
419  *
420  * Defines a GstDebugCategory variable.
421  * This macro expands to nothing if debugging is disabled.
422  */
423 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
424 /**
425  * GST_DEBUG_CATEGORY_EXTERN:
426  * @cat: the category
427  *
428  * Declares a GstDebugCategory variable as extern. Use in header files.
429  * This macro expands to nothing if debugging is disabled.
430  */
431 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
432
433 /**
434  * GST_DEBUG_CATEGORY_STATIC:
435  * @cat: the category
436  *
437  * Defines a static GstDebugCategory variable.
438  * This macro expands to nothing if debugging is disabled.
439  */
440 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
441
442 /**
443  * GST_DEBUG_CATEGORY_INIT:
444  * @cat: the category to initialize.
445  * @name: the name of the category.
446  * @color: the colors to use for a color representation or 0 for no color.
447  * @description: optional description of the category.
448  *
449  * Initializes a new #GstDebugCategory with the given properties and set to
450  * the default threshold.
451  *
452  * <note>
453  * <para>
454  * This macro expands to nothing if debugging is disabled.
455  * </para>
456  * <para>
457  * When naming your category, please follow the following conventions to ensure
458  * that the pattern matching for categories works as expected. It is not
459  * earth-shattering if you don't follow these conventions, but it would be nice
460  * for everyone.
461  * </para>
462  * <para>
463  * If you define a category for a plugin or a feature of it, name the category
464  * like the feature. So if you wanted to write a "filesrc" element, you would
465  * name the category "filesrc". Use lowercase letters only.
466  * If you define more than one category for the same element, append an
467  * underscore and an identifier to your categories, like this: "filesrc_cache"
468  * </para>
469  * <para>
470  * If you create a library or an application using debugging categories, use a
471  * common prefix followed by an underscore for all your categories. GStreamer
472  * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
473  * to include uppercase letters.
474  * </para>
475  * </note>
476  */
477 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
478   if (cat == NULL)                                                      \
479     cat = _gst_debug_category_new (name,color,description);             \
480 }G_STMT_END
481
482 /**
483  * GST_DEBUG_CATEGORY_GET:
484  * @cat: the category to initialize.
485  * @name: log category name
486  *
487  * Looks up an existing #GstDebugCategory by its @name and sets @cat. If the
488  * category is not found, but GST_CAT_DEFAULT is defined, that is assigned to
489  * @cat. Otherwise @cat will be %NULL.
490  *
491  * |[
492  * GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
493  * #define GST_CAT_DEFAULT gst_myplugin_debug
494  * GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
495  * ...
496  * GST_DEBUG_CATEGORY_INIT (gst_myplugin_debug, "myplugin", 0, "nice element");
497  * GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
498  * ]|
499  */
500 #ifdef GST_CAT_DEFAULT
501 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
502   cat = _gst_debug_get_category (name);                 \
503   if (!cat) {                                           \
504     cat = GST_CAT_DEFAULT;                              \
505   }                                                     \
506 }G_STMT_END
507 #else
508 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
509   cat = _gst_debug_get_category (name);                 \
510 }G_STMT_END
511 #endif
512
513 /**
514  * GST_CAT_DEFAULT:
515  *
516  * Default gstreamer core debug log category. Please define your own.
517  */
518 GST_EXPORT GstDebugCategory *   GST_CAT_DEFAULT;
519 /* this symbol may not be used */
520 GST_EXPORT gboolean                     _gst_debug_enabled;
521
522 /* the min debug level, used for quickly discarding debug
523  * messages that fall under the threshold. */
524 GST_EXPORT GstDebugLevel            _gst_debug_min;
525
526 /**
527  * GST_CAT_LEVEL_LOG:
528  * @cat: category to use
529  * @level: the severity of the message
530  * @object: (allow-none): the #GObject the message belongs to or %NULL if none
531  * @...: A printf-style message to output
532  *
533  * Outputs a debugging message. This is the most general macro for outputting
534  * debugging messages. You will probably want to use one of the ones described
535  * below.
536  */
537 #ifdef G_HAVE_ISO_VARARGS
538 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{           \
539   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {                                         \
540     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
541         (GObject *) (object), __VA_ARGS__);                             \
542   }                                                                     \
543 }G_STMT_END
544 #else /* G_HAVE_GNUC_VARARGS */
545 #ifdef G_HAVE_GNUC_VARARGS
546 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{       \
547   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {                                         \
548     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
549         (GObject *) (object), ##args );                                 \
550   }                                                                     \
551 }G_STMT_END
552 #else /* no variadic macros, use inline */
553 static inline void
554 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
555     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
556 {
557   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {
558     gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
559         varargs);
560   }
561 }
562
563 static inline void
564 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
565     gpointer object, const char *format, ...)
566 {
567   va_list varargs;
568
569   va_start (varargs, format);
570   GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
571   va_end (varargs);
572 }
573 #endif
574 #endif /* G_HAVE_ISO_VARARGS */
575
576 /* This one doesn't have varargs in the macro, so it's different than all the
577  * other macros and hence in a separate block right here. Docs chunks are
578  * with the other doc chunks below though. */
579 #define __GST_CAT_MEMDUMP_LOG(cat,object,msg,data,length) G_STMT_START{       \
580     if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= GST_LEVEL_MAX &&                     \
581                     GST_LEVEL_MEMDUMP <= _gst_debug_min)) {                   \
582     _gst_debug_dump_mem ((cat), __FILE__, GST_FUNCTION, __LINE__,             \
583         (GObject *) (object), (msg), (data), (length));                       \
584   }                                                                           \
585 }G_STMT_END
586
587 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length)  \
588     __GST_CAT_MEMDUMP_LOG(cat,obj,msg,data,length)
589 #define GST_CAT_MEMDUMP(cat,msg,data,length)             \
590     __GST_CAT_MEMDUMP_LOG(cat,NULL,msg,data,length)
591 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)          \
592     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,obj,msg,data,length)
593 #define GST_MEMDUMP(msg,data,length)                     \
594     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,NULL,msg,data,length)
595
596 /**
597  * GST_CAT_ERROR_OBJECT:
598  * @cat: category to use
599  * @obj: the #GObject the message belongs to
600  * @...: printf-style message to output
601  *
602  * Output an error message belonging to the given object in the given category.
603  */
604 /**
605  * GST_CAT_WARNING_OBJECT:
606  * @cat: category to use
607  * @obj: the #GObject the message belongs to
608  * @...: printf-style message to output
609  *
610  * Output a warning message belonging to the given object in the given category.
611  */
612 /**
613  * GST_CAT_INFO_OBJECT:
614  * @cat: category to use
615  * @obj: the #GObject the message belongs to
616  * @...: printf-style message to output
617  *
618  * Output an informational message belonging to the given object in the given
619  * category.
620  */
621 /**
622  * GST_CAT_DEBUG_OBJECT:
623  * @cat: category to use
624  * @obj: the #GObject the message belongs to
625  * @...: printf-style message to output
626  *
627  * Output an debugging message belonging to the given object in the given category.
628  */
629 /**
630  * GST_CAT_LOG_OBJECT:
631  * @cat: category to use
632  * @obj: the #GObject the message belongs to
633  * @...: printf-style message to output
634  *
635  * Output an logging message belonging to the given object in the given category.
636  */
637 /**
638  * GST_CAT_FIXME_OBJECT:
639  * @cat: category to use
640  * @obj: the #GObject the message belongs to
641  * @...: printf-style message to output
642  *
643  * Output a fixme message belonging to the given object in the given category.
644  */
645 /**
646  * GST_CAT_TRACE_OBJECT:
647  * @cat: category to use
648  * @obj: the #GObject the message belongs to
649  * @...: printf-style message to output
650  *
651  * Output a tracing message belonging to the given object in the given
652  * category.
653  */
654 /**
655  * GST_CAT_MEMDUMP_OBJECT:
656  * @cat: category to use
657  * @obj: the #GObject the message belongs to
658  * @msg: message string to log with the data
659  * @data: pointer to the data to output
660  * @length: length of the data to output
661  *
662  * Output a hexdump of @data relating to the given object in the given
663  * category.
664  */
665
666
667 /**
668  * GST_CAT_ERROR:
669  * @cat: category to use
670  * @...: printf-style message to output
671  *
672  * Output an error message in the given category.
673  */
674 /**
675  * GST_CAT_WARNING:
676  * @cat: category to use
677  * @...: printf-style message to output
678  *
679  * Output an warning message in the given category.
680  */
681 /**
682  * GST_CAT_INFO:
683  * @cat: category to use
684  * @...: printf-style message to output
685  *
686  * Output an informational message in the given category.
687  */
688 /**
689  * GST_CAT_DEBUG:
690  * @cat: category to use
691  * @...: printf-style message to output
692  *
693  * Output an debugging message in the given category.
694  */
695 /**
696  * GST_CAT_LOG:
697  * @cat: category to use
698  * @...: printf-style message to output
699  *
700  * Output an logging message in the given category.
701  */
702 /**
703  * GST_CAT_FIXME:
704  * @cat: category to use
705  * @...: printf-style message to output
706  *
707  * Output an fixme message in the given category.
708  */
709 /**
710  * GST_CAT_TRACE:
711  * @cat: category to use
712  * @...: printf-style message to output
713  *
714  * Output a tracing message in the given category.
715  */
716 /**
717  * GST_CAT_MEMDUMP:
718  * @cat: category to use
719  * @msg: message string to log with the data
720  * @data: pointer to the data to output
721  * @length: length of the data to output
722  *
723  * Output a hexdump of @data in the given category.
724  */
725
726
727 /**
728  * GST_ERROR_OBJECT:
729  * @obj: the #GObject the message belongs to
730  * @...: printf-style message to output
731  *
732  * Output an error message belonging to the given object in the default category.
733  */
734 /**
735  * GST_WARNING_OBJECT:
736  * @obj: the #GObject the message belongs to
737  * @...: printf-style message to output
738  *
739  * Output a warning message belonging to the given object in the default category.
740  */
741 /**
742  * GST_INFO_OBJECT:
743  * @obj: the #GObject the message belongs to
744  * @...: printf-style message to output
745  *
746  * Output an informational message belonging to the given object in the default
747  * category.
748  */
749 /**
750  * GST_DEBUG_OBJECT:
751  * @obj: the #GObject the message belongs to
752  * @...: printf-style message to output
753  *
754  * Output a debugging message belonging to the given object in the default
755  * category.
756  */
757 /**
758  * GST_LOG_OBJECT:
759  * @obj: the #GObject the message belongs to
760  * @...: printf-style message to output
761  *
762  * Output a logging message belonging to the given object in the default category.
763  */
764 /**
765  * GST_FIXME_OBJECT:
766  * @obj: the #GObject the message belongs to
767  * @...: printf-style message to output
768  *
769  * Output a fixme message belonging to the given object in the default category.
770  */
771 /**
772  * GST_TRACE_OBJECT:
773  * @obj: the #GObject the message belongs to
774  * @...: printf-style message to output
775  *
776  * Output a tracing message belonging to the given object in the default category.
777  */
778 /**
779  * GST_MEMDUMP_OBJECT:
780  * @obj: the #GObject the message belongs to
781  * @msg: message string to log with the data
782  * @data: pointer to the data to output
783  * @length: length of the data to output
784  *
785  * Output a logging message belonging to the given object in the default category.
786  */
787
788
789 /**
790  * GST_ERROR:
791  * @...: printf-style message to output
792  *
793  * Output an error message in the default category.
794  */
795 /**
796  * GST_WARNING:
797  * @...: printf-style message to output
798  *
799  * Output a warning message in the default category.
800  */
801 /**
802  * GST_INFO:
803  * @...: printf-style message to output
804  *
805  * Output an informational message in the default category.
806  */
807 /**
808  * GST_DEBUG:
809  * @...: printf-style message to output
810  *
811  * Output a debugging message in the default category.
812  */
813 /**
814  * GST_LOG:
815  * @...: printf-style message to output
816  *
817  * Output a logging message in the default category.
818  */
819 /**
820  * GST_FIXME:
821  * @...: printf-style message to output
822  *
823  * Output a fixme message in the default category.
824  */
825 /**
826  * GST_TRACE:
827  * @...: printf-style message to output
828  *
829  * Output a tracing message in the default category.
830  */
831 /**
832  * GST_MEMDUMP:
833  * @msg: message string to log with the data
834  * @data: pointer to the data to output
835  * @length: length of the data to output
836  *
837  * Output a hexdump of @data.
838  */
839
840 #ifdef G_HAVE_ISO_VARARGS
841
842 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
843 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
844 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
845 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
846 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
847 #define GST_CAT_FIXME_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
848 #define GST_CAT_TRACE_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
849
850 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
851 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
852 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
853 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
854 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
855 #define GST_CAT_FIXME(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
856 #define GST_CAT_TRACE(cat,...)          GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
857
858 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
859 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
860 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
861 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
862 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
863 #define GST_FIXME_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
864 #define GST_TRACE_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
865
866 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
867 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
868 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
869 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
870 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
871 #define GST_FIXME(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
872 #define GST_TRACE(...)          GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
873
874 #else
875 #ifdef G_HAVE_GNUC_VARARGS
876
877 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
878 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
879 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
880 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
881 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
882 #define GST_CAT_FIXME_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  ##args )
883 #define GST_CAT_TRACE_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  ##args )
884
885 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
886 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
887 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
888 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
889 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
890 #define GST_CAT_FIXME(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, ##args )
891 #define GST_CAT_TRACE(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, ##args )
892
893 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
894 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
895 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
896 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
897 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
898 #define GST_FIXME_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  ##args )
899 #define GST_TRACE_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  ##args )
900
901 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
902 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
903 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
904 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
905 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
906 #define GST_FIXME(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, ##args )
907 #define GST_TRACE(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, ##args )
908
909 #else
910 /* no variadic macros, use inline */
911 static inline void
912 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
913     ...)
914 {
915   va_list varargs;
916
917   va_start (varargs, format);
918   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
919   va_end (varargs);
920 }
921
922 static inline void
923 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
924     const char *format, ...)
925 {
926   va_list varargs;
927
928   va_start (varargs, format);
929   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
930   va_end (varargs);
931 }
932
933 static inline void
934 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
935     ...)
936 {
937   va_list varargs;
938
939   va_start (varargs, format);
940   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
941   va_end (varargs);
942 }
943
944 static inline void
945 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
946     ...)
947 {
948   va_list varargs;
949
950   va_start (varargs, format);
951   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
952   va_end (varargs);
953 }
954
955 static inline void
956 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
957     ...)
958 {
959   va_list varargs;
960
961   va_start (varargs, format);
962   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
963   va_end (varargs);
964 }
965
966 static inline void
967 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
968     ...)
969 {
970   va_list varargs;
971
972   va_start (varargs, format);
973   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, obj, format, varargs);
974   va_end (varargs);
975 }
976
977 static inline void
978 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
979     ...)
980 {
981   va_list varargs;
982
983   va_start (varargs, format);
984   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, obj, format, varargs);
985   va_end (varargs);
986 }
987
988 static inline void
989 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
990 {
991   va_list varargs;
992
993   va_start (varargs, format);
994   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
995   va_end (varargs);
996 }
997
998 static inline void
999 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1000 {
1001   va_list varargs;
1002
1003   va_start (varargs, format);
1004   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
1005   va_end (varargs);
1006 }
1007
1008 static inline void
1009 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1010 {
1011   va_list varargs;
1012
1013   va_start (varargs, format);
1014   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
1015   va_end (varargs);
1016 }
1017
1018 static inline void
1019 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1020 {
1021   va_list varargs;
1022
1023   va_start (varargs, format);
1024   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
1025   va_end (varargs);
1026 }
1027
1028 static inline void
1029 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1030 {
1031   va_list varargs;
1032
1033   va_start (varargs, format);
1034   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
1035   va_end (varargs);
1036 }
1037
1038 static inline void
1039 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
1040 {
1041   va_list varargs;
1042
1043   va_start (varargs, format);
1044   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, NULL, format, varargs);
1045   va_end (varargs);
1046 }
1047
1048 static inline void
1049 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
1050 {
1051   va_list varargs;
1052
1053   va_start (varargs, format);
1054   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, NULL, format, varargs);
1055   va_end (varargs);
1056 }
1057
1058 static inline void
1059 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1060 {
1061   va_list varargs;
1062
1063   va_start (varargs, format);
1064   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
1065       varargs);
1066   va_end (varargs);
1067 }
1068
1069 static inline void
1070 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1071 {
1072   va_list varargs;
1073
1074   va_start (varargs, format);
1075   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
1076       varargs);
1077   va_end (varargs);
1078 }
1079
1080 static inline void
1081 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1082 {
1083   va_list varargs;
1084
1085   va_start (varargs, format);
1086   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
1087       varargs);
1088   va_end (varargs);
1089 }
1090
1091 static inline void
1092 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1093 {
1094   va_list varargs;
1095
1096   va_start (varargs, format);
1097   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
1098       varargs);
1099   va_end (varargs);
1100 }
1101
1102 static inline void
1103 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1104 {
1105   va_list varargs;
1106
1107   va_start (varargs, format);
1108   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
1109       varargs);
1110   va_end (varargs);
1111 }
1112
1113 static inline void
1114 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
1115 {
1116   va_list varargs;
1117
1118   va_start (varargs, format);
1119   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, obj, format,
1120       varargs);
1121   va_end (varargs);
1122 }
1123
1124 static inline void
1125 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
1126 {
1127   va_list varargs;
1128
1129   va_start (varargs, format);
1130   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, obj, format,
1131       varargs);
1132   va_end (varargs);
1133 }
1134
1135 static inline void
1136 GST_ERROR (const char *format, ...)
1137 {
1138   va_list varargs;
1139
1140   va_start (varargs, format);
1141   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
1142       varargs);
1143   va_end (varargs);
1144 }
1145
1146 static inline void
1147 GST_WARNING (const char *format, ...)
1148 {
1149   va_list varargs;
1150
1151   va_start (varargs, format);
1152   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
1153       varargs);
1154   va_end (varargs);
1155 }
1156
1157 static inline void
1158 GST_INFO (const char *format, ...)
1159 {
1160   va_list varargs;
1161
1162   va_start (varargs, format);
1163   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
1164       varargs);
1165   va_end (varargs);
1166 }
1167
1168 static inline void
1169 GST_DEBUG (const char *format, ...)
1170 {
1171   va_list varargs;
1172
1173   va_start (varargs, format);
1174   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
1175       varargs);
1176   va_end (varargs);
1177 }
1178
1179 static inline void
1180 GST_LOG (const char *format, ...)
1181 {
1182   va_list varargs;
1183
1184   va_start (varargs, format);
1185   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
1186       format, varargs);
1187   va_end (varargs);
1188 }
1189
1190 static inline void
1191 GST_FIXME (const char *format, ...)
1192 {
1193   va_list varargs;
1194
1195   va_start (varargs, format);
1196   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, NULL, format,
1197       varargs);
1198   va_end (varargs);
1199 }
1200
1201 static inline void
1202 GST_TRACE (const char *format, ...)
1203 {
1204   va_list varargs;
1205
1206   va_start (varargs, format);
1207   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, NULL, format,
1208       varargs);
1209   va_end (varargs);
1210 }
1211 #endif
1212 #endif
1213
1214
1215 /********** function pointer stuff **********/
1216
1217 /**
1218  * GST_DEBUG_REGISTER_FUNCPTR:
1219  * @ptr: pointer to the function to register
1220  *
1221  * Register a pointer to a function with its name, so it can later be used by
1222  * GST_DEBUG_FUNCPTR_NAME().
1223  *
1224  * Use this variant of #GST_DEBUG_FUNCPTR if you do not need to use @ptr.
1225  */
1226 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) \
1227   _gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr)
1228 /**
1229  * GST_DEBUG_FUNCPTR:
1230  * @ptr: pointer to the function to register
1231  *
1232  * Register a pointer to a function with its name, so it can later be used by
1233  * GST_DEBUG_FUNCPTR_NAME().
1234  *
1235  * Returns: the value passed to @ptr.
1236  */
1237 #define GST_DEBUG_FUNCPTR(ptr) \
1238   (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
1239
1240 /**
1241  * GST_DEBUG_FUNCPTR_NAME:
1242  * @ptr: address of the function of which to look up the name
1243  *
1244  * Retrieves the name of the function, if it was previously registered with
1245  * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
1246  *
1247  * This macro returns a constant string which must not be modified or
1248  * freed by the caller.
1249  */
1250 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
1251   _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
1252
1253
1254 #else /* GST_DISABLE_GST_DEBUG */
1255
1256
1257 #ifndef GST_INFO_C
1258
1259 #if defined(__GNUC__) && __GNUC__ >= 3
1260 #  pragma GCC poison gst_debug_log
1261 #  pragma GCC poison gst_debug_log_valist
1262 #  pragma GCC poison _gst_debug_category_new
1263 #endif
1264
1265 #define _gst_debug_min GST_LEVEL_NONE
1266
1267 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1268 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1269
1270 #define gst_debug_level_get_name(level)                         ("NONE")
1271 #define gst_debug_message_get(message)                          ("")
1272 #define gst_debug_add_log_function(func,data,notify)    G_STMT_START{ }G_STMT_END
1273 #define gst_debug_set_active(active)                    G_STMT_START{ }G_STMT_END
1274 #define gst_debug_is_active()                           (FALSE)
1275 #define gst_debug_set_colored(colored)                  G_STMT_START{ }G_STMT_END
1276 #define gst_debug_set_color_mode(mode)                  G_STMT_START{ }G_STMT_END
1277 #define gst_debug_set_color_mode_from_string(mode)      G_STMT_START{ }G_STMT_END
1278 #define gst_debug_is_colored()                          (FALSE)
1279 #define gst_debug_get_color_mode()                      (GST_DEBUG_COLOR_MODE_OFF)
1280 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1281 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1282 #define gst_debug_set_threshold_for_name(name,level)    G_STMT_START{ }G_STMT_END
1283 #define gst_debug_unset_threshold_for_name(name)        G_STMT_START{ }G_STMT_END
1284
1285 /* we are using dummy function prototypes here to eat ';' as these macros are
1286  * used outside of functions */
1287 #define GST_DEBUG_CATEGORY(var)                         void _gst_debug_dummy_##var (void)
1288 #define GST_DEBUG_CATEGORY_EXTERN(var)                  void _gst_debug_dummy_extern_##var (void)
1289 #define GST_DEBUG_CATEGORY_STATIC(var)                  void _gst_debug_dummy_static_##var (void)
1290
1291 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    G_STMT_START{ }G_STMT_END
1292 #define GST_DEBUG_CATEGORY_GET(var,name)                G_STMT_START{ }G_STMT_END
1293 #define gst_debug_category_free(category)               G_STMT_START{ }G_STMT_END
1294 #define gst_debug_category_set_threshold(category,level) G_STMT_START{ }G_STMT_END
1295 #define gst_debug_category_reset_threshold(category)    G_STMT_START{ }G_STMT_END
1296 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
1297 #define gst_debug_category_get_name(cat)                ("")
1298 #define gst_debug_category_get_color(cat)               (0)
1299 #define gst_debug_category_get_description(cat)         ("")
1300 #define gst_debug_get_all_categories()                  (NULL)
1301 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
1302 #define gst_debug_construct_win_color(colorinfo)        (0)
1303
1304 #endif /* !GST_INFO_C */
1305
1306 #ifdef G_HAVE_ISO_VARARGS
1307
1308 #define GST_CAT_LEVEL_LOG(cat,level,...)                G_STMT_START{ }G_STMT_END
1309
1310 #define GST_CAT_ERROR_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1311 #define GST_CAT_WARNING_OBJECT(...)                     G_STMT_START{ }G_STMT_END
1312 #define GST_CAT_INFO_OBJECT(...)                        G_STMT_START{ }G_STMT_END
1313 #define GST_CAT_DEBUG_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1314 #define GST_CAT_LOG_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1315 #define GST_CAT_FIXME_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1316 #define GST_CAT_TRACE_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1317
1318 #define GST_CAT_ERROR(...)                              G_STMT_START{ }G_STMT_END
1319 #define GST_CAT_WARNING(...)                            G_STMT_START{ }G_STMT_END
1320 #define GST_CAT_INFO(...)                               G_STMT_START{ }G_STMT_END
1321 #define GST_CAT_DEBUG(...)                              G_STMT_START{ }G_STMT_END
1322 #define GST_CAT_LOG(...)                                G_STMT_START{ }G_STMT_END
1323 #define GST_CAT_FIXME(...)                              G_STMT_START{ }G_STMT_END
1324 #define GST_CAT_TRACE(...)                              G_STMT_START{ }G_STMT_END
1325
1326 #define GST_ERROR_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1327 #define GST_WARNING_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1328 #define GST_INFO_OBJECT(...)                            G_STMT_START{ }G_STMT_END
1329 #define GST_DEBUG_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1330 #define GST_LOG_OBJECT(...)                             G_STMT_START{ }G_STMT_END
1331 #define GST_FIXME_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1332 #define GST_TRACE_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1333
1334 #define GST_ERROR(...)                                  G_STMT_START{ }G_STMT_END
1335 #define GST_WARNING(...)                                G_STMT_START{ }G_STMT_END
1336 #define GST_INFO(...)                                   G_STMT_START{ }G_STMT_END
1337 #define GST_DEBUG(...)                                  G_STMT_START{ }G_STMT_END
1338 #define GST_LOG(...)                                    G_STMT_START{ }G_STMT_END
1339 #define GST_FIXME(...)                                  G_STMT_START{ }G_STMT_END
1340 #define GST_TRACE(...)                                  G_STMT_START{ }G_STMT_END
1341
1342 #else /* !G_HAVE_ISO_VARARGS */
1343 #ifdef G_HAVE_GNUC_VARARGS
1344
1345 #define GST_CAT_LEVEL_LOG(cat,level,args...)            G_STMT_START{ }G_STMT_END
1346
1347 #define GST_CAT_ERROR_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1348 #define GST_CAT_WARNING_OBJECT(args...)                 G_STMT_START{ }G_STMT_END
1349 #define GST_CAT_INFO_OBJECT(args...)                    G_STMT_START{ }G_STMT_END
1350 #define GST_CAT_DEBUG_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1351 #define GST_CAT_LOG_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1352 #define GST_CAT_FIXME_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1353 #define GST_CAT_TRACE_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1354
1355 #define GST_CAT_ERROR(args...)                          G_STMT_START{ }G_STMT_END
1356 #define GST_CAT_WARNING(args...)                        G_STMT_START{ }G_STMT_END
1357 #define GST_CAT_INFO(args...)                           G_STMT_START{ }G_STMT_END
1358 #define GST_CAT_DEBUG(args...)                          G_STMT_START{ }G_STMT_END
1359 #define GST_CAT_LOG(args...)                            G_STMT_START{ }G_STMT_END
1360 #define GST_CAT_FIXME(args...)                          G_STMT_START{ }G_STMT_END
1361 #define GST_CAT_TRACE(args...)                          G_STMT_START{ }G_STMT_END
1362
1363 #define GST_ERROR_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1364 #define GST_WARNING_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1365 #define GST_INFO_OBJECT(args...)                        G_STMT_START{ }G_STMT_END
1366 #define GST_DEBUG_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1367 #define GST_LOG_OBJECT(args...)                         G_STMT_START{ }G_STMT_END
1368 #define GST_FIXME_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1369 #define GST_TRACE_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1370
1371 #define GST_ERROR(args...)                              G_STMT_START{ }G_STMT_END
1372 #define GST_WARNING(args...)                            G_STMT_START{ }G_STMT_END
1373 #define GST_INFO(args...)                               G_STMT_START{ }G_STMT_END
1374 #define GST_DEBUG(args...)                              G_STMT_START{ }G_STMT_END
1375 #define GST_LOG(args...)                                G_STMT_START{ }G_STMT_END
1376 #define GST_FIXME(args...)                              G_STMT_START{ }G_STMT_END
1377 #define GST_TRACE(args...)                              G_STMT_START{ }G_STMT_END
1378
1379 #else /* !G_HAVE_GNUC_VARARGS */
1380 static inline void
1381 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
1382     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
1383 {
1384 }
1385
1386 static inline void
1387 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1388     ...)
1389 {
1390 }
1391
1392 static inline void
1393 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1394     const char *format, ...)
1395 {
1396 }
1397
1398 static inline void
1399 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1400     ...)
1401 {
1402 }
1403
1404 static inline void
1405 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1406     ...)
1407 {
1408 }
1409
1410 static inline void
1411 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1412     ...)
1413 {
1414 }
1415
1416 static inline void
1417 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1418     ...)
1419 {
1420 }
1421
1422 static inline void
1423 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1424     ...)
1425 {
1426 }
1427
1428 static inline void
1429 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1430 {
1431 }
1432
1433 static inline void
1434 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1435 {
1436 }
1437
1438 static inline void
1439 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1440 {
1441 }
1442
1443 static inline void
1444 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1445 {
1446 }
1447
1448 static inline void
1449 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1450 {
1451 }
1452
1453 static inline void
1454 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
1455 {
1456 }
1457
1458 static inline void
1459 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
1460 {
1461 }
1462
1463 static inline void
1464 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1465 {
1466 }
1467
1468 static inline void
1469 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1470 {
1471 }
1472
1473 static inline void
1474 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1475 {
1476 }
1477
1478 static inline void
1479 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1480 {
1481 }
1482
1483 static inline void
1484 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1485 {
1486 }
1487
1488 static inline void
1489 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
1490 {
1491 }
1492
1493 static inline void
1494 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
1495 {
1496 }
1497
1498 static inline void
1499 GST_ERROR (const char *format, ...)
1500 {
1501 }
1502
1503 static inline void
1504 GST_WARNING (const char *format, ...)
1505 {
1506 }
1507
1508 static inline void
1509 GST_INFO (const char *format, ...)
1510 {
1511 }
1512
1513 static inline void
1514 GST_DEBUG (const char *format, ...)
1515 {
1516 }
1517
1518 static inline void
1519 GST_LOG (const char *format, ...)
1520 {
1521 }
1522
1523 static inline void
1524 GST_FIXME (const char *format, ...)
1525 {
1526 }
1527
1528 static inline void
1529 GST_TRACE (const char *format, ...)
1530 {
1531 }
1532
1533 #endif /* G_HAVE_GNUC_VARARGS */
1534 #endif /* G_HAVE_ISO_VARARGS */
1535
1536 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) G_STMT_START{ }G_STMT_END
1537 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
1538 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
1539
1540 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length) G_STMT_START{ }G_STMT_END
1541 #define GST_CAT_MEMDUMP(cat,msg,data,length)            G_STMT_START{ }G_STMT_END
1542 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)         G_STMT_START{ }G_STMT_END
1543 #define GST_MEMDUMP(msg,data,length)                    G_STMT_START{ }G_STMT_END
1544
1545 #endif /* GST_DISABLE_GST_DEBUG */
1546
1547
1548 void gst_debug_print_stack_trace (void);
1549
1550 G_END_DECLS
1551
1552 #endif /* __GSTINFO_H__ */