summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2013-04-17 13:47:35 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2013-04-17 13:47:35 +0200
commit8f8036f3446f25764f335d3e77b0c822f19921b4 (patch)
treef06ea0bfbd823afe4f0ecdde8c01cf042fdccb57 /tools
parentf5f0dd50c8be55c0a0b7c74189abf4c8b123e6ca (diff)
gst-launch: Add GstContext support
gst-launch will collect all the contexts from the pipeline elements and update the overall pipeline context with it.
Diffstat (limited to 'tools')
-rw-r--r--tools/gst-launch.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/gst-launch.c b/tools/gst-launch.c
index 66fc4052f..a4351051c 100644
--- a/tools/gst-launch.c
+++ b/tools/gst-launch.c
@@ -480,6 +480,18 @@ intr_handler (gpointer user_data)
#endif /* G_OS_UNIX */
+static gboolean
+merge_structures (GQuark field_id, const GValue * value, gpointer user_data)
+{
+ GstStructure *s2 = user_data;
+
+ /* Copy all fields that are not set yet */
+ if (!gst_structure_id_has_field (s2, field_id))
+ gst_structure_id_set_value (s2, field_id, value);
+
+ return TRUE;
+}
+
/* returns ELR_ERROR if there was an error
* or ELR_INTERRUPT if we caught a keyboard interrupt
* or ELR_NO_ERROR otherwise. */
@@ -792,6 +804,36 @@ event_loop (GstElement * pipeline, gboolean blocking, gboolean do_progress,
}
break;
}
+ case GST_MESSAGE_HAVE_CONTEXT:{
+ GstContext *context1, *context2;
+ gchar *context_str;
+
+ gst_message_parse_have_context (message, &context1);
+
+ context_str =
+ gst_structure_to_string (gst_context_get_structure (context1));
+ PRINT (_("Got context from element '%s': %s\n"),
+ GST_ELEMENT_NAME (GST_MESSAGE_SRC (message)), context_str);
+ g_free (context_str);
+
+ context2 = gst_element_get_context (pipeline);
+ if (context2) {
+ GstStructure *s1, *s2;
+
+ /* Merge structures */
+ context2 = gst_context_make_writable (context2);
+ s1 = gst_context_get_structure (context1);
+ s2 = gst_context_get_structure (context2);
+ gst_structure_foreach (s1, merge_structures, s2);
+ gst_element_set_context (pipeline, context2);
+ gst_context_unref (context2);
+ } else {
+ /* Copy over the context */
+ gst_element_set_context (pipeline, context1);
+ }
+ gst_context_unref (context1);
+ break;
+ }
default:
/* just be quiet by default */
break;