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 "../gsterror.h"
15 #include "../gsturi.h"
16 #include "../gstutils.h"
17 #include "../gstvalue.h"
18 #include "../gstchildproxy.h"
21 /* All error messages in this file are user-visible and need to be translated.
22 * Don't start the message with a capital, and don't end them with a period,
23 * as they will be presented inside a sentence/error.
26 #define YYERROR_VERBOSE 1
27 #define YYPARSE_PARAM graph
29 #ifdef __GST_PARSE_TRACE
30 static guint __strings;
32 static guint __chains;
34 __gst_parse_strdup (gchar *org)
39 /* g_print ("ALLOCATED STR (%3u): %p %s\n", __strings, ret, ret); */
43 __gst_parse_strfree (gchar *str)
46 /* g_print ("FREEING STR (%3u): %p %s\n", __strings - 1, str, str); */
48 g_return_if_fail (__strings > 0);
52 link_t *__gst_parse_link_new ()
56 ret = g_new0 (link_t, 1);
57 /* g_print ("ALLOCATED LINK (%3u): %p\n", __links, ret); */
61 __gst_parse_link_free (link_t *data)
64 /* g_print ("FREEING LINK (%3u): %p\n", __links - 1, data); */
66 g_return_if_fail (__links > 0);
71 __gst_parse_chain_new ()
75 ret = g_new0 (chain_t, 1);
76 /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
80 __gst_parse_chain_free (chain_t *data)
82 /* g_print ("FREEING CHAIN (%3u): %p\n", __chains - 1, data); */
84 g_return_if_fail (__chains > 0);
88 #endif /* __GST_PARSE_TRACE */
96 /* FIXME: need to connect to "disposed" signal to clean up,
97 * but there is no such signal */
100 /*** define SET_ERROR and ERROR macros/functions */
102 #ifdef G_HAVE_ISO_VARARGS
104 # define SET_ERROR(error, type, ...) \
106 GST_CAT_ERROR (GST_CAT_PIPELINE, __VA_ARGS__); \
107 if ((error) && !*(error)) { \
108 g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
112 # define ERROR(type, ...) \
113 SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
115 #elif defined(G_HAVE_GNUC_VARARGS)
117 # define SET_ERROR(error, type, args...) \
119 GST_CAT_ERROR (GST_CAT_PIPELINE, args ); \
120 if ((error) && !*(error)) { \
121 g_set_error ((error), GST_PARSE_ERROR, (type), args ); \
125 # define ERROR(type, args...) \
126 SET_ERROR (((graph_t *) graph)->error,(type) , args )
131 SET_ERROR (GError **error, gint type, const char *format, ...)
135 g_warning ("error while parsing");
140 va_start (varargs, format);
141 string = g_strdup_vprintf (format, varargs);
144 g_set_error (error, GST_PARSE_ERROR, type, string);
151 #endif /* G_HAVE_ISO_VARARGS */
153 /*** define YYPRINTF macro/function if we're debugging */
155 /* bison 1.35 calls this macro with side effects, we need to make sure the
156 side effects work - crappy bison */
158 #ifndef GST_DISABLE_GST_DEBUG
161 # ifdef G_HAVE_ISO_VARARGS
163 /* # define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__) */
164 # define YYFPRINTF(a, ...) \
166 gchar *temp = g_strdup_printf (__VA_ARGS__); \
167 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
171 # elif defined(G_HAVE_GNUC_VARARGS)
173 # define YYFPRINTF(a, args...) \
175 gchar *temp = g_strdup_printf ( args ); \
176 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
183 YYPRINTF(const char *format, ...)
188 va_start (varargs, format);
189 temp = g_strdup_vprintf (format, varargs);
190 GST_CAT_LOG (GST_CAT_PIPELINE, "%s", temp);
195 # endif /* G_HAVE_ISO_VARARGS */
197 #endif /* GST_DISABLE_GST_DEBUG */
199 #define GST_BIN_MAKE(res, type, chainval, assign) \
201 chain_t *chain = chainval; \
203 GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
205 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY_BIN, \
206 _("specified empty bin \"%s\", not allowed"), type); \
207 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
208 g_slist_free (assign); \
211 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, \
212 _("no bin \"%s\", skipping"), type); \
213 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
214 g_slist_free (assign); \
217 for (walk = chain->elements; walk; walk = walk->next ) \
218 gst_bin_add (bin, GST_ELEMENT (walk->data)); \
219 g_slist_free (chain->elements); \
220 chain->elements = g_slist_prepend (NULL, bin); \
222 /* set the properties now */ \
223 for (walk = assign; walk; walk = walk->next) \
224 gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
225 g_slist_free (assign); \
229 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) \
231 link = gst_parse_link_new (); \
233 link->sink = _sink; \
234 link->src_name = _src_name; \
235 link->sink_name = _sink_name; \
236 link->src_pads = _src_pads; \
237 link->sink_pads = _sink_pads; \
241 #define MAKE_REF(link, _src, _pads) \
243 gchar *padname = _src; \
244 GSList *pads = _pads; \
246 while (*padname != '.') padname++; \
249 if (*padname != '\0') \
250 pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
252 MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
256 gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
264 /* parse the string, so the property name is null-terminated an pos points
265 to the beginning of the value */
266 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
272 while (g_ascii_isspace (*pos)) pos++;
275 while (g_ascii_isspace (*pos)) pos++;
278 pos[strlen (pos) - 1] = '\0';
280 gst_parse_unescape (pos);
282 if (gst_child_proxy_lookup (GST_OBJECT (element), value, &target, &pspec)) {
283 value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
284 GST_LOG ("parsing property %s as a %s", pspec->name,
285 g_type_name (value_type));
286 g_value_init (&v, value_type);
287 if (!gst_value_deserialize (&v, pos))
289 g_object_set_property (G_OBJECT (target), pspec->name, &v);
290 gst_object_unref (target);
292 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, \
293 _("no property \"%s\" in element \"%s\""), value, \
294 GST_ELEMENT_NAME (element));
298 gst_parse_strfree (value);
304 gst_object_unref (target);
305 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
306 _("could not set property \"%s\" in element \"%s\" to \"%s\""),
307 value, GST_ELEMENT_NAME (element), pos);
311 gst_parse_free_link (link_t *link)
313 gst_parse_strfree (link->src_name);
314 gst_parse_strfree (link->sink_name);
315 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
316 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
317 g_slist_free (link->src_pads);
318 g_slist_free (link->sink_pads);
319 if (link->caps) gst_caps_unref (link->caps);
320 gst_parse_link_free (link);
324 gst_parse_element_lock (GstElement *element, gboolean lock)
328 gboolean unlocked_peer = FALSE;
329 gboolean done = FALSE;
332 if (gst_element_is_locked_state (element) == lock)
337 /* check if we have an unlocked peer */
338 pads = gst_element_iterate_pads (element);
341 switch (gst_iterator_next (pads, &data)) {
342 case GST_ITERATOR_OK:
344 GstPad *pad = GST_PAD_CAST (data);
346 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
347 !gst_element_is_locked_state (
348 GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
349 unlocked_peer = TRUE;
352 gst_object_unref (GST_OBJECT (pad));
355 case GST_ITERATOR_RESYNC:
356 unlocked_peer = FALSE;
357 gst_iterator_resync (pads);
359 case GST_ITERATOR_DONE:
363 g_assert_not_reached ();
367 gst_iterator_free (pads);
369 if (!(lock && unlocked_peer)) {
370 GST_CAT_DEBUG (GST_CAT_PIPELINE, "setting locked state on element");
371 gst_element_set_locked_state (element, lock);
374 /* try to sync state with parent */
375 GST_CAT_DEBUG (GST_CAT_PIPELINE,
376 "trying to sync state of element with parent");
377 /* FIXME: it would be nice if we can figure out why it failed
378 (e.g. caps nego) and give an error about that instead. */
379 if (gst_element_set_state (element, GST_STATE_PLAYING)
380 == GST_STATE_CHANGE_FAILURE)
381 GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
387 /* check if there are other pads to (un)lock */
388 walk = (GList *) element->pads;
389 for (; walk; walk = walk->next) {
390 pad = GST_PAD_CAST (walk->data);
391 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
392 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
393 if (gst_element_is_locked_state (next) != lock)
394 gst_parse_element_lock (next, lock);
399 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
401 DelayedLink *link = (DelayedLink *) data;
403 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
404 GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (link->src_pad),
405 GST_STR_NULL (GST_ELEMENT_NAME (link->sink)), GST_STR_NULL (link->sink_pad));
407 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink,
408 link->sink_pad, link->caps)) {
409 /* do this here, we don't want to get any problems later on when
410 * unlocking states */
411 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
412 GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (link->src_pad),
413 GST_STR_NULL (GST_ELEMENT_NAME (link->sink)), GST_STR_NULL (link->sink_pad));
414 g_signal_handler_disconnect (src, link->signal_id);
415 g_free (link->src_pad);
416 g_free (link->sink_pad);
417 if (link->caps) gst_caps_unref (link->caps);
418 if (!gst_element_is_locked_state (src))
419 gst_parse_element_lock (link->sink, FALSE);
423 /* both padnames and the caps may be NULL */
425 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
426 GstElement *sink, const gchar *sink_pad,
429 GList *templs = gst_element_class_get_pad_template_list (
430 GST_ELEMENT_GET_CLASS (src));
432 for (; templs; templs = templs->next) {
433 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
434 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) &&
435 (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
437 DelayedLink *data = g_new (DelayedLink, 1);
439 /* TODO: maybe we should check if src_pad matches this template's names */
441 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
442 GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (src_pad),
443 GST_STR_NULL (GST_ELEMENT_NAME (sink)), GST_STR_NULL (sink_pad));
445 data->src_pad = g_strdup (src_pad);
447 data->sink_pad = g_strdup (sink_pad);
449 data->caps = gst_caps_copy (caps);
453 data->signal_id = g_signal_connect (G_OBJECT (src), "pad-added",
454 G_CALLBACK (gst_parse_found_pad), data);
461 * performs a link and frees the struct. src and sink elements must be given
462 * return values 0 - link performed
467 gst_parse_perform_link (link_t *link, graph_t *graph)
469 GstElement *src = link->src;
470 GstElement *sink = link->sink;
471 GSList *srcs = link->src_pads;
472 GSList *sinks = link->sink_pads;
473 g_assert (GST_IS_ELEMENT (src));
474 g_assert (GST_IS_ELEMENT (sink));
476 GST_CAT_INFO (GST_CAT_PIPELINE,
477 "linking %s:%s to %s:%s (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
478 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "(any)",
479 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "(any)",
480 g_slist_length (srcs), g_slist_length (sinks), link->caps);
482 if (!srcs || !sinks) {
483 if (gst_element_link_pads_filtered (src,
484 srcs ? (const gchar *) srcs->data : NULL, sink,
485 sinks ? (const gchar *) sinks->data : NULL, link->caps)) {
486 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
489 if (gst_parse_perform_delayed_link (src,
490 srcs ? (const gchar *) srcs->data : NULL,
491 sink, sinks ? (const gchar *) sinks->data : NULL, link->caps)) {
492 gst_parse_element_lock (sink, TRUE);
499 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
502 while (srcs && sinks) {
503 const gchar *src_pad = (const gchar *) srcs->data;
504 const gchar *sink_pad = (const gchar *) sinks->data;
505 srcs = g_slist_next (srcs);
506 sinks = g_slist_next (sinks);
507 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad,
509 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
512 if (gst_parse_perform_delayed_link (src, src_pad,
515 gst_parse_element_lock (sink, TRUE);
524 gst_parse_free_link (link);
528 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
529 _("could not link %s to %s"), GST_ELEMENT_NAME (src),
530 GST_ELEMENT_NAME (sink));
531 gst_parse_free_link (link);
536 static int yylex (void *lvalp);
537 static int yyerror (const char *s);
550 %token <s> IDENTIFIER
551 %left <s> REF PADREF BINREF
552 %token <s> ASSIGNMENT
558 %type <l> linkpart link
561 %type <p> padlist pads assignments
573 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
575 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1);
576 gst_parse_strfree ($1);
580 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
584 assignments: /* NOP */ { $$ = NULL; }
585 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
587 bin: '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
588 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
589 gst_parse_strfree ($1);
591 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
592 gst_parse_strfree ($1);
594 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
595 gst_parse_strfree ($1);
599 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
600 | PADREF padlist { $$ = $2;
601 $$ = g_slist_prepend ($$, $1);
604 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
605 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
608 reference: REF { MAKE_REF ($$, $1, NULL); }
609 | REF padlist { MAKE_REF ($$, $1, $2); }
612 linkpart: reference { $$ = $1; }
613 | pads { MAKE_REF ($$, NULL, $1); }
614 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
617 link: linkpart LINK linkpart { $$ = $1;
619 $$->caps = gst_caps_from_string ($2);
621 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2);
622 gst_parse_strfree ($2);
624 $$->sink_name = $3->src_name;
625 $$->sink_pads = $3->src_pads;
626 gst_parse_link_free ($3);
630 linklist: link { $$ = g_slist_prepend (NULL, $1); }
631 | link linklist { $$ = g_slist_prepend ($2, $1); }
632 | linklist error { $$ = $1; }
635 chain: element { $$ = gst_parse_chain_new ();
636 $$->first = $$->last = $1;
637 $$->front = $$->back = NULL;
638 $$->elements = g_slist_prepend (NULL, $1);
641 | chain chain { if ($1->back && $2->front) {
642 if (!$1->back->sink_name) {
643 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
644 gst_parse_free_link ($1->back);
646 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
648 if (!$2->front->src_name) {
649 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
650 gst_parse_free_link ($2->front);
652 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
655 } else if ($1->back) {
656 if (!$1->back->sink_name) {
657 $1->back->sink = $2->first;
659 } else if ($2->front) {
660 if (!$2->front->src_name) {
661 $2->front->src = $1->last;
663 $1->back = $2->front;
667 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
671 $1->elements = g_slist_concat ($1->elements, $2->elements);
673 gst_parse_chain_free ($2);
676 | chain linklist { GSList *walk;
678 $2 = g_slist_prepend ($2, $1->back);
681 if (!((link_t *) $2->data)->src_name) {
682 ((link_t *) $2->data)->src = $1->last;
685 for (walk = $2; walk; walk = walk->next) {
686 link_t *link = (link_t *) walk->data;
687 if (!link->sink_name && walk->next) {
688 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
689 gst_parse_free_link (link);
690 } else if (!link->src_name && !link->src) {
691 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
692 gst_parse_free_link (link);
695 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
704 | chain error { $$ = $1; }
705 | link chain { if ($2->front) {
706 if (!$2->front->src_name) {
707 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
708 gst_parse_free_link ($2->front);
710 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
713 if (!$1->sink_name) {
714 $1->sink = $2->first;
719 | PARSE_URL chain { $$ = $2;
721 GstElement *element =
722 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
724 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
725 _("no source element for URI \"%s\""), $1);
727 $$->front->src = element;
728 ((graph_t *) graph)->links = g_slist_prepend (
729 ((graph_t *) graph)->links, $$->front);
731 $$->elements = g_slist_prepend ($$->elements, element);
734 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
735 _("no element to link URI \"%s\" to"), $1);
739 | link PARSE_URL { GstElement *element =
740 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
742 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
743 _("no sink element for URI \"%s\""), $2);
745 } else if ($1->sink_name || $1->sink_pads) {
746 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
747 _("could not link sink element for URI \"%s\""), $2);
750 $$ = gst_parse_chain_new ();
751 $$->first = $$->last = element;
753 $$->front->sink = element;
754 $$->elements = g_slist_prepend (NULL, element);
759 graph: /* NOP */ { SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
760 $$ = (graph_t *) graph;
762 | chain { $$ = (graph_t *) graph;
764 if (!$1->front->src_name) {
765 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
766 gst_parse_free_link ($1->front);
768 $$->links = g_slist_prepend ($$->links, $1->front);
773 if (!$1->back->sink_name) {
774 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
775 gst_parse_free_link ($1->back);
777 $$->links = g_slist_prepend ($$->links, $1->back);
787 extern FILE *_gst_parse_yyin;
788 int _gst_parse_yylex (YYSTYPE *lvalp);
790 static int yylex (void *lvalp) {
791 return _gst_parse_yylex ((YYSTYPE*) lvalp);
795 yyerror (const char *s)
797 /* FIXME: This should go into the GError somehow, but how? */
798 GST_WARNING ("Error during parsing: %s", s);
802 struct yy_buffer_state * _gst_parse_yy_scan_string (char*);
803 void _gst_parse_yy_delete_buffer (struct yy_buffer_state *);
805 _gst_parse_launch (const gchar *str, GError **error)
812 struct yy_buffer_state *buf;
814 g_return_val_if_fail (str != NULL, NULL);
820 #ifdef __GST_PARSE_TRACE
821 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
822 __strings = __chains = __links = 0;
823 #endif /* __GST_PARSE_TRACE */
825 dstr = g_strdup (str);
826 buf = _gst_parse_yy_scan_string (dstr);
832 if (yyparse (&g) != 0) {
833 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX,
834 "Unrecoverable syntax error while parsing pipeline %s", str);
839 _gst_parse_yy_delete_buffer (buf);
841 GST_CAT_DEBUG (GST_CAT_PIPELINE, "got %u elements and %u links",
842 g.chain ? g_slist_length (g.chain->elements) : 0,
843 g_slist_length (g.links));
847 } else if (!(((chain_t *) g.chain)->elements->next)) {
848 /* only one toplevel element */
849 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
850 g_slist_free (((chain_t *) g.chain)->elements);
851 if (GST_IS_BIN (ret))
853 gst_parse_chain_free (g.chain);
855 /* put all elements in our bin */
856 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
859 for (walk = g.chain->elements; walk; walk = walk->next)
860 gst_bin_add (bin, GST_ELEMENT (walk->data));
862 g_slist_free (g.chain->elements);
863 ret = GST_ELEMENT (bin);
864 gst_parse_chain_free (g.chain);
868 for (walk = g.links; walk; walk = walk->next) {
869 link_t *l = (link_t *) walk->data;
873 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
875 gst_object_unref (l->src);
877 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
881 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
882 "No element named \"%s\" - omitting link", l->src_name);
883 gst_parse_free_link (l);
890 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
892 gst_object_unref (l->sink);
894 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
898 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
899 "No element named \"%s\" - omitting link", l->sink_name);
900 gst_parse_free_link (l);
904 gst_parse_perform_link (l, &g);
906 g_slist_free (g.links);
909 #ifdef __GST_PARSE_TRACE
910 GST_CAT_DEBUG (GST_CAT_PIPELINE,
911 "TRACE: %u strings, %u chains and %u links left", __strings, __chains,
913 if (__strings || __chains || __links) {
914 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings,
917 #endif /* __GST_PARSE_TRACE */
925 g_slist_foreach (g.chain->elements, (GFunc)gst_object_unref, NULL);
926 g_slist_free (g.chain->elements);
927 gst_parse_chain_free (g.chain);
930 g_slist_foreach (g.links, (GFunc)gst_parse_free_link, NULL);
931 g_slist_free (g.links);