From f38b77d70b6ffa643f09bcf5e81e4cd490f9d410 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Wed, 9 May 2007 16:32:07 +0000 Subject: [PATCH] gst/: Maintain API and ABI when --disable-parse is used. Now that we have an appropriate error code, we can just retu... Original commit message from CVS: Based on patch by: Peter Kjellerstedt * 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. --- ChangeLog | 20 +++++++ gst/Makefile.am | 13 ++--- gst/gstparse.c | 27 +++++++++- gst/gstparse.h | 13 ----- gst/gstutils.c | 15 +++++- gst/gstutils.h | 10 ---- tests/check/Makefile.am | 2 +- tests/check/pipelines/.gitignore | 1 + tests/check/pipelines/parse-disabled.c | 72 ++++++++++++++++++++++++++ 9 files changed, 136 insertions(+), 37 deletions(-) create mode 100644 tests/check/pipelines/parse-disabled.c diff --git a/ChangeLog b/ChangeLog index 24f52078be..8a5d8fd528 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2007-05-09 Tim-Philipp Müller + + Based on patch by: Peter Kjellerstedt + + * 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 * tests/benchmarks/complexity.c: (main): diff --git a/gst/Makefile.am b/gst/Makefile.am index 766d6c3db1..342955318d 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -17,13 +17,9 @@ endif 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 @@ -70,7 +66,7 @@ built_header_make = gstenumtypes.h gstmarshal.h 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 @@ -119,7 +115,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \ $(GST_URI_SRC) \ gstutils.c \ gstvalue.c \ - $(GST_PARSE_SRC) \ + gstparse.c \ $(GST_REGISTRY_SRC) \ $(GST_LOADSAVE_SRC) @@ -199,16 +195,13 @@ gst_headers = \ 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 \ diff --git a/gst/gstparse.c b/gst/gstparse.c index 8bcb5260c0..041f68ad35 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -34,6 +34,7 @@ #include #include "gstparse.h" +#include "gsterror.h" #include "gstinfo.h" extern GstElement *_gst_parse_launch (const gchar *, GError **); @@ -55,6 +56,7 @@ gst_parse_error_quark (void) return quark; } +#ifndef GST_DISABLE_PARSE static gchar * _gst_parse_escape (const gchar * str) { @@ -77,6 +79,7 @@ _gst_parse_escape (const gchar * str) return newstr; } +#endif /* !GST_DISABLE_PARSE */ /** * gst_parse_launchv: @@ -92,6 +95,7 @@ _gst_parse_escape (const gchar * str) GstElement * gst_parse_launchv (const gchar ** argv, GError ** error) { +#ifndef GST_DISABLE_PARSE GstElement *element; GString *str; const gchar **argvp, *arg; @@ -117,6 +121,17 @@ gst_parse_launchv (const gchar ** argv, GError ** error) 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 } /** @@ -136,6 +151,7 @@ gst_parse_launchv (const gchar ** argv, GError ** error) 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); @@ -146,6 +162,15 @@ gst_parse_launch (const gchar * pipeline_description, GError ** error) element = _gst_parse_launch (pipeline_description, error); return element; +#else + gchar *msg; - /* ERRORS */ + 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); + + return NULL; +#endif } diff --git a/gst/gstparse.h b/gst/gstparse.h index b21d1de8fa..39ebfc70b5 100644 --- a/gst/gstparse.h +++ b/gst/gstparse.h @@ -23,14 +23,10 @@ #ifndef __GST_PARSE_H__ #define __GST_PARSE_H__ -#include - #include G_BEGIN_DECLS -#ifndef GST_DISABLE_PARSE - GQuark gst_parse_error_quark (void); /** * GST_PARSE_ERROR: @@ -66,15 +62,6 @@ typedef enum 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__ */ diff --git a/gst/gstutils.c b/gst/gstutils.c index a36f9dca53..f7b32d0a5a 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -34,6 +34,7 @@ #include "gstghostpad.h" #include "gstutils.h" +#include "gsterror.h" #include "gstinfo.h" #include "gstparse.h" #include "gst-i18n-lib.h" @@ -3181,7 +3182,6 @@ gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction) return pad; } -#ifndef GST_DISABLE_PARSE /** * gst_parse_bin_from_description: * @bin_description: command line describing the bin @@ -3208,6 +3208,7 @@ GstElement * 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; @@ -3241,5 +3242,15 @@ gst_parse_bin_from_description (const gchar * bin_description, } 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 +} diff --git a/gst/gstutils.h b/gst/gstutils.h index 1a1c763306..723a04957b 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -25,8 +25,6 @@ #ifndef __GST_UTILS_H__ #define __GST_UTILS_H__ -#include - #include #include @@ -670,18 +668,10 @@ void gst_element_found_tags_for_pad (GstElement * element, 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 diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index c16da59aea..c01ca8770c 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -27,7 +27,7 @@ SUPPRESSIONS = $(top_srcdir)/common/gst.supp 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 diff --git a/tests/check/pipelines/.gitignore b/tests/check/pipelines/.gitignore index ec131885f2..5d73873915 100644 --- a/tests/check/pipelines/.gitignore +++ b/tests/check/pipelines/.gitignore @@ -4,3 +4,4 @@ simple-launch-lines stress parse-launch *.check.xml +parse-disabled diff --git a/tests/check/pipelines/parse-disabled.c b/tests/check/pipelines/parse-disabled.c new file mode 100644 index 0000000000..b70a5f679f --- /dev/null +++ b/tests/check/pipelines/parse-disabled.c @@ -0,0 +1,72 @@ +/* GStreamer unit test for disabled gst-parse + * Copyright (C) 2007 Tim-Philipp Müller + * * + * 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 + +#include + +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);