Move dataurisrc element from -bad
[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. You can use this in
266  * combination with GStreamer's debug logging system as well as the functions
267  * gst_info_vasprintf(), gst_info_strdup_vprintf() and gst_info_strdup_printf()
268  * to pretty-print the following types: #GstCaps, #GstStructure,
269  * #GstCapsFeatures, #GstTagList, #GstDateTime, #GstBuffer, #GstBufferList,
270  * #GstMessage, #GstEvent, #GstQuery, #GstContext, #GstPad, #GstObject. All
271  * #GObject types will be printed as typename plus pointer, and everything
272  * else will simply be printed as pointer address.
273  *
274  * This can only be used on types whose size is >= sizeof(gpointer).
275  */
276 #define GST_PTR_FORMAT     "p\aA"
277
278 /**
279  * GST_SEGMENT_FORMAT:
280  *
281  * printf format type used to debug GStreamer segments. You can use this in
282  * combination with GStreamer's debug logging system as well as the functions
283  * gst_info_vasprintf(), gst_info_strdup_vprintf() and gst_info_strdup_printf()
284  * to pretty-print #GstSegment structures.
285  * This can only be used on pointers to GstSegment structures.
286  */
287 #define GST_SEGMENT_FORMAT "p\aB"
288
289 typedef struct _GstDebugMessage GstDebugMessage;
290
291 /**
292  * GstLogFunction:
293  * @category: a #GstDebugCategory
294  * @level: a #GstDebugLevel
295  * @file: file name
296  * @function: function name
297  * @line: line number
298  * @object: a #GObject
299  * @message: the message
300  * @user_data: user data for the log function
301  *
302  * Function prototype for a logging function that can be registered with
303  * gst_debug_add_log_function().
304  * Use G_GNUC_NO_INSTRUMENT on that function.
305  */
306 typedef void (*GstLogFunction)  (GstDebugCategory * category,
307                                  GstDebugLevel      level,
308                                  const gchar      * file,
309                                  const gchar      * function,
310                                  gint               line,
311                                  GObject          * object,
312                                  GstDebugMessage  * message,
313                                  gpointer           user_data);
314
315 void                gst_debug_log            (GstDebugCategory * category,
316                                           GstDebugLevel      level,
317                                           const gchar      * file,
318                                           const gchar      * function,
319                                           gint               line,
320                                           GObject          * object,
321                                           const gchar      * format,
322                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
323
324 void            gst_debug_log_valist     (GstDebugCategory * category,
325                                           GstDebugLevel      level,
326                                           const gchar      * file,
327                                           const gchar      * function,
328                                           gint                line,
329                                           GObject          * object,
330                                           const gchar      * format,
331                                           va_list            args) G_GNUC_NO_INSTRUMENT;
332
333 /* do not use this function, use the GST_DEBUG_CATEGORY_INIT macro */
334 GstDebugCategory *_gst_debug_category_new (const gchar * name,
335                                            guint         color,
336                                            const gchar * description);
337 /* do not use this function, use the GST_DEBUG_CATEGORY_GET macro */
338 GstDebugCategory *_gst_debug_get_category (const gchar *name);
339
340
341 /* do not use this function, use the GST_CAT_MEMDUMP_* macros */
342 void _gst_debug_dump_mem (GstDebugCategory * cat, const gchar * file,
343     const gchar * func, gint line, GObject * obj, const gchar * msg,
344     const guint8 * data, guint length);
345
346 /* we define this to avoid a compiler warning regarding a cast from a function
347  * pointer to a void pointer
348  * (see https://bugzilla.gnome.org/show_bug.cgi?id=309253)
349  */
350 typedef void (* GstDebugFuncPtr)        (void);
351
352 /* do no use these functions, use the GST_DEBUG*_FUNCPTR macros */
353 void    _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
354                                          const gchar *          ptrname);
355 const gchar *
356         _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func) G_GNUC_NO_INSTRUMENT;
357
358
359 const gchar   * gst_debug_message_get    (GstDebugMessage  * message);
360
361 void            gst_debug_log_default    (GstDebugCategory * category,
362                                           GstDebugLevel      level,
363                                           const gchar      * file,
364                                           const gchar      * function,
365                                           gint               line,
366                                           GObject          * object,
367                                           GstDebugMessage  * message,
368                                           gpointer           user_data) G_GNUC_NO_INSTRUMENT;
369
370 const gchar *   gst_debug_level_get_name (GstDebugLevel level);
371
372 void            gst_debug_add_log_function            (GstLogFunction func,
373                                                        gpointer       user_data,
374                                                        GDestroyNotify notify);
375
376 guint           gst_debug_remove_log_function         (GstLogFunction func);
377 guint           gst_debug_remove_log_function_by_data (gpointer       data);
378
379 void            gst_debug_set_active  (gboolean active);
380 gboolean        gst_debug_is_active   (void);
381
382 void            gst_debug_set_colored (gboolean colored);
383 void            gst_debug_set_color_mode   (GstDebugColorMode mode);
384 void            gst_debug_set_color_mode_from_string (const gchar * mode);
385 gboolean        gst_debug_is_colored  (void);
386 GstDebugColorMode gst_debug_get_color_mode (void);
387
388 void            gst_debug_set_default_threshold      (GstDebugLevel level);
389 GstDebugLevel   gst_debug_get_default_threshold      (void);
390 void            gst_debug_set_threshold_for_name     (const gchar * name,
391                                                       GstDebugLevel level);
392 void            gst_debug_set_threshold_from_string  (const gchar * list, gboolean reset);
393 void            gst_debug_unset_threshold_for_name   (const gchar * name);
394
395
396 void            gst_debug_category_free              (GstDebugCategory *        category);
397 void                gst_debug_category_set_threshold     (GstDebugCategory *    category,
398                                                       GstDebugLevel             level);
399 void            gst_debug_category_reset_threshold   (GstDebugCategory *        category);
400 GstDebugLevel   gst_debug_category_get_threshold     (GstDebugCategory *        category);
401 const gchar *   gst_debug_category_get_name          (GstDebugCategory *        category);
402 guint           gst_debug_category_get_color         (GstDebugCategory *        category);
403 const gchar *   gst_debug_category_get_description   (GstDebugCategory *        category);
404 GSList *        gst_debug_get_all_categories    (void);
405
406
407 gchar * gst_debug_construct_term_color (guint colorinfo);
408 gint    gst_debug_construct_win_color  (guint colorinfo);
409
410 gint    gst_info_vasprintf              (gchar ** result,
411                                          const gchar * format,
412                                          va_list args) G_GNUC_PRINTF (2, 0);
413 gchar * gst_info_strdup_vprintf         (const gchar *format, va_list args) G_GNUC_PRINTF (1, 0);
414 gchar * gst_info_strdup_printf          (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
415
416 void    gst_print                       (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
417 void    gst_println                     (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
418
419 void    gst_printerr                    (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
420 void    gst_printerrln                  (const gchar * format, ...) G_GNUC_PRINTF (1, 2);
421
422 #ifndef GST_DISABLE_GST_DEBUG
423
424 /* cast to void * avoids a warning with gcc 6
425  * see https://bugzilla.gnome.org/show_bug.cgi?id=764526 */
426 #define gst_debug_add_log_function(func,data,notify) \
427 G_STMT_START{                                        \
428   if (func == (void *) gst_debug_log_default) {               \
429     gst_debug_add_log_function(NULL,data,notify);    \
430   } else {                                           \
431     gst_debug_add_log_function(func,data,notify);    \
432   }                                                  \
433 }G_STMT_END
434
435 #define gst_debug_remove_log_function(func)   \
436     (func == (void *) gst_debug_log_default) ?         \
437         gst_debug_remove_log_function(NULL) : \
438         gst_debug_remove_log_function(func)
439
440 /**
441  * GST_DEBUG_CATEGORY:
442  * @cat: the category
443  *
444  * Defines a GstDebugCategory variable.
445  * This macro expands to nothing if debugging is disabled.
446  */
447 #define GST_DEBUG_CATEGORY(cat) GstDebugCategory *cat = NULL
448 /**
449  * GST_DEBUG_CATEGORY_EXTERN:
450  * @cat: the category
451  *
452  * Declares a GstDebugCategory variable as extern. Use in header files.
453  * This macro expands to nothing if debugging is disabled.
454  */
455 #define GST_DEBUG_CATEGORY_EXTERN(cat) extern GstDebugCategory *cat
456
457 /**
458  * GST_DEBUG_CATEGORY_STATIC:
459  * @cat: the category
460  *
461  * Defines a static GstDebugCategory variable.
462  * This macro expands to nothing if debugging is disabled.
463  */
464 #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
465
466 /**
467  * GST_DEBUG_CATEGORY_INIT:
468  * @cat: the category to initialize.
469  * @name: the name of the category.
470  * @color: the colors to use for a color representation or 0 for no color.
471  * @description: optional description of the category.
472  *
473  * Initializes a new #GstDebugCategory with the given properties and set to
474  * the default threshold.
475  *
476  * <note>
477  * <para>
478  * This macro expands to nothing if debugging is disabled.
479  * </para>
480  * <para>
481  * When naming your category, please follow the following conventions to ensure
482  * that the pattern matching for categories works as expected. It is not
483  * earth-shattering if you don't follow these conventions, but it would be nice
484  * for everyone.
485  * </para>
486  * <para>
487  * If you define a category for a plugin or a feature of it, name the category
488  * like the feature. So if you wanted to write a "filesrc" element, you would
489  * name the category "filesrc". Use lowercase letters only.
490  * If you define more than one category for the same element, append an
491  * underscore and an identifier to your categories, like this: "filesrc_cache"
492  * </para>
493  * <para>
494  * If you create a library or an application using debugging categories, use a
495  * common prefix followed by an underscore for all your categories. GStreamer
496  * uses the GST prefix so GStreamer categories look like "GST_STATES". Be sure
497  * to include uppercase letters.
498  * </para>
499  * </note>
500  */
501 #define GST_DEBUG_CATEGORY_INIT(cat,name,color,description) G_STMT_START{\
502   if (cat == NULL)                                                      \
503     cat = _gst_debug_category_new (name,color,description);             \
504 }G_STMT_END
505
506 /**
507  * GST_DEBUG_CATEGORY_GET:
508  * @cat: the category to initialize.
509  * @name: log category name
510  *
511  * Looks up an existing #GstDebugCategory by its @name and sets @cat. If the
512  * category is not found, but GST_CAT_DEFAULT is defined, that is assigned to
513  * @cat. Otherwise @cat will be %NULL.
514  *
515  * |[<!-- language="C" -->
516  * GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
517  * #define GST_CAT_DEFAULT gst_myplugin_debug
518  * GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
519  * ...
520  * GST_DEBUG_CATEGORY_INIT (gst_myplugin_debug, "myplugin", 0, "nice element");
521  * GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
522  * ]|
523  */
524 #ifdef GST_CAT_DEFAULT
525 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
526   cat = _gst_debug_get_category (name);                 \
527   if (!cat) {                                           \
528     cat = GST_CAT_DEFAULT;                              \
529   }                                                     \
530 }G_STMT_END
531 #else
532 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
533   cat = _gst_debug_get_category (name);                 \
534 }G_STMT_END
535 #endif
536
537 /**
538  * GST_CAT_DEFAULT:
539  *
540  * Default gstreamer core debug log category. Please define your own.
541  */
542 GST_EXPORT GstDebugCategory *   GST_CAT_DEFAULT;
543 /* this symbol may not be used */
544 GST_EXPORT gboolean                     _gst_debug_enabled;
545
546 /* the min debug level, used for quickly discarding debug
547  * messages that fall under the threshold. */
548 GST_EXPORT GstDebugLevel            _gst_debug_min;
549
550 /**
551  * GST_CAT_LEVEL_LOG:
552  * @cat: category to use
553  * @level: the severity of the message
554  * @object: (allow-none): the #GObject the message belongs to or %NULL if none
555  * @...: A printf-style message to output
556  *
557  * Outputs a debugging message. This is the most general macro for outputting
558  * debugging messages. You will probably want to use one of the ones described
559  * below.
560  */
561 #ifdef G_HAVE_ISO_VARARGS
562 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{           \
563   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {                                         \
564     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
565         (GObject *) (object), __VA_ARGS__);                             \
566   }                                                                     \
567 }G_STMT_END
568 #else /* G_HAVE_GNUC_VARARGS */
569 #ifdef G_HAVE_GNUC_VARARGS
570 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{       \
571   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {                                         \
572     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,    \
573         (GObject *) (object), ##args );                                 \
574   }                                                                     \
575 }G_STMT_END
576 #else /* no variadic macros, use inline */
577 static inline void
578 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
579     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
580 {
581   if (G_UNLIKELY (level <= GST_LEVEL_MAX && level <= _gst_debug_min)) {
582     gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
583         varargs);
584   }
585 }
586
587 static inline void
588 GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
589     gpointer object, const char *format, ...)
590 {
591   va_list varargs;
592
593   va_start (varargs, format);
594   GST_CAT_LEVEL_LOG_valist (cat, level, object, format, varargs);
595   va_end (varargs);
596 }
597 #endif
598 #endif /* G_HAVE_ISO_VARARGS */
599
600 /* This one doesn't have varargs in the macro, so it's different than all the
601  * other macros and hence in a separate block right here. Docs chunks are
602  * with the other doc chunks below though. */
603 #define __GST_CAT_MEMDUMP_LOG(cat,object,msg,data,length) G_STMT_START{       \
604     if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= GST_LEVEL_MAX &&                     \
605                     GST_LEVEL_MEMDUMP <= _gst_debug_min)) {                   \
606     _gst_debug_dump_mem ((cat), __FILE__, GST_FUNCTION, __LINE__,             \
607         (GObject *) (object), (msg), (data), (length));                       \
608   }                                                                           \
609 }G_STMT_END
610
611 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length)  \
612     __GST_CAT_MEMDUMP_LOG(cat,obj,msg,data,length)
613 #define GST_CAT_MEMDUMP(cat,msg,data,length)             \
614     __GST_CAT_MEMDUMP_LOG(cat,NULL,msg,data,length)
615 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)          \
616     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,obj,msg,data,length)
617 #define GST_MEMDUMP(msg,data,length)                     \
618     __GST_CAT_MEMDUMP_LOG(GST_CAT_DEFAULT,NULL,msg,data,length)
619
620 /**
621  * GST_CAT_ERROR_OBJECT:
622  * @cat: category to use
623  * @obj: the #GObject the message belongs to
624  * @...: printf-style message to output
625  *
626  * Output an error message belonging to the given object in the given category.
627  */
628 /**
629  * GST_CAT_WARNING_OBJECT:
630  * @cat: category to use
631  * @obj: the #GObject the message belongs to
632  * @...: printf-style message to output
633  *
634  * Output a warning message belonging to the given object in the given category.
635  */
636 /**
637  * GST_CAT_INFO_OBJECT:
638  * @cat: category to use
639  * @obj: the #GObject the message belongs to
640  * @...: printf-style message to output
641  *
642  * Output an informational message belonging to the given object in the given
643  * category.
644  */
645 /**
646  * GST_CAT_DEBUG_OBJECT:
647  * @cat: category to use
648  * @obj: the #GObject the message belongs to
649  * @...: printf-style message to output
650  *
651  * Output an debugging message belonging to the given object in the given category.
652  */
653 /**
654  * GST_CAT_LOG_OBJECT:
655  * @cat: category to use
656  * @obj: the #GObject the message belongs to
657  * @...: printf-style message to output
658  *
659  * Output an logging message belonging to the given object in the given category.
660  */
661 /**
662  * GST_CAT_FIXME_OBJECT:
663  * @cat: category to use
664  * @obj: the #GObject the message belongs to
665  * @...: printf-style message to output
666  *
667  * Output a fixme message belonging to the given object in the given category.
668  */
669 /**
670  * GST_CAT_TRACE_OBJECT:
671  * @cat: category to use
672  * @obj: the #GObject the message belongs to
673  * @...: printf-style message to output
674  *
675  * Output a tracing message belonging to the given object in the given
676  * category.
677  */
678 /**
679  * GST_CAT_MEMDUMP_OBJECT:
680  * @cat: category to use
681  * @obj: the #GObject the message belongs to
682  * @msg: message string to log with the data
683  * @data: pointer to the data to output
684  * @length: length of the data to output
685  *
686  * Output a hexdump of @data relating to the given object in the given
687  * category.
688  */
689
690
691 /**
692  * GST_CAT_ERROR:
693  * @cat: category to use
694  * @...: printf-style message to output
695  *
696  * Output an error message in the given category.
697  */
698 /**
699  * GST_CAT_WARNING:
700  * @cat: category to use
701  * @...: printf-style message to output
702  *
703  * Output an warning message in the given category.
704  */
705 /**
706  * GST_CAT_INFO:
707  * @cat: category to use
708  * @...: printf-style message to output
709  *
710  * Output an informational message in the given category.
711  */
712 /**
713  * GST_CAT_DEBUG:
714  * @cat: category to use
715  * @...: printf-style message to output
716  *
717  * Output an debugging message in the given category.
718  */
719 /**
720  * GST_CAT_LOG:
721  * @cat: category to use
722  * @...: printf-style message to output
723  *
724  * Output an logging message in the given category.
725  */
726 /**
727  * GST_CAT_FIXME:
728  * @cat: category to use
729  * @...: printf-style message to output
730  *
731  * Output an fixme message in the given category.
732  */
733 /**
734  * GST_CAT_TRACE:
735  * @cat: category to use
736  * @...: printf-style message to output
737  *
738  * Output a tracing message in the given category.
739  */
740 /**
741  * GST_CAT_MEMDUMP:
742  * @cat: category to use
743  * @msg: message string to log with the data
744  * @data: pointer to the data to output
745  * @length: length of the data to output
746  *
747  * Output a hexdump of @data in the given category.
748  */
749
750
751 /**
752  * GST_ERROR_OBJECT:
753  * @obj: the #GObject the message belongs to
754  * @...: printf-style message to output
755  *
756  * Output an error message belonging to the given object in the default category.
757  */
758 /**
759  * GST_WARNING_OBJECT:
760  * @obj: the #GObject the message belongs to
761  * @...: printf-style message to output
762  *
763  * Output a warning message belonging to the given object in the default category.
764  */
765 /**
766  * GST_INFO_OBJECT:
767  * @obj: the #GObject the message belongs to
768  * @...: printf-style message to output
769  *
770  * Output an informational message belonging to the given object in the default
771  * category.
772  */
773 /**
774  * GST_DEBUG_OBJECT:
775  * @obj: the #GObject the message belongs to
776  * @...: printf-style message to output
777  *
778  * Output a debugging message belonging to the given object in the default
779  * category.
780  */
781 /**
782  * GST_LOG_OBJECT:
783  * @obj: the #GObject the message belongs to
784  * @...: printf-style message to output
785  *
786  * Output a logging message belonging to the given object in the default category.
787  */
788 /**
789  * GST_FIXME_OBJECT:
790  * @obj: the #GObject the message belongs to
791  * @...: printf-style message to output
792  *
793  * Output a fixme message belonging to the given object in the default category.
794  */
795 /**
796  * GST_TRACE_OBJECT:
797  * @obj: the #GObject the message belongs to
798  * @...: printf-style message to output
799  *
800  * Output a tracing message belonging to the given object in the default category.
801  */
802 /**
803  * GST_MEMDUMP_OBJECT:
804  * @obj: the #GObject the message belongs to
805  * @msg: message string to log with the data
806  * @data: pointer to the data to output
807  * @length: length of the data to output
808  *
809  * Output a logging message belonging to the given object in the default category.
810  */
811
812
813 /**
814  * GST_ERROR:
815  * @...: printf-style message to output
816  *
817  * Output an error message in the default category.
818  */
819 /**
820  * GST_WARNING:
821  * @...: printf-style message to output
822  *
823  * Output a warning message in the default category.
824  */
825 /**
826  * GST_INFO:
827  * @...: printf-style message to output
828  *
829  * Output an informational message in the default category.
830  */
831 /**
832  * GST_DEBUG:
833  * @...: printf-style message to output
834  *
835  * Output a debugging message in the default category.
836  */
837 /**
838  * GST_LOG:
839  * @...: printf-style message to output
840  *
841  * Output a logging message in the default category.
842  */
843 /**
844  * GST_FIXME:
845  * @...: printf-style message to output
846  *
847  * Output a fixme message in the default category.
848  */
849 /**
850  * GST_TRACE:
851  * @...: printf-style message to output
852  *
853  * Output a tracing message in the default category.
854  */
855 /**
856  * GST_MEMDUMP:
857  * @msg: message string to log with the data
858  * @data: pointer to the data to output
859  * @length: length of the data to output
860  *
861  * Output a hexdump of @data.
862  */
863
864 #ifdef G_HAVE_ISO_VARARGS
865
866 #define GST_CAT_ERROR_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
867 #define GST_CAT_WARNING_OBJECT(cat,obj,...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
868 #define GST_CAT_INFO_OBJECT(cat,obj,...)        GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
869 #define GST_CAT_DEBUG_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
870 #define GST_CAT_LOG_OBJECT(cat,obj,...)         GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
871 #define GST_CAT_FIXME_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
872 #define GST_CAT_TRACE_OBJECT(cat,obj,...)       GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
873
874 #define GST_CAT_ERROR(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
875 #define GST_CAT_WARNING(cat,...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
876 #define GST_CAT_INFO(cat,...)                   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
877 #define GST_CAT_DEBUG(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
878 #define GST_CAT_LOG(cat,...)                    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
879 #define GST_CAT_FIXME(cat,...)                  GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
880 #define GST_CAT_TRACE(cat,...)          GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
881
882 #define GST_ERROR_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  __VA_ARGS__)
883 #define GST_WARNING_OBJECT(obj,...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  __VA_ARGS__)
884 #define GST_INFO_OBJECT(obj,...)        GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  __VA_ARGS__)
885 #define GST_DEBUG_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
886 #define GST_LOG_OBJECT(obj,...)         GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  __VA_ARGS__)
887 #define GST_FIXME_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  __VA_ARGS__)
888 #define GST_TRACE_OBJECT(obj,...)       GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  __VA_ARGS__)
889
890 #define GST_ERROR(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
891 #define GST_WARNING(...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
892 #define GST_INFO(...)                   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
893 #define GST_DEBUG(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
894 #define GST_LOG(...)                    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
895 #define GST_FIXME(...)                  GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
896 #define GST_TRACE(...)          GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)
897
898 #else
899 #ifdef G_HAVE_GNUC_VARARGS
900
901 #define GST_CAT_ERROR_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   obj,  ##args )
902 #define GST_CAT_WARNING_OBJECT(cat,obj,args...) GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, obj,  ##args )
903 #define GST_CAT_INFO_OBJECT(cat,obj,args...)    GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    obj,  ##args )
904 #define GST_CAT_DEBUG_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   obj,  ##args )
905 #define GST_CAT_LOG_OBJECT(cat,obj,args...)     GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     obj,  ##args )
906 #define GST_CAT_FIXME_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   obj,  ##args )
907 #define GST_CAT_TRACE_OBJECT(cat,obj,args...)   GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   obj,  ##args )
908
909 #define GST_CAT_ERROR(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_ERROR,   NULL, ##args )
910 #define GST_CAT_WARNING(cat,args...)            GST_CAT_LEVEL_LOG (cat, GST_LEVEL_WARNING, NULL, ##args )
911 #define GST_CAT_INFO(cat,args...)               GST_CAT_LEVEL_LOG (cat, GST_LEVEL_INFO,    NULL, ##args )
912 #define GST_CAT_DEBUG(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_DEBUG,   NULL, ##args )
913 #define GST_CAT_LOG(cat,args...)                GST_CAT_LEVEL_LOG (cat, GST_LEVEL_LOG,     NULL, ##args )
914 #define GST_CAT_FIXME(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_FIXME,   NULL, ##args )
915 #define GST_CAT_TRACE(cat,args...)              GST_CAT_LEVEL_LOG (cat, GST_LEVEL_TRACE,   NULL, ##args )
916
917 #define GST_ERROR_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   obj,  ##args )
918 #define GST_WARNING_OBJECT(obj,args...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj,  ##args )
919 #define GST_INFO_OBJECT(obj,args...)    GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    obj,  ##args )
920 #define GST_DEBUG_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  ##args )
921 #define GST_LOG_OBJECT(obj,args...)     GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     obj,  ##args )
922 #define GST_FIXME_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   obj,  ##args )
923 #define GST_TRACE_OBJECT(obj,args...)   GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   obj,  ##args )
924
925 #define GST_ERROR(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, ##args )
926 #define GST_WARNING(args...)            GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, ##args )
927 #define GST_INFO(args...)               GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, ##args )
928 #define GST_DEBUG(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, ##args )
929 #define GST_LOG(args...)                GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, ##args )
930 #define GST_FIXME(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, ##args )
931 #define GST_TRACE(args...)              GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, ##args )
932
933 #else
934 /* no variadic macros, use inline */
935 static inline void
936 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
937     ...)
938 {
939   va_list varargs;
940
941   va_start (varargs, format);
942   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, obj, format, varargs);
943   va_end (varargs);
944 }
945
946 static inline void
947 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
948     const char *format, ...)
949 {
950   va_list varargs;
951
952   va_start (varargs, format);
953   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, obj, format, varargs);
954   va_end (varargs);
955 }
956
957 static inline void
958 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
959     ...)
960 {
961   va_list varargs;
962
963   va_start (varargs, format);
964   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, obj, format, varargs);
965   va_end (varargs);
966 }
967
968 static inline void
969 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
970     ...)
971 {
972   va_list varargs;
973
974   va_start (varargs, format);
975   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, obj, format, varargs);
976   va_end (varargs);
977 }
978
979 static inline void
980 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
981     ...)
982 {
983   va_list varargs;
984
985   va_start (varargs, format);
986   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, obj, format, varargs);
987   va_end (varargs);
988 }
989
990 static inline void
991 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
992     ...)
993 {
994   va_list varargs;
995
996   va_start (varargs, format);
997   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, obj, format, varargs);
998   va_end (varargs);
999 }
1000
1001 static inline void
1002 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1003     ...)
1004 {
1005   va_list varargs;
1006
1007   va_start (varargs, format);
1008   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, obj, format, varargs);
1009   va_end (varargs);
1010 }
1011
1012 static inline void
1013 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1014 {
1015   va_list varargs;
1016
1017   va_start (varargs, format);
1018   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_ERROR, NULL, format, varargs);
1019   va_end (varargs);
1020 }
1021
1022 static inline void
1023 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1024 {
1025   va_list varargs;
1026
1027   va_start (varargs, format);
1028   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_WARNING, NULL, format, varargs);
1029   va_end (varargs);
1030 }
1031
1032 static inline void
1033 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1034 {
1035   va_list varargs;
1036
1037   va_start (varargs, format);
1038   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_INFO, NULL, format, varargs);
1039   va_end (varargs);
1040 }
1041
1042 static inline void
1043 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1044 {
1045   va_list varargs;
1046
1047   va_start (varargs, format);
1048   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_DEBUG, NULL, format, varargs);
1049   va_end (varargs);
1050 }
1051
1052 static inline void
1053 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1054 {
1055   va_list varargs;
1056
1057   va_start (varargs, format);
1058   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_LOG, NULL, format, varargs);
1059   va_end (varargs);
1060 }
1061
1062 static inline void
1063 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
1064 {
1065   va_list varargs;
1066
1067   va_start (varargs, format);
1068   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_FIXME, NULL, format, varargs);
1069   va_end (varargs);
1070 }
1071
1072 static inline void
1073 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
1074 {
1075   va_list varargs;
1076
1077   va_start (varargs, format);
1078   GST_CAT_LEVEL_LOG_valist (cat, GST_LEVEL_TRACE, NULL, format, varargs);
1079   va_end (varargs);
1080 }
1081
1082 static inline void
1083 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1084 {
1085   va_list varargs;
1086
1087   va_start (varargs, format);
1088   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, obj, format,
1089       varargs);
1090   va_end (varargs);
1091 }
1092
1093 static inline void
1094 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1095 {
1096   va_list varargs;
1097
1098   va_start (varargs, format);
1099   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, obj, format,
1100       varargs);
1101   va_end (varargs);
1102 }
1103
1104 static inline void
1105 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1106 {
1107   va_list varargs;
1108
1109   va_start (varargs, format);
1110   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, obj, format,
1111       varargs);
1112   va_end (varargs);
1113 }
1114
1115 static inline void
1116 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1117 {
1118   va_list varargs;
1119
1120   va_start (varargs, format);
1121   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, obj, format,
1122       varargs);
1123   va_end (varargs);
1124 }
1125
1126 static inline void
1127 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1128 {
1129   va_list varargs;
1130
1131   va_start (varargs, format);
1132   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, obj, format,
1133       varargs);
1134   va_end (varargs);
1135 }
1136
1137 static inline void
1138 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
1139 {
1140   va_list varargs;
1141
1142   va_start (varargs, format);
1143   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, obj, format,
1144       varargs);
1145   va_end (varargs);
1146 }
1147
1148 static inline void
1149 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
1150 {
1151   va_list varargs;
1152
1153   va_start (varargs, format);
1154   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, obj, format,
1155       varargs);
1156   va_end (varargs);
1157 }
1158
1159 static inline void
1160 GST_ERROR (const char *format, ...)
1161 {
1162   va_list varargs;
1163
1164   va_start (varargs, format);
1165   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_ERROR, NULL, format,
1166       varargs);
1167   va_end (varargs);
1168 }
1169
1170 static inline void
1171 GST_WARNING (const char *format, ...)
1172 {
1173   va_list varargs;
1174
1175   va_start (varargs, format);
1176   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, format,
1177       varargs);
1178   va_end (varargs);
1179 }
1180
1181 static inline void
1182 GST_INFO (const char *format, ...)
1183 {
1184   va_list varargs;
1185
1186   va_start (varargs, format);
1187   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_INFO, NULL, format,
1188       varargs);
1189   va_end (varargs);
1190 }
1191
1192 static inline void
1193 GST_DEBUG (const char *format, ...)
1194 {
1195   va_list varargs;
1196
1197   va_start (varargs, format);
1198   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_DEBUG, NULL, format,
1199       varargs);
1200   va_end (varargs);
1201 }
1202
1203 static inline void
1204 GST_LOG (const char *format, ...)
1205 {
1206   va_list varargs;
1207
1208   va_start (varargs, format);
1209   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_LOG, NULL,
1210       format, varargs);
1211   va_end (varargs);
1212 }
1213
1214 static inline void
1215 GST_FIXME (const char *format, ...)
1216 {
1217   va_list varargs;
1218
1219   va_start (varargs, format);
1220   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_FIXME, NULL, format,
1221       varargs);
1222   va_end (varargs);
1223 }
1224
1225 static inline void
1226 GST_TRACE (const char *format, ...)
1227 {
1228   va_list varargs;
1229
1230   va_start (varargs, format);
1231   GST_CAT_LEVEL_LOG_valist (GST_CAT_DEFAULT, GST_LEVEL_TRACE, NULL, format,
1232       varargs);
1233   va_end (varargs);
1234 }
1235 #endif
1236 #endif
1237
1238
1239 /********** function pointer stuff **********/
1240
1241 /**
1242  * GST_DEBUG_REGISTER_FUNCPTR:
1243  * @ptr: pointer to the function to register
1244  *
1245  * Register a pointer to a function with its name, so it can later be used by
1246  * GST_DEBUG_FUNCPTR_NAME().
1247  *
1248  * Use this variant of #GST_DEBUG_FUNCPTR if you do not need to use @ptr.
1249  */
1250 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) \
1251   _gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr)
1252 /**
1253  * GST_DEBUG_FUNCPTR:
1254  * @ptr: pointer to the function to register
1255  *
1256  * Register a pointer to a function with its name, so it can later be used by
1257  * GST_DEBUG_FUNCPTR_NAME().
1258  *
1259  * Returns: the value passed to @ptr.
1260  */
1261 #define GST_DEBUG_FUNCPTR(ptr) \
1262   (_gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr) , ptr)
1263
1264 /**
1265  * GST_DEBUG_FUNCPTR_NAME:
1266  * @ptr: address of the function of which to look up the name
1267  *
1268  * Retrieves the name of the function, if it was previously registered with
1269  * GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
1270  *
1271  * This macro returns a constant string which must not be modified or
1272  * freed by the caller.
1273  */
1274 #define GST_DEBUG_FUNCPTR_NAME(ptr) \
1275   _gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)
1276
1277
1278 #else /* GST_DISABLE_GST_DEBUG */
1279
1280
1281 #ifndef GST_INFO_C
1282
1283 #if defined(__GNUC__) && __GNUC__ >= 3
1284 #  pragma GCC poison gst_debug_log
1285 #  pragma GCC poison gst_debug_log_valist
1286 #  pragma GCC poison _gst_debug_category_new
1287 #endif
1288
1289 #define _gst_debug_min GST_LEVEL_NONE
1290
1291 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1292 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1293
1294 #define gst_debug_level_get_name(level)                         ("NONE")
1295 #define gst_debug_message_get(message)                          ("")
1296 #define gst_debug_add_log_function(func,data,notify)    G_STMT_START{ }G_STMT_END
1297 #define gst_debug_set_active(active)                    G_STMT_START{ }G_STMT_END
1298 #define gst_debug_is_active()                           (FALSE)
1299 #define gst_debug_set_colored(colored)                  G_STMT_START{ }G_STMT_END
1300 #define gst_debug_set_color_mode(mode)                  G_STMT_START{ }G_STMT_END
1301 #define gst_debug_set_color_mode_from_string(mode)      G_STMT_START{ }G_STMT_END
1302 #define gst_debug_is_colored()                          (FALSE)
1303 #define gst_debug_get_color_mode()                      (GST_DEBUG_COLOR_MODE_OFF)
1304 #define gst_debug_set_default_threshold(level)          G_STMT_START{ }G_STMT_END
1305 #define gst_debug_get_default_threshold()               (GST_LEVEL_NONE)
1306 #define gst_debug_set_threshold_for_name(name,level)    G_STMT_START{ }G_STMT_END
1307 #define gst_debug_unset_threshold_for_name(name)        G_STMT_START{ }G_STMT_END
1308
1309 /* we are using dummy function prototypes here to eat ';' as these macros are
1310  * used outside of functions */
1311 #define GST_DEBUG_CATEGORY(var)                         void _gst_debug_dummy_##var (void)
1312 #define GST_DEBUG_CATEGORY_EXTERN(var)                  void _gst_debug_dummy_extern_##var (void)
1313 #define GST_DEBUG_CATEGORY_STATIC(var)                  void _gst_debug_dummy_static_##var (void)
1314
1315 #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc)    G_STMT_START{ }G_STMT_END
1316 #define GST_DEBUG_CATEGORY_GET(var,name)                G_STMT_START{ }G_STMT_END
1317 #define gst_debug_category_free(category)               G_STMT_START{ }G_STMT_END
1318 #define gst_debug_category_set_threshold(category,level) G_STMT_START{ }G_STMT_END
1319 #define gst_debug_category_reset_threshold(category)    G_STMT_START{ }G_STMT_END
1320 #define gst_debug_category_get_threshold(category)      (GST_LEVEL_NONE)
1321 #define gst_debug_category_get_name(cat)                ("")
1322 #define gst_debug_category_get_color(cat)               (0)
1323 #define gst_debug_category_get_description(cat)         ("")
1324 #define gst_debug_get_all_categories()                  (NULL)
1325 #define gst_debug_construct_term_color(colorinfo)       (g_strdup ("00"))
1326 #define gst_debug_construct_win_color(colorinfo)        (0)
1327
1328 #endif /* !GST_INFO_C */
1329
1330 #ifdef G_HAVE_ISO_VARARGS
1331
1332 #define GST_CAT_LEVEL_LOG(cat,level,...)                G_STMT_START{ }G_STMT_END
1333
1334 #define GST_CAT_ERROR_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1335 #define GST_CAT_WARNING_OBJECT(...)                     G_STMT_START{ }G_STMT_END
1336 #define GST_CAT_INFO_OBJECT(...)                        G_STMT_START{ }G_STMT_END
1337 #define GST_CAT_DEBUG_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1338 #define GST_CAT_LOG_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1339 #define GST_CAT_FIXME_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1340 #define GST_CAT_TRACE_OBJECT(...)                       G_STMT_START{ }G_STMT_END
1341
1342 #define GST_CAT_ERROR(...)                              G_STMT_START{ }G_STMT_END
1343 #define GST_CAT_WARNING(...)                            G_STMT_START{ }G_STMT_END
1344 #define GST_CAT_INFO(...)                               G_STMT_START{ }G_STMT_END
1345 #define GST_CAT_DEBUG(...)                              G_STMT_START{ }G_STMT_END
1346 #define GST_CAT_LOG(...)                                G_STMT_START{ }G_STMT_END
1347 #define GST_CAT_FIXME(...)                              G_STMT_START{ }G_STMT_END
1348 #define GST_CAT_TRACE(...)                              G_STMT_START{ }G_STMT_END
1349
1350 #define GST_ERROR_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1351 #define GST_WARNING_OBJECT(...)                         G_STMT_START{ }G_STMT_END
1352 #define GST_INFO_OBJECT(...)                            G_STMT_START{ }G_STMT_END
1353 #define GST_DEBUG_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1354 #define GST_LOG_OBJECT(...)                             G_STMT_START{ }G_STMT_END
1355 #define GST_FIXME_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1356 #define GST_TRACE_OBJECT(...)                           G_STMT_START{ }G_STMT_END
1357
1358 #define GST_ERROR(...)                                  G_STMT_START{ }G_STMT_END
1359 #define GST_WARNING(...)                                G_STMT_START{ }G_STMT_END
1360 #define GST_INFO(...)                                   G_STMT_START{ }G_STMT_END
1361 #define GST_DEBUG(...)                                  G_STMT_START{ }G_STMT_END
1362 #define GST_LOG(...)                                    G_STMT_START{ }G_STMT_END
1363 #define GST_FIXME(...)                                  G_STMT_START{ }G_STMT_END
1364 #define GST_TRACE(...)                                  G_STMT_START{ }G_STMT_END
1365
1366 #else /* !G_HAVE_ISO_VARARGS */
1367 #ifdef G_HAVE_GNUC_VARARGS
1368
1369 #define GST_CAT_LEVEL_LOG(cat,level,args...)            G_STMT_START{ }G_STMT_END
1370
1371 #define GST_CAT_ERROR_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1372 #define GST_CAT_WARNING_OBJECT(args...)                 G_STMT_START{ }G_STMT_END
1373 #define GST_CAT_INFO_OBJECT(args...)                    G_STMT_START{ }G_STMT_END
1374 #define GST_CAT_DEBUG_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1375 #define GST_CAT_LOG_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1376 #define GST_CAT_FIXME_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1377 #define GST_CAT_TRACE_OBJECT(args...)                   G_STMT_START{ }G_STMT_END
1378
1379 #define GST_CAT_ERROR(args...)                          G_STMT_START{ }G_STMT_END
1380 #define GST_CAT_WARNING(args...)                        G_STMT_START{ }G_STMT_END
1381 #define GST_CAT_INFO(args...)                           G_STMT_START{ }G_STMT_END
1382 #define GST_CAT_DEBUG(args...)                          G_STMT_START{ }G_STMT_END
1383 #define GST_CAT_LOG(args...)                            G_STMT_START{ }G_STMT_END
1384 #define GST_CAT_FIXME(args...)                          G_STMT_START{ }G_STMT_END
1385 #define GST_CAT_TRACE(args...)                          G_STMT_START{ }G_STMT_END
1386
1387 #define GST_ERROR_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1388 #define GST_WARNING_OBJECT(args...)                     G_STMT_START{ }G_STMT_END
1389 #define GST_INFO_OBJECT(args...)                        G_STMT_START{ }G_STMT_END
1390 #define GST_DEBUG_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1391 #define GST_LOG_OBJECT(args...)                         G_STMT_START{ }G_STMT_END
1392 #define GST_FIXME_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1393 #define GST_TRACE_OBJECT(args...)                       G_STMT_START{ }G_STMT_END
1394
1395 #define GST_ERROR(args...)                              G_STMT_START{ }G_STMT_END
1396 #define GST_WARNING(args...)                            G_STMT_START{ }G_STMT_END
1397 #define GST_INFO(args...)                               G_STMT_START{ }G_STMT_END
1398 #define GST_DEBUG(args...)                              G_STMT_START{ }G_STMT_END
1399 #define GST_LOG(args...)                                G_STMT_START{ }G_STMT_END
1400 #define GST_FIXME(args...)                              G_STMT_START{ }G_STMT_END
1401 #define GST_TRACE(args...)                              G_STMT_START{ }G_STMT_END
1402
1403 #else /* !G_HAVE_GNUC_VARARGS */
1404 static inline void
1405 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
1406     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
1407 {
1408 }
1409
1410 static inline void
1411 GST_CAT_ERROR_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1412     ...)
1413 {
1414 }
1415
1416 static inline void
1417 GST_CAT_WARNING_OBJECT (GstDebugCategory * cat, gpointer obj,
1418     const char *format, ...)
1419 {
1420 }
1421
1422 static inline void
1423 GST_CAT_INFO_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1424     ...)
1425 {
1426 }
1427
1428 static inline void
1429 GST_CAT_DEBUG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1430     ...)
1431 {
1432 }
1433
1434 static inline void
1435 GST_CAT_LOG_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1436     ...)
1437 {
1438 }
1439
1440 static inline void
1441 GST_CAT_FIXME_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1442     ...)
1443 {
1444 }
1445
1446 static inline void
1447 GST_CAT_TRACE_OBJECT (GstDebugCategory * cat, gpointer obj, const char *format,
1448     ...)
1449 {
1450 }
1451
1452 static inline void
1453 GST_CAT_ERROR (GstDebugCategory * cat, const char *format, ...)
1454 {
1455 }
1456
1457 static inline void
1458 GST_CAT_WARNING (GstDebugCategory * cat, const char *format, ...)
1459 {
1460 }
1461
1462 static inline void
1463 GST_CAT_INFO (GstDebugCategory * cat, const char *format, ...)
1464 {
1465 }
1466
1467 static inline void
1468 GST_CAT_DEBUG (GstDebugCategory * cat, const char *format, ...)
1469 {
1470 }
1471
1472 static inline void
1473 GST_CAT_LOG (GstDebugCategory * cat, const char *format, ...)
1474 {
1475 }
1476
1477 static inline void
1478 GST_CAT_FIXME (GstDebugCategory * cat, const char *format, ...)
1479 {
1480 }
1481
1482 static inline void
1483 GST_CAT_TRACE (GstDebugCategory * cat, const char *format, ...)
1484 {
1485 }
1486
1487 static inline void
1488 GST_ERROR_OBJECT (gpointer obj, const char *format, ...)
1489 {
1490 }
1491
1492 static inline void
1493 GST_WARNING_OBJECT (gpointer obj, const char *format, ...)
1494 {
1495 }
1496
1497 static inline void
1498 GST_INFO_OBJECT (gpointer obj, const char *format, ...)
1499 {
1500 }
1501
1502 static inline void
1503 GST_DEBUG_OBJECT (gpointer obj, const char *format, ...)
1504 {
1505 }
1506
1507 static inline void
1508 GST_LOG_OBJECT (gpointer obj, const char *format, ...)
1509 {
1510 }
1511
1512 static inline void
1513 GST_FIXME_OBJECT (gpointer obj, const char *format, ...)
1514 {
1515 }
1516
1517 static inline void
1518 GST_TRACE_OBJECT (gpointer obj, const char *format, ...)
1519 {
1520 }
1521
1522 static inline void
1523 GST_ERROR (const char *format, ...)
1524 {
1525 }
1526
1527 static inline void
1528 GST_WARNING (const char *format, ...)
1529 {
1530 }
1531
1532 static inline void
1533 GST_INFO (const char *format, ...)
1534 {
1535 }
1536
1537 static inline void
1538 GST_DEBUG (const char *format, ...)
1539 {
1540 }
1541
1542 static inline void
1543 GST_LOG (const char *format, ...)
1544 {
1545 }
1546
1547 static inline void
1548 GST_FIXME (const char *format, ...)
1549 {
1550 }
1551
1552 static inline void
1553 GST_TRACE (const char *format, ...)
1554 {
1555 }
1556
1557 #endif /* G_HAVE_GNUC_VARARGS */
1558 #endif /* G_HAVE_ISO_VARARGS */
1559
1560 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) G_STMT_START{ }G_STMT_END
1561 #define GST_DEBUG_FUNCPTR(ptr) (ptr)
1562 #define GST_DEBUG_FUNCPTR_NAME(ptr) (g_strdup_printf ("%p", ptr))
1563
1564 #define GST_CAT_MEMDUMP_OBJECT(cat,obj,msg,data,length) G_STMT_START{ }G_STMT_END
1565 #define GST_CAT_MEMDUMP(cat,msg,data,length)            G_STMT_START{ }G_STMT_END
1566 #define GST_MEMDUMP_OBJECT(obj,msg,data,length)         G_STMT_START{ }G_STMT_END
1567 #define GST_MEMDUMP(msg,data,length)                    G_STMT_START{ }G_STMT_END
1568
1569 #endif /* GST_DISABLE_GST_DEBUG */
1570
1571
1572 void gst_debug_print_stack_trace (void);
1573 gchar * gst_debug_get_stack_trace (void);
1574
1575 G_END_DECLS
1576
1577 #endif /* __GSTINFO_H__ */