2007-05-09 Tim-Philipp Müller <tim at centricular dot net>
+ Based on patch by: Peter Kjellerstedt <pkj at axis com>
+
+ * gst/Makefile.am:
+ * gst/gstparse.c: (gst_parse_launchv), (gst_parse_launch):
+ * gst/gstparse.h:
+ * gst/gstutils.c: (gst_parse_bin_from_description):
+ * gst/gstutils.h:
+ Maintain API and ABI when --disable-parse is used. Now that
+ we have an appropriate error code, we can just return NULL and the
+ appropriate error when gst_parse_launch() is used despite it having
+ been disabled (#342564).
+
+ * tests/check/Makefile.am:
+ * tests/check/pipelines/.cvsignore:
+ * tests/check/pipelines/parse-disabled.c:
+ Make sure these functions exist and return NULL plus a GError when
+ --disable-parse is used.
+
+2007-05-09 Tim-Philipp Müller <tim at centricular dot net>
+
* tests/benchmarks/complexity.c: (main):
* tests/benchmarks/mass-elements.c: (main):
Set a good example and don't leak messages.
endif
if GST_DISABLE_PARSE
-GST_PARSE_SRC =
-GST_PARSE_H =
SUBDIRS_PARSE =
GST_PARSE_LA =
else
-GST_PARSE_SRC = gstparse.c
-GST_PARSE_H = gstparse.h
SUBDIRS_PARSE = parse
GST_PARSE_LA = parse/libgstparse.la
endif
built_source_make = $(GST_ENUMTYPES_SRC) gstmarshal.c
EXTRA_libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
- gstmarshal.list gstparse.c gsttrace.c gstxml.c \
+ gstmarshal.list gsttrace.c gstxml.c \
gstregistryxml.c gstregistrybinary.c
$(GST_URI_SRC) \
gstutils.c \
gstvalue.c \
- $(GST_PARSE_SRC) \
+ gstparse.c \
$(GST_REGISTRY_SRC) \
$(GST_LOADSAVE_SRC)
gstutils.h \
gstvalue.h \
gstregistry.h \
- $(GST_PARSE_H) \
+ gstparse.h \
gstxml.h
libgstreamer_@GST_MAJORMINOR@include_HEADERS = $(gst_headers)
nodist_libgstreamer_@GST_MAJORMINOR@include_HEADERS = \
$(built_header_configure) $(built_header_make)
-EXTRA_DIST = \
- gstparse.h
-
noinst_HEADERS = \
gettext.h \
glib-compat-private.h \
#include <string.h>
#include "gstparse.h"
+#include "gsterror.h"
#include "gstinfo.h"
extern GstElement *_gst_parse_launch (const gchar *, GError **);
return quark;
}
+#ifndef GST_DISABLE_PARSE
static gchar *
_gst_parse_escape (const gchar * str)
{
return newstr;
}
+#endif /* !GST_DISABLE_PARSE */
/**
* gst_parse_launchv:
GstElement *
gst_parse_launchv (const gchar ** argv, GError ** error)
{
+#ifndef GST_DISABLE_PARSE
GstElement *element;
GString *str;
const gchar **argvp, *arg;
g_string_free (str, TRUE);
return element;
+#else
+ gchar *msg;
+
+ GST_WARNING ("Disabled API called: gst_parse_launchv()");
+
+ msg = gst_error_get_message (GST_CORE_ERROR, GST_CORE_ERROR_DISABLED);
+ g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_DISABLED, "%s", msg);
+ g_free (msg);
+
+ return NULL;
+#endif
}
/**
GstElement *
gst_parse_launch (const gchar * pipeline_description, GError ** error)
{
+#ifndef GST_DISABLE_PARSE
GstElement *element;
g_return_val_if_fail (pipeline_description != NULL, NULL);
element = _gst_parse_launch (pipeline_description, error);
return element;
+#else
+ gchar *msg;
+
+ GST_WARNING ("Disabled API called: gst_parse_launch()");
+
+ msg = gst_error_get_message (GST_CORE_ERROR, GST_CORE_ERROR_DISABLED);
+ g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_DISABLED, "%s", msg);
+ g_free (msg);
- /* ERRORS */
+ return NULL;
+#endif
}
#ifndef __GST_PARSE_H__
#define __GST_PARSE_H__
-#include <gst/gstconfig.h>
-
#include <gst/gstelement.h>
G_BEGIN_DECLS
-#ifndef GST_DISABLE_PARSE
-
GQuark gst_parse_error_quark (void);
/**
* GST_PARSE_ERROR:
GstElement* gst_parse_launch (const gchar *pipeline_description, GError **error);
GstElement* gst_parse_launchv (const gchar **argv, GError **error);
-#else /* GST_DISABLE_PARSE */
-
-#if defined _GNUC_ && _GNUC_ >= 3
-#pragma GCC poison gst_parse_launch
-#pragma GCC poison gst_parse_launchv
-#endif
-
-#endif /* GST_DISABLE_PARSE */
-
G_END_DECLS
#endif /* __GST_PARSE_H__ */
#include "gstghostpad.h"
#include "gstutils.h"
+#include "gsterror.h"
#include "gstinfo.h"
#include "gstparse.h"
#include "gst-i18n-lib.h"
return pad;
}
-#ifndef GST_DISABLE_PARSE
/**
* gst_parse_bin_from_description:
* @bin_description: command line describing the bin
gst_parse_bin_from_description (const gchar * bin_description,
gboolean ghost_unconnected_pads, GError ** err)
{
+#ifndef GST_DISABLE_PARSE
GstPad *pad = NULL;
GstBin *bin;
gchar *desc;
}
return GST_ELEMENT (bin);
-}
+#else
+ gchar *msg;
+
+ GST_WARNING ("Disabled API called: gst_parse_bin_from_description()");
+
+ msg = gst_error_get_message (GST_CORE_ERROR, GST_CORE_ERROR_DISABLED);
+ g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_DISABLED, "%s", msg);
+ g_free (msg);
+
+ return NULL;
#endif
+}
#ifndef __GST_UTILS_H__
#define __GST_UTILS_H__
-#include <gst/gstconfig.h>
-
#include <glib.h>
#include <gst/gstbin.h>
void gst_element_found_tags (GstElement * element,
GstTagList * list);
-#ifndef GST_DISABLE_PARSE
/* parse utility functions */
GstElement * gst_parse_bin_from_description (const gchar * bin_description,
gboolean ghost_unconnected_pads,
GError ** err);
-#else /* GST_DISABLE_PARSE */
-
-#if defined _GNUC_ && _GNUC_ >= 3
-#pragma GCC poison gst_parse_bin_from_description
-#endif
-
-#endif
G_END_DECLS
clean-local: clean-local-check
if GST_DISABLE_PARSE
-PARSE_CHECKS =
+PARSE_CHECKS = pipelines/parse-disabled
else
PARSE_CHECKS = pipelines/simple-launch-lines pipelines/cleanup pipelines/parse-launch
endif
stress
parse-launch
*.check.xml
+parse-disabled
--- /dev/null
+/* GStreamer unit test for disabled gst-parse
+ * Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
+ * *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gst/check/gstcheck.h>
+
+#include <gst/gstconfig.h>
+
+GST_START_TEST (test_parse_launch_errors)
+{
+ GstElement *pipe;
+ GError *err;
+ const gchar *arr[] = { "fakesrc", "fakesink", NULL };
+
+ err = NULL;
+ pipe = gst_parse_launch ("fakesrc ! fakesink", &err);
+ fail_unless (err != NULL, "expected an error, but did not get one");
+ fail_unless (pipe == NULL, "got pipeline, but expected NULL");
+ fail_unless (err->domain == GST_CORE_ERROR);
+ fail_unless (err->code == GST_CORE_ERROR_DISABLED);
+ g_error_free (err);
+
+ err = NULL;
+ pipe = gst_parse_bin_from_description ("fakesrc ! fakesink", TRUE, &err);
+ fail_unless (err != NULL, "expected an error, but did not get one");
+ fail_unless (pipe == NULL, "got pipeline, but expected NULL");
+ fail_unless (err->domain == GST_CORE_ERROR);
+ fail_unless (err->code == GST_CORE_ERROR_DISABLED);
+ g_error_free (err);
+
+ err = NULL;
+ pipe = gst_parse_launchv (arr, &err);
+ fail_unless (err != NULL, "expected an error, but did not get one");
+ fail_unless (pipe == NULL, "got pipeline, but expected NULL");
+ fail_unless (err->domain == GST_CORE_ERROR);
+ fail_unless (err->code == GST_CORE_ERROR_DISABLED);
+ g_error_free (err);
+}
+
+GST_END_TEST;
+
+static Suite *
+parsedisabled_suite (void)
+{
+ Suite *s = suite_create ("Parse Launch (Disabled Mode)");
+ TCase *tc_chain = tcase_create ("parselaunchdisabled");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_parse_launch_errors);
+ return s;
+}
+
+GST_CHECK_MAIN (parsedisabled);