parse-launch: Add flag for placing elements in a bin instead of a pipeline
authorCarlos Rafael Giani <dv@pseudoterminal.org>
Fri, 11 Mar 2016 08:23:04 +0000 (09:23 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 24 Mar 2016 12:50:12 +0000 (14:50 +0200)
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
gst/gstparse.h
gst/parse/grammar.y

index a85fcf0..329578e 100644 (file)
@@ -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,
index 44912f0..55f28eb 100644 (file)
@@ -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())
index 49c3170..3f1a8bc 100644 (file)
@@ -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) {