message: new API for additional custom data to error messages
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Wed, 2 Mar 2016 11:22:23 +0000 (11:22 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 22 Jul 2016 13:16:34 +0000 (14:16 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=756806

gst/gstelement.c
gst/gstelement.h
gst/gstmessage.c
gst/gstmessage.h
tests/check/gst/gstmessage.c
win32/common/libgstreamer.def

index 4333d53..fb53987 100644 (file)
@@ -1819,7 +1819,7 @@ _gst_element_error_printf (const gchar * format, ...)
 }
 
 /**
- * gst_element_message_full:
+ * gst_element_message_full_with_details:
  * @element:  a #GstElement to send message from
  * @type:     the #GstMessageType
  * @domain:   the GStreamer GError domain this message belongs to
@@ -1833,18 +1833,22 @@ _gst_element_error_printf (const gchar * format, ...)
  * @file:     the source code file where the error was generated
  * @function: the source code function where the error was generated
  * @line:     the source code line where the error was generated
+ * @structure:(transfer full): optional details structure
  *
  * Post an error, warning or info message on the bus from inside an element.
  *
  * @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or
  * #GST_MESSAGE_INFO.
  *
+ * Since: 1.10
+ *
  * MT safe.
  */
-void gst_element_message_full
+void gst_element_message_full_with_details
     (GstElement * element, GstMessageType type,
     GQuark domain, gint code, gchar * text,
-    gchar * debug, const gchar * file, const gchar * function, gint line)
+    gchar * debug, const gchar * file, const gchar * function, gint line,
+    GstStructure * structure)
 {
   GError *gerror = NULL;
   gchar *name;
@@ -1891,20 +1895,24 @@ void gst_element_message_full
   switch (type) {
     case GST_MESSAGE_ERROR:
       message =
-          gst_message_new_error (GST_OBJECT_CAST (element), gerror, sent_debug);
+          gst_message_new_error_with_details (GST_OBJECT_CAST (element), gerror,
+          sent_debug, structure);
       break;
     case GST_MESSAGE_WARNING:
-      message = gst_message_new_warning (GST_OBJECT_CAST (element), gerror,
-          sent_debug);
+      message =
+          gst_message_new_warning_with_details (GST_OBJECT_CAST (element),
+          gerror, sent_debug, structure);
       break;
     case GST_MESSAGE_INFO:
-      message = gst_message_new_info (GST_OBJECT_CAST (element), gerror,
-          sent_debug);
+      message =
+          gst_message_new_info_with_details (GST_OBJECT_CAST (element), gerror,
+          sent_debug, structure);
       break;
     default:
       g_assert_not_reached ();
       break;
   }
+
   gst_element_post_message (element, message);
 
   GST_CAT_INFO_OBJECT (GST_CAT_ERROR_SYSTEM, element, "posted %s message: %s",
@@ -1917,6 +1925,38 @@ void gst_element_message_full
 }
 
 /**
+ * gst_element_message_full:
+ * @element:  a #GstElement to send message from
+ * @type:     the #GstMessageType
+ * @domain:   the GStreamer GError domain this message belongs to
+ * @code:     the GError code belonging to the domain
+ * @text:     (allow-none) (transfer full): an allocated text string to be used
+ *            as a replacement for the default message connected to code,
+ *            or %NULL
+ * @debug:    (allow-none) (transfer full): an allocated debug message to be
+ *            used as a replacement for the default debugging information,
+ *            or %NULL
+ * @file:     the source code file where the error was generated
+ * @function: the source code function where the error was generated
+ * @line:     the source code line where the error was generated
+ *
+ * Post an error, warning or info message on the bus from inside an element.
+ *
+ * @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or
+ * #GST_MESSAGE_INFO.
+ *
+ * MT safe.
+ */
+void gst_element_message_full
+    (GstElement * element, GstMessageType type,
+    GQuark domain, gint code, gchar * text,
+    gchar * debug, const gchar * file, const gchar * function, gint line)
+{
+  gst_element_message_full_with_details (element, type, domain, code, text,
+      debug, file, function, line, NULL);
+}
+
+/**
  * gst_element_is_locked_state:
  * @element: a #GstElement.
  *
@@ -3439,3 +3479,19 @@ _priv_gst_element_cleanup (void)
     gst_element_setup_thread_pool ();
   }
 }
+
+GstStructure *
+gst_element_message_details_new (const char *name, ...)
+{
+  GstStructure *structure;
+  va_list varargs;
+
+  if (name == NULL)
+    return NULL;
+
+  va_start (varargs, name);
+  structure = gst_structure_new_valist ("details", name, varargs);
+  va_end (varargs);
+
+  return structure;
+}
index a18b0ca..e49b862 100644 (file)
@@ -399,8 +399,11 @@ typedef enum
  */
 #define GST_ELEMENT_START_TIME(elem)            (GST_ELEMENT_CAST(elem)->start_time)
 
+GstStructure *gst_element_message_details_new(const char *name, ...);
+#define GST_ELEMENT_MESSAGE_MAKE_DETAILS(args) gst_element_message_details_new args
+
 /**
- * GST_ELEMENT_ERROR:
+ * GST_ELEMENT_ERROR_WITH_DETAILS:
  * @el:     the element that generates the error
  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
  * @code:   error code defined for that domain (see #gstreamer-GstGError)
@@ -408,12 +411,17 @@ typedef enum
             parentheses)
  * @debug:  debugging information for the message (format string and args
             enclosed in parentheses)
+ * @args    optional name, type, value triplets, which will be stored
+ *          in the associated GstStructure. NULL terminator required.
+ *          Must be enclosed within parentheses.
  *
  * Utility function that elements can use in case they encountered a fatal
  * data processing error. The pipeline will post an error message and the
  * application will be requested to stop further media processing.
+ *
+ * Since: 1.10
  */
-#define GST_ELEMENT_ERROR(el, domain, code, text, debug)                \
+#define GST_ELEMENT_ERROR_WITH_DETAILS(el, domain, code, text, debug, args)  \
 G_STMT_START {                                                          \
   gchar *__txt = _gst_element_error_printf text;                        \
   gchar *__dbg = _gst_element_error_printf debug;                       \
@@ -421,13 +429,31 @@ G_STMT_START {                                                          \
     GST_WARNING_OBJECT (el, "error: %s", __txt);                        \
   if (__dbg)                                                            \
     GST_WARNING_OBJECT (el, "error: %s", __dbg);                        \
-  gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR,         \
-    GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
-    __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                    \
+  gst_element_message_full_with_details (GST_ELEMENT(el),               \
+    GST_MESSAGE_ERROR, GST_ ## domain ## _ERROR,                        \
+      GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__,        \
+      GST_FUNCTION, __LINE__, GST_ELEMENT_MESSAGE_MAKE_DETAILS(args));  \
 } G_STMT_END
 
 /**
- * GST_ELEMENT_WARNING:
+ * GST_ELEMENT_ERROR:
+ * @el:     the element that generates the error
+ * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
+ * @code:   error code defined for that domain (see #gstreamer-GstGError)
+ * @text:   the message to display (format string and args enclosed in
+            parentheses)
+ * @debug:  debugging information for the message (format string and args
+            enclosed in parentheses)
+ *
+ * Utility function that elements can use in case they encountered a fatal
+ * data processing error. The pipeline will post an error message and the
+ * application will be requested to stop further media processing.
+ */
+#define GST_ELEMENT_ERROR(el, domain, code, text, debug)                \
+  GST_ELEMENT_ERROR_WITH_DETAILS(el, domain, code, text, debug, (NULL))
+
+/**
+ * GST_ELEMENT_WARNING_WITH_DETAILS:
  * @el:     the element that generates the warning
  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
  * @code:   error code defined for that domain (see #gstreamer-GstGError)
@@ -435,12 +461,17 @@ G_STMT_START {                                                          \
             parentheses)
  * @debug:  debugging information for the message (format string and args
             enclosed in parentheses)
+ * @args    optional name, type, value triplets, which will be stored
+ *          in the associated GstStructure. NULL terminator required.
+ *          Must be enclosed within parentheses.
  *
  * Utility function that elements can use in case they encountered a non-fatal
  * data processing problem. The pipeline will post a warning message and the
  * application will be informed.
+ *
+ * Since: 1.10
  */
-#define GST_ELEMENT_WARNING(el, domain, code, text, debug)              \
+#define GST_ELEMENT_WARNING_WITH_DETAILS(el, domain, code, text, debug, args)\
 G_STMT_START {                                                          \
   gchar *__txt = _gst_element_error_printf text;                        \
   gchar *__dbg = _gst_element_error_printf debug;                       \
@@ -448,13 +479,31 @@ G_STMT_START {                                                          \
     GST_WARNING_OBJECT (el, "warning: %s", __txt);                      \
   if (__dbg)                                                            \
     GST_WARNING_OBJECT (el, "warning: %s", __dbg);                      \
-  gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING,       \
-    GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
-  __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                      \
+  gst_element_message_full_with_details (GST_ELEMENT(el),               \
+    GST_MESSAGE_WARNING, GST_ ## domain ## _ERROR,                      \
+    GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__,          \
+    GST_FUNCTION, __LINE__, GST_ELEMENT_MESSAGE_MAKE_DETAILS(args));    \
 } G_STMT_END
 
 /**
- * GST_ELEMENT_INFO:
+ * GST_ELEMENT_WARNING:
+ * @el:     the element that generates the warning
+ * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
+ * @code:   error code defined for that domain (see #gstreamer-GstGError)
+ * @text:   the message to display (format string and args enclosed in
+            parentheses)
+ * @debug:  debugging information for the message (format string and args
+            enclosed in parentheses)
+ *
+ * Utility function that elements can use in case they encountered a non-fatal
+ * data processing problem. The pipeline will post a warning message and the
+ * application will be informed.
+ */
+#define GST_ELEMENT_WARNING(el, domain, code, text, debug)              \
+  GST_ELEMENT_WARNING_WITH_DETAILS(el, domain, code, text, debug, (NULL))
+
+/**
+ * GST_ELEMENT_INFO_WITH_DETAILS:
  * @el:     the element that generates the information
  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
  * @code:   error code defined for that domain (see #gstreamer-GstGError)
@@ -462,13 +511,20 @@ G_STMT_START {                                                          \
             parentheses)
  * @debug:  debugging information for the message (format string and args
             enclosed in parentheses)
+ * @args    optional name, type, value triplets, which will be stored
+ *          in the associated GstStructure. NULL terminator required.
+ *          Must be enclosed within parentheses.
  *
  * Utility function that elements can use in case they want to inform
  * the application of something noteworthy that is not an error.
  * The pipeline will post a info message and the
  * application will be informed.
+ * Optional name, type, value triplets may be supplied, and will be stored
+ * in the associated GstStructure. NULL terminator required.
+ *
+ * Since: 1.10
  */
-#define GST_ELEMENT_INFO(el, domain, code, text, debug)                 \
+#define GST_ELEMENT_INFO_WITH_DETAILS(el, domain, code, text, debug, args)   \
 G_STMT_START {                                                          \
   gchar *__txt = _gst_element_error_printf text;                        \
   gchar *__dbg = _gst_element_error_printf debug;                       \
@@ -476,11 +532,30 @@ G_STMT_START {                                                          \
     GST_INFO_OBJECT (el, "info: %s", __txt);                            \
   if (__dbg)                                                            \
     GST_INFO_OBJECT (el, "info: %s", __dbg);                            \
-  gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_INFO,          \
-    GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
-  __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                      \
+  gst_element_message_full_with_details (GST_ELEMENT(el),               \
+    GST_MESSAGE_INFO, GST_ ## domain ## _ERROR,                         \
+    GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__,          \
+    GST_FUNCTION, __LINE__, GST_ELEMENT_MESSAGE_MAKE_DETAILS(args));    \
 } G_STMT_END
 
+/**
+ * GST_ELEMENT_INFO:
+ * @el:     the element that generates the information
+ * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
+ * @code:   error code defined for that domain (see #gstreamer-GstGError)
+ * @text:   the message to display (format string and args enclosed in
+            parentheses)
+ * @debug:  debugging information for the message (format string and args
+            enclosed in parentheses)
+ *
+ * Utility function that elements can use in case they want to inform
+ * the application of something noteworthy that is not an error.
+ * The pipeline will post a info message and the
+ * application will be informed.
+ */
+#define GST_ELEMENT_INFO(el, domain, code, text, debug)                 \
+  GST_ELEMENT_INFO_WITH_DETAILS(el, domain, code, text, debug, (NULL))
+
 /* the state change mutexes and conds */
 /**
  * GST_STATE_GET_LOCK:
@@ -798,6 +873,12 @@ void                    gst_element_message_full        (GstElement * element, G
                                                          gchar * debug, const gchar * file,
                                                          const gchar * function, gint line);
 
+void                    gst_element_message_full_with_details (GstElement * element, GstMessageType type,
+                                                         GQuark domain, gint code, gchar * text,
+                                                         gchar * debug, const gchar * file,
+                                                         const gchar * function, gint line,
+                                                         GstStructure * structure);
+
 /* state management */
 gboolean                gst_element_is_locked_state     (GstElement *element);
 gboolean                gst_element_set_locked_state    (GstElement *element, gboolean locked_state);
index 0e7c1bc..821ba5a 100644 (file)
@@ -112,6 +112,8 @@ static GstMessageQuarks message_quarks[] = {
   {0, NULL, 0}
 };
 
+static GQuark details_quark = 0;
+
 GType _gst_message_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
 
@@ -126,6 +128,7 @@ _priv_gst_message_initialize (void)
     message_quarks[i].quark =
         g_quark_from_static_string (message_quarks[i].name);
   }
+  details_quark = g_quark_from_static_string ("details");
 
   _gst_message_type = gst_message_get_type ();
 }
@@ -389,10 +392,11 @@ gst_message_new_eos (GstObject * src)
 }
 
 /**
- * gst_message_new_error:
+ * gst_message_new_error_with_details:
  * @src: (transfer none) (allow-none): The object originating the message.
  * @error: (transfer none): The GError for this message.
  * @debug: A debugging string.
+ * @details: (transfer full): (allow-none): A GstStructure with details
  *
  * Create a new error message. The message will copy @error and
  * @debug. This message is posted by element when a fatal event
@@ -401,10 +405,13 @@ gst_message_new_eos (GstObject * src)
  *
  * Returns: (transfer full): the new error message.
  *
+ * Since: 1.10
+ *
  * MT safe.
  */
 GstMessage *
-gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
+gst_message_new_error_with_details (GstObject * src, GError * error,
+    const gchar * debug, GstStructure * details)
 {
   GstMessage *message;
   GstStructure *structure;
@@ -413,25 +420,88 @@ gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
   message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
+  if (details) {
+    GValue v = G_VALUE_INIT;
+
+    g_value_init (&v, GST_TYPE_STRUCTURE);
+    g_value_take_boxed (&v, details);
+    gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
+        &v);
+  }
 
   return message;
 }
 
 /**
- * gst_message_new_warning:
+ * gst_message_new_error:
+ * @src: (transfer none) (allow-none): The object originating the message.
+ * @error: (transfer none): The GError for this message.
+ * @debug: A debugging string.
+ *
+ * Create a new error message. The message will copy @error and
+ * @debug. This message is posted by element when a fatal event
+ * occurred. The pipeline will probably (partially) stop. The application
+ * receiving this message should stop the pipeline.
+ *
+ * Returns: (transfer full): the new error message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
+{
+  return gst_message_new_error_with_details (src, error, debug, NULL);
+}
+
+/**
+ * gst_message_parse_error_details:
+ * @message: (transfer none): The message object
+ * @structure: (out): A pointer to the returned details
+ *
+ * Returns the optional details structure, may be NULL if none.
+ * The returned structure must not be freed.
+ *
+ * Since: 1.10
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_error_details (GstMessage * message,
+    const GstStructure ** structure)
+{
+  const GValue *v;
+
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
+  g_return_if_fail (structure != NULL);
+
+  *structure = NULL;
+  v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
+      details_quark);
+  if (v) {
+    *structure = g_value_get_boxed (v);
+  }
+}
+
+/**
+ * gst_message_new_warning_with_details:
  * @src: (transfer none) (allow-none): The object originating the message.
  * @error: (transfer none): The GError for this message.
  * @debug: A debugging string.
+ * @details: (transfer full): (allow-none): A GstStructure with details
  *
  * Create a new warning message. The message will make copies of @error and
  * @debug.
  *
- * Returns: (transfer full): The new warning message.
+ * Returns: (transfer full): the new warning message.
+ *
+ * Since: 1.10
  *
  * MT safe.
  */
 GstMessage *
-gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
+gst_message_new_warning_with_details (GstObject * src, GError * error,
+    const gchar * debug, GstStructure * details)
 {
   GstMessage *message;
   GstStructure *structure;
@@ -440,25 +510,86 @@ gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
   message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
+  if (details) {
+    GValue v = G_VALUE_INIT;
+
+    g_value_init (&v, GST_TYPE_STRUCTURE);
+    g_value_take_boxed (&v, details);
+    gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
+        &v);
+  }
 
   return message;
 }
 
 /**
- * gst_message_new_info:
+ * gst_message_new_warning:
  * @src: (transfer none) (allow-none): The object originating the message.
  * @error: (transfer none): The GError for this message.
  * @debug: A debugging string.
  *
- * Create a new info message. The message will make copies of @error and
+ * Create a new warning message. The message will make copies of @error and
  * @debug.
  *
+ * Returns: (transfer full): the new warning message.
+ *
  * MT safe.
+ */
+GstMessage *
+gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
+{
+  return gst_message_new_warning_with_details (src, error, debug, NULL);
+}
+
+/**
+ * gst_message_parse_warning_details:
+ * @message: (transfer none): The message object
+ * @structure: (out): A pointer to the returned details structure
  *
- * Returns: (transfer full): the new info message.
+ * Returns the optional details structure, may be NULL if none
+ * The returned structure must not be freed.
+ *
+ * Since: 1.10
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_warning_details (GstMessage * message,
+    const GstStructure ** structure)
+{
+  const GValue *v;
+
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
+  g_return_if_fail (structure != NULL);
+
+  *structure = NULL;
+  v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
+      details_quark);
+  if (v) {
+    *structure = g_value_get_boxed (v);
+  }
+}
+
+/**
+ * gst_message_new_info_with_details:
+ * @src: (transfer none) (allow-none): The object originating the message.
+ * @error: (transfer none): The GError for this message.
+ * @debug: A debugging string.
+ * @details: (transfer full): (allow-none): A GstStructure with details
+ *
+ * Create a new info message. The message will make copies of @error and
+ * @debug.
+ *
+ * Returns: (transfer full): the new warning message.
+ *
+ * Since: 1.10
+ *
+ * MT safe.
  */
 GstMessage *
-gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
+gst_message_new_info_with_details (GstObject * src, GError * error,
+    const gchar * debug, GstStructure * details)
 {
   GstMessage *message;
   GstStructure *structure;
@@ -467,11 +598,68 @@ gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
   message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
+  if (details) {
+    GValue v = G_VALUE_INIT;
+
+    g_value_init (&v, GST_TYPE_STRUCTURE);
+    g_value_take_boxed (&v, details);
+    gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
+        &v);
+  }
 
   return message;
 }
 
 /**
+ * gst_message_new_info:
+ * @src: (transfer none) (allow-none): The object originating the message.
+ * @error: (transfer none): The GError for this message.
+ * @debug: A debugging string.
+ *
+ * Create a new info message. The message will make copies of @error and
+ * @debug.
+ *
+ * Returns: (transfer full): the new info message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
+{
+  return gst_message_new_info_with_details (src, error, debug, NULL);
+}
+
+/**
+ * gst_message_parse_info_details:
+ * @message: (transfer none): The message object
+ * @structure: (out): A pointer to the returned details structure
+ *
+ * Returns the optional details structure, may be NULL if none
+ * The returned structure must not be freed.
+ *
+ * Since: 1.10
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_info_details (GstMessage * message,
+    const GstStructure ** structure)
+{
+  const GValue *v;
+
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
+  g_return_if_fail (structure != NULL);
+
+  *structure = NULL;
+  v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
+      details_quark);
+  if (v) {
+    *structure = g_value_get_boxed (v);
+  }
+}
+
+/**
  * gst_message_new_tag:
  * @src: (transfer none) (allow-none): The object originating the message.
  * @tag_list: (transfer full): the tag list for the message.
index f8ae704..0fb0bf8 100644 (file)
@@ -445,15 +445,21 @@ GstMessage *    gst_message_new_eos             (GstObject * src) G_GNUC_MALLOC;
 /* ERROR */
 
 GstMessage *    gst_message_new_error           (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
+GstMessage *    gst_message_new_error_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
 void            gst_message_parse_error         (GstMessage *message, GError **gerror, gchar **debug);
+void            gst_message_parse_error_details (GstMessage *message, const GstStructure **structure);
 
 /* WARNING */
 GstMessage *    gst_message_new_warning         (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
+GstMessage *    gst_message_new_warning_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
 void            gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **debug);
+void            gst_message_parse_warning_details (GstMessage *message, const GstStructure **structure);
 
 /* INFO */
 GstMessage *    gst_message_new_info            (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
+GstMessage *    gst_message_new_info_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
 void            gst_message_parse_info          (GstMessage *message, GError **gerror, gchar **debug);
+void            gst_message_parse_info_details  (GstMessage *message, const GstStructure **structure);
 
 /* TAG */
 GstMessage *    gst_message_new_tag             (GstObject * src, GstTagList * tag_list) G_GNUC_MALLOC;
index 8c404b2..77110ba 100644 (file)
@@ -68,6 +68,46 @@ GST_START_TEST (test_parsing)
     g_error_free (error);
     g_free (debug);
   }
+  /* GST_MESSAGE_ERROR with details */
+  {
+    GError *error = NULL;
+    gchar *debug;
+    GstStructure *d;
+    const GstStructure *dc;
+
+    error = g_error_new (domain, 10, "test error");
+    fail_if (error == NULL);
+    d = gst_structure_new ("title", "test-field", G_TYPE_STRING,
+        "test-contents", NULL);
+    message =
+        gst_message_new_error_with_details (NULL, error, "error string", d);
+    fail_if (message == NULL);
+    fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
+    fail_unless (GST_MESSAGE_SRC (message) == NULL);
+
+    g_error_free (error);
+    error = NULL;
+    debug = NULL;
+
+    gst_message_parse_error (message, NULL, NULL);
+
+    gst_message_parse_error (message, &error, &debug);
+    fail_if (error == NULL);
+    fail_if (debug == NULL);
+    fail_unless (strcmp (error->message, "test error") == 0);
+    fail_unless (error->domain == domain);
+    fail_unless (error->code == 10);
+    fail_unless (strcmp (debug, "error string") == 0);
+    gst_message_parse_error_details (message, &dc);
+    fail_unless (dc != NULL);
+    fail_unless (gst_structure_has_field_typed (dc, "test-field",
+            G_TYPE_STRING));
+    fail_unless (gst_structure_get_string (dc, "test-field"), "test-contents");
+
+    gst_message_unref (message);
+    g_error_free (error);
+    g_free (debug);
+  }
   /* GST_MESSAGE_WARNING   */
   {
     GError *warning = NULL;
index 065c526..90d4490 100644 (file)
@@ -538,6 +538,7 @@ EXPORTS
        gst_element_lost_state
        gst_element_make_from_uri
        gst_element_message_full
+       gst_element_message_full_with_details
        gst_element_no_more_pads
        gst_element_post_message
        gst_element_provide_clock
@@ -698,11 +699,13 @@ EXPORTS
        gst_memory_resize
        gst_memory_share
        gst_memory_unmap
+       gst_message_error_set_details
        gst_message_get_seqnum
        gst_message_get_stream_status_object
        gst_message_get_structure
        gst_message_get_type
        gst_message_has_name
+       gst_message_info_set_details
        gst_message_new_application
        gst_message_new_async_done
        gst_message_new_async_start
@@ -716,8 +719,10 @@ EXPORTS
        gst_message_new_element
        gst_message_new_eos
        gst_message_new_error
+       gst_message_new_error_with_details
        gst_message_new_have_context
        gst_message_new_info
+       gst_message_new_info_with_details
        gst_message_new_latency
        gst_message_new_need_context
        gst_message_new_new_clock
@@ -740,6 +745,7 @@ EXPORTS
        gst_message_new_tag
        gst_message_new_toc
        gst_message_new_warning
+       gst_message_new_warning_with_details
        gst_message_parse_async_done
        gst_message_parse_buffering
        gst_message_parse_buffering_stats
@@ -749,9 +755,11 @@ EXPORTS
        gst_message_parse_device_added
        gst_message_parse_device_removed
        gst_message_parse_error
+       gst_message_parse_error_details
        gst_message_parse_group_id
        gst_message_parse_have_context
        gst_message_parse_info
+       gst_message_parse_info_details
        gst_message_parse_new_clock
        gst_message_parse_progress
        gst_message_parse_property_notify
@@ -772,6 +780,7 @@ EXPORTS
        gst_message_parse_tag
        gst_message_parse_toc
        gst_message_parse_warning
+       gst_message_parse_warning_details
        gst_message_set_buffering_stats
        gst_message_set_group_id
        gst_message_set_qos_stats
@@ -784,6 +793,7 @@ EXPORTS
        gst_message_type_get_name
        gst_message_type_get_type
        gst_message_type_to_quark
+       gst_message_warning_set_details
        gst_meta_api_type_get_tags
        gst_meta_api_type_has_tag
        gst_meta_api_type_register