From af85bd8dbf8816b1c2be23450bd064e857ad1b0e Mon Sep 17 00:00:00 2001 From: Alexander Saprykin Date: Wed, 14 Mar 2012 20:41:48 +0400 Subject: [PATCH] Add new TOC message --- gst/gstmessage.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gst/gstmessage.h | 7 +++++++ 2 files changed, 66 insertions(+) diff --git a/gst/gstmessage.c b/gst/gstmessage.c index 423ebc2..b7fec38 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -113,6 +113,7 @@ static GstMessageQuarks message_quarks[] = { {GST_MESSAGE_STEP_START, "step-start", 0}, {GST_MESSAGE_QOS, "qos", 0}, {GST_MESSAGE_PROGRESS, "progress", 0}, + {GST_MESSAGE_TOC, "toc", 0}, {0, NULL, 0} }; @@ -2154,3 +2155,61 @@ gst_message_parse_progress (GstMessage * message, GstProgressType * type, GST_QUARK (CODE), G_TYPE_STRING, code, GST_QUARK (TEXT), G_TYPE_STRING, text, NULL); } + +/** + * gst_message_new_toc: + * @src: the object originating the message. + * @toc: #GstToc structure for the message. + * @updated: whether TOC was updated or not. + * + * Create a new TOC message. The message is posted by elements + * that discovered or updated a TOC. + * + * Returns: a new TOC message. + * + * MT safe. + * + * Since: 0.10.37 + */ +GstMessage * +gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated) +{ + GstStructure *toc_struct; + + g_return_val_if_fail (toc != NULL, NULL); + + toc_struct = _gst_toc_to_structure (toc); + + if (G_LIKELY (toc_struct != NULL)) { + _gst_toc_structure_set_updated (toc_struct, updated); + return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct); + } else + return NULL; +} + +/** + * gst_message_parse_toc: + * @message: a valid #GstMessage of type GST_MESSAGE_TOC. + * @toc: (out): return location for the TOC. + * @updated: (out): return location for the updated flag. + * + * Extract the TOC from the #GstMessage. The TOC returned in the + * output argument is a copy; the caller must free it with + * gst_toc_free() when done. + * + * MT safe. + * + * Since: 0.10.37 + */ +void +gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated) +{ + g_return_if_fail (GST_IS_MESSAGE (message)); + g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC); + g_return_if_fail (toc != NULL); + + *toc = _gst_toc_from_structure (message->structure); + + if (updated != NULL) + *updated = _gst_toc_structure_get_updated (message->structure); +} diff --git a/gst/gstmessage.h b/gst/gstmessage.h index f0fcc7a..ae5fc19 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -89,6 +89,8 @@ typedef struct _GstMessageClass GstMessageClass; * @GST_MESSAGE_QOS: A buffer was dropped or an element changed its processing * strategy for Quality of Service reasons. Since: 0.10.29 * @GST_MESSAGE_PROGRESS: A progress message. Since: 0.10.33 + * @GST_MESSAGE_TOC: A new table of contents (TOC) was found or previously found TOC + * was updated. Since: 0.10.37 * @GST_MESSAGE_ANY: mask for all of the above messages. * * The different message types that are available. @@ -125,6 +127,7 @@ typedef enum GST_MESSAGE_STEP_START = (1 << 23), GST_MESSAGE_QOS = (1 << 24), GST_MESSAGE_PROGRESS = (1 << 25), + GST_MESSAGE_TOC = (1 << 26), GST_MESSAGE_ANY = ~0 } GstMessageType; @@ -133,6 +136,7 @@ typedef enum #include #include #include +#include /** * GST_MESSAGE_TRACE_NAME: @@ -522,6 +526,9 @@ GstMessage * gst_message_new_progress (GstObject * src, GstProgress void gst_message_parse_progress (GstMessage * message, GstProgressType * type, gchar ** code, gchar ** text); +/* TOC */ +GstMessage * gst_message_new_toc (GstObject *src, GstToc *toc, gboolean updated); +void gst_message_parse_toc (GstMessage *message, GstToc **toc, gboolean *updated); /* custom messages */ GstMessage * gst_message_new_custom (GstMessageType type, -- 2.7.4