summaryrefslogtreecommitdiff
path: root/gst/gstevent.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2013-03-28 15:35:13 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2013-03-29 16:40:21 +0100
commitb90906103104216aad85ea262a97340280e70369 (patch)
treeb82eea74a73bb71a827136d92cb8caadc85bcbe4 /gst/gstevent.c
parentbd85fe34adbcb369f86f74ab384838a969f68d64 (diff)
downloadgstreamer-b90906103104216aad85ea262a97340280e70369.tar.gz
gst: Add new GstContext miniobject for sharing contexts in a pipeline
Diffstat (limited to 'gst/gstevent.c')
-rw-r--r--gst/gstevent.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gst/gstevent.c b/gst/gstevent.c
index bb9736301b..1993eceecc 100644
--- a/gst/gstevent.c
+++ b/gst/gstevent.c
@@ -116,6 +116,7 @@ static GstEventQuarks event_quarks[] = {
{GST_EVENT_BUFFERSIZE, "buffersize", 0},
{GST_EVENT_SINK_MESSAGE, "sink-message", 0},
{GST_EVENT_EOS, "eos", 0},
+ {GST_EVENT_CONTEXT, "context", 0},
{GST_EVENT_SEGMENT_DONE, "segment-done", 0},
{GST_EVENT_GAP, "gap", 0},
{GST_EVENT_QOS, "qos", 0},
@@ -1597,3 +1598,52 @@ gst_event_parse_segment_done (GstEvent * event, GstFormat * format,
if (position != NULL)
*position = g_value_get_int64 (val);
}
+
+/**
+ * gst_event_new_context:
+ * @msg: (transfer full): the #GstContext
+ *
+ * Create a new context event. The purpose of the context event is
+ * to pass a pipeline-local context to downstream elements.
+ *
+ * Returns: (transfer full): a new #GstEvent
+ */
+GstEvent *
+gst_event_new_context (GstContext * context)
+{
+ GstEvent *event;
+ GstStructure *structure;
+
+ g_return_val_if_fail (context != NULL, NULL);
+
+ GST_CAT_INFO (GST_CAT_EVENT, "creating context event");
+
+ structure = gst_structure_new_id (GST_QUARK (EVENT_SEEK),
+ GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
+ event = gst_event_new_custom (GST_EVENT_CONTEXT, structure);
+ gst_context_unref (context);
+
+ return event;
+}
+
+/**
+ * gst_event_parse_context:
+ * @event: The event to query
+ * @context: (out) (transfer full): a pointer to store the #GstContext in.
+ *
+ * Parse the context event. Unref @context after usage.
+ */
+void
+gst_event_parse_context (GstEvent * event, GstContext ** context)
+{
+ const GstStructure *structure;
+
+ g_return_if_fail (GST_IS_EVENT (event));
+ g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_CONTEXT);
+
+ structure = GST_EVENT_STRUCTURE (event);
+ if (context)
+ *context =
+ GST_CONTEXT (g_value_dup_boxed (gst_structure_id_get_value
+ (structure, GST_QUARK (CONTEXT))));
+}