Add new TOC message

This commit is contained in:
Alexander Saprykin 2012-03-14 20:41:48 +04:00 committed by Stefan Sauer
parent 2cb82d42fb
commit af85bd8dbf
2 changed files with 66 additions and 0 deletions

View file

@ -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);
}

View file

@ -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 <gst/gstelement.h>
#include <gst/gsttaglist.h>
#include <gst/gststructure.h>
#include <gst/gsttoc.h>
/**
* 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,