docs: convert NULL, TRUE, and FALSE to %NULL, %TRUE, and %FALSE
[platform/upstream/gstreamer.git] / gst / gstinfo.h
index c2f12ce..319e841 100644 (file)
@@ -17,8 +17,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifndef __GSTINFO_H__
 #include <glib-object.h>
 #include <gst/gstconfig.h>
 
-#ifndef M_PI
-#define M_PI  3.14159265358979323846
-#endif
-
 G_BEGIN_DECLS
 
 /**
  * GstDebugLevel:
  * @GST_LEVEL_NONE: No debugging level specified or desired. Used to deactivate
  *  debugging output.
- * @GST_LEVEL_ERROR: Error messages are to be used only when an error occured
+ * @GST_LEVEL_ERROR: Error messages are to be used only when an error occurred
  *  that stops the application from keeping working correctly.
  *  An examples is gst_element_error, which outputs a message with this priority.
- *  It does not mean that the application is terminating as with g_errror.
+ *  It does not mean that the application is terminating as with g_error.
  * @GST_LEVEL_WARNING: Warning messages are to inform about abnormal behaviour
  *  that could lead to problems or weird behaviour later on. An example of this
  *  would be clocking issues ("your computer is pretty slow") or broken input
  *  data ("Can't synchronize to stream.")
+ * @GST_LEVEL_FIXME: Fixme messages are messages that indicate that something
+ *  in the executed code path is not fully implemented or handled yet. Note
+ *  that this does not replace proper error handling in any way, the purpose
+ *  of this message is to make it easier to spot incomplete/unfinished pieces
+ *  of code when reading the debug log.
  * @GST_LEVEL_INFO: Informational messages should be used to keep the developer
  *  updated about what is happening.
  *  Examples where this should be used are when a typefind function has
@@ -62,16 +63,11 @@ G_BEGIN_DECLS
  *  should never output anything else but LOG messages. Use this log level to
  *  log recurring information in chain functions and loop functions, for
  *  example.
- * @GST_LEVEL_FIXME: Fixme messages are messages that indicate that something
- *  in the executed code path is not fully implemented or handled yet. Note
- *  that this does not replace proper error handling in any way, the purpose
- *  of this message is to make it easier to spot incomplete/unfinished pieces
- *  of code when reading the debug log. (Since: 0.10.23)
- * @GST_LEVEL_TRACE: Tracing-related messages (Since: 0.10.30)
+ * @GST_LEVEL_TRACE: Tracing-related messages.
  *  Examples for this are referencing/dereferencing of objects.
  * @GST_LEVEL_MEMDUMP: memory dump messages are used to log (small) chunks of
  *  data as memory dumps in the log. They will be displayed as hexdump with
- *  ASCII characters. (Since: 0.10.23)
+ *  ASCII characters.
  * @GST_LEVEL_COUNT: The number of defined debugging levels.
  *
  * The level defines the importance of a debugging message. The more important a
@@ -79,12 +75,12 @@ G_BEGIN_DECLS
  */
 typedef enum {
   GST_LEVEL_NONE = 0,
-  GST_LEVEL_ERROR,
-  GST_LEVEL_WARNING,
-  GST_LEVEL_INFO,
-  GST_LEVEL_DEBUG,
-  GST_LEVEL_LOG,
-  GST_LEVEL_FIXME = 6,
+  GST_LEVEL_ERROR = 1,
+  GST_LEVEL_WARNING = 2,
+  GST_LEVEL_FIXME = 3,
+  GST_LEVEL_INFO = 4,
+  GST_LEVEL_DEBUG = 5,
+  GST_LEVEL_LOG = 6,
   GST_LEVEL_TRACE = 7,
   /* add more */
   GST_LEVEL_MEMDUMP = 9,
@@ -163,6 +159,20 @@ typedef enum {
   GST_DEBUG_UNDERLINE          = 0x0200
 } GstDebugColorFlags;
 
+/**
+ * GstDebugColorMode:
+ * @GST_DEBUG_COLOR_MODE_OFF: Do not use colors in logs.
+ * @GST_DEBUG_COLOR_MODE_ON: Paint logs in a platform-specific way.
+ * @GST_DEBUG_COLOR_MODE_UNIX: Paint logs with UNIX terminal color codes
+ *                             no matter what platform GStreamer is running on.
+ */
+typedef enum {
+  GST_DEBUG_COLOR_MODE_OFF  = 0,
+  GST_DEBUG_COLOR_MODE_ON   = 1,
+  GST_DEBUG_COLOR_MODE_UNIX = 2
+} GstDebugColorMode;
+
+
 #define GST_DEBUG_FG_MASK      (0x000F)
 #define GST_DEBUG_BG_MASK      (0x00F0)
 #define GST_DEBUG_FORMAT_MASK  (0xFF00)
@@ -189,9 +199,9 @@ struct _GstDebugCategory {
  * GST_STR_NULL:
  * @str: The string to check.
  *
- * Macro to use when a string must not be NULL, but may be NULL. If the string
- * is NULL, "(NULL)" is printed instead.
- * In GStreamer printf string arguments may not be NULL, because on some
+ * Macro to use when a string must not be %NULL, but may be %NULL. If the string
+ * is %NULL, "(NULL)" is printed instead.
+ * In GStreamer printf string arguments may not be %NULL, because on some
  * platforms (ie Solaris) the libc crashes in that case. This includes debugging
  * strings.
  */
@@ -233,6 +243,21 @@ struct _GstDebugCategory {
 #endif
 #endif /* ifndef GST_FUNCTION */
 
+/**
+ * GST_PTR_FORMAT:
+ *
+ * printf format type used to debug GStreamer types.
+ * This can only be used on types whose size is >= sizeof(gpointer).
+ */
+#define GST_PTR_FORMAT     "p\aA"
+
+/**
+ * GST_SEGMENT_FORMAT:
+ *
+ * printf format type used to debug GStreamer segments.
+ * This can only be used on pointers to GstSegment structures.
+ */
+#define GST_SEGMENT_FORMAT "p\aB"
 
 typedef struct _GstDebugMessage GstDebugMessage;
 
@@ -245,7 +270,7 @@ typedef struct _GstDebugMessage GstDebugMessage;
  * @line: line number
  * @object: a #GObject
  * @message: the message
- * @data: user data for the log function
+ * @user_data: user data for the log function
  *
  * Function prototype for a logging function that can be registered with
  * gst_debug_add_log_function().
@@ -258,26 +283,7 @@ typedef void (*GstLogFunction)  (GstDebugCategory * category,
                                  gint               line,
                                  GObject          * object,
                                  GstDebugMessage  * message,
-                                 gpointer           data);
-
-
-/* FIXME 0.11: move this into private headers */
-void            _gst_debug_init (void);
-
-
-#ifdef GST_USING_PRINTF_EXTENSION
-
-/* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */
-void               gst_debug_log            (GstDebugCategory * category,
-                                          GstDebugLevel      level,
-                                          const gchar      * file,
-                                          const gchar      * function,
-                                          gint               line,
-                                          GObject          * object,
-                                          const gchar      * format,
-                                          ...) G_GNUC_NO_INSTRUMENT;
-
-#else /* GST_USING_PRINTF_EXTENSION */
+                                 gpointer           user_data);
 
 void               gst_debug_log            (GstDebugCategory * category,
                                           GstDebugLevel      level,
@@ -288,8 +294,6 @@ void                    gst_debug_log            (GstDebugCategory * category,
                                           const gchar      * format,
                                           ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
 
-#endif /* GST_USING_PRINTF_EXTENSION */
-
 void            gst_debug_log_valist     (GstDebugCategory * category,
                                           GstDebugLevel      level,
                                           const gchar      * file,
@@ -321,7 +325,7 @@ typedef     void (* GstDebugFuncPtr)        (void);
 /* do no use these functions, use the GST_DEBUG*_FUNCPTR macros */
 void   _gst_debug_register_funcptr     (GstDebugFuncPtr        func,
                                         const gchar *          ptrname);
-G_CONST_RETURN gchar *
+const gchar *
        _gst_debug_nameof_funcptr       (GstDebugFuncPtr        func) G_GNUC_NO_INSTRUMENT;
 
 
@@ -336,11 +340,12 @@ void            gst_debug_log_default    (GstDebugCategory * category,
                                           GstDebugMessage  * message,
                                           gpointer           unused) G_GNUC_NO_INSTRUMENT;
 
-G_CONST_RETURN gchar *
-                gst_debug_level_get_name (GstDebugLevel level);
+const gchar *   gst_debug_level_get_name (GstDebugLevel level);
 
 void            gst_debug_add_log_function            (GstLogFunction func,
-                                                       gpointer       data);
+                                                       gpointer       user_data,
+                                                       GDestroyNotify notify);
+
 guint           gst_debug_remove_log_function         (GstLogFunction func);
 guint           gst_debug_remove_log_function_by_data (gpointer       data);
 
@@ -348,12 +353,16 @@ void            gst_debug_set_active  (gboolean active);
 gboolean        gst_debug_is_active   (void);
 
 void            gst_debug_set_colored (gboolean colored);
+void            gst_debug_set_color_mode   (GstDebugColorMode mode);
+void            gst_debug_set_color_mode_from_string (const gchar * mode);
 gboolean        gst_debug_is_colored  (void);
+GstDebugColorMode gst_debug_get_color_mode (void);
 
 void            gst_debug_set_default_threshold      (GstDebugLevel level);
 GstDebugLevel   gst_debug_get_default_threshold      (void);
 void            gst_debug_set_threshold_for_name     (const gchar * name,
                                                       GstDebugLevel level);
+void            gst_debug_set_threshold_from_string  (const gchar * list, gboolean reset);
 void            gst_debug_unset_threshold_for_name   (const gchar * name);
 
 
@@ -362,11 +371,9 @@ void                   gst_debug_category_set_threshold     (GstDebugCategory *    catego
                                                       GstDebugLevel            level);
 void            gst_debug_category_reset_threshold   (GstDebugCategory *       category);
 GstDebugLevel   gst_debug_category_get_threshold     (GstDebugCategory *       category);
-G_CONST_RETURN gchar *
-                   gst_debug_category_get_name          (GstDebugCategory *    category);
+const gchar *   gst_debug_category_get_name          (GstDebugCategory *       category);
 guint           gst_debug_category_get_color         (GstDebugCategory *       category);
-G_CONST_RETURN gchar *
-                gst_debug_category_get_description   (GstDebugCategory *       category);
+const gchar *   gst_debug_category_get_description   (GstDebugCategory *       category);
 GSList *        gst_debug_get_all_categories   (void);
 
 
@@ -376,6 +383,20 @@ gint    gst_debug_construct_win_color  (guint colorinfo);
 
 #ifndef GST_DISABLE_GST_DEBUG
 
+#define gst_debug_add_log_function(func,data,notify) \
+G_STMT_START{                                        \
+  if (func == gst_debug_log_default) {               \
+    gst_debug_add_log_function(NULL,data,notify);    \
+  } else {                                           \
+    gst_debug_add_log_function(func,data,notify);    \
+  }                                                  \
+}G_STMT_END
+
+#define gst_debug_remove_log_function(func)   \
+    (func == gst_debug_log_default) ?         \
+        gst_debug_remove_log_function(NULL) : \
+        gst_debug_remove_log_function(func)
+
 /**
  * GST_DEBUG_CATEGORY:
  * @cat: the category
@@ -449,7 +470,7 @@ gint    gst_debug_construct_win_color  (guint colorinfo);
  *
  * Looks up an existing #GstDebugCategory by its @name and sets @cat. If the
  * category is not found, but GST_CAT_DEFAULT is defined, that is assigned to
- * @cat. Otherwise @cat will be NULL.
+ * @cat. Otherwise @cat will be %NULL.
  *
  * |[
  * GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
@@ -459,8 +480,6 @@ gint    gst_debug_construct_win_color  (guint colorinfo);
  * GST_DEBUG_CATEGORY_INIT (gst_myplugin_debug, "myplugin", 0, "nice element");
  * GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
  * ]|
- *
- * Since: 0.10.24
  */
 #ifdef GST_CAT_DEFAULT
 #define GST_DEBUG_CATEGORY_GET(cat,name)  G_STMT_START{\
@@ -482,17 +501,17 @@ gint    gst_debug_construct_win_color  (guint colorinfo);
  */
 GST_EXPORT GstDebugCategory *  GST_CAT_DEFAULT;
 /* this symbol may not be used */
-extern gboolean                        __gst_debug_enabled;
+GST_EXPORT gboolean                    _gst_debug_enabled;
 
-/* since 0.10.7, the min debug level, used for quickly discarding debug
+/* the min debug level, used for quickly discarding debug
  * messages that fall under the threshold. */
-GST_EXPORT GstDebugLevel            __gst_debug_min; 
+GST_EXPORT GstDebugLevel            _gst_debug_min;
 
 /**
  * GST_CAT_LEVEL_LOG:
  * @cat: category to use
  * @level: the severity of the message
- * @object: the #GObject the message belongs to or NULL if none
+ * @object: (allow-none): the #GObject the message belongs to or %NULL if none
  * @...: A printf-style message to output
  *
  * Outputs a debugging message. This is the most general macro for outputting
@@ -501,7 +520,7 @@ GST_EXPORT GstDebugLevel            __gst_debug_min;
  */
 #ifdef G_HAVE_ISO_VARARGS
 #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{          \
-  if (G_UNLIKELY (level <= __gst_debug_min)) {                                         \
+  if (G_UNLIKELY (level <= _gst_debug_min)) {                                          \
     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,   \
         (GObject *) (object), __VA_ARGS__);                            \
   }                                                                    \
@@ -509,7 +528,7 @@ GST_EXPORT GstDebugLevel            __gst_debug_min;
 #else /* G_HAVE_GNUC_VARARGS */
 #ifdef G_HAVE_GNUC_VARARGS
 #define GST_CAT_LEVEL_LOG(cat,level,object,args...) G_STMT_START{      \
-  if (G_UNLIKELY (level <= __gst_debug_min)) {                                         \
+  if (G_UNLIKELY (level <= _gst_debug_min)) {                                          \
     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__,   \
         (GObject *) (object), ##args );                                        \
   }                                                                    \
@@ -519,7 +538,7 @@ static inline void
 GST_CAT_LEVEL_LOG_valist (GstDebugCategory * cat,
     GstDebugLevel level, gpointer object, const char *format, va_list varargs)
 {
-  if (G_UNLIKELY (level <= __gst_debug_min)) {
+  if (G_UNLIKELY (level <= _gst_debug_min)) {
     gst_debug_log_valist (cat, level, "", "", 0, (GObject *) object, format,
         varargs);
   }
@@ -542,7 +561,7 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * other macros and hence in a separate block right here. Docs chunks are
  * with the other doc chunks below though. */
 #define __GST_CAT_MEMDUMP_LOG(cat,object,msg,data,length) G_STMT_START{       \
-  if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= __gst_debug_min)) {                    \
+  if (G_UNLIKELY (GST_LEVEL_MEMDUMP <= _gst_debug_min)) {                    \
     _gst_debug_dump_mem ((cat), __FILE__, GST_FUNCTION, __LINE__,             \
         (GObject *) (object), (msg), (data), (length));                       \
   }                                                                           \
@@ -605,8 +624,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output a fixme message belonging to the given object in the given category.
- *
- * Since: 0.10.23
  */
 /**
  * GST_CAT_TRACE_OBJECT:
@@ -616,8 +633,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  *
  * Output a tracing message belonging to the given object in the given
  * category.
- *
- * Since: 0.10.30
  */
 /**
  * GST_CAT_MEMDUMP_OBJECT:
@@ -629,8 +644,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  *
  * Output a hexdump of @data relating to the given object in the given
  * category.
- *
- * Since: 0.10.23
  */
 
 
@@ -675,8 +688,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output an fixme message in the given category.
- *
- * Since: 0.10.23
  */
 /**
  * GST_CAT_TRACE:
@@ -684,8 +695,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output a tracing message in the given category.
- *
- * Since: 0.10.30
  */
 /**
  * GST_CAT_MEMDUMP:
@@ -695,8 +704,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @length: length of the data to output
  *
  * Output a hexdump of @data in the given category.
- *
- * Since: 0.10.23
  */
 
 
@@ -743,8 +750,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output a fixme message belonging to the given object in the default category.
- *
- * Since: 0.10.23
  */
 /**
  * GST_TRACE_OBJECT:
@@ -752,8 +757,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output a tracing message belonging to the given object in the default category.
- *
- * Since: 0.10.30
  */
 /**
  * GST_MEMDUMP_OBJECT:
@@ -763,8 +766,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @length: length of the data to output
  *
  * Output a logging message belonging to the given object in the default category.
- *
- * Since: 0.10.23
  */
 
 
@@ -803,16 +804,12 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @...: printf-style message to output
  *
  * Output a fixme message in the default category.
- *
- * Since: 0.10.23
  */
 /**
  * GST_TRACE:
  * @...: printf-style message to output
  *
  * Output a tracing message in the default category.
- *
- * Since: 0.10.30
  */
 /**
  * GST_MEMDUMP:
@@ -821,8 +818,6 @@ GST_CAT_LEVEL_LOG (GstDebugCategory * cat, GstDebugLevel level,
  * @length: length of the data to output
  *
  * Output a hexdump of @data.
- *
- * Since: 0.10.23
  */
 
 #ifdef G_HAVE_ISO_VARARGS
@@ -1210,8 +1205,6 @@ GST_TRACE (const char *format, ...)
  * GST_DEBUG_FUNCPTR_NAME().
  *
  * Use this variant of #GST_DEBUG_FUNCPTR if you do not need to use @ptr.
- *
- * Since: 0.10.26
  */
 #define GST_DEBUG_REGISTER_FUNCPTR(ptr) \
   _gst_debug_register_funcptr((GstDebugFuncPtr)(ptr), #ptr)
@@ -1252,20 +1245,21 @@ GST_TRACE (const char *format, ...)
 #  pragma GCC poison _gst_debug_category_new
 #endif
 
-#define __gst_debug_min GST_LEVEL_NONE
-
-#define _gst_debug_init()                              G_STMT_START{ }G_STMT_END
+#define _gst_debug_min GST_LEVEL_NONE
 
 #define gst_debug_set_default_threshold(level)         G_STMT_START{ }G_STMT_END
 #define gst_debug_get_default_threshold()              (GST_LEVEL_NONE)
 
 #define gst_debug_level_get_name(level)                                ("NONE")
 #define gst_debug_message_get(message)                         ("")
-#define gst_debug_add_log_function(func,data)          G_STMT_START{ }G_STMT_END
+#define gst_debug_add_log_function(func,data,notify)    G_STMT_START{ }G_STMT_END
 #define gst_debug_set_active(active)                   G_STMT_START{ }G_STMT_END
 #define gst_debug_is_active()                          (FALSE)
 #define gst_debug_set_colored(colored)                 G_STMT_START{ }G_STMT_END
+#define gst_debug_set_color_mode(mode)                 G_STMT_START{ }G_STMT_END
+#define gst_debug_set_color_mode_from_string(mode)     G_STMT_START{ }G_STMT_END
 #define gst_debug_is_colored()                         (FALSE)
+#define gst_debug_get_color_mode()                     (GST_DEBUG_COLOR_MODE_OFF)
 #define gst_debug_set_default_threshold(level)         G_STMT_START{ }G_STMT_END
 #define gst_debug_get_default_threshold()              (GST_LEVEL_NONE)
 #define gst_debug_set_threshold_for_name(name,level)   G_STMT_START{ }G_STMT_END