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_LOG (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_LOG (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)
228 /* parse the string, so the property name is null-terminated an pos points
229 to the beginning of the value */
230 while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
236 while (g_ascii_isspace (*pos)) pos++;
239 while (g_ascii_isspace (*pos)) pos++;
242 pos[strlen (pos) - 1] = '\0';
244 gst_parse_unescape (pos);
245 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);
325 if (G_IS_VALUE (&v2))
330 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
331 _("could not set property \"%s\" in element \"%s\" to \"%s\""),
332 value, GST_ELEMENT_NAME (element), pos);
335 ERROR (GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
336 _("could not convert \"%s\" so that it fits property \"%s\" in element \"%s\""),
337 pos, value, GST_ELEMENT_NAME (element));
341 gst_parse_free_link (link_t *link)
343 gst_parse_strfree (link->src_name);
344 gst_parse_strfree (link->sink_name);
345 g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
346 g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
347 g_slist_free (link->src_pads);
348 g_slist_free (link->sink_pads);
349 if (link->caps) gst_caps_free (link->caps);
350 gst_parse_link_free (link);
353 gst_parse_element_lock (GstElement *element, gboolean lock)
356 GList *walk = (GList *) gst_element_get_pad_list (element);
357 gboolean unlocked_peer = FALSE;
359 if (gst_element_is_locked_state (element) == lock)
361 /* check if we have an unlocked peer */
363 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
365 if (GST_PAD_IS_SINK (pad) && GST_PAD_PEER (pad) &&
366 !gst_element_is_locked_state (GST_PAD_PARENT (GST_PAD_PEER (pad)))) {
367 unlocked_peer = TRUE;
372 if (!(lock && unlocked_peer)) {
373 gst_element_set_locked_state (element, lock);
375 gst_element_sync_state_with_parent (element);
380 /* check if there are other pads to (un)lock */
381 walk = (GList *) gst_element_get_pad_list (element);
383 pad = (GstPad *) GST_PAD_REALIZE (walk->data);
385 if (GST_PAD_IS_SRC (pad) && GST_PAD_PEER (pad)) {
386 GstElement *next = GST_ELEMENT (GST_OBJECT_PARENT (GST_PAD_PEER (pad)));
387 if (gst_element_is_locked_state (next) != lock)
388 gst_parse_element_lock (next, lock);
393 gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
395 DelayedLink *link = (DelayedLink *) data;
397 GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
398 GST_ELEMENT_NAME (src), link->src_pad,
399 GST_ELEMENT_NAME (link->sink), link->sink_pad);
401 if (gst_element_link_pads_filtered (src, link->src_pad, link->sink, link->sink_pad, link->caps)) {
402 /* do this here, we don't want to get any problems later on when unlocking states */
403 GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
404 GST_ELEMENT_NAME (src), link->src_pad,
405 GST_ELEMENT_NAME (link->sink), link->sink_pad);
406 g_signal_handler_disconnect (src, link->signal_id);
407 g_free (link->src_pad);
408 g_free (link->sink_pad);
409 if (link->caps) gst_caps_free (link->caps);
410 if (!gst_element_is_locked_state (src))
411 gst_parse_element_lock (link->sink, FALSE);
415 /* both padnames and the caps may be NULL */
417 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
418 GstElement *sink, const gchar *sink_pad, GstCaps *caps)
420 GList *templs = gst_element_get_pad_template_list (src);
423 GstPadTemplate *templ = (GstPadTemplate *) templs->data;
424 if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
426 DelayedLink *data = g_new (DelayedLink, 1);
428 /* TODO: maybe we should check if src_pad matches this template's names */
430 GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
431 GST_ELEMENT_NAME (src), src_pad, GST_ELEMENT_NAME (sink), sink_pad);
433 data->src_pad = g_strdup (src_pad);
435 data->sink_pad = g_strdup (sink_pad);
437 data->caps = gst_caps_copy (caps);
441 data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",
442 G_CALLBACK (gst_parse_found_pad), data);
445 templs = g_list_next (templs);
450 * performs a link and frees the struct. src and sink elements must be given
451 * return values 0 - link performed
456 gst_parse_perform_link (link_t *link, graph_t *graph)
458 GstElement *src = link->src;
459 GstElement *sink = link->sink;
460 GSList *srcs = link->src_pads;
461 GSList *sinks = link->sink_pads;
462 g_assert (GST_IS_ELEMENT (src));
463 g_assert (GST_IS_ELEMENT (sink));
465 GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s:%s to %s:%s (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
466 GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "(any)",
467 GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "(any)",
468 g_slist_length (srcs), g_slist_length (sinks),
471 if (!srcs || !sinks) {
472 if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL,
473 sink, sinks ? (const gchar *) sinks->data : NULL,
475 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
478 if (gst_parse_perform_delayed_link (src, srcs ? (const gchar *) srcs->data : NULL,
479 sink, sinks ? (const gchar *) sinks->data : NULL,
481 gst_parse_element_lock (sink, TRUE);
488 if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
491 while (srcs && sinks) {
492 const gchar *src_pad = (const gchar *) srcs->data;
493 const gchar *sink_pad = (const gchar *) sinks->data;
494 srcs = g_slist_next (srcs);
495 sinks = g_slist_next (sinks);
496 if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad, link->caps)) {
497 gst_parse_element_lock (sink, gst_element_is_locked_state (src));
500 if (gst_parse_perform_delayed_link (src, src_pad,
503 gst_parse_element_lock (sink, TRUE);
512 gst_parse_free_link (link);
516 ERROR (GST_PARSE_ERROR_LINK, _("could not link %s to %s"), GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
517 gst_parse_free_link (link);
522 static int yylex (void *lvalp);
523 static int yyerror (const char *s);
536 %token <s> IDENTIFIER
537 %left <s> REF PADREF BINREF
538 %token <s> ASSIGNMENT
544 %type <l> linkpart link
547 %type <p> padlist pads assignments
549 %left '{' '}' '(' ')'
559 element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL);
561 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1);
562 gst_parse_strfree ($1);
566 | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph);
570 assignments: /* NOP */ { $$ = NULL; }
571 | assignments ASSIGNMENT { $$ = g_slist_prepend ($1, $2); }
573 bin: '{' assignments chain '}' { GST_BIN_MAKE ($$, "thread", $3, $2); }
574 | '(' assignments chain ')' { GST_BIN_MAKE ($$, "bin", $3, $2); }
575 | BINREF assignments chain ')' { GST_BIN_MAKE ($$, $1, $3, $2);
576 gst_parse_strfree ($1);
578 | '{' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
579 | '(' assignments '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
580 | BINREF assignments ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
581 gst_parse_strfree ($1);
583 | '{' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
584 | '(' assignments error '}' { GST_BIN_MAKE ($$, "thread", NULL, $2); }
585 | BINREF assignments error ')' { GST_BIN_MAKE ($$, $1, NULL, $2);
586 gst_parse_strfree ($1);
590 pads: PADREF { $$ = g_slist_prepend (NULL, $1); }
591 | PADREF padlist { $$ = $2;
592 $$ = g_slist_prepend ($$, $1);
595 padlist: ',' IDENTIFIER { $$ = g_slist_prepend (NULL, $2); }
596 | ',' IDENTIFIER padlist { $$ = g_slist_prepend ($3, $2); }
599 reference: REF { MAKE_REF ($$, $1, NULL); }
600 | REF padlist { MAKE_REF ($$, $1, $2); }
603 linkpart: reference { $$ = $1; }
604 | pads { MAKE_REF ($$, NULL, $1); }
605 | /* NOP */ { MAKE_REF ($$, NULL, NULL); }
608 link: linkpart LINK linkpart { $$ = $1;
610 $$->caps = gst_caps_from_string ($2);
612 ERROR (GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2);
613 gst_parse_strfree ($2);
615 $$->sink_name = $3->src_name;
616 $$->sink_pads = $3->src_pads;
617 gst_parse_link_free ($3);
621 linklist: link { $$ = g_slist_prepend (NULL, $1); }
622 | link linklist { $$ = g_slist_prepend ($2, $1); }
623 | linklist error { $$ = $1; }
626 chain: element { $$ = gst_parse_chain_new ();
627 $$->first = $$->last = $1;
628 $$->front = $$->back = NULL;
629 $$->elements = g_slist_prepend (NULL, $1);
632 | chain chain { if ($1->back && $2->front) {
633 if (!$1->back->sink_name) {
634 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
635 gst_parse_free_link ($1->back);
637 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
639 if (!$2->front->src_name) {
640 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
641 gst_parse_free_link ($2->front);
643 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
646 } else if ($1->back) {
647 if (!$1->back->sink_name) {
648 $1->back->sink = $2->first;
650 } else if ($2->front) {
651 if (!$2->front->src_name) {
652 $2->front->src = $1->last;
654 $1->back = $2->front;
658 if (!$1->back->sink || !$1->back->src) {
659 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $1->back);
662 gst_parse_perform_link ($1->back, (graph_t *) graph);
667 $1->elements = g_slist_concat ($1->elements, $2->elements);
668 gst_parse_chain_free ($2);
671 | chain linklist { GSList *walk;
673 $2 = g_slist_prepend ($2, $1->back);
676 if (!((link_t *) $2->data)->src_name) {
677 ((link_t *) $2->data)->src = $1->last;
682 link_t *link = (link_t *) walk->data;
684 if (!link->sink_name && walk) {
685 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
686 gst_parse_free_link (link);
687 } else if (!link->src_name && !link->src) {
688 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
689 gst_parse_free_link (link);
692 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, link);
701 | chain error { $$ = $1; }
702 | link chain { if ($2->front) {
703 if (!$2->front->src_name) {
704 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
705 gst_parse_free_link ($2->front);
707 ((graph_t *) graph)->links = g_slist_prepend (((graph_t *) graph)->links, $2->front);
710 if (!$1->sink_name) {
711 $1->sink = $2->first;
716 | PARSE_URL chain { $$ = $2;
718 GstElement *element =
719 gst_element_make_from_uri (GST_URI_SRC, $1, NULL);
721 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
722 _("no source element for URI \"%s\""), $1);
724 $$->front->src = element;
725 ((graph_t *) graph)->links = g_slist_prepend (
726 ((graph_t *) graph)->links, $$->front);
728 $$->elements = g_slist_prepend ($$->elements, element);
731 ERROR (GST_PARSE_ERROR_LINK,
732 _("no element to link URI \"%s\" to"), $1);
736 | link PARSE_URL { GstElement *element =
737 gst_element_make_from_uri (GST_URI_SINK, $2, NULL);
739 ERROR (GST_PARSE_ERROR_NO_SUCH_ELEMENT,
740 _("no sink element for URI \"%s\""), $2);
742 } else if ($1->sink_name || $1->sink_pads) {
743 ERROR (GST_PARSE_ERROR_LINK,
744 _("could not link sink element for URI \"%s\""), $2);
747 $$ = gst_parse_chain_new ();
748 $$->first = $$->last = element;
750 $$->front->sink = element;
751 $$->elements = g_slist_prepend (NULL, element);
756 graph: /* NOP */ { ERROR (GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
757 $$ = (graph_t *) graph;
759 | chain { $$ = (graph_t *) graph;
761 if (!$1->front->src_name) {
762 ERROR (GST_PARSE_ERROR_LINK, _("link without source element"));
763 gst_parse_free_link ($1->front);
765 $$->links = g_slist_prepend ($$->links, $1->front);
770 if (!$1->back->sink_name) {
771 ERROR (GST_PARSE_ERROR_LINK, _("link without sink element"));
772 gst_parse_free_link ($1->back);
774 $$->links = g_slist_prepend ($$->links, $1->back);
784 extern FILE *_gst_parse_yyin;
785 int _gst_parse_yylex (YYSTYPE *lvalp);
787 static int yylex (void *lvalp) {
788 return _gst_parse_yylex ((YYSTYPE*) lvalp);
792 yyerror (const char *s)
794 /* FIXME: This should go into the GError somehow, but how? */
795 g_warning ("error: %s", s);
799 int _gst_parse_yy_scan_string (char*);
801 _gst_parse_launch (const gchar *str, GError **error)
809 g_return_val_if_fail (str != NULL, NULL);
815 #ifdef __GST_PARSE_TRACE
816 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
817 __strings = __chains = __links = 0;
818 #endif /* __GST_PARSE_TRACE */
820 dstr = g_strdup (str);
821 _gst_parse_yy_scan_string (dstr);
823 #ifndef GST_DISABLE_GST_DEBUG
827 if (yyparse (&g) != 0) {
828 SET_ERROR (error, GST_PARSE_ERROR_SYNTAX, "Unrecoverable syntax error while parsing pipeline");
834 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));
838 } else if (!(((chain_t *) g.chain)->elements->next)) {
839 /* only one toplevel element */
840 ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
841 g_slist_free (((chain_t *) g.chain)->elements);
842 if (GST_IS_BIN (ret))
845 /* put all elements in our bin */
846 bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
848 walk = g.chain->elements;
850 gst_bin_add (bin, GST_ELEMENT (walk->data));
851 walk = g_slist_next (walk);
853 g_slist_free (g.chain->elements);
854 ret = GST_ELEMENT (bin);
856 gst_parse_chain_free (g.chain);
861 link_t *l = (link_t *) walk->data;
863 walk = g_slist_next (walk);
867 l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
869 l->src = strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
873 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->src_name);
874 gst_parse_free_link (l);
881 l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
883 l->sink = strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
887 SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, "No element named \"%s\" - omitting link", l->sink_name);
888 gst_parse_free_link (l);
893 gst_parse_perform_link (l, &g);
895 g_slist_free (g.links);
898 #ifdef __GST_PARSE_TRACE
899 GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
900 if (__strings || __chains || __links) {
901 g_warning ("TRACE: %u strings, %u chains and %u links left", __strings, __chains, __links);
903 #endif /* __GST_PARSE_TRACE */
911 walk = g.chain->elements;
913 gst_object_unref (GST_OBJECT (walk->data));
916 g_slist_free (g.chain->elements);
918 gst_parse_chain_free (g.chain);
922 gst_parse_free_link ((link_t *) walk->data);
925 g_slist_free (g.links);