From: Tim-Philipp Müller Date: Mon, 26 Jul 2010 15:04:02 +0000 (+0200) Subject: pbutils: add compile time and runtime version checks for gst-plugins-base X-Git-Tag: RELEASE-0.10.31~359 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a0c2517eebb7fa935e2e881fc5544c879ec1a00;p=platform%2Fupstream%2Fgst-plugins-base.git pbutils: add compile time and runtime version checks for gst-plugins-base So people can check what version of the gst-plugins-base libs they're building against or linked against. API: GST_PLUGINS_BASE_VERSION_MAJOR API: GST_PLUGINS_BASE_VERSION_MINOR API: GST_PLUGINS_BASE_VERSION_MICRO API: GST_PLUGINS_BASE_VERSION_NANO API: GST_CHECK_PLUGINS_BASE_VERSION API: gst_plugins_base_version() API: gst_plugins_base_version_string() --- diff --git a/.gitignore b/.gitignore index 3b739b87f..005392e43 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ Makefile *.gir *.typelib +gst-libs/gst/pbutils/gstpluginsbaseversion.h gst-libs/gst/tag/mklangtables tmp-orc.c diff --git a/configure.ac b/configure.ac index e6195d180..fdc04f033 100644 --- a/configure.ac +++ b/configure.ac @@ -911,6 +911,7 @@ gst-libs/gst/rtsp/Makefile gst-libs/gst/sdp/Makefile gst-libs/gst/tag/Makefile gst-libs/gst/pbutils/Makefile +gst-libs/gst/pbutils/gstpluginsbaseversion.h gst-libs/gst/video/Makefile tools/Makefile pkgconfig/Makefile diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 8fc9c89a8..b9dc18c34 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -1729,6 +1729,14 @@ gst_tag_get_language_code_iso_639_2T gst/pbutils/pbutils.h gst_pb_utils_init + +GST_PLUGINS_BASE_VERSION_MAJOR +GST_PLUGINS_BASE_VERSION_MINOR +GST_PLUGINS_BASE_VERSION_MICRO +GST_PLUGINS_BASE_VERSION_NANO +GST_CHECK_PLUGINS_BASE_VERSION +gst_plugins_base_version +gst_plugins_base_version_string
diff --git a/gst-libs/gst/pbutils/Makefile.am b/gst-libs/gst/pbutils/Makefile.am index fe635e50c..9c98dadda 100644 --- a/gst-libs/gst/pbutils/Makefile.am +++ b/gst-libs/gst/pbutils/Makefile.am @@ -18,7 +18,11 @@ built_sources = \ built_headers = \ pbutils-enumtypes.h +built_headers_configure = \ + gstpluginsbaseversion.h + libgstpbutils_@GST_MAJORMINOR@_la_SOURCES = \ + gstpluginsbaseversion.c \ pbutils.c \ descriptions.c \ install-plugins.c \ @@ -31,7 +35,7 @@ libgstpbutils_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMIN libgstpbutils_@GST_MAJORMINOR@include_HEADERS = \ $(headers_pbutils) nodist_libgstpbutils_@GST_MAJORMINOR@include_HEADERS = \ - pbutils-enumtypes.h + $(built_headers) $(built_headers_configure) libgstpbutils_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS) libgstpbutils_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) @@ -43,6 +47,8 @@ BUILT_SOURCES = \ CLEANFILES = $(BUILT_SOURCES) +# DISTCLEANFILES is for files generated by configure +DISTCLEANFILES = $(built_header_configure) include $(top_srcdir)/common/gst-glib-gen.mak diff --git a/gst-libs/gst/pbutils/gstpluginsbaseversion.c b/gst-libs/gst/pbutils/gstpluginsbaseversion.c new file mode 100644 index 000000000..997a0b836 --- /dev/null +++ b/gst-libs/gst/pbutils/gstpluginsbaseversion.c @@ -0,0 +1,78 @@ +/* GStreamer base plugins libraries version information + * Copyright (C) 2010 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. + */ + +/** + * SECTION:gstpluginsbaseversion + * @short_description: GStreamer gst-plugins-base libraries version macros. + * + * Use the GST_PLUGINS_BASE_VERSION_* macros e.g. to check what version of + * gst-plugins-base you are building against, and gst_plugins_base_version() + * if you need to check at runtime what version of the gst-plugins-base + * libraries are being used / you are currently linked against. + * + * The version macros get defined by including . + */ + +#include "gstpluginsbaseversion.h" + +/** + * gst_plugins_base_version: + * @major: (out): pointer to a guint to store the major version number, or %NULL + * @minor: (out): pointer to a guint to store the minor version number, or %NULL + * @micro: (out): pointer to a guint to store the micro version number, or %NULL + * @nano: (out): pointer to a guint to store the nano version number, or %NULL + * + * Gets the version number of the GStreamer Plugins Base libraries. + * + * Since: 0.10.31 + */ +void +gst_plugins_base_version (guint * major, guint * minor, guint * micro, + guint * nano) +{ + if (major) + *major = GST_PLUGINS_BASE_VERSION_MAJOR; + if (minor) + *minor = GST_PLUGINS_BASE_VERSION_MINOR; + if (micro) + *micro = GST_PLUGINS_BASE_VERSION_MICRO; + if (nano) + *nano = GST_PLUGINS_BASE_VERSION_NANO; +} + +/** + * gst_plugins_base_version_string: + * + * This function returns a string that is useful for describing this version + * of GStreamer's gst-plugins-base libraries to the outside world: user agent + * strings, logging, about dialogs ... + * + * Returns: a newly allocated string describing this version of gst-plugins-base + * + * Since: 0.10.31 + */ +gchar * +gst_plugins_base_version_string (void) +{ + return g_strdup_printf ("GStreamer Base Plugins %d.%d.%d%s", + GST_PLUGINS_BASE_VERSION_MAJOR, GST_PLUGINS_BASE_VERSION_MINOR, + GST_PLUGINS_BASE_VERSION_MICRO, + ((GST_PLUGINS_BASE_VERSION_NANO == 0) ? "" : + ((GST_PLUGINS_BASE_VERSION_NANO == 1) ? " (GIT)" : " (prerelease)"))); +} diff --git a/gst-libs/gst/pbutils/gstpluginsbaseversion.h.in b/gst-libs/gst/pbutils/gstpluginsbaseversion.h.in new file mode 100644 index 000000000..044932144 --- /dev/null +++ b/gst-libs/gst/pbutils/gstpluginsbaseversion.h.in @@ -0,0 +1,84 @@ +/* GStreamer base plugins libraries version information + * Copyright (C) 2010 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. + */ + +#ifndef __GST_PLUGINS_BASE_VERSION_H__ +#define __GST_PLUGINS_BASE_VERSION_H__ + +#include + +G_BEGIN_DECLS + +/** + * GST_PLUGINS_BASE_VERSION_MAJOR: + * + * The major version of GStreamer's gst-plugins-base libraries at compile time. + * + * Since: 0.10.31 + */ +#define GST_PLUGINS_BASE_VERSION_MAJOR (@PACKAGE_VERSION_MAJOR@) +/** + * GST_PLUGINS_BASE_VERSION_MINOR: + * + * The minor version of GStreamer's gst-plugins-base libraries at compile time. + * + * Since: 0.10.31 + */ +#define GST_PLUGINS_BASE_VERSION_MINOR (@PACKAGE_VERSION_MINOR@) +/** + * GST_PLUGINS_BASE_VERSION_MICRO: + * + * The micro version of GStreamer's gst-plugins-base libraries at compile time. + * + * Since: 0.10.31 + */ +#define GST_PLUGINS_BASE_VERSION_MICRO (@PACKAGE_VERSION_MICRO@) +/** + * GST_PLUGINS_BASE_VERSION_NANO: + * + * The nano version of GStreamer's gst-plugins-base libraries at compile time. + * Actual releases have 0, GIT versions have 1, prerelease versions have 2-... + * + * Since: 0.10.31 + */ +#define GST_PLUGINS_BASE_VERSION_NANO (@PACKAGE_VERSION_NANO@) + +/** + * GST_CHECK_PLUGIN_BASE_VERSION: + * @major: a number indicating the major version + * @minor: a number indicating the minor version + * @micro: a number indicating the micro version + * + * Check whether a GStreamer's gst-plugins-base libraries' version equal to + * or greater than major.minor.micro is present. + * + * Since: 0.10.31 + */ +#define GST_CHECK_PLUGINS_BASE_VERSION(major,minor,micro) \ + (GST_PLUGINS_BASE_VERSION_MAJOR > (major) || \ + (GST_PLUGINS_BASE_VERSION_MAJOR == (major) && GST_PLUGINS_BASE_VERSION_MINOR > (minor)) || \ + (GST_PLUGINS_BASE_VERSION_MAJOR == (major) && GST_PLUGINS_BASE_VERSION_MINOR == (minor) && \ + GST_PLUGINS_BASE_VERSION_MICRO >= (micro))) + +void gst_plugins_base_version (guint *major, guint *minor, guint *micro, guint *nano); + +gchar * gst_plugins_base_version_string (void); + +G_END_DECLS + +#endif /* __GST_PLUGINS_BASE_VERSION_H__ */ diff --git a/gst-libs/gst/pbutils/pbutils.h b/gst-libs/gst/pbutils/pbutils.h index 02f7f6bfc..b0141ec55 100644 --- a/gst-libs/gst/pbutils/pbutils.h +++ b/gst-libs/gst/pbutils/pbutils.h @@ -22,6 +22,7 @@ #include +#include #include #include #include diff --git a/tests/check/libs/pbutils.c b/tests/check/libs/pbutils.c index 84f58e761..ae632214e 100644 --- a/tests/check/libs/pbutils.c +++ b/tests/check/libs/pbutils.c @@ -704,6 +704,33 @@ GST_START_TEST (test_pb_utils_installer_details) GST_END_TEST; +GST_START_TEST (test_pb_utils_versions) +{ + gchar *s; + guint maj, min, mic, nano; + + gst_plugins_base_version (NULL, NULL, NULL, NULL); + gst_plugins_base_version (&maj, &min, &mic, &nano); + fail_unless_equals_int (maj, GST_PLUGINS_BASE_VERSION_MAJOR); + fail_unless_equals_int (min, GST_PLUGINS_BASE_VERSION_MINOR); + fail_unless_equals_int (mic, GST_PLUGINS_BASE_VERSION_MICRO); + fail_unless_equals_int (nano, GST_PLUGINS_BASE_VERSION_NANO); + + s = gst_plugins_base_version_string (); + if (GST_PLUGINS_BASE_VERSION_NANO == 0) { + fail_if (strstr (s, "GIT") || strstr (s, "git") || strstr (s, "prerel")); + } + if (GST_PLUGINS_BASE_VERSION_NANO == 1) { + fail_unless (strstr (s, "GIT") || strstr (s, "git")); + } + if (GST_PLUGINS_BASE_VERSION_NANO >= 2) { + fail_unless (strstr (s, "Prerelease") || strstr (s, "prerelease")); + } + g_free (s); +} + +GST_END_TEST; + static Suite * libgstpbutils_suite (void) { @@ -717,6 +744,7 @@ libgstpbutils_suite (void) tcase_add_test (tc_chain, test_pb_utils_get_codec_description); tcase_add_test (tc_chain, test_pb_utils_install_plugins); tcase_add_test (tc_chain, test_pb_utils_installer_details); + tcase_add_test (tc_chain, test_pb_utils_versions); return s; } diff --git a/win32/common/libgstpbutils.def b/win32/common/libgstpbutils.def index 7f4d71b98..cacb6100d 100644 --- a/win32/common/libgstpbutils.def +++ b/win32/common/libgstpbutils.def @@ -30,3 +30,5 @@ EXPORTS gst_pb_utils_get_sink_description gst_pb_utils_get_source_description gst_pb_utils_init + gst_plugins_base_version + gst_plugins_base_version_string