2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2002 Andy Wingo <wingo@pobox.com>
6 * gstparse.c: get a pipeline from a text pipeline description
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 * @short_description: Get a pipeline from a text pipeline description
28 * These function allow to create a pipeline based on the syntax used in the
29 * gst-launch utillity.
33 #include "gst_private.h"
40 extern GstElement *_gst_parse_launch (const gchar *, GError **);
43 * gst_parse_error_quark:
45 * Get the error quark used by the parsing subsystem.
47 * Returns: the quark of the parse errors.
50 gst_parse_error_quark (void)
52 static GQuark quark = 0;
55 quark = g_quark_from_static_string ("gst_parse_error");
59 #ifndef GST_DISABLE_PARSE
61 _gst_parse_escape (const gchar * str)
66 g_return_val_if_fail (str != NULL, NULL);
68 gstr = g_string_sized_new (strlen (str));
72 g_string_append_c (gstr, '\\');
73 g_string_append_c (gstr, *str);
78 g_string_free (gstr, FALSE);
82 #endif /* !GST_DISABLE_PARSE */
86 * @argv: null-terminated array of arguments
87 * @error: pointer to a #GError
89 * Create a new element based on command line syntax.
90 * @error will contain an error message if an erroneuos pipeline is specified.
91 * An error does not mean that the pipeline could not be constructed.
93 * Returns: a new element on success and %NULL on failure.
96 gst_parse_launchv (const gchar ** argv, GError ** error)
98 #ifndef GST_DISABLE_PARSE
101 const gchar **argvp, *arg;
104 g_return_val_if_fail (argv != NULL, NULL);
106 /* let's give it a nice size. */
107 str = g_string_sized_new (1024);
112 tmp = _gst_parse_escape (arg);
113 g_string_append (str, tmp);
115 g_string_append (str, " ");
119 element = gst_parse_launch (str->str, error);
121 g_string_free (str, TRUE);
127 GST_WARNING ("Disabled API called: gst_parse_launchv()");
129 msg = gst_error_get_message (GST_CORE_ERROR, GST_CORE_ERROR_DISABLED);
130 g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_DISABLED, "%s", msg);
139 * @pipeline_description: the command line describing the pipeline
140 * @error: the error message in case of an erroneous pipeline.
142 * Create a new pipeline based on command line syntax.
143 * Please note that you might get a return value that is not %NULL even though
144 * the @error is set. In this case there was a recoverable parsing error and you
145 * can try to play the pipeline.
147 * Returns: a new element on success, %NULL on failure. If more than one toplevel
148 * element is specified by the @pipeline_description, all elements are put into
149 * a #GstPipeline, which than is returned.
152 gst_parse_launch (const gchar * pipeline_description, GError ** error)
154 #ifndef GST_DISABLE_PARSE
157 g_return_val_if_fail (pipeline_description != NULL, NULL);
159 GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s",
160 pipeline_description);
162 element = _gst_parse_launch (pipeline_description, error);
168 GST_WARNING ("Disabled API called: gst_parse_launch()");
170 msg = gst_error_get_message (GST_CORE_ERROR, GST_CORE_ERROR_DISABLED);
171 g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_DISABLED, "%s", msg);