From fdd5d22828e544ce1db9802f4ab1da0406edfed6 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Fri, 11 Mar 2016 09:23:04 +0100 Subject: [PATCH] parse-launch: Add flag for placing elements in a bin instead of a pipeline By default, gst_parse_launch_full() creates a GstPipeline if there's more than one toplevel element. Add a flag to let it use a GstBin instead. Also fix the parser to let it use this flag for GST_TYPE_ELEMENT property values, to avoid having GstPipelines inside other GstPipelines. https://bugzilla.gnome.org/show_bug.cgi?id=763457 --- gst/gstparse.c | 4 +++- gst/gstparse.h | 6 +++++- gst/parse/grammar.y | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gst/gstparse.c b/gst/gstparse.c index a85fcf0..329578e 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -306,7 +306,9 @@ gst_parse_launch (const gchar * pipeline_description, GError ** error) * * Returns: (transfer floating): a new element on success, %NULL on failure. If * more than one toplevel element is specified by the @pipeline_description, - * all elements are put into a #GstPipeline, which then is returned. + * all elements are put into a #GstPipeline, which then is returned (unless + * the GST_PARSE_FLAG_PLACE_IN_BIN flag is set, in which case they are put + * in a #GstBin instead). */ GstElement * gst_parse_launch_full (const gchar * pipeline_description, diff --git a/gst/gstparse.h b/gst/gstparse.h index 44912f0..55f28eb 100644 --- a/gst/gstparse.h +++ b/gst/gstparse.h @@ -70,6 +70,9 @@ typedef enum * in some cases) * @GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS: If a bin only has a single element, * just return the element. + * @GST_PARSE_FLAG_PLACE_IN_BIN: If more than one toplevel element is described + * by the pipeline description string, put them in a #GstBin instead of a + * #GstPipeline. (Since 1.10) * * Parsing options. */ @@ -77,7 +80,8 @@ typedef enum { GST_PARSE_FLAG_NONE = 0, GST_PARSE_FLAG_FATAL_ERRORS = (1 << 0), - GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS = (1 << 1) + GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS = (1 << 1), + GST_PARSE_FLAG_PLACE_IN_BIN = (1 << 2) } GstParseFlags; #define GST_TYPE_PARSE_CONTEXT (gst_parse_context_get_type()) diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y index 49c3170..3f1a8bc 100644 --- a/gst/parse/grammar.y +++ b/gst/parse/grammar.y @@ -333,7 +333,7 @@ static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object, GstElement *bin; bin = gst_parse_bin_from_description_full (set->value_str, TRUE, NULL, - GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS, NULL); + GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS | GST_PARSE_FLAG_PLACE_IN_BIN, NULL); if (bin) { g_value_set_object (&v, bin); got_value = TRUE; @@ -429,7 +429,7 @@ static void gst_parse_element_set (gchar *value, GstElement *element, graph_t *g GstElement *bin; bin = gst_parse_bin_from_description_full (pos, TRUE, NULL, - GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS, NULL); + GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS | GST_PARSE_FLAG_PLACE_IN_BIN, NULL); if (bin) { g_value_set_object (&v, bin); got_value = TRUE; @@ -1107,7 +1107,10 @@ priv_gst_parse_launch (const gchar *str, GError **error, GstParseContext *ctx, /* put all elements in our bin if necessary */ if(g.chain->elements->next){ - bin = GST_BIN (gst_element_factory_make ("pipeline", NULL)); + if (flags & GST_PARSE_FLAG_PLACE_IN_BIN) + bin = GST_BIN (gst_element_factory_make ("bin", NULL)); + else + bin = GST_BIN (gst_element_factory_make ("pipeline", NULL)); g_assert (bin); for (walk = g.chain->elements; walk; walk = walk->next) { -- 2.7.4