2 #include <glib-object.h>
8 #include "../gst_private.h"
9 #include "../gst-i18n-lib.h"
11 #include "../gstconfig.h"
12 #include "../gstparse.h"
13 #include "../gstinfo.h"
14 #include "../gsturi.h"
17 /* All error messages in this file are user-visible and need to be translated.
18 * Don't start the message with a capital, and don't end them with a period,
19 * as they will be presented inside a sentence/error.
22 #define YYERROR_VERBOSE 1
23 #define YYPARSE_PARAM graph
25 #ifdef __GST_PARSE_TRACE
26 static guint __strings;
28 static guint __chains;
30 __gst_parse_strdup (gchar *org)
35 /* g_print ("ALLOCATED STR (%3u): %p %s\n", __strings, ret, ret); */
39 __gst_parse_strfree (gchar *str)
42 /* g_print ("FREEING STR (%3u): %p %s\n", __strings - 1, str, str); */
44 g_return_if_fail (__strings > 0);
48 link_t *__gst_parse_link_new ()
52 ret = g_new0 (link_t, 1);
53 /* g_print ("ALLOCATED LINK (%3u): %p\n", __links, ret); */
57 __gst_parse_link_free (link_t *data)
60 /* g_print ("FREEING LINK (%3u): %p\n", __links - 1, data); */
62 g_return_if_fail (__links > 0);
67 __gst_parse_chain_new ()
71 ret = g_new0 (chain_t, 1);
72 /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
76 __gst_parse_chain_free (chain_t *data)
79 /* g_print ("FREEING CHAIN (%3u): %p\n", __chains - 1, data); */
81 g_return_if_fail (__chains > 0);
86 #endif /* __GST_PARSE_TRACE */
94 /* FIXME: need to connect to "disposed" signal to clean up, but there is no such signal */
97 #ifdef G_HAVE_ISO_VARARGS
98 #define SET_ERROR(error, type, ...) G_STMT_START{ \
101 g_warning (__VA_ARGS__); \
103 g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
107 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
108 #ifndef GST_DISABLE_GST_DEBUG
110 /* bison 1.35 calls this macro with side effects, we need to make sure the
111 side effects work - crappy bison
112 # define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__)
114 # define YYFPRINTF(a, ...) G_STMT_START{ \
115 gchar *temp = g_strdup_printf (__VA_ARGS__); \
116 GST_CAT_DEBUG (GST_CAT_PIPELINE, temp); \
121 #elif defined(G_HAVE_GNUC_VARARGS)
123 #define SET_ERROR(error, type, args...) G_STMT_START{ \
126 g_warning ( ## args ); \
128 g_set_error ((error), GST_PARSE_ERROR, (type), ## args ); \
132 #define ERROR(type, args...) SET_ERROR (((graph_t *) graph)->error, (type), ## args )
133 #ifndef GST_DISABLE_GST_DEBUG
135 /* bison 1.35 calls this macro with side effects, we need to make sure the
136 side effects work - crappy bison
137 # define YYFPRINTF(a, args...) GST_CAT_DEBUG (GST_CAT_PIPELINE, ## args )
139 # define YYFPRINTF(a, args...) G_STMT_START{ \
140 gchar *temp = g_strdup_printf ( ## args ); \
141 GST_CAT_DEBUG (GST_CAT_PIPELINE, temp); \
148 #define SET_ERROR(error, type, ...) G_STMT_START{ \
151 g_warning ("error while parsing"); \
153 g_set_error ((error), GST_PARSE_ERROR, (type), "error while parsing"); \
157 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), "error while parsing")
158 #ifndef GST_DISABLE_GST_DEBUG
162 #endif /* G_HAVE_ISO_VARARGS */
164 #define GST_BIN_MAKE(res, type, chainval, assign) G_STMT_START{ \
165 chain_t *chain = chainval; \
167 GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
169 ERROR (GST_PARSE_ERROR_EMPTY_BIN, _("specified empty bin \"%s\", not allowed"), type); \
170 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
171 g_slist_free (assign); \
174 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no bin \"%s\", skipping"), type); \
175 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
176 g_slist_free (assign); \
179 walk = chain->elements; \
181 gst_bin_add (bin, GST_ELEMENT (walk->data)); \
184 g_slist_free (chain->elements); \
185 chain->elements = g_slist_prepend (NULL, bin); \
187 /* set the properties now */ \
190 gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
191 walk = g_slist_next (walk); \
193 g_slist_free (assign); \
197 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) G_STMT_START{ \
198 link = gst_parse_link_new (); \
200 link->sink = _sink; \
201 link->src_name = _src_name; \
202 link->sink_name = _sink_name; \
203 link->src_pads = _src_pads; \
204 link->sink_pads = _sink_pads; \
208 #define MAKE_REF(link, _src, _pads) G_STMT_START{ \
209 gchar *padname = _src; \
210 GSList *pads = _pads; \
212 while (*padname != '.') padname++; \
215 if (*padname != '\0') \
216 pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
218 MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
222 gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
226 /* parse the string, so the property name is null-terminated an pos points
227 to the beginning of the value */
228 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
234 while (g_ascii_isspace (*pos)) pos++;
237 while (g_ascii_isspace (*pos)) pos++;
240 pos[strlen (pos) - 1] = '\0';
242 gst_parse_unescape (pos);
243 if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), value))) {
246 g_value_init (&v, G_PARAM_SPEC_VALUE_TYPE(pspec));
247 switch (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec))) {
249 g_value_set_string (&v, pos);
252 if (g_ascii_strcasecmp (pos, "true") && g_ascii_strcasecmp (pos, "yes") && g_ascii_strcasecmp (pos, "1")) {
253 g_value_set_boolean (&v, FALSE);
255 g_value_set_boolean (&v, TRUE);
260 gchar *endptr = NULL;
261 GEnumClass *klass = (GEnumClass *) g_type_class_peek (G_PARAM_SPEC_VALUE_TYPE (pspec));
262 if (klass == NULL) goto error;
263 if (!(en = g_enum_get_value_by_name (klass, pos))) {
264 if (!(en = g_enum_get_value_by_nick (klass, pos))) {
265 gint i = strtol (pos, &endptr, 0);
266 if (endptr && *endptr == '\0') {
267 en = g_enum_get_value (klass, i);
273 g_value_set_enum (&v, en->value);
281 g_value_init (&v2, G_TYPE_LONG);
282 l = strtol (pos, &endptr, 0);
283 if (*endptr != '\0') goto error_conversion;
284 g_value_set_long (&v2, l);
285 if (!g_value_transform (&v2, &v)) goto error_conversion;
290 case G_TYPE_UINT64: {
293 g_value_init (&v2, G_TYPE_ULONG);
294 ul = strtoul (pos, &endptr, 0);
295 if (*endptr != '\0') goto error_conversion;
296 g_value_set_ulong (&v2, ul);
297 if (!g_value_transform (&v2, &v)) goto error_conversion;
301 case G_TYPE_DOUBLE: {
304 g_value_init (&v2, G_TYPE_DOUBLE);
305 d = g_ascii_strtod (pos, &endptr);
306 if (*endptr != '\0') goto error_conversion;
307 g_value_set_double (&v2, d);
308 if (!g_value_transform (&v2, &v)) goto error_conversion;
313 g_warning ("property \"%s\" in element %s cannot be set", value, GST_ELEMENT_NAME (element));
316 g_object_set_property (G_OBJECT (element), value, &v);
318 ERROR (GST_PARSE_ERROR_NO_SUCH_PROPERTY, _("no property \"%s\" in element \"%s\""), value, GST_ELEMENT_NAME (element));
322 gst_parse_strfree (value);
326 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
327 _("could not set property \"%s\" in element \"%s\" to \"%s\""),
328 value, GST_ELEMENT_NAME (element), pos);
331 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
332 _("could not convert \"%s\" so that it fits property \"%s\" in element \"%s\""),
333 pos, value, GST_ELEMENT_NAME (element));
337 gst_parse_free_link (link_t *link)
339 gst_parse_strfree (link->src_name);
340 gst_parse_strfree (link->sink_name);
341 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
342 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
343 g_slist_free (link->src_pads);
344 g_slist_free (link->sink_pads);
345 if (link->caps) gst_caps_free (link->caps);
346 gst_parse_link_free (link);
349 gst_parse_element_lock (GstElement *element, gboolean lock)
352 GList *walk = (GList *) gst_element_get_pad_list (element);
353 gboolean unlocked_peer = FALSE;
355 if (gst_element_is_locked_state (element) == lock)
357 /* check if we have an unlocked peer */
359 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
361 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
362 !gst_element_is_locked_state (GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
363 unlocked_peer = TRUE;
368 if (!(lock && unlocked_peer)) {
369 gst_element_set_locked_state (element, lock);
371 gst_element_sync_state_with_parent (element);
376 /* check if there are other pads to (un)lock */
377 walk = (GList *) gst_element_get_pad_list (element);
379 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
381 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
382 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
383 if (gst_element_is_locked_state (next) != lock)
384 gst_parse_element_lock (next, lock);
389 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
391 DelayedLink *link = (DelayedLink *) data;
393 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
394 GST_ELEMENT_NAME (src), link->src_pad,
395 GST_ELEMENT_NAME (link->sink), link->sink_pad);
397 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink, link->sink_pad, link->caps)) {
398 /* do this here, we don't want to get any problems later on when unlocking states */
399 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
400 GST_ELEMENT_NAME (src), link->src_pad,
401 GST_ELEMENT_NAME (link->sink), link->sink_pad);
402 g_signal_handler_disconnect (src, link->signal_id);
403 g_free (link->src_pad);
404 g_free (link->sink_pad);
405 if (link->caps) gst_caps_free (link->caps);
406 if (!gst_element_is_locked_state (src))
407 gst_parse_element_lock (link->sink, FALSE);
411 /* both padnames and the caps may be NULL */
413 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
414 GstElement *sink, const gchar *sink_pad, GstCaps *caps)
416 GList *templs = gst_element_get_pad_template_list (src);
419 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
420 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
422 DelayedLink *data = g_new (DelayedLink, 1);
424 /* TODO: maybe we should check if src_pad matches this template's names */
426 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
427 GST_ELEMENT_NAME (src), src_pad, GST_ELEMENT_NAME (sink), sink_pad);
429 data->src_pad = g_strdup (src_pad);
431 data->sink_pad = g_strdup (sink_pad);
433 data->caps = gst_caps_copy (caps);
437 data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
438 G_CALLBACK (gst_parse_found_pad), data);
441 templs = g_list_next (templs);
446 * performs a link and frees the struct. src and sink elements must be given
447 * return values 0 - link performed
452 gst_parse_perform_link (link_t *link, graph_t *graph)
454 GstElement *src = link->src;
455 GstElement *sink = link->sink;
456 GSList *srcs = link->src_pads;
457 GSList *sinks = link->sink_pads;
458 g_assert (GST_IS_ELEMENT (src));
459 g_assert (GST_IS_ELEMENT (sink));
461 GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u with caps \"%" GST_PTR_FORMAT "\"",
462 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "---", g_slist_length (srcs),
463 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "---", g_slist_length (sinks),
466 if (!srcs || !sinks) {
467 if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL,
468 sink, sinks ? (const gchar *) sinks->data : NULL,
470 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
473 if (gst_parse_perform_delayed_link (src, srcs ? (const gchar *) srcs->data : NULL,
474 sink, sinks ? (const gchar *) sinks->data : NULL,
476 gst_parse_element_lock (sink, TRUE);
483 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
486 while (srcs && sinks) {
487 const gchar *src_pad = (const gchar *) srcs->data;
488 const gchar *sink_pad = (const gchar *) sinks->data;
489 srcs = g_slist_next (srcs);
490 sinks = g_slist_next (sinks);
491 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad, link->caps)) {
492 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
495 if (gst_parse_perform_delayed_link (src, src_pad,
498 gst_parse_element_lock (sink, TRUE);
507 gst_parse_free_link (link);
511 ERROR (GST_PARSE_ERROR_LINK, _("could not link %s to %s"), GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
512 gst_parse_free_link (link);
517 static int yylex (void *lvalp);
518 static int yyerror (const char *s);
531 %token <s> IDENTIFIER
532 %left <s> REF PADREF BINREF
533 %token <s> ASSIGNMENT
539 %type <l> linkpart link
542 %type <p> padlist pads assignments
544 %left '{' '}' '(' ')'
554 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
556 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1);
557 gst_parse_strfree ($1);
561 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
565 assignments: /* NOP */ { $$ = NULL; }
566 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
568 bin: '{' assignments chain '}' { GST_BIN_MAKE ($$, "thread", $3, $2); }
569 | '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
570 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
571 gst_parse_strfree ($1);
573 | '{' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
574 | '(' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
575 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
576 gst_parse_strfree ($1);
578 | '{' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
579 | '(' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
580 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
581 gst_parse_strfree ($1);
585 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
586 | PADREF padlist { $$ = $2;
587 $$ = g_slist_prepend ($$, $1);
590 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
591 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
594 reference: REF { MAKE_REF ($$, $1, NULL); }
595 | REF padlist { MAKE_REF ($$, $1, $2); }
598 linkpart: reference { $$ = $1; }
599 | pads { MAKE_REF ($$, NULL, $1); }
600 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
603 link: linkpart LINK linkpart { $$ = $1;
605 $$->caps = gst_caps_from_string ($2);
607 ERROR (GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2);
608 gst_parse_strfree ($2);
610 $$->sink_name = $3->src_name;
611 $$->sink_pads = $3->src_pads;
612 gst_parse_link_free ($3);
616 linklist: link { $$ = g_slist_prepend (NULL, $1); }
617 | link linklist { $$ = g_slist_prepend ($2, $1); }
618 | linklist error { $$ = $1; }
621 chain: element { $$ = gst_parse_chain_new ();
622 $$->first = $$->last = $1;
623 $$->front = $$->back = NULL;
624 $$->elements = g_slist_prepend (NULL, $1);
627 | chain chain { if ($1->back && $2->front) {
628 if (!$1->back->sink_name) {
629 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
630 gst_parse_free_link ($1->back);
632 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
634 if (!$2->front->src_name) {
635 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
636 gst_parse_free_link ($2->front);
638 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
641 } else if ($1->back) {
642 if (!$1->back->sink_name) {
643 $1->back->sink = $2->first;
645 } else if ($2->front) {
646 if (!$2->front->src_name) {
647 $2->front->src = $1->last;
649 $1->back = $2->front;
653 if (!$1->back->sink || !$1->back->src) {
654 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
657 gst_parse_perform_link ($1->back, (graph_t *) graph);
662 $1->elements = g_slist_concat ($1->elements, $2->elements);
663 gst_parse_chain_free ($2);
666 | chain linklist { GSList *walk;
668 $2 = g_slist_prepend ($2, $1->back);
671 if (!((link_t *) $2->data)->src_name) {
672 ((link_t *) $2->data)->src = $1->last;
677 link_t *link = (link_t *) walk->data;
679 if (!link->sink_name && walk) {
680 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
681 gst_parse_free_link (link);
682 } else if (!link->src_name && !link->src) {
683 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
684 gst_parse_free_link (link);
687 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
696 | chain error { $$ = $1; }
697 | link chain { if ($2->front) {
698 if (!$2->front->src_name) {
699 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
700 gst_parse_free_link ($2->front);
702 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
705 if (!$1->sink_name) {
706 $1->sink = $2->first;
711 | PARSE_URL chain { $$ = $2;
713 GstElement *element =
714 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
716 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
717 _("no source element for URI \"%s\""), $1);
719 $$->front->src = element;
720 ((graph_t *) graph)->links = g_slist_prepend (
721 ((graph_t *) graph)->links, $$->front);
723 $$->elements = g_slist_prepend ($$->elements, element);
726 ERROR (GST_PARSE_ERROR_LINK,
727 _("no element to link URI \"%s\" to"), $1);
731 | link PARSE_URL { GstElement *element =
732 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
734 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
735 _("no sink element for URI \"%s\""), $2);
737 } else if ($1->sink_name || $1->sink_pads) {
738 ERROR (GST_PARSE_ERROR_LINK,
739 _("could not link sink element for URI \"%s\""), $2);
742 $$ = gst_parse_chain_new ();
743 $$->first = $$->last = element;
745 $$->front->sink = element;
746 $$->elements = g_slist_prepend (NULL, element);
751 graph: /* NOP */ { ERROR (GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
752 $$ = (graph_t *) graph;
754 | chain { $$ = (graph_t *) graph;
756 if (!$1->front->src_name) {
757 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
758 gst_parse_free_link ($1->front);
760 $$->links = g_slist_prepend ($$->links, $1->front);
765 if (!$1->back->sink_name) {
766 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
767 gst_parse_free_link ($1->back);
769 $$->links = g_slist_prepend ($$->links, $1->back);
779 extern FILE *_gst_parse_yyin;
780 int _gst_parse_yylex (YYSTYPE *lvalp);
782 static int yylex (void *lvalp) {
783 return _gst_parse_yylex ((YYSTYPE*) lvalp);
787 yyerror (const char *s)
789 /* FIXME: This should go into the GError somehow, but how? */
790 g_warning ("error: %s\n", s);
794 int _gst_parse_yy_scan_string (char*);
796 _gst_parse_launch (const gchar *str, GError **error)
804 g_return_val_if_fail (str != NULL, NULL);
810 #ifdef __GST_PARSE_TRACE
811 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
812 __strings = __chains = __links = 0;
813 #endif /* __GST_PARSE_TRACE */
815 dstr = g_strdup (str);
816 _gst_parse_yy_scan_string (dstr);
818 #ifndef GST_DISABLE_GST_DEBUG
822 if (yyparse (&g) != 0) {
823 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX, "Unrecoverable syntax error while parsing pipeline");
829 GST_CAT_INFO (GST_CAT_PIPELINE, "got %u elements and %u links", g.chain ? g_slist_length (g.chain->elements) : 0, g_slist_length (g.links));
833 } else if (!(((chain_t *) g.chain)->elements->next)) {
834 /* only one toplevel element */
835 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
836 g_slist_free (((chain_t *) g.chain)->elements);
837 if (GST_IS_BIN (ret))
840 /* put all elements in our bin */
841 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
843 walk = g.chain->elements;
845 gst_bin_add (bin, GST_ELEMENT (walk->data));
846 walk = g_slist_next (walk);
848 g_slist_free (g.chain->elements);
849 ret = GST_ELEMENT (bin);
851 gst_parse_chain_free (g.chain);
856 link_t *l = (link_t *) walk->data;
858 walk = g_slist_next (walk);
862 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
864 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
868 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->src_name);
869 gst_parse_free_link (l);
876 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
878 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
882 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->sink_name);
883 gst_parse_free_link (l);
888 gst_parse_perform_link (l, &g);
890 g_slist_free (g.links);
893 #ifdef __GST_PARSE_TRACE
894 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
895 if (__strings || __chains || __links) {
896 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
898 #endif /* __GST_PARSE_TRACE */
906 walk = g.chain->elements;
908 gst_object_unref (GST_OBJECT (walk->data));
911 g_slist_free (g.chain->elements);
913 gst_parse_chain_free (g.chain);
917 gst_parse_free_link ((link_t *) walk->data);
920 g_slist_free (g.links);