diff --git a/src/pipewire/meson.build b/src/pipewire/meson.build index 9929d498e..8f149eb1c 100644 --- a/src/pipewire/meson.build +++ b/src/pipewire/meson.build @@ -61,6 +61,11 @@ pipewire_sources = [ 'work-queue.c', ] +configure_file(input : 'version.h.in', + output : 'version.h', + install_dir : 'include/pipewire', + configuration : cdata) + install_headers(pipewire_headers, subdir : 'pipewire') libpipewire_c_args = [ diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 488edd0ff..394ed2dd9 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -31,8 +31,9 @@ #include -#include "pipewire/pipewire.h" -#include "pipewire/private.h" +#include "pipewire.h" +#include "private.h" +#include "version.h" #define MAX_SUPPORT 32 @@ -596,3 +597,9 @@ enum pw_direction pw_direction_reverse(enum pw_direction direction) return PW_DIRECTION_INPUT; return direction; } + +/** Get the currently running version */ +const char* pw_get_library_version(void) +{ + return pw_get_headers_version(); +} diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index b037f80da..6e7e40d64 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -46,6 +46,7 @@ extern "C" { #include #include #include +#include /** \mainpage * diff --git a/src/pipewire/version.h.in b/src/pipewire/version.h.in new file mode 100644 index 000000000..1e43bef92 --- /dev/null +++ b/src/pipewire/version.h.in @@ -0,0 +1,63 @@ +/* PipeWire + * Copyright (C) 2018 Wim Taymans + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PIPEWIRE_VERSION_H__ +#define __PIPEWIRE_VERSION_H__ + +/* WARNING: Make sure to edit the real source file version.h.in! */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Return the version of the header files. Keep in mind that this is +a macro and not a function, so it is impossible to get the pointer of +it. */ +#define pw_get_headers_version() ("@PIPEWIRE_VERSION_MAJOR@.@PIPEWIRE_VERSION_MINOR@.@PIPEWIRE_VERSION_MICRO@") + +/** Return the version of the library the current application is + * linked to. */ +const char* pw_get_library_version(void); + +/** The current API version. Versions prior to 0.2.0 have + * PW_API_VERSION undefined. Please note that this is only ever + * increased on incompatible API changes! */ +#define PW_API_VERSION @PIPEWIRE_API_VERSION@ + +/** The major version of PipeWire. \since 0.2.0 */ +#define PW_MAJOR @PIPEWIRE_VERSION_MAJOR@ + +/** The minor version of PipeWire. \since 0.2.0 */ +#define PW_MINOR @PIPEWIRE_VERSION_MINOR@ + +/** The micro version of PipeWire. \since 0.2.0 */ +#define PW_MICRO @PIPEWIRE_VERSION_MICRO@ + +/** Evaluates to TRUE if the PipeWire library version is equal or + * newer than the specified. \since 0.2.0 */ +#define PW_CHECK_VERSION(major,minor,micro) \ + ((PW_MAJOR > (major)) || \ + (PW_MAJOR == (major) && PW_MINOR > (minor)) || \ + (PW_MAJOR == (major) && PW_MINOR == (minor) && PW_MICRO >= (micro))) + +#ifdef __cplusplus +} +#endif + +#endif /* __PIPEWIRE_VERION_H__ */