mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-27 00:16:37 +00:00
message: new API for additional custom data to error messages
https://bugzilla.gnome.org/show_bug.cgi?id=756806
This commit is contained in:
parent
714ea37282
commit
1105caa805
6 changed files with 424 additions and 43 deletions
|
@ -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
|
* @element: a #GstElement to send message from
|
||||||
* @type: the #GstMessageType
|
* @type: the #GstMessageType
|
||||||
* @domain: the GStreamer GError domain this message belongs to
|
* @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
|
* @file: the source code file where the error was generated
|
||||||
* @function: the source code function 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
|
* @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.
|
* 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
|
* @type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or
|
||||||
* #GST_MESSAGE_INFO.
|
* #GST_MESSAGE_INFO.
|
||||||
*
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
void gst_element_message_full
|
void gst_element_message_full_with_details
|
||||||
(GstElement * element, GstMessageType type,
|
(GstElement * element, GstMessageType type,
|
||||||
GQuark domain, gint code, gchar * text,
|
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;
|
GError *gerror = NULL;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
@ -1891,20 +1895,24 @@ void gst_element_message_full
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
message =
|
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;
|
break;
|
||||||
case GST_MESSAGE_WARNING:
|
case GST_MESSAGE_WARNING:
|
||||||
message = gst_message_new_warning (GST_OBJECT_CAST (element), gerror,
|
message =
|
||||||
sent_debug);
|
gst_message_new_warning_with_details (GST_OBJECT_CAST (element),
|
||||||
|
gerror, sent_debug, structure);
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_INFO:
|
case GST_MESSAGE_INFO:
|
||||||
message = gst_message_new_info (GST_OBJECT_CAST (element), gerror,
|
message =
|
||||||
sent_debug);
|
gst_message_new_info_with_details (GST_OBJECT_CAST (element), gerror,
|
||||||
|
sent_debug, structure);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_element_post_message (element, message);
|
gst_element_post_message (element, message);
|
||||||
|
|
||||||
GST_CAT_INFO_OBJECT (GST_CAT_ERROR_SYSTEM, element, "posted %s message: %s",
|
GST_CAT_INFO_OBJECT (GST_CAT_ERROR_SYSTEM, element, "posted %s message: %s",
|
||||||
|
@ -1916,6 +1924,38 @@ void gst_element_message_full
|
||||||
g_free (sent_text);
|
g_free (sent_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* gst_element_is_locked_state:
|
||||||
* @element: a #GstElement.
|
* @element: a #GstElement.
|
||||||
|
@ -3439,3 +3479,19 @@ _priv_gst_element_cleanup (void)
|
||||||
gst_element_setup_thread_pool ();
|
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;
|
||||||
|
}
|
||||||
|
|
123
gst/gstelement.h
123
gst/gstelement.h
|
@ -399,6 +399,42 @@ typedef enum
|
||||||
*/
|
*/
|
||||||
#define GST_ELEMENT_START_TIME(elem) (GST_ELEMENT_CAST(elem)->start_time)
|
#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_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)
|
||||||
|
* @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)
|
||||||
|
* @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_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; \
|
||||||
|
if (__txt) \
|
||||||
|
GST_WARNING_OBJECT (el, "error: %s", __txt); \
|
||||||
|
if (__dbg) \
|
||||||
|
GST_WARNING_OBJECT (el, "error: %s", __dbg); \
|
||||||
|
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_ERROR:
|
* GST_ELEMENT_ERROR:
|
||||||
* @el: the element that generates the error
|
* @el: the element that generates the error
|
||||||
|
@ -414,16 +450,39 @@ typedef enum
|
||||||
* application will be requested to stop further media processing.
|
* application will be requested to stop further media processing.
|
||||||
*/
|
*/
|
||||||
#define GST_ELEMENT_ERROR(el, domain, code, text, debug) \
|
#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)
|
||||||
|
* @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)
|
||||||
|
* @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_WITH_DETAILS(el, domain, code, text, debug, args)\
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
gchar *__txt = _gst_element_error_printf text; \
|
gchar *__txt = _gst_element_error_printf text; \
|
||||||
gchar *__dbg = _gst_element_error_printf debug; \
|
gchar *__dbg = _gst_element_error_printf debug; \
|
||||||
if (__txt) \
|
if (__txt) \
|
||||||
GST_WARNING_OBJECT (el, "error: %s", __txt); \
|
GST_WARNING_OBJECT (el, "warning: %s", __txt); \
|
||||||
if (__dbg) \
|
if (__dbg) \
|
||||||
GST_WARNING_OBJECT (el, "error: %s", __dbg); \
|
GST_WARNING_OBJECT (el, "warning: %s", __dbg); \
|
||||||
gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, \
|
gst_element_message_full_with_details (GST_ELEMENT(el), \
|
||||||
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \
|
GST_MESSAGE_WARNING, GST_ ## domain ## _ERROR, \
|
||||||
__txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
|
GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
|
||||||
|
GST_FUNCTION, __LINE__, GST_ELEMENT_MESSAGE_MAKE_DETAILS(args)); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -441,16 +500,42 @@ G_STMT_START { \
|
||||||
* application will be informed.
|
* application will be informed.
|
||||||
*/
|
*/
|
||||||
#define GST_ELEMENT_WARNING(el, domain, code, text, debug) \
|
#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)
|
||||||
|
* @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)
|
||||||
|
* @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_WITH_DETAILS(el, domain, code, text, debug, args) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
gchar *__txt = _gst_element_error_printf text; \
|
gchar *__txt = _gst_element_error_printf text; \
|
||||||
gchar *__dbg = _gst_element_error_printf debug; \
|
gchar *__dbg = _gst_element_error_printf debug; \
|
||||||
if (__txt) \
|
if (__txt) \
|
||||||
GST_WARNING_OBJECT (el, "warning: %s", __txt); \
|
GST_INFO_OBJECT (el, "info: %s", __txt); \
|
||||||
if (__dbg) \
|
if (__dbg) \
|
||||||
GST_WARNING_OBJECT (el, "warning: %s", __dbg); \
|
GST_INFO_OBJECT (el, "info: %s", __dbg); \
|
||||||
gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, \
|
gst_element_message_full_with_details (GST_ELEMENT(el), \
|
||||||
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \
|
GST_MESSAGE_INFO, GST_ ## domain ## _ERROR, \
|
||||||
__txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
|
GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
|
||||||
|
GST_FUNCTION, __LINE__, GST_ELEMENT_MESSAGE_MAKE_DETAILS(args)); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -469,17 +554,7 @@ G_STMT_START { \
|
||||||
* application will be informed.
|
* application will be informed.
|
||||||
*/
|
*/
|
||||||
#define GST_ELEMENT_INFO(el, domain, code, text, debug) \
|
#define GST_ELEMENT_INFO(el, domain, code, text, debug) \
|
||||||
G_STMT_START { \
|
GST_ELEMENT_INFO_WITH_DETAILS(el, domain, code, text, debug, (NULL))
|
||||||
gchar *__txt = _gst_element_error_printf text; \
|
|
||||||
gchar *__dbg = _gst_element_error_printf debug; \
|
|
||||||
if (__txt) \
|
|
||||||
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__); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
/* the state change mutexes and conds */
|
/* the state change mutexes and conds */
|
||||||
/**
|
/**
|
||||||
|
@ -798,6 +873,12 @@ void gst_element_message_full (GstElement * element, G
|
||||||
gchar * debug, const gchar * file,
|
gchar * debug, const gchar * file,
|
||||||
const gchar * function, gint line);
|
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 */
|
/* state management */
|
||||||
gboolean gst_element_is_locked_state (GstElement *element);
|
gboolean gst_element_is_locked_state (GstElement *element);
|
||||||
gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
|
gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
|
||||||
|
|
216
gst/gstmessage.c
216
gst/gstmessage.c
|
@ -112,6 +112,8 @@ static GstMessageQuarks message_quarks[] = {
|
||||||
{0, NULL, 0}
|
{0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GQuark details_quark = 0;
|
||||||
|
|
||||||
GType _gst_message_type = 0;
|
GType _gst_message_type = 0;
|
||||||
GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
|
GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
|
||||||
|
|
||||||
|
@ -126,6 +128,7 @@ _priv_gst_message_initialize (void)
|
||||||
message_quarks[i].quark =
|
message_quarks[i].quark =
|
||||||
g_quark_from_static_string (message_quarks[i].name);
|
g_quark_from_static_string (message_quarks[i].name);
|
||||||
}
|
}
|
||||||
|
details_quark = g_quark_from_static_string ("details");
|
||||||
|
|
||||||
_gst_message_type = gst_message_get_type ();
|
_gst_message_type = gst_message_get_type ();
|
||||||
}
|
}
|
||||||
|
@ -388,6 +391,47 @@ gst_message_new_eos (GstObject * src)
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* occurred. The pipeline will probably (partially) stop. The application
|
||||||
|
* receiving this message should stop the pipeline.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): the new error message.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
|
*/
|
||||||
|
GstMessage *
|
||||||
|
gst_message_new_error_with_details (GstObject * src, GError * error,
|
||||||
|
const gchar * debug, GstStructure * details)
|
||||||
|
{
|
||||||
|
GstMessage *message;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
|
||||||
|
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_error:
|
* gst_message_new_error:
|
||||||
* @src: (transfer none) (allow-none): The object originating the message.
|
* @src: (transfer none) (allow-none): The object originating the message.
|
||||||
|
@ -405,14 +449,75 @@ gst_message_new_eos (GstObject * src)
|
||||||
*/
|
*/
|
||||||
GstMessage *
|
GstMessage *
|
||||||
gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
|
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.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
|
*/
|
||||||
|
GstMessage *
|
||||||
|
gst_message_new_warning_with_details (GstObject * src, GError * error,
|
||||||
|
const gchar * debug, GstStructure * details)
|
||||||
{
|
{
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
|
structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
|
||||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
||||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||||
message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
|
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;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -426,20 +531,81 @@ gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
|
||||||
* Create a new warning message. The message will make copies of @error and
|
* Create a new warning message. The message will make copies of @error and
|
||||||
* @debug.
|
* @debug.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): The new warning message.
|
* Returns: (transfer full): the new warning message.
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
GstMessage *
|
GstMessage *
|
||||||
gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
|
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 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_with_details (GstObject * src, GError * error,
|
||||||
|
const gchar * debug, GstStructure * details)
|
||||||
{
|
{
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
|
structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
|
||||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
||||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||||
message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
|
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;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -453,22 +619,44 @@ gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
|
||||||
* Create a new info message. The message will make copies of @error and
|
* Create a new info message. The message will make copies of @error and
|
||||||
* @debug.
|
* @debug.
|
||||||
*
|
*
|
||||||
* MT safe.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): the new info message.
|
* Returns: (transfer full): the new info message.
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
GstMessage *
|
GstMessage *
|
||||||
gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
|
gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
|
||||||
{
|
{
|
||||||
GstMessage *message;
|
return gst_message_new_info_with_details (src, error, debug, NULL);
|
||||||
GstStructure *structure;
|
}
|
||||||
|
|
||||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
|
/**
|
||||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
* gst_message_parse_info_details:
|
||||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
* @message: (transfer none): The message object
|
||||||
message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
|
* @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;
|
||||||
|
|
||||||
return message;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -445,15 +445,21 @@ GstMessage * gst_message_new_eos (GstObject * src) G_GNUC_MALLOC;
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
|
|
||||||
GstMessage * gst_message_new_error (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
|
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 (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
|
void gst_message_parse_error_details (GstMessage *message, const GstStructure **structure);
|
||||||
|
|
||||||
/* WARNING */
|
/* WARNING */
|
||||||
GstMessage * gst_message_new_warning (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
|
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 (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
|
void gst_message_parse_warning_details (GstMessage *message, const GstStructure **structure);
|
||||||
|
|
||||||
/* INFO */
|
/* INFO */
|
||||||
GstMessage * gst_message_new_info (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
|
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 (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
|
void gst_message_parse_info_details (GstMessage *message, const GstStructure **structure);
|
||||||
|
|
||||||
/* TAG */
|
/* TAG */
|
||||||
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list) G_GNUC_MALLOC;
|
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list) G_GNUC_MALLOC;
|
||||||
|
|
|
@ -68,6 +68,46 @@ GST_START_TEST (test_parsing)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (debug);
|
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 */
|
/* GST_MESSAGE_WARNING */
|
||||||
{
|
{
|
||||||
GError *warning = NULL;
|
GError *warning = NULL;
|
||||||
|
|
|
@ -538,6 +538,7 @@ EXPORTS
|
||||||
gst_element_lost_state
|
gst_element_lost_state
|
||||||
gst_element_make_from_uri
|
gst_element_make_from_uri
|
||||||
gst_element_message_full
|
gst_element_message_full
|
||||||
|
gst_element_message_full_with_details
|
||||||
gst_element_no_more_pads
|
gst_element_no_more_pads
|
||||||
gst_element_post_message
|
gst_element_post_message
|
||||||
gst_element_provide_clock
|
gst_element_provide_clock
|
||||||
|
@ -698,11 +699,13 @@ EXPORTS
|
||||||
gst_memory_resize
|
gst_memory_resize
|
||||||
gst_memory_share
|
gst_memory_share
|
||||||
gst_memory_unmap
|
gst_memory_unmap
|
||||||
|
gst_message_error_set_details
|
||||||
gst_message_get_seqnum
|
gst_message_get_seqnum
|
||||||
gst_message_get_stream_status_object
|
gst_message_get_stream_status_object
|
||||||
gst_message_get_structure
|
gst_message_get_structure
|
||||||
gst_message_get_type
|
gst_message_get_type
|
||||||
gst_message_has_name
|
gst_message_has_name
|
||||||
|
gst_message_info_set_details
|
||||||
gst_message_new_application
|
gst_message_new_application
|
||||||
gst_message_new_async_done
|
gst_message_new_async_done
|
||||||
gst_message_new_async_start
|
gst_message_new_async_start
|
||||||
|
@ -716,8 +719,10 @@ EXPORTS
|
||||||
gst_message_new_element
|
gst_message_new_element
|
||||||
gst_message_new_eos
|
gst_message_new_eos
|
||||||
gst_message_new_error
|
gst_message_new_error
|
||||||
|
gst_message_new_error_with_details
|
||||||
gst_message_new_have_context
|
gst_message_new_have_context
|
||||||
gst_message_new_info
|
gst_message_new_info
|
||||||
|
gst_message_new_info_with_details
|
||||||
gst_message_new_latency
|
gst_message_new_latency
|
||||||
gst_message_new_need_context
|
gst_message_new_need_context
|
||||||
gst_message_new_new_clock
|
gst_message_new_new_clock
|
||||||
|
@ -740,6 +745,7 @@ EXPORTS
|
||||||
gst_message_new_tag
|
gst_message_new_tag
|
||||||
gst_message_new_toc
|
gst_message_new_toc
|
||||||
gst_message_new_warning
|
gst_message_new_warning
|
||||||
|
gst_message_new_warning_with_details
|
||||||
gst_message_parse_async_done
|
gst_message_parse_async_done
|
||||||
gst_message_parse_buffering
|
gst_message_parse_buffering
|
||||||
gst_message_parse_buffering_stats
|
gst_message_parse_buffering_stats
|
||||||
|
@ -749,9 +755,11 @@ EXPORTS
|
||||||
gst_message_parse_device_added
|
gst_message_parse_device_added
|
||||||
gst_message_parse_device_removed
|
gst_message_parse_device_removed
|
||||||
gst_message_parse_error
|
gst_message_parse_error
|
||||||
|
gst_message_parse_error_details
|
||||||
gst_message_parse_group_id
|
gst_message_parse_group_id
|
||||||
gst_message_parse_have_context
|
gst_message_parse_have_context
|
||||||
gst_message_parse_info
|
gst_message_parse_info
|
||||||
|
gst_message_parse_info_details
|
||||||
gst_message_parse_new_clock
|
gst_message_parse_new_clock
|
||||||
gst_message_parse_progress
|
gst_message_parse_progress
|
||||||
gst_message_parse_property_notify
|
gst_message_parse_property_notify
|
||||||
|
@ -772,6 +780,7 @@ EXPORTS
|
||||||
gst_message_parse_tag
|
gst_message_parse_tag
|
||||||
gst_message_parse_toc
|
gst_message_parse_toc
|
||||||
gst_message_parse_warning
|
gst_message_parse_warning
|
||||||
|
gst_message_parse_warning_details
|
||||||
gst_message_set_buffering_stats
|
gst_message_set_buffering_stats
|
||||||
gst_message_set_group_id
|
gst_message_set_group_id
|
||||||
gst_message_set_qos_stats
|
gst_message_set_qos_stats
|
||||||
|
@ -784,6 +793,7 @@ EXPORTS
|
||||||
gst_message_type_get_name
|
gst_message_type_get_name
|
||||||
gst_message_type_get_type
|
gst_message_type_get_type
|
||||||
gst_message_type_to_quark
|
gst_message_type_to_quark
|
||||||
|
gst_message_warning_set_details
|
||||||
gst_meta_api_type_get_tags
|
gst_meta_api_type_get_tags
|
||||||
gst_meta_api_type_has_tag
|
gst_meta_api_type_has_tag
|
||||||
gst_meta_api_type_register
|
gst_meta_api_type_register
|
||||||
|
|
Loading…
Reference in a new issue