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
This commit is contained in:
Carlos Rafael Giani 2016-03-11 09:23:04 +01:00 committed by Sebastian Dröge
parent bc78548cfe
commit fdd5d22828
3 changed files with 14 additions and 5 deletions

View 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,

View 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())

View 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) {