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 "../gstvalue.h"
19 /* All error messages in this file are user-visible and need to be translated.
20 * Don't start the message with a capital, and don't end them with a period,
21 * as they will be presented inside a sentence/error.
24 #define YYERROR_VERBOSE 1
25 #define YYPARSE_PARAM graph
27 #ifdef __GST_PARSE_TRACE
28 static guint __strings;
30 static guint __chains;
32 __gst_parse_strdup (gchar *org)
37 /* g_print ("ALLOCATED STR (%3u): %p %s\n", __strings, ret, ret); */
41 __gst_parse_strfree (gchar *str)
44 /* g_print ("FREEING STR (%3u): %p %s\n", __strings - 1, str, str); */
46 g_return_if_fail (__strings > 0);
50 link_t *__gst_parse_link_new ()
54 ret = g_new0 (link_t, 1);
55 /* g_print ("ALLOCATED LINK (%3u): %p\n", __links, ret); */
59 __gst_parse_link_free (link_t *data)
62 /* g_print ("FREEING LINK (%3u): %p\n", __links - 1, data); */
64 g_return_if_fail (__links > 0);
69 __gst_parse_chain_new ()
73 ret = g_new0 (chain_t, 1);
74 /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
78 __gst_parse_chain_free (chain_t *data)
80 /* g_print ("FREEING CHAIN (%3u): %p\n", __chains - 1, data); */
82 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{ \
99 GST_CAT_ERROR (GST_CAT_PIPELINE, __VA_ARGS__); \
100 if ((error) && !*(error)) { \
101 g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
104 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
105 #ifndef GST_DISABLE_GST_DEBUG
107 /* bison 1.35 calls this macro with side effects, we need to make sure the
108 side effects work - crappy bison
109 # define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__)
111 # define YYFPRINTF(a, ...) G_STMT_START{ \
112 gchar *temp = g_strdup_printf (__VA_ARGS__); \
113 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
118 #elif defined(G_HAVE_GNUC_VARARGS)
120 #define SET_ERROR(error, type, args...) G_STMT_START{ \
121 GST_CAT_ERROR (GST_CAT_PIPELINE, args ); \
122 if ((error) && !*(error)) { \
123 g_set_error ((error), GST_PARSE_ERROR, (type), args ); \
126 #define ERROR(type, args...) SET_ERROR (((graph_t *) graph)->error, (type) , args )
127 #ifndef GST_DISABLE_GST_DEBUG
129 /* bison 1.35 calls this macro with side effects, we need to make sure the
130 side effects work - crappy bison
131 # define YYFPRINTF(a, args...) GST_CAT_DEBUG (GST_CAT_PIPELINE, args )
133 # define YYFPRINTF(a, args...) G_STMT_START{ \
134 gchar *temp = g_strdup_printf ( args ); \
135 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
143 SET_ERROR (GError **error, gint type, const char *format, ...)
147 g_warning ("error while parsing");
152 va_start (varargs, format);
153 string = g_strdup_vprintf (format, varargs);
156 g_set_error (error, GST_PARSE_ERROR, type, string);
163 #ifndef GST_DISABLE_GST_DEBUG
166 YYPRINTF(const char *format, ...)
171 va_start (varargs, format);
172 temp = g_strdup_vprintf ( format, varargs );
173 GST_CAT_LOG (GST_CAT_PIPELINE, "%s", temp);
181 #define GST_BIN_MAKE(res, type, chainval, assign) G_STMT_START{ \
182 chain_t *chain = chainval; \
184 GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
186 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY_BIN, _("specified empty bin \"%s\", not allowed"), type); \
187 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
188 g_slist_free (assign); \
191 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no bin \"%s\", skipping"), type); \
192 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
193 g_slist_free (assign); \
196 for (walk = chain->elements; walk; walk = walk->next ) \
197 gst_bin_add (bin, GST_ELEMENT (walk->data)); \
198 g_slist_free (chain->elements); \
199 chain->elements = g_slist_prepend (NULL, bin); \
201 /* set the properties now */ \
202 for (walk = assign; walk; walk = walk->next) \
203 gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
204 g_slist_free (assign); \
208 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) G_STMT_START{ \
209 link = gst_parse_link_new (); \
211 link->sink = _sink; \
212 link->src_name = _src_name; \
213 link->sink_name = _sink_name; \
214 link->src_pads = _src_pads; \
215 link->sink_pads = _sink_pads; \
219 #define MAKE_REF(link, _src, _pads) G_STMT_START{ \
220 gchar *padname = _src; \
221 GSList *pads = _pads; \
223 while (*padname != '.') padname++; \
226 if (*padname != '\0') \
227 pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
229 MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
233 gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
239 /* parse the string, so the property name is null-terminated an pos points
240 to the beginning of the value */
241 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
247 while (g_ascii_isspace (*pos)) pos++;
250 while (g_ascii_isspace (*pos)) pos++;
253 pos[strlen (pos) - 1] = '\0';
255 gst_parse_unescape (pos);
256 if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), value))) {
257 g_value_init (&v, G_PARAM_SPEC_VALUE_TYPE(pspec));
258 if (!gst_value_deserialize (&v, pos))
260 g_object_set_property (G_OBJECT (element), value, &v);
262 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, _("no property \"%s\" in element \"%s\""), value, GST_ELEMENT_NAME (element));
266 gst_parse_strfree (value);
269 if (G_IS_VALUE (&v2))
274 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
275 _("could not set property \"%s\" in element \"%s\" to \"%s\""),
276 value, GST_ELEMENT_NAME (element), pos);
280 gst_parse_free_link (link_t *link)
282 gst_parse_strfree (link->src_name);
283 gst_parse_strfree (link->sink_name);
284 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
285 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
286 g_slist_free (link->src_pads);
287 g_slist_free (link->sink_pads);
288 if (link->caps) gst_caps_free (link->caps);
289 gst_parse_link_free (link);
292 gst_parse_element_lock (GstElement *element, gboolean lock)
295 GList *walk = (GList *) gst_element_get_pad_list (element);
296 gboolean unlocked_peer = FALSE;
298 if (gst_element_is_locked_state (element) == lock)
300 /* check if we have an unlocked peer */
301 for (; walk; walk = walk->next) {
302 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
303 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
304 !gst_element_is_locked_state (GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
305 unlocked_peer = TRUE;
310 if (!(lock && unlocked_peer)) {
311 GST_CAT_DEBUG (GST_CAT_PIPELINE, "setting locked state on element");
312 gst_element_set_locked_state (element, lock);
315 /* try to sync state with parent */
316 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying to sync state of element with parent");
317 /* FIXME: it would be nice if we can figure out why it failed
318 (e.g. caps nego) and give an error about that instead. */
319 if (!gst_element_sync_state_with_parent (element))
320 GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
326 /* check if there are other pads to (un)lock */
327 walk = (GList *) gst_element_get_pad_list (element);
328 for (; walk; walk = walk->next) {
329 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
330 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
331 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
332 if (gst_element_is_locked_state (next) != lock)
333 gst_parse_element_lock (next, lock);
338 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
340 DelayedLink *link = (DelayedLink *) data;
342 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
343 GST_ELEMENT_NAME (src), link->src_pad,
344 GST_ELEMENT_NAME (link->sink), link->sink_pad);
346 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink, link->sink_pad, link->caps)) {
347 /* do this here, we don't want to get any problems later on when unlocking states */
348 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
349 GST_ELEMENT_NAME (src), link->src_pad,
350 GST_ELEMENT_NAME (link->sink), link->sink_pad);
351 g_signal_handler_disconnect (src, link->signal_id);
352 g_free (link->src_pad);
353 g_free (link->sink_pad);
354 if (link->caps) gst_caps_free (link->caps);
355 if (!gst_element_is_locked_state (src))
356 gst_parse_element_lock (link->sink, FALSE);
360 /* both padnames and the caps may be NULL */
362 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
363 GstElement *sink, const gchar *sink_pad, GstCaps *caps)
365 GList *templs = gst_element_get_pad_template_list (src);
367 for (; templs; templs = templs->next) {
368 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
369 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
371 DelayedLink *data = g_new (DelayedLink, 1);
373 /* TODO: maybe we should check if src_pad matches this template's names */
375 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
376 GST_ELEMENT_NAME (src), src_pad, GST_ELEMENT_NAME (sink), sink_pad);
378 data->src_pad = g_strdup (src_pad);
380 data->sink_pad = g_strdup (sink_pad);
382 data->caps = gst_caps_copy (caps);
386 data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
387 G_CALLBACK (gst_parse_found_pad), data);
394 * performs a link and frees the struct. src and sink elements must be given
395 * return values 0 - link performed
400 gst_parse_perform_link (link_t *link, graph_t *graph)
402 GstElement *src = link->src;
403 GstElement *sink = link->sink;
404 GSList *srcs = link->src_pads;
405 GSList *sinks = link->sink_pads;
406 g_assert (GST_IS_ELEMENT (src));
407 g_assert (GST_IS_ELEMENT (sink));
409 GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s:%s to %s:%s (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
410 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "(any)",
411 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "(any)",
412 g_slist_length (srcs), g_slist_length (sinks),
415 if (!srcs || !sinks) {
416 if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL,
417 sink, sinks ? (const gchar *) sinks->data : NULL,
419 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
422 if (gst_parse_perform_delayed_link (src, srcs ? (const gchar *) srcs->data : NULL,
423 sink, sinks ? (const gchar *) sinks->data : NULL,
425 gst_parse_element_lock (sink, TRUE);
432 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
435 while (srcs && sinks) {
436 const gchar *src_pad = (const gchar *) srcs->data;
437 const gchar *sink_pad = (const gchar *) sinks->data;
438 srcs = g_slist_next (srcs);
439 sinks = g_slist_next (sinks);
440 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad, link->caps)) {
441 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
444 if (gst_parse_perform_delayed_link (src, src_pad,
447 gst_parse_element_lock (sink, TRUE);
456 gst_parse_free_link (link);
460 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not link %s to %s"), GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
461 gst_parse_free_link (link);
466 static int yylex (void *lvalp);
467 static int yyerror (const char *s);
480 %token <s> IDENTIFIER
481 %left <s> REF PADREF BINREF
482 %token <s> ASSIGNMENT
488 %type <l> linkpart link
491 %type <p> padlist pads assignments
493 %left '{' '}' '(' ')'
503 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
505 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1);
506 gst_parse_strfree ($1);
510 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
514 assignments: /* NOP */ { $$ = NULL; }
515 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
517 bin: '{' assignments chain '}' { GST_BIN_MAKE ($$, "thread", $3, $2); }
518 | '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
519 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
520 gst_parse_strfree ($1);
522 | '{' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
523 | '(' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
524 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
525 gst_parse_strfree ($1);
527 | '{' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
528 | '(' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
529 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
530 gst_parse_strfree ($1);
534 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
535 | PADREF padlist { $$ = $2;
536 $$ = g_slist_prepend ($$, $1);
539 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
540 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
543 reference: REF { MAKE_REF ($$, $1, NULL); }
544 | REF padlist { MAKE_REF ($$, $1, $2); }
547 linkpart: reference { $$ = $1; }
548 | pads { MAKE_REF ($$, NULL, $1); }
549 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
552 link: linkpart LINK linkpart { $$ = $1;
554 $$->caps = gst_caps_from_string ($2);
556 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2);
557 gst_parse_strfree ($2);
559 $$->sink_name = $3->src_name;
560 $$->sink_pads = $3->src_pads;
561 gst_parse_link_free ($3);
565 linklist: link { $$ = g_slist_prepend (NULL, $1); }
566 | link linklist { $$ = g_slist_prepend ($2, $1); }
567 | linklist error { $$ = $1; }
570 chain: element { $$ = gst_parse_chain_new ();
571 $$->first = $$->last = $1;
572 $$->front = $$->back = NULL;
573 $$->elements = g_slist_prepend (NULL, $1);
576 | chain chain { if ($1->back && $2->front) {
577 if (!$1->back->sink_name) {
578 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
579 gst_parse_free_link ($1->back);
581 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
583 if (!$2->front->src_name) {
584 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
585 gst_parse_free_link ($2->front);
587 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
590 } else if ($1->back) {
591 if (!$1->back->sink_name) {
592 $1->back->sink = $2->first;
594 } else if ($2->front) {
595 if (!$2->front->src_name) {
596 $2->front->src = $1->last;
598 $1->back = $2->front;
602 if (!$1->back->sink || !$1->back->src) {
603 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
606 gst_parse_perform_link ($1->back, (graph_t *) graph);
611 $1->elements = g_slist_concat ($1->elements, $2->elements);
613 gst_parse_chain_free ($2);
616 | chain linklist { GSList *walk;
618 $2 = g_slist_prepend ($2, $1->back);
621 if (!((link_t *) $2->data)->src_name) {
622 ((link_t *) $2->data)->src = $1->last;
625 for (walk = $2; walk; walk = walk->next) {
626 link_t *link = (link_t *) walk->data;
627 if (!link->sink_name && walk->next) {
628 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
629 gst_parse_free_link (link);
630 } else if (!link->src_name && !link->src) {
631 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
632 gst_parse_free_link (link);
635 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
644 | chain error { $$ = $1; }
645 | link chain { if ($2->front) {
646 if (!$2->front->src_name) {
647 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
648 gst_parse_free_link ($2->front);
650 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
653 if (!$1->sink_name) {
654 $1->sink = $2->first;
659 | PARSE_URL chain { $$ = $2;
661 GstElement *element =
662 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
664 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
665 _("no source element for URI \"%s\""), $1);
667 $$->front->src = element;
668 ((graph_t *) graph)->links = g_slist_prepend (
669 ((graph_t *) graph)->links, $$->front);
671 $$->elements = g_slist_prepend ($$->elements, element);
674 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
675 _("no element to link URI \"%s\" to"), $1);
679 | link PARSE_URL { GstElement *element =
680 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
682 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
683 _("no sink element for URI \"%s\""), $2);
685 } else if ($1->sink_name || $1->sink_pads) {
686 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
687 _("could not link sink element for URI \"%s\""), $2);
690 $$ = gst_parse_chain_new ();
691 $$->first = $$->last = element;
693 $$->front->sink = element;
694 $$->elements = g_slist_prepend (NULL, element);
699 graph: /* NOP */ { SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
700 $$ = (graph_t *) graph;
702 | chain { $$ = (graph_t *) graph;
704 if (!$1->front->src_name) {
705 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
706 gst_parse_free_link ($1->front);
708 $$->links = g_slist_prepend ($$->links, $1->front);
713 if (!$1->back->sink_name) {
714 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
715 gst_parse_free_link ($1->back);
717 $$->links = g_slist_prepend ($$->links, $1->back);
727 extern FILE *_gst_parse_yyin;
728 int _gst_parse_yylex (YYSTYPE *lvalp);
730 static int yylex (void *lvalp) {
731 return _gst_parse_yylex ((YYSTYPE*) lvalp);
735 yyerror (const char *s)
737 /* FIXME: This should go into the GError somehow, but how? */
738 g_warning ("error: %s", s);
742 struct yy_buffer_state * _gst_parse_yy_scan_string (char*);
743 void _gst_parse_yy_delete_buffer (struct yy_buffer_state *);
745 _gst_parse_launch (const gchar *str, GError **error)
752 struct yy_buffer_state *buf;
754 g_return_val_if_fail (str != NULL, NULL);
760 #ifdef __GST_PARSE_TRACE
761 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
762 __strings = __chains = __links = 0;
763 #endif /* __GST_PARSE_TRACE */
765 dstr = g_strdup (str);
766 buf = _gst_parse_yy_scan_string (dstr);
768 #ifndef GST_DISABLE_GST_DEBUG
772 if (yyparse (&g) != 0) {
773 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX, "Unrecoverable syntax error while parsing pipeline %s", str);
778 _gst_parse_yy_delete_buffer (buf);
780 GST_CAT_DEBUG (GST_CAT_PIPELINE, "got %u elements and %u links", g.chain ? g_slist_length (g.chain->elements) : 0, g_slist_length (g.links));
784 } else if (!(((chain_t *) g.chain)->elements->next)) {
785 /* only one toplevel element */
786 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
787 g_slist_free (((chain_t *) g.chain)->elements);
788 if (GST_IS_BIN (ret))
790 gst_parse_chain_free (g.chain);
792 /* put all elements in our bin */
793 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
796 for (walk = g.chain->elements; walk; walk = walk->next)
797 gst_bin_add (bin, GST_ELEMENT (walk->data));
799 g_slist_free (g.chain->elements);
800 ret = GST_ELEMENT (bin);
801 gst_parse_chain_free (g.chain);
805 for (walk = g.links; walk; walk = walk->next) {
806 link_t *l = (link_t *) walk->data;
810 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
812 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
816 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->src_name);
817 gst_parse_free_link (l);
824 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
826 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
830 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->sink_name);
831 gst_parse_free_link (l);
835 gst_parse_perform_link (l, &g);
837 g_slist_free (g.links);
840 #ifdef __GST_PARSE_TRACE
841 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
842 if (__strings || __chains || __links) {
843 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
845 #endif /* __GST_PARSE_TRACE */
853 g_slist_foreach (g.chain->elements, (GFunc)gst_object_unref, NULL);
854 g_slist_free (g.chain->elements);
855 gst_parse_chain_free (g.chain);
858 g_slist_foreach (g.links, (GFunc)gst_parse_free_link, NULL);
859 g_slist_free (g.links);