2 #include <glib-object.h>
8 #include "../gst_private.h"
10 #include "../gstconfig.h"
11 #include "../gstparse.h"
12 #include "../gstinfo.h"
13 #include "../gsturi.h"
16 #define YYERROR_VERBOSE 1
17 #define YYPARSE_PARAM graph
19 #ifdef __GST_PARSE_TRACE
20 static guint __strings;
22 static guint __chains;
24 __gst_parse_strdup (gchar *org)
29 /* g_print ("ALLOCATED STR (%3u): %p %s\n", __strings, ret, ret); */
33 __gst_parse_strfree (gchar *str)
36 /* g_print ("FREEING STR (%3u): %p %s\n", __strings - 1, str, str); */
38 g_return_if_fail (__strings > 0);
42 link_t *__gst_parse_link_new ()
46 ret = g_new0 (link_t, 1);
47 /* g_print ("ALLOCATED LINK (%3u): %p\n", __links, ret); */
51 __gst_parse_link_free (link_t *data)
54 /* g_print ("FREEING LINK (%3u): %p\n", __links - 1, data); */
56 g_return_if_fail (__links > 0);
61 __gst_parse_chain_new ()
65 ret = g_new0 (chain_t, 1);
66 /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
70 __gst_parse_chain_free (chain_t *data)
73 /* g_print ("FREEING CHAIN (%3u): %p\n", __chains - 1, data); */
75 g_return_if_fail (__chains > 0);
80 #endif /* __GST_PARSE_TRACE */
88 /* FIXME: need to connect to "disposed" signal to clean up, but there is no such signal */
91 #ifdef G_HAVE_ISO_VARARGS
92 #define SET_ERROR(error, type, ...) G_STMT_START{ \
95 g_warning (__VA_ARGS__); \
97 g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
101 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
102 #ifndef GST_DISABLE_GST_DEBUG
104 /* bison 1.35 calls this macro with side effects, we need to make sure the
105 side effects work - crappy bison
106 # define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__)
108 # define YYFPRINTF(a, ...) G_STMT_START{ \
109 gchar *temp = g_strdup_printf (__VA_ARGS__); \
110 GST_CAT_DEBUG (GST_CAT_PIPELINE, temp); \
115 #elif defined(G_HAVE_GNUC_VARARGS)
117 #define SET_ERROR(error, type, args...) G_STMT_START{ \
120 g_warning ( ## args ); \
122 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_DEBUG (GST_CAT_PIPELINE, temp); \
142 #define SET_ERROR(error, type, ...) G_STMT_START{ \
145 g_warning ("error while parsing"); \
147 g_set_error ((error), GST_PARSE_ERROR, (type), "error while parsing"); \
151 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), "error while parsing")
152 #ifndef GST_DISABLE_GST_DEBUG
156 #endif /* G_HAVE_ISO_VARARGS */
158 #define GST_BIN_MAKE(res, type, chainval, assign) G_STMT_START{ \
159 chain_t *chain = chainval; \
161 GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
163 ERROR (GST_PARSE_ERROR_EMPTY_BIN, "Specified empty bin \"%s\", not allowed", type); \
164 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
165 g_slist_free (assign); \
168 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No bin \"%s\", omitting...", type); \
169 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
170 g_slist_free (assign); \
173 walk = chain->elements; \
175 gst_bin_add (bin, GST_ELEMENT (walk->data)); \
178 g_slist_free (chain->elements); \
179 chain->elements = g_slist_prepend (NULL, bin); \
181 /* set the properties now */ \
184 gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
185 walk = g_slist_next (walk); \
187 g_slist_free (assign); \
191 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) G_STMT_START{ \
192 link = gst_parse_link_new (); \
194 link->sink = _sink; \
195 link->src_name = _src_name; \
196 link->sink_name = _sink_name; \
197 link->src_pads = _src_pads; \
198 link->sink_pads = _sink_pads; \
202 #define MAKE_REF(link, _src, _pads) G_STMT_START{ \
203 gchar *padname = _src; \
204 GSList *pads = _pads; \
206 while (*padname != '.') padname++; \
209 if (*padname != '\0') \
210 pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
212 MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
216 gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
220 /* parse the string, so the property name is null-terminated an pos points
221 to the beginning of the value */
222 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
228 while (g_ascii_isspace (*pos)) pos++;
231 while (g_ascii_isspace (*pos)) pos++;
234 pos[strlen (pos) - 1] = '\0';
236 gst_parse_unescape (pos);
237 if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), value))) {
240 g_value_init (&v, G_PARAM_SPEC_VALUE_TYPE(pspec));
241 switch (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec))) {
243 g_value_set_string (&v, pos);
246 if (g_ascii_strcasecmp (pos, "true") && g_ascii_strcasecmp (pos, "yes") && g_ascii_strcasecmp (pos, "1")) {
247 g_value_set_boolean (&v, FALSE);
249 g_value_set_boolean (&v, TRUE);
254 gchar *endptr = NULL;
255 GEnumClass *klass = (GEnumClass *) g_type_class_peek (G_PARAM_SPEC_VALUE_TYPE (pspec));
256 if (klass == NULL) goto error;
257 if (!(en = g_enum_get_value_by_name (klass, pos))) {
258 if (!(en = g_enum_get_value_by_nick (klass, pos))) {
259 gint i = strtol (pos, &endptr, 0);
260 if (endptr && *endptr == '\0') {
261 en = g_enum_get_value (klass, i);
267 g_value_set_enum (&v, en->value);
275 g_value_init (&v2, G_TYPE_LONG);
276 l = strtol (pos, &endptr, 0);
277 if (*endptr != '\0') goto error_conversion;
278 g_value_set_long (&v2, l);
279 if (!g_value_transform (&v2, &v)) goto error_conversion;
284 case G_TYPE_UINT64: {
287 g_value_init (&v2, G_TYPE_ULONG);
288 ul = strtoul (pos, &endptr, 0);
289 if (*endptr != '\0') goto error_conversion;
290 g_value_set_ulong (&v2, ul);
291 if (!g_value_transform (&v2, &v)) goto error_conversion;
295 case G_TYPE_DOUBLE: {
298 g_value_init (&v2, G_TYPE_DOUBLE);
299 d = g_ascii_strtod (pos, &endptr);
300 if (*endptr != '\0') goto error_conversion;
301 g_value_set_double (&v2, d);
302 if (!g_value_transform (&v2, &v)) goto error_conversion;
307 g_warning ("property \"%s\" in element %s cannot be set", value, GST_ELEMENT_NAME (element));
310 g_object_set_property (G_OBJECT (element), value, &v);
312 ERROR (GST_PARSE_ERROR_NO_SUCH_PROPERTY, "No property \"%s\" in element \"%s\"", value, GST_ELEMENT_NAME (element));
316 gst_parse_strfree (value);
320 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
321 "Could not set property \"%s\" in element \"%s\" to \"%s\"",
322 value, GST_ELEMENT_NAME (element), pos);
325 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
326 "Could not convert \"%s\" so that it fits property \"%s\" in element \"%s\"",
327 pos, value, GST_ELEMENT_NAME (element));
331 gst_parse_free_link (link_t *link)
333 gst_parse_strfree (link->src_name);
334 gst_parse_strfree (link->sink_name);
335 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
336 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
337 g_slist_free (link->src_pads);
338 g_slist_free (link->sink_pads);
339 gst_caps_unref (link->caps);
340 gst_parse_link_free (link);
343 gst_parse_element_lock (GstElement *element, gboolean lock)
346 GList *walk = (GList *) gst_element_get_pad_list (element);
347 gboolean unlocked_peer = FALSE;
349 if (gst_element_is_locked_state (element) == lock)
351 /* check if we have an unlocked peer */
353 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
355 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
356 !gst_element_is_locked_state (GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
357 unlocked_peer = TRUE;
362 if (!(lock && unlocked_peer)) {
363 gst_element_set_locked_state (element, lock);
365 gst_element_sync_state_with_parent (element);
370 /* check if there are other pads to (un)lock */
371 walk = (GList *) gst_element_get_pad_list (element);
373 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
375 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
376 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
377 if (gst_element_is_locked_state (next) != lock)
378 gst_parse_element_lock (next, lock);
383 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
385 DelayedLink *link = (DelayedLink *) data;
387 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
388 GST_ELEMENT_NAME (src), link->src_pad,
389 GST_ELEMENT_NAME (link->sink), link->sink_pad);
391 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink, link->sink_pad, link->caps)) {
392 /* do this here, we don't want to get any problems later on when unlocking states */
393 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
394 GST_ELEMENT_NAME (src), link->src_pad,
395 GST_ELEMENT_NAME (link->sink), link->sink_pad);
396 g_signal_handler_disconnect (src, link->signal_id);
397 g_free (link->src_pad);
398 g_free (link->sink_pad);
399 gst_caps_unref (link->caps);
400 if (!gst_element_is_locked_state (src))
401 gst_parse_element_lock (link->sink, FALSE);
405 /* both padnames and the caps may be NULL */
407 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
408 GstElement *sink, const gchar *sink_pad, GstCaps *caps)
410 GList *templs = gst_element_get_pad_template_list (src);
413 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
414 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
416 DelayedLink *data = g_new (DelayedLink, 1);
418 /* TODO: maybe we should check if src_pad matches this template's names */
420 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
421 GST_ELEMENT_NAME (src), src_pad, GST_ELEMENT_NAME (sink), sink_pad);
423 data->src_pad = g_strdup (src_pad);
425 data->sink_pad = g_strdup (sink_pad);
426 data->caps = gst_caps_ref (caps);
427 data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
428 G_CALLBACK (gst_parse_found_pad), data);
431 templs = g_list_next (templs);
436 * performs a link and frees the struct. src and sink elements must be given
437 * return values 0 - link performed
442 gst_parse_perform_link (link_t *link, graph_t *graph)
444 GstElement *src = link->src;
445 GstElement *sink = link->sink;
446 GSList *srcs = link->src_pads;
447 GSList *sinks = link->sink_pads;
448 g_assert (GST_IS_ELEMENT (src));
449 g_assert (GST_IS_ELEMENT (sink));
451 GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u with caps \"%s\"",
452 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "---", g_slist_length (srcs),
453 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "---", g_slist_length (sinks),
454 link->caps ? gst_caps_to_string (link->caps) : "-");
456 if (!srcs || !sinks) {
457 if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL,
458 sink, sinks ? (const gchar *) sinks->data : NULL,
460 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
463 if (gst_parse_perform_delayed_link (src, srcs ? (const gchar *) srcs->data : NULL,
464 sink, sinks ? (const gchar *) sinks->data : NULL,
466 gst_parse_element_lock (sink, TRUE);
473 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
476 while (srcs && sinks) {
477 const gchar *src_pad = (const gchar *) srcs->data;
478 const gchar *sink_pad = (const gchar *) sinks->data;
479 srcs = g_slist_next (srcs);
480 sinks = g_slist_next (sinks);
481 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad, link->caps)) {
482 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
485 if (gst_parse_perform_delayed_link (src, src_pad,
488 gst_parse_element_lock (sink, TRUE);
497 gst_parse_free_link (link);
501 ERROR (GST_PARSE_ERROR_LINK, "could not link %s to %s", GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
502 gst_parse_free_link (link);
507 static int yylex (void *lvalp);
508 static int yyerror (const char *s);
521 %token <s> IDENTIFIER
522 %left <s> REF PADREF BINREF
523 %token <s> ASSIGNMENT
529 %type <l> linkpart link
532 %type <p> padlist pads assignments
534 %left '{' '}' '(' ')'
544 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
546 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element \"%s\"", $1);
547 gst_parse_strfree ($1);
551 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
555 assignments: /* NOP */ { $$ = NULL; }
556 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
558 bin: '{' assignments chain '}' { GST_BIN_MAKE ($$, "thread", $3, $2); }
559 | '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
560 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
561 gst_parse_strfree ($1);
563 | '{' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
564 | '(' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
565 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
566 gst_parse_strfree ($1);
568 | '{' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
569 | '(' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
570 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
571 gst_parse_strfree ($1);
575 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
576 | PADREF padlist { $$ = $2;
577 $$ = g_slist_prepend ($$, $1);
580 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
581 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
584 reference: REF { MAKE_REF ($$, $1, NULL); }
585 | REF padlist { MAKE_REF ($$, $1, $2); }
588 linkpart: reference { $$ = $1; }
589 | pads { MAKE_REF ($$, NULL, $1); }
590 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
593 link: linkpart LINK linkpart { $$ = $1;
595 $$->caps = gst_caps_from_string ($2);
597 ERROR (GST_PARSE_ERROR_LINK, "could not parse caps \"%s\"", $2);
598 gst_parse_strfree ($2);
599 gst_caps_ref($$->caps);
600 gst_caps_sink($$->caps);
602 $$->sink_name = $3->src_name;
603 $$->sink_pads = $3->src_pads;
604 gst_parse_link_free ($3);
608 linklist: link { $$ = g_slist_prepend (NULL, $1); }
609 | link linklist { $$ = g_slist_prepend ($2, $1); }
610 | linklist error { $$ = $1; }
613 chain: element { $$ = gst_parse_chain_new ();
614 $$->first = $$->last = $1;
615 $$->front = $$->back = NULL;
616 $$->elements = g_slist_prepend (NULL, $1);
619 | chain chain { if ($1->back && $2->front) {
620 if (!$1->back->sink_name) {
621 ERROR (GST_PARSE_ERROR_LINK, "link without source element");
622 gst_parse_free_link ($1->back);
624 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
626 if (!$2->front->src_name) {
627 ERROR (GST_PARSE_ERROR_LINK, "link without sink element");
628 gst_parse_free_link ($2->front);
630 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
633 } else if ($1->back) {
634 if (!$1->back->sink_name) {
635 $1->back->sink = $2->first;
637 } else if ($2->front) {
638 if (!$2->front->src_name) {
639 $2->front->src = $1->last;
641 $1->back = $2->front;
645 if (!$1->back->sink || !$1->back->src) {
646 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
649 gst_parse_perform_link ($1->back, (graph_t *) graph);
654 $1->elements = g_slist_concat ($1->elements, $2->elements);
655 gst_parse_chain_free ($2);
658 | chain linklist { GSList *walk;
660 $2 = g_slist_prepend ($2, $1->back);
663 if (!((link_t *) $2->data)->src_name) {
664 ((link_t *) $2->data)->src = $1->last;
669 link_t *link = (link_t *) walk->data;
671 if (!link->sink_name && walk) {
672 ERROR (GST_PARSE_ERROR_LINK, "link without sink element");
673 gst_parse_free_link (link);
674 } else if (!link->src_name && !link->src) {
675 ERROR (GST_PARSE_ERROR_LINK, "link without source element");
676 gst_parse_free_link (link);
679 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
688 | chain error { $$ = $1; }
689 | link chain { if ($2->front) {
690 if (!$2->front->src_name) {
691 ERROR (GST_PARSE_ERROR_LINK, "link without source element");
692 gst_parse_free_link ($2->front);
694 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
697 if (!$1->sink_name) {
698 $1->sink = $2->first;
703 | PARSE_URL chain { $$ = $2;
705 GstElement *element =
706 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
708 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
709 "No source element for URI \"%s\"", $1);
711 $$->front->src = element;
712 ((graph_t *) graph)->links = g_slist_prepend (
713 ((graph_t *) graph)->links, $$->front);
715 $$->elements = g_slist_prepend ($$->elements, element);
718 ERROR (GST_PARSE_ERROR_LINK,
719 "No element to link URI \"%s\" to", $1);
723 | link PARSE_URL { GstElement *element =
724 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
726 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
727 "No sink element for URI \"%s\"", $2);
729 } else if ($1->sink_name || $1->sink_pads) {
730 ERROR (GST_PARSE_ERROR_LINK,
731 "could not link sink element for URI \"%s\"", $2);
734 $$ = gst_parse_chain_new ();
735 $$->first = $$->last = element;
737 $$->front->sink = element;
738 $$->elements = g_slist_prepend (NULL, element);
743 graph: /* NOP */ { ERROR (GST_PARSE_ERROR_EMPTY, "Empty pipeline not allowed");
744 $$ = (graph_t *) graph;
746 | chain { $$ = (graph_t *) graph;
748 if (!$1->front->src_name) {
749 ERROR (GST_PARSE_ERROR_LINK, "link without source element");
750 gst_parse_free_link ($1->front);
752 $$->links = g_slist_prepend ($$->links, $1->front);
757 if (!$1->back->sink_name) {
758 ERROR (GST_PARSE_ERROR_LINK, "link without sink element");
759 gst_parse_free_link ($1->back);
761 $$->links = g_slist_prepend ($$->links, $1->back);
771 extern FILE *_gst_parse_yyin;
772 int _gst_parse_yylex (YYSTYPE *lvalp);
774 static int yylex (void *lvalp) {
775 return _gst_parse_yylex ((YYSTYPE*) lvalp);
779 yyerror (const char *s)
781 /* FIXME: This should go into the GError somehow, but how? */
782 g_warning ("error: %s\n", s);
786 int _gst_parse_yy_scan_string (char*);
788 _gst_parse_launch (const gchar *str, GError **error)
796 g_return_val_if_fail (str != NULL, NULL);
802 #ifdef __GST_PARSE_TRACE
803 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
804 __strings = __chains = __links = 0;
805 #endif /* __GST_PARSE_TRACE */
807 dstr = g_strdup (str);
808 _gst_parse_yy_scan_string (dstr);
810 #ifndef GST_DISABLE_GST_DEBUG
814 if (yyparse (&g) != 0) {
815 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX, "Unrecoverable syntax error while parsing pipeline");
821 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));
825 } else if (!(((chain_t *) g.chain)->elements->next)) {
826 /* only one toplevel element */
827 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
828 g_slist_free (((chain_t *) g.chain)->elements);
829 if (GST_IS_BIN (ret))
832 /* put all elements in our bin */
833 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
835 walk = g.chain->elements;
837 gst_bin_add (bin, GST_ELEMENT (walk->data));
838 walk = g_slist_next (walk);
840 g_slist_free (g.chain->elements);
841 ret = GST_ELEMENT (bin);
843 gst_parse_chain_free (g.chain);
848 link_t *l = (link_t *) walk->data;
850 walk = g_slist_next (walk);
854 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
856 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
860 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->src_name);
861 gst_parse_free_link (l);
868 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
870 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
874 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->sink_name);
875 gst_parse_free_link (l);
880 gst_parse_perform_link (l, &g);
882 g_slist_free (g.links);
885 #ifdef __GST_PARSE_TRACE
886 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
887 if (__strings || __chains || __links) {
888 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
890 #endif /* __GST_PARSE_TRACE */
898 walk = g.chain->elements;
900 gst_object_unref (GST_OBJECT (walk->data));
903 g_slist_free (g.chain->elements);
905 gst_parse_chain_free (g.chain);
909 gst_parse_free_link ((link_t *) walk->data);
912 g_slist_free (g.links);