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"
20 /* All error messages in this file are user-visible and need to be translated.
21 * Don't start the message with a capital, and don't end them with a period,
22 * as they will be presented inside a sentence/error.
25 #define YYERROR_VERBOSE 1
26 #define YYPARSE_PARAM graph
28 #ifdef __GST_PARSE_TRACE
29 static guint __strings;
31 static guint __chains;
33 __gst_parse_strdup (gchar *org)
38 /* g_print ("ALLOCATED STR (%3u): %p %s\n", __strings, ret, ret); */
42 __gst_parse_strfree (gchar *str)
45 /* g_print ("FREEING STR (%3u): %p %s\n", __strings - 1, str, str); */
47 g_return_if_fail (__strings > 0);
51 link_t *__gst_parse_link_new ()
55 ret = g_new0 (link_t, 1);
56 /* g_print ("ALLOCATED LINK (%3u): %p\n", __links, ret); */
60 __gst_parse_link_free (link_t *data)
63 /* g_print ("FREEING LINK (%3u): %p\n", __links - 1, data); */
65 g_return_if_fail (__links > 0);
70 __gst_parse_chain_new ()
74 ret = g_new0 (chain_t, 1);
75 /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
79 __gst_parse_chain_free (chain_t *data)
81 /* g_print ("FREEING CHAIN (%3u): %p\n", __chains - 1, data); */
83 g_return_if_fail (__chains > 0);
87 #endif /* __GST_PARSE_TRACE */
95 /* FIXME: need to connect to "disposed" signal to clean up, but there is no such signal */
98 #ifdef G_HAVE_ISO_VARARGS
99 #define SET_ERROR(error, type, ...) G_STMT_START{ \
100 GST_CAT_ERROR (GST_CAT_PIPELINE, __VA_ARGS__); \
101 if ((error) && !*(error)) { \
102 g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
105 #define ERROR(type, ...) SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
106 #ifndef GST_DISABLE_GST_DEBUG
108 /* bison 1.35 calls this macro with side effects, we need to make sure the
109 side effects work - crappy bison
110 # define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__)
112 # define YYFPRINTF(a, ...) G_STMT_START{ \
113 gchar *temp = g_strdup_printf (__VA_ARGS__); \
114 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
119 #elif defined(G_HAVE_GNUC_VARARGS)
121 #define SET_ERROR(error, type, args...) G_STMT_START{ \
122 GST_CAT_ERROR (GST_CAT_PIPELINE, args ); \
123 if ((error) && !*(error)) { \
124 g_set_error ((error), GST_PARSE_ERROR, (type), args ); \
127 #define ERROR(type, args...) SET_ERROR (((graph_t *) graph)->error, (type) , args )
128 #ifndef GST_DISABLE_GST_DEBUG
130 /* bison 1.35 calls this macro with side effects, we need to make sure the
131 side effects work - crappy bison
132 # define YYFPRINTF(a, args...) GST_CAT_DEBUG (GST_CAT_PIPELINE, args )
134 # define YYFPRINTF(a, args...) G_STMT_START{ \
135 gchar *temp = g_strdup_printf ( args ); \
136 GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
144 SET_ERROR (GError **error, gint type, const char *format, ...)
148 g_warning ("error while parsing");
153 va_start (varargs, format);
154 string = g_strdup_vprintf (format, varargs);
157 g_set_error (error, GST_PARSE_ERROR, type, string);
164 #ifndef GST_DISABLE_GST_DEBUG
167 YYPRINTF(const char *format, ...)
172 va_start (varargs, format);
173 temp = g_strdup_vprintf ( format, varargs );
174 GST_CAT_LOG (GST_CAT_PIPELINE, "%s", temp);
182 #define GST_BIN_MAKE(res, type, chainval, assign) G_STMT_START{ \
183 chain_t *chain = chainval; \
185 GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
187 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY_BIN, _("specified empty bin \"%s\", not allowed"), type); \
188 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
189 g_slist_free (assign); \
192 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no bin \"%s\", skipping"), type); \
193 g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
194 g_slist_free (assign); \
197 for (walk = chain->elements; walk; walk = walk->next ) \
198 gst_bin_add (bin, GST_ELEMENT (walk->data)); \
199 g_slist_free (chain->elements); \
200 chain->elements = g_slist_prepend (NULL, bin); \
202 /* set the properties now */ \
203 for (walk = assign; walk; walk = walk->next) \
204 gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
205 g_slist_free (assign); \
209 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) G_STMT_START{ \
210 link = gst_parse_link_new (); \
212 link->sink = _sink; \
213 link->src_name = _src_name; \
214 link->sink_name = _sink_name; \
215 link->src_pads = _src_pads; \
216 link->sink_pads = _sink_pads; \
220 #define MAKE_REF(link, _src, _pads) G_STMT_START{ \
221 gchar *padname = _src; \
222 GSList *pads = _pads; \
224 while (*padname != '.') padname++; \
227 if (*padname != '\0') \
228 pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
230 MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
234 gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
240 /* parse the string, so the property name is null-terminated an pos points
241 to the beginning of the value */
242 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
248 while (g_ascii_isspace (*pos)) pos++;
251 while (g_ascii_isspace (*pos)) pos++;
254 pos[strlen (pos) - 1] = '\0';
256 gst_parse_unescape (pos);
257 if ((pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), value))) {
258 g_value_init (&v, G_PARAM_SPEC_VALUE_TYPE(pspec));
259 if (!gst_value_deserialize (&v, pos))
261 g_object_set_property (G_OBJECT (element), value, &v);
263 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, _("no property \"%s\" in element \"%s\""), value, GST_ELEMENT_NAME (element));
267 gst_parse_strfree (value);
270 if (G_IS_VALUE (&v2))
275 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
276 _("could not set property \"%s\" in element \"%s\" to \"%s\""),
277 value, GST_ELEMENT_NAME (element), pos);
281 gst_parse_free_link (link_t *link)
283 gst_parse_strfree (link->src_name);
284 gst_parse_strfree (link->sink_name);
285 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
286 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
287 g_slist_free (link->src_pads);
288 g_slist_free (link->sink_pads);
289 if (link->caps) gst_caps_unref (link->caps);
290 gst_parse_link_free (link);
294 gst_parse_element_lock (GstElement *element, gboolean lock)
298 gboolean unlocked_peer = FALSE;
299 gboolean done = FALSE;
302 if (gst_element_is_locked_state (element) == lock)
307 /* check if we have an unlocked peer */
308 pads = gst_element_iterate_pads (element);
311 switch (gst_iterator_next (pads, &data)) {
312 case GST_ITERATOR_OK:
314 GstPad *pad = GST_PAD_CAST (data);
316 pad = gst_pad_realize (pad);
317 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
318 !gst_element_is_locked_state (GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
319 unlocked_peer = TRUE;
322 gst_object_unref (GST_OBJECT (pad));
325 case GST_ITERATOR_RESYNC:
326 unlocked_peer = FALSE;
327 gst_iterator_resync (pads);
329 case GST_ITERATOR_DONE:
333 g_assert_not_reached ();
337 gst_iterator_free (pads);
339 if (!(lock && unlocked_peer)) {
340 GST_CAT_DEBUG (GST_CAT_PIPELINE, "setting locked state on element");
341 gst_element_set_locked_state (element, lock);
344 /* try to sync state with parent */
345 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying to sync state of element with parent");
346 /* FIXME: it would be nice if we can figure out why it failed
347 (e.g. caps nego) and give an error about that instead. */
348 if (gst_element_set_state (element, GST_STATE_PLAYING) == GST_STATE_FAILURE)
349 GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
355 /* check if there are other pads to (un)lock */
356 walk = (GList *) element->pads;
357 for (; walk; walk = walk->next) {
358 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
359 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
360 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
361 if (gst_element_is_locked_state (next) != lock)
362 gst_parse_element_lock (next, lock);
367 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
369 DelayedLink *link = (DelayedLink *) data;
371 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
372 GST_ELEMENT_NAME (src), link->src_pad,
373 GST_ELEMENT_NAME (link->sink), link->sink_pad);
375 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink, link->sink_pad, link->caps)) {
376 /* do this here, we don't want to get any problems later on when unlocking states */
377 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
378 GST_ELEMENT_NAME (src), link->src_pad,
379 GST_ELEMENT_NAME (link->sink), link->sink_pad);
380 g_signal_handler_disconnect (src, link->signal_id);
381 g_free (link->src_pad);
382 g_free (link->sink_pad);
383 if (link->caps) gst_caps_unref (link->caps);
384 if (!gst_element_is_locked_state (src))
385 gst_parse_element_lock (link->sink, FALSE);
389 /* both padnames and the caps may be NULL */
391 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
392 GstElement *sink, const gchar *sink_pad, GstCaps *caps)
394 GList *templs = gst_element_class_get_pad_template_list (GST_ELEMENT_GET_CLASS (src));
396 for (; templs; templs = templs->next) {
397 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
398 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
400 DelayedLink *data = g_new (DelayedLink, 1);
402 /* TODO: maybe we should check if src_pad matches this template's names */
404 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
405 GST_ELEMENT_NAME (src), src_pad, GST_ELEMENT_NAME (sink), sink_pad);
407 data->src_pad = g_strdup (src_pad);
409 data->sink_pad = g_strdup (sink_pad);
411 data->caps = gst_caps_copy (caps);
415 data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
416 G_CALLBACK (gst_parse_found_pad), data);
423 * performs a link and frees the struct. src and sink elements must be given
424 * return values 0 - link performed
429 gst_parse_perform_link (link_t *link, graph_t *graph)
431 GstElement *src = link->src;
432 GstElement *sink = link->sink;
433 GSList *srcs = link->src_pads;
434 GSList *sinks = link->sink_pads;
435 g_assert (GST_IS_ELEMENT (src));
436 g_assert (GST_IS_ELEMENT (sink));
438 GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s:%s to %s:%s (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
439 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "(any)",
440 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "(any)",
441 g_slist_length (srcs), g_slist_length (sinks),
444 if (!srcs || !sinks) {
445 if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL,
446 sink, sinks ? (const gchar *) sinks->data : NULL,
448 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
451 if (gst_parse_perform_delayed_link (src, srcs ? (const gchar *) srcs->data : NULL,
452 sink, sinks ? (const gchar *) sinks->data : NULL,
454 gst_parse_element_lock (sink, TRUE);
461 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
464 while (srcs && sinks) {
465 const gchar *src_pad = (const gchar *) srcs->data;
466 const gchar *sink_pad = (const gchar *) sinks->data;
467 srcs = g_slist_next (srcs);
468 sinks = g_slist_next (sinks);
469 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad, link->caps)) {
470 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
473 if (gst_parse_perform_delayed_link (src, src_pad,
476 gst_parse_element_lock (sink, TRUE);
485 gst_parse_free_link (link);
489 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not link %s to %s"), GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
490 gst_parse_free_link (link);
495 static int yylex (void *lvalp);
496 static int yyerror (const char *s);
509 %token <s> IDENTIFIER
510 %left <s> REF PADREF BINREF
511 %token <s> ASSIGNMENT
517 %type <l> linkpart link
520 %type <p> padlist pads assignments
522 %left '{' '}' '(' ')'
532 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
534 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1);
535 gst_parse_strfree ($1);
539 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
543 assignments: /* NOP */ { $$ = NULL; }
544 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
546 bin: '{' assignments chain '}' { GST_BIN_MAKE ($$, "thread", $3, $2); }
547 | '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
548 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
549 gst_parse_strfree ($1);
551 | '{' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
552 | '(' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
553 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
554 gst_parse_strfree ($1);
556 | '{' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
557 | '(' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
558 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
559 gst_parse_strfree ($1);
563 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
564 | PADREF padlist { $$ = $2;
565 $$ = g_slist_prepend ($$, $1);
568 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
569 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
572 reference: REF { MAKE_REF ($$, $1, NULL); }
573 | REF padlist { MAKE_REF ($$, $1, $2); }
576 linkpart: reference { $$ = $1; }
577 | pads { MAKE_REF ($$, NULL, $1); }
578 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
581 link: linkpart LINK linkpart { $$ = $1;
583 $$->caps = gst_caps_from_string ($2);
585 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2);
586 gst_parse_strfree ($2);
588 $$->sink_name = $3->src_name;
589 $$->sink_pads = $3->src_pads;
590 gst_parse_link_free ($3);
594 linklist: link { $$ = g_slist_prepend (NULL, $1); }
595 | link linklist { $$ = g_slist_prepend ($2, $1); }
596 | linklist error { $$ = $1; }
599 chain: element { $$ = gst_parse_chain_new ();
600 $$->first = $$->last = $1;
601 $$->front = $$->back = NULL;
602 $$->elements = g_slist_prepend (NULL, $1);
605 | chain chain { if ($1->back && $2->front) {
606 if (!$1->back->sink_name) {
607 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
608 gst_parse_free_link ($1->back);
610 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
612 if (!$2->front->src_name) {
613 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
614 gst_parse_free_link ($2->front);
616 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
619 } else if ($1->back) {
620 if (!$1->back->sink_name) {
621 $1->back->sink = $2->first;
623 } else if ($2->front) {
624 if (!$2->front->src_name) {
625 $2->front->src = $1->last;
627 $1->back = $2->front;
631 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
635 $1->elements = g_slist_concat ($1->elements, $2->elements);
637 gst_parse_chain_free ($2);
640 | chain linklist { GSList *walk;
642 $2 = g_slist_prepend ($2, $1->back);
645 if (!((link_t *) $2->data)->src_name) {
646 ((link_t *) $2->data)->src = $1->last;
649 for (walk = $2; walk; walk = walk->next) {
650 link_t *link = (link_t *) walk->data;
651 if (!link->sink_name && walk->next) {
652 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
653 gst_parse_free_link (link);
654 } else if (!link->src_name && !link->src) {
655 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
656 gst_parse_free_link (link);
659 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
668 | chain error { $$ = $1; }
669 | link chain { if ($2->front) {
670 if (!$2->front->src_name) {
671 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
672 gst_parse_free_link ($2->front);
674 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
677 if (!$1->sink_name) {
678 $1->sink = $2->first;
683 | PARSE_URL chain { $$ = $2;
685 GstElement *element =
686 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
688 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
689 _("no source element for URI \"%s\""), $1);
691 $$->front->src = element;
692 ((graph_t *) graph)->links = g_slist_prepend (
693 ((graph_t *) graph)->links, $$->front);
695 $$->elements = g_slist_prepend ($$->elements, element);
698 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
699 _("no element to link URI \"%s\" to"), $1);
703 | link PARSE_URL { GstElement *element =
704 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
706 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
707 _("no sink element for URI \"%s\""), $2);
709 } else if ($1->sink_name || $1->sink_pads) {
710 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
711 _("could not link sink element for URI \"%s\""), $2);
714 $$ = gst_parse_chain_new ();
715 $$->first = $$->last = element;
717 $$->front->sink = element;
718 $$->elements = g_slist_prepend (NULL, element);
723 graph: /* NOP */ { SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
724 $$ = (graph_t *) graph;
726 | chain { $$ = (graph_t *) graph;
728 if (!$1->front->src_name) {
729 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without source element"));
730 gst_parse_free_link ($1->front);
732 $$->links = g_slist_prepend ($$->links, $1->front);
737 if (!$1->back->sink_name) {
738 SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("link without sink element"));
739 gst_parse_free_link ($1->back);
741 $$->links = g_slist_prepend ($$->links, $1->back);
751 extern FILE *_gst_parse_yyin;
752 int _gst_parse_yylex (YYSTYPE *lvalp);
754 static int yylex (void *lvalp) {
755 return _gst_parse_yylex ((YYSTYPE*) lvalp);
759 yyerror (const char *s)
761 /* FIXME: This should go into the GError somehow, but how? */
762 g_warning ("error: %s", s);
766 struct yy_buffer_state * _gst_parse_yy_scan_string (char*);
767 void _gst_parse_yy_delete_buffer (struct yy_buffer_state *);
769 _gst_parse_launch (const gchar *str, GError **error)
776 struct yy_buffer_state *buf;
778 g_return_val_if_fail (str != NULL, NULL);
784 #ifdef __GST_PARSE_TRACE
785 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
786 __strings = __chains = __links = 0;
787 #endif /* __GST_PARSE_TRACE */
789 dstr = g_strdup (str);
790 buf = _gst_parse_yy_scan_string (dstr);
792 #ifndef GST_DISABLE_GST_DEBUG
796 if (yyparse (&g) != 0) {
797 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX, "Unrecoverable syntax error while parsing pipeline %s", str);
802 _gst_parse_yy_delete_buffer (buf);
804 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));
808 } else if (!(((chain_t *) g.chain)->elements->next)) {
809 /* only one toplevel element */
810 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
811 g_slist_free (((chain_t *) g.chain)->elements);
812 if (GST_IS_BIN (ret))
814 gst_parse_chain_free (g.chain);
816 /* put all elements in our bin */
817 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
820 for (walk = g.chain->elements; walk; walk = walk->next)
821 gst_bin_add (bin, GST_ELEMENT (walk->data));
823 g_slist_free (g.chain->elements);
824 ret = GST_ELEMENT (bin);
825 gst_parse_chain_free (g.chain);
829 for (walk = g.links; walk; walk = walk->next) {
830 link_t *l = (link_t *) walk->data;
834 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
836 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
840 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->src_name);
841 gst_parse_free_link (l);
848 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
850 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
854 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->sink_name);
855 gst_parse_free_link (l);
859 gst_parse_perform_link (l, &g);
861 g_slist_free (g.links);
864 #ifdef __GST_PARSE_TRACE
865 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
866 if (__strings || __chains || __links) {
867 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
869 #endif /* __GST_PARSE_TRACE */
877 g_slist_foreach (g.chain->elements, (GFunc)gst_object_unref, NULL);
878 g_slist_free (g.chain->elements);
879 gst_parse_chain_free (g.chain);
882 g_slist_foreach (g.links, (GFunc)gst_parse_free_link, NULL);
883 g_slist_free (g.links);