From 2b121be8f0e56aa087afd7623145eb0f7171d45f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 21 Feb 2024 02:30:11 +0530 Subject: [PATCH] soup: Link to libsoup in all cases on non-Linux We have unsolvable issues on macOS because of this, and the feature was added specifically for issues that occur on Linux distros since they ship both libsoup 2.4 and 3.0. Everyone else should just pick one and use it, since you cannot mix the two in a single process anyway. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1171 Part-of: --- .gitlab-ci.yml | 2 - .../adaptivedemux2/gstadaptivedemuxelement.c | 2 +- .../ext/adaptivedemux2/meson.build | 104 +++++---- .../ext/soup/gstsoupelement.c | 2 +- .../ext/soup/gstsouphttpsrc.c | 8 +- .../gst-plugins-good/ext/soup/gstsouploader.c | 207 +++++++----------- .../gst-plugins-good/ext/soup/gstsouploader.h | 6 +- .../gst-plugins-good/ext/soup/gstsouputils.h | 2 +- .../gst-plugins-good/ext/soup/meson.build | 83 ++++--- .../gst-plugins-good/meson_options.txt | 4 +- .../gst-plugins-good/tests/check/meson.build | 6 - subprojects/libsoup.wrap | 4 + 12 files changed, 201 insertions(+), 229 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 916e47d01c..a32d8d6f03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -348,7 +348,6 @@ build clang fedora x86_64: -Dgst-plugins-base:pango=enabled -Dgst-plugins-good:cairo=enabled -Dgst-plugins-good:soup=enabled - -Dgst-plugins-good:soup-lookup-dep=true # Needs to not be empty otherwise the newline -> space replace command in # `script:` will fail MESON_CROSS_ARGS: ' ' @@ -415,7 +414,6 @@ build vs2019 arm64 uwp: MESON_CROSS_ARGS: > -Dgst-plugins-base:pango=disabled -Dgst-plugins-good:cairo=disabled - -Dgst-plugins-good:soup-lookup-dep=false -Dgst-devtools:cairo=disabled --cross-file ci/meson/vs2019-arm64-cross-file.txt --native-file ci/meson/vs2019-x64-native-file.txt diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c index 1d8f53769c..79f9800809 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxelement.c @@ -36,7 +36,7 @@ adaptivedemux2_base_element_init (GstPlugin * plugin) "adaptivedemux2"); g_once_init_leave (&res, TRUE); } -#ifndef STATIC_SOUP +#ifndef LINK_SOUP if (!gst_soup_load_library ()) { GST_WARNING ("Failed to load libsoup library"); return FALSE; diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build b/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build index 6f4564deb0..ad83a09166 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/meson.build @@ -56,6 +56,7 @@ hls_dep = dependency('', required : false) adaptivedemux2_dep = dependency('', required : false) adaptivedemux2_opt = get_option('adaptivedemux2') +soup_ver_opt = get_option('soup-version') if adaptivedemux2_opt.disabled() message('Not building adaptivedemux2 plugin because it was disabled') subdir_done() @@ -74,60 +75,71 @@ plugin_sources += dash_sources plugin_sources += smoothstreaming_sources plugin_sources += hls_sources +libdl = cc.find_library('dl', required: false) soup_loader_args = ['-DBUILDING_ADAPTIVEDEMUX2'] +soup_link_args = [] +soup_link_deps = [] default_library = get_option('default_library') -if default_library in ['static', 'both'] - libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48', - required : false, fallback : ['libsoup', 'libsoup_dep'], - default_options: ['sysprof=disabled']) - libsoup3_dep = dependency('libsoup-3.0', required : false, - fallback : ['libsoup3', 'libsoup_dep']) - - if libsoup3_dep.found() - soup_dep = libsoup3_dep - static_soup_loader_args = ['-DSTATIC_SOUP=3'] - elif libsoup2_dep.found() - soup_dep = libsoup2_dep - static_soup_loader_args = ['-DSTATIC_SOUP=2'] - else - if adaptivedemux2_opt.enabled() - error(f'adaptivedemux2: Either libsoup2 or libsoup3 is needed for build with default_library=@default_library@') - endif - - message(f'Not building adaptivedemux2 plugin: either libsoup2 or libsoup3 is needed for build with default_library=@default_library@') - subdir_done() +if host_system != 'linux' or default_library in ['static', 'both'] + if soup_ver_opt in ['auto', '3'] + libsoup3_dep = dependency('libsoup-3.0', allow_fallback: true, + required: soup_ver_opt == '3' and soup_opt.enabled()) + endif + if soup_ver_opt in ['auto', '2'] + libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48', allow_fallback: true, + default_options: ['sysprof=disabled'], + required: soup_ver_opt == '2' and soup_opt.enabled()) endif - # Static plugin links to libsoup directly at build time - adaptivedemux2_static = static_library('gstadaptivedemux2', - plugin_sources, - include_directories: [configinc, libsinc], - c_args: [gst_plugins_good_args, soup_loader_args, soup_loader_args, hls_cargs, - '-DGST_ISOFF_API=G_GNUC_INTERNAL'], - dependencies: [gst_dep, gsttag_dep, gstnet_dep, gstbase_dep, - gstpbutils_dep, gstapp_dep, soup_dep, - gio_dep, adaptive_xml2_dep, - hls_crypto_dep, libm], - install: true, - install_dir: plugins_install_dir) + if libsoup3_dep.found() + soup_link_deps += [libsoup3_dep] + soup_link_args = ['-DLINK_SOUP=3'] + elif libsoup2_dep.found() + soup_link_deps += [libsoup2_dep] + soup_link_args = ['-DLINK_SOUP=2'] + else + if adaptivedemux2_opt.enabled() + error(f'adaptivedemux2: Either libsoup2 or libsoup3 is needed') + endif + message(f'Not building adaptivedemux2 plugin: either libsoup2 or libsoup3 is needed') + subdir_done() + endif endif -if default_library in ['shared', 'both'] - # Shared plugin doesn't link to libsoup but dlopen()s it at runtime - libdl = cc.find_library('dl', required: false) +# Shared plugin doesn't link to libsoup but dlopen()s it at runtime +adaptive_kwargs = { + 'sources': plugin_sources, + 'include_directories': [configinc, libsinc], + 'install': true, + 'install_dir': plugins_install_dir, +} +adaptive_deps = [gmodule_dep, gst_dep, gsttag_dep, gstnet_dep, gstbase_dep, gstpbutils_dep, + gstapp_dep, gio_dep, adaptive_xml2_dep, hls_crypto_dep, libdl, libm] +adaptive_args = [gst_plugins_good_args, soup_loader_args, hls_cargs, + '-DGST_ISOFF_API=G_GNUC_INTERNAL'] - adaptivedemux2_shared = shared_library('gstadaptivedemux2', - plugin_sources, - include_directories: [configinc, libsinc], - c_args: [gst_plugins_good_args, soup_loader_args, hls_cargs, - '-DGST_ISOFF_API=G_GNUC_INTERNAL'], - dependencies: [gsttag_dep, gstnet_dep, gstbase_dep, - gstpbutils_dep, gstapp_dep, gio_dep, - gmodule_dep, adaptive_xml2_dep, - hls_crypto_dep, libm, libdl], - install: true, - install_dir: plugins_install_dir) +if host_system != 'linux' + adaptivedemux2 = library('gstadaptivedemux2', + c_args: [adaptive_args, soup_link_args], + dependencies: [adaptive_deps, soup_link_deps], + kwargs: adaptive_kwargs) + adaptivedemux2_static = adaptivedemux2 + adaptivedemux2_shared = adaptivedemux2 +else + if default_library in ['static', 'both'] + # Static plugin links to libsoup directly at build time + adaptivedemux2_static = static_library('gstadaptivedemux2', + c_args: [adaptive_args, soup_link_args], + dependencies: [adaptive_deps, soup_link_deps], + kwargs: adaptive_kwargs) + endif + if default_library in ['shared', 'both'] + adaptivedemux2_shared = shared_library('gstadaptivedemux2', + c_args: adaptive_args, + dependencies: adaptive_deps, + kwargs: adaptive_kwargs) + endif endif # Use the static library to generate the .pc file if it's available. The shared diff --git a/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c b/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c index bd1ad3501b..d99caf9089 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsoupelement.c @@ -56,7 +56,7 @@ soup_element_init (GstPlugin * plugin) g_once_init_leave (&res, TRUE); } -#ifndef STATIC_SOUP +#ifndef LINK_SOUP if (!gst_soup_load_library ()) { GST_WARNING ("Failed to load libsoup library"); return FALSE; diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c index dc8b86a3cf..346478aec0 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsouphttpsrc.c @@ -1016,11 +1016,11 @@ thread_func (gpointer user_data) NULL); g_object_unref (proxy_resolver); } -#if !defined(STATIC_SOUP) || STATIC_SOUP == 2 +#if !defined(LINK_SOUP) || LINK_SOUP == 2 } else { g_object_set (session->session, "ssl-strict", src->ssl_strict, NULL); if (src->proxy != NULL) { - /* Need #if because there's no proxy->soup_uri when STATIC_SOUP == 3 */ + /* Need #if because there's no proxy->soup_uri when LINK_SOUP == 3 */ g_object_set (session->session, "proxy-uri", src->proxy->soup_uri, NULL); } #endif @@ -1618,7 +1618,7 @@ gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src) } /* SOUP_STATUS_IS_TRANSPORT_ERROR was replaced with GError in libsoup-3.0 */ -#if !defined(STATIC_SOUP) || STATIC_SOUP == 2 +#if !defined(LINK_SOUP) || LINK_SOUP == 2 if (SOUP_STATUS_IS_TRANSPORT_ERROR (status_code)) { switch (status_code) { case SOUP_STATUS_CANT_RESOLVE: @@ -1785,7 +1785,7 @@ gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method) /* SOUP_MESSAGE_OVERWRITE_CHUNKS is gone in libsoup-3.0, and * soup_message_body_set_accumulate() requires SoupMessageBody, which * can only be fetched from SoupServerMessage, not SoupMessage */ -#if !defined(STATIC_SOUP) || STATIC_SOUP == 2 +#if !defined(LINK_SOUP) || LINK_SOUP == 2 if (gst_soup_loader_get_api_version () == 2) flags |= SOUP_MESSAGE_OVERWRITE_CHUNKS; #endif diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouploader.c b/subprojects/gst-plugins-good/ext/soup/gstsouploader.c index 840c2e7dd7..9192e4dac5 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouploader.c +++ b/subprojects/gst-plugins-good/ext/soup/gstsouploader.c @@ -23,13 +23,6 @@ #include #endif -#ifdef G_OS_WIN32 -#include -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -#define GST_WINAPI_ONLY_APP -#endif -#endif /* G_OS_WIN32 */ - #ifdef BUILDING_ADAPTIVEDEMUX2 GST_DEBUG_CATEGORY (gst_adaptivedemux_soup_debug); #define GST_CAT_DEFAULT gst_adaptivedemux_soup_debug @@ -39,17 +32,14 @@ GST_DEBUG_CATEGORY (gst_soup_debug); #endif -#ifndef STATIC_SOUP +#ifndef LINK_SOUP -/* G_OS_WIN32 is handled separately below */ -#ifdef __APPLE__ -#define LIBSOUP_3_SONAME "libsoup-3.0.0.dylib" -#define LIBSOUP_2_SONAME "libsoup-2.4.1.dylib" -#else -#define LIBSOUP_3_SONAME "libsoup-3.0.so.0" -#define LIBSOUP_2_SONAME "libsoup-2.4.so.1" +#if defined(__APPLE__) || defined(G_OS_WIN32) +#error "dlopen of libsoup is only supported on Linux" #endif +#define LIBSOUP_3_SONAME "libsoup-3.0.so.0" +#define LIBSOUP_2_SONAME "libsoup-2.4.so.1" #define LOAD_SYMBOL(name) G_STMT_START { \ if (!g_module_symbol (module, G_STRINGIFY (name), (gpointer *) &G_PASTE (vtable->_, name))) { \ @@ -187,52 +177,9 @@ gst_soup_load_library (void) g_clear_pointer (&handle, dlclose); } -#else /* !HAVE_RTLD_NOLOAD */ - -#ifdef G_OS_WIN32 - -#define LIBSOUP2_MSVC_DLL "soup-2.4-1.dll" -#define LIBSOUP3_MSVC_DLL "soup-3.0-0.dll" -#define LIBSOUP2_MINGW_DLL "libsoup-2.4-1.dll" -#define LIBSOUP3_MINGW_DLL "libsoup-3.0-0.dll" - - { -#ifdef _MSC_VER - const char *candidates[5] = { LIBSOUP3_MSVC_DLL, LIBSOUP2_MSVC_DLL, - LIBSOUP3_MINGW_DLL, LIBSOUP2_MINGW_DLL, 0 - }; #else - const char *candidates[5] = { LIBSOUP3_MINGW_DLL, LIBSOUP2_MINGW_DLL, - LIBSOUP3_MSVC_DLL, LIBSOUP2_MSVC_DLL, 0 - }; -#endif /* _MSC_VER */ - - guint len = g_strv_length ((gchar **) candidates); -#if !GST_WINAPI_ONLY_APP - for (guint i = 0; i < len; i++) { - HMODULE phModule; - BOOL loaded = - GetModuleHandleExA (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - candidates[i], &phModule); - if (loaded) { - GST_DEBUG ("%s is resident. Using it.", candidates[i]); - libsoup_sonames[0] = candidates[i]; - break; - } - } -#endif - if (libsoup_sonames[0] == NULL) { - GST_DEBUG ("No resident libsoup, trying them all"); - for (guint i = 0; i < len; i++) { - libsoup_sonames[i] = candidates[i]; - } - } - } -#else /* !G_OS_WIN32 */ libsoup_sonames[0] = LIBSOUP_3_SONAME; libsoup_sonames[1] = LIBSOUP_2_SONAME; -#endif /* G_OS_WIN32 */ - #endif /* HAVE_RTLD_NOLOAD */ vtable = &gst_soup_vtable; @@ -317,13 +264,13 @@ gst_soup_load_library (void) return vtable->loaded; } -#endif /* !STATIC_SOUP */ +#endif /* !LINK_SOUP */ guint gst_soup_loader_get_api_version (void) { -#ifdef STATIC_SOUP - return STATIC_SOUP; +#ifdef LINK_SOUP + return LINK_SOUP; #else return gst_soup_vtable.lib_version; #endif @@ -346,10 +293,10 @@ _soup_session_new_with_options (const char *optname1, ...) SoupLogger * _soup_logger_new (SoupLoggerLogLevel level) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return soup_logger_new (level, -1); -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_logger_new (level); #endif #else @@ -366,7 +313,7 @@ void _soup_logger_set_printer (SoupLogger * logger, SoupLoggerPrinter printer, gpointer printer_data, GDestroyNotify destroy) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_logger_set_printer (logger, printer, printer_data, destroy); #else g_assert (gst_soup_vtable._soup_logger_set_printer != NULL); @@ -378,7 +325,7 @@ _soup_logger_set_printer (SoupLogger * logger, SoupLoggerPrinter printer, void _soup_session_add_feature (SoupSession * session, SoupSessionFeature * feature) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_session_add_feature (session, feature); #else g_assert (gst_soup_vtable._soup_session_add_feature != NULL); @@ -390,8 +337,8 @@ GstSoupUri * gst_soup_uri_new (const char *uri_string) { GstSoupUri *uri = g_new0 (GstSoupUri, 1); -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 uri->soup_uri = soup_uri_new (uri_string); #else uri->uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS, NULL); @@ -412,48 +359,48 @@ gst_soup_uri_new (const char *uri_string) void gst_soup_uri_free (GstSoupUri * uri) { -#if (defined(STATIC_SOUP) && STATIC_SOUP == 3) || (!defined(STATIC_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) +#if (defined(LINK_SOUP) && LINK_SOUP == 3) || (!defined(LINK_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) if (uri->uri) { g_uri_unref (uri->uri); } #endif -#if defined(STATIC_SOUP) -#if STATIC_SOUP == 2 +#if defined(LINK_SOUP) +#if LINK_SOUP == 2 if (uri->soup_uri) { soup_uri_free (uri->soup_uri); } #endif -#else /* !STATIC_SOUP */ +#else /* !LINK_SOUP */ if (uri->soup_uri) { g_assert (gst_soup_vtable._soup_uri_free_2 != NULL); gst_soup_vtable._soup_uri_free_2 (uri->soup_uri); } -#endif /* STATIC_SOUP */ +#endif /* LINK_SOUP */ g_free (uri); } char * gst_soup_uri_to_string (GstSoupUri * uri) { -#if (defined(STATIC_SOUP) && STATIC_SOUP == 3) || (!defined(STATIC_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) +#if (defined(LINK_SOUP) && LINK_SOUP == 3) || (!defined(LINK_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) if (uri->uri) { return g_uri_to_string_partial (uri->uri, G_URI_HIDE_PASSWORD); } #endif -#if defined(STATIC_SOUP) -#if STATIC_SOUP == 2 +#if defined(LINK_SOUP) +#if LINK_SOUP == 2 if (uri->soup_uri) { return soup_uri_to_string (uri->soup_uri, FALSE); } #endif -#else /* !STATIC_SOUP */ +#else /* !LINK_SOUP */ if (uri->soup_uri) { g_assert (gst_soup_vtable._soup_uri_to_string_2 != NULL); return gst_soup_vtable._soup_uri_to_string_2 (uri->soup_uri, FALSE); } -#endif /* STATIC_SOUP */ +#endif /* LINK_SOUP */ g_assert_not_reached (); return NULL; @@ -462,12 +409,12 @@ gst_soup_uri_to_string (GstSoupUri * uri) char * gst_soup_message_uri_to_string (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 SoupURI *uri = NULL; uri = soup_message_get_uri (msg); return soup_uri_to_string (uri, FALSE); -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 GUri *uri = NULL; uri = soup_message_get_uri (msg); return g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD); @@ -499,7 +446,7 @@ gst_soup_message_uri_to_string (SoupMessage * msg) guint _soup_get_major_version (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_get_major_version (); #else g_assert (gst_soup_vtable._soup_get_major_version != NULL); @@ -510,7 +457,7 @@ _soup_get_major_version (void) guint _soup_get_minor_version (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_get_minor_version (); #else g_assert (gst_soup_vtable._soup_get_minor_version != NULL); @@ -521,7 +468,7 @@ _soup_get_minor_version (void) guint _soup_get_micro_version (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_get_micro_version (); #else g_assert (gst_soup_vtable._soup_get_micro_version != NULL); @@ -533,12 +480,12 @@ void _soup_message_set_request_body_from_bytes (SoupMessage * msg, const char *content_type, GBytes * bytes) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 gsize size; gconstpointer data = g_bytes_get_data (bytes, &size); soup_message_body_append (msg->request_body, SOUP_MEMORY_COPY, data, size); -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 soup_message_set_request_body_from_bytes (msg, content_type, bytes); #endif #else @@ -561,7 +508,7 @@ _soup_message_set_request_body_from_bytes (SoupMessage * msg, GType _soup_session_get_type (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_session_get_type (); #else g_assert (gst_soup_vtable._soup_session_get_type != NULL); @@ -572,7 +519,7 @@ _soup_session_get_type (void) GType _soup_logger_log_level_get_type (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_logger_log_level_get_type (); #else g_assert (gst_soup_vtable._soup_logger_log_level_get_type != NULL); @@ -583,7 +530,7 @@ _soup_logger_log_level_get_type (void) GType _soup_content_decoder_get_type (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_content_decoder_get_type (); #else g_assert (gst_soup_vtable._soup_content_decoder_get_type != NULL); @@ -594,7 +541,7 @@ _soup_content_decoder_get_type (void) GType _soup_cookie_jar_get_type (void) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_cookie_jar_get_type (); #else g_assert (gst_soup_vtable._soup_cookie_jar_get_type != NULL); @@ -605,7 +552,7 @@ _soup_cookie_jar_get_type (void) void _soup_session_abort (SoupSession * session) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_session_abort (session); #else g_assert (gst_soup_vtable._soup_session_abort != NULL); @@ -616,7 +563,7 @@ _soup_session_abort (SoupSession * session) SoupMessage * _soup_message_new (const char *method, const char *uri_string) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_new (method, uri_string); #else g_assert (gst_soup_vtable._soup_message_new != NULL); @@ -627,10 +574,10 @@ _soup_message_new (const char *method, const char *uri_string) SoupMessageHeaders * _soup_message_get_request_headers (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return msg->request_headers; -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_message_get_request_headers (msg); #endif #else @@ -647,10 +594,10 @@ _soup_message_get_request_headers (SoupMessage * msg) SoupMessageHeaders * _soup_message_get_response_headers (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return msg->response_headers; -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_message_get_response_headers (msg); #endif #else @@ -667,7 +614,7 @@ _soup_message_get_response_headers (SoupMessage * msg) void _soup_message_headers_remove (SoupMessageHeaders * hdrs, const char *name) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_headers_remove (hdrs, name); #else g_assert (gst_soup_vtable._soup_message_headers_remove != NULL); @@ -679,7 +626,7 @@ void _soup_message_headers_append (SoupMessageHeaders * hdrs, const char *name, const char *value) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_headers_append (hdrs, name, value); #else g_assert (gst_soup_vtable._soup_message_headers_append != NULL); @@ -690,7 +637,7 @@ _soup_message_headers_append (SoupMessageHeaders * hdrs, const char *name, void _soup_message_set_flags (SoupMessage * msg, SoupMessageFlags flags) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_set_flags (msg, flags); #else g_assert (gst_soup_vtable._soup_message_set_flags != NULL); @@ -701,7 +648,7 @@ _soup_message_set_flags (SoupMessage * msg, SoupMessageFlags flags) void _soup_session_add_feature_by_type (SoupSession * session, GType feature_type) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_session_add_feature_by_type (session, feature_type); #else g_assert (gst_soup_vtable._soup_session_add_feature_by_type != NULL); @@ -713,7 +660,7 @@ void _soup_message_headers_foreach (SoupMessageHeaders * hdrs, SoupMessageHeadersForeachFunc func, gpointer user_data) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_headers_foreach (hdrs, func, user_data); #else g_assert (gst_soup_vtable._soup_message_headers_foreach != NULL); @@ -724,7 +671,7 @@ _soup_message_headers_foreach (SoupMessageHeaders * hdrs, SoupEncoding _soup_message_headers_get_encoding (SoupMessageHeaders * hdrs) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_headers_get_encoding (hdrs); #else g_assert (gst_soup_vtable._soup_message_headers_get_encoding != NULL); @@ -735,7 +682,7 @@ _soup_message_headers_get_encoding (SoupMessageHeaders * hdrs) goffset _soup_message_headers_get_content_length (SoupMessageHeaders * hdrs) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_headers_get_content_length (hdrs); #else g_assert (gst_soup_vtable._soup_message_headers_get_content_length != NULL); @@ -746,10 +693,10 @@ _soup_message_headers_get_content_length (SoupMessageHeaders * hdrs) SoupStatus _soup_message_get_status (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return msg->status_code; -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_message_get_status (msg); #endif #else @@ -766,10 +713,10 @@ _soup_message_get_status (SoupMessage * msg) const char * _soup_message_get_reason_phrase (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return msg->reason_phrase; -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_message_get_reason_phrase (msg); #endif #else @@ -786,7 +733,7 @@ _soup_message_get_reason_phrase (SoupMessage * msg) const char * _soup_message_headers_get_one (SoupMessageHeaders * hdrs, const char *name) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_headers_get_one (hdrs, name); #else g_assert (gst_soup_vtable._soup_message_headers_get_one != NULL); @@ -797,7 +744,7 @@ _soup_message_headers_get_one (SoupMessageHeaders * hdrs, const char *name) void _soup_message_disable_feature (SoupMessage * msg, GType feature_type) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_disable_feature (msg, feature_type); #else g_assert (gst_soup_vtable._soup_message_disable_feature != NULL); @@ -809,7 +756,7 @@ const char * _soup_message_headers_get_content_type (SoupMessageHeaders * hdrs, GHashTable ** params) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_headers_get_content_type (hdrs, params); #else g_assert (gst_soup_vtable._soup_message_headers_get_content_type != NULL); @@ -821,7 +768,7 @@ gboolean _soup_message_headers_get_content_range (SoupMessageHeaders * hdrs, goffset * start, goffset * end, goffset * total_length) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_message_headers_get_content_range (hdrs, start, end, total_length); #else @@ -835,7 +782,7 @@ void _soup_message_headers_set_range (SoupMessageHeaders * hdrs, goffset start, goffset end) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_message_headers_set_range (hdrs, start, end); #else g_assert (gst_soup_vtable._soup_message_headers_set_range != NULL); @@ -847,7 +794,7 @@ void _soup_auth_authenticate (SoupAuth * auth, const char *username, const char *password) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_auth_authenticate (auth, username, password); #else g_assert (gst_soup_vtable._soup_auth_authenticate != NULL); @@ -858,10 +805,10 @@ _soup_auth_authenticate (SoupAuth * auth, const char *username, const char * _soup_message_get_method (SoupMessage * msg) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 return msg->method; -#elif STATIC_SOUP == 3 +#elif LINK_SOUP == 3 return soup_message_get_method (msg); #endif #else @@ -880,8 +827,8 @@ _soup_session_send_async (SoupSession * session, SoupMessage * msg, GCancellable * cancellable, GAsyncReadyCallback callback, gpointer user_data) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 2 +#ifdef LINK_SOUP +#if LINK_SOUP == 2 soup_session_send_async (session, msg, cancellable, callback, user_data); #else soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, cancellable, @@ -904,7 +851,7 @@ GInputStream * _soup_session_send_finish (SoupSession * session, GAsyncResult * result, GError ** error) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_session_send_finish (session, result, error); #else g_assert (gst_soup_vtable._soup_session_send_finish != NULL); @@ -916,7 +863,7 @@ GInputStream * _soup_session_send (SoupSession * session, SoupMessage * msg, GCancellable * cancellable, GError ** error) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_session_send (session, msg, cancellable, error); #else g_assert (gst_soup_vtable._soup_session_send != NULL); @@ -928,8 +875,8 @@ void gst_soup_session_cancel_message (SoupSession * session, SoupMessage * msg, GCancellable * cancellable) { -#ifdef STATIC_SOUP -#if STATIC_SOUP == 3 +#ifdef LINK_SOUP +#if LINK_SOUP == 3 g_cancellable_cancel (cancellable); #else soup_session_cancel_message (session, msg, SOUP_STATUS_CANCELLED); @@ -948,7 +895,7 @@ gst_soup_session_cancel_message (SoupSession * session, SoupMessage * msg, SoupCookie * _soup_cookie_parse (const char *header) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP return soup_cookie_parse (header, NULL); #else g_assert (gst_soup_vtable._soup_cookie_parse != NULL); @@ -960,7 +907,7 @@ _soup_cookie_parse (const char *header) void _soup_cookies_to_request (GSList * cookies, SoupMessage * msg) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_cookies_to_request (cookies, msg); #else g_assert (gst_soup_vtable._soup_cookies_to_request != NULL); @@ -971,7 +918,7 @@ _soup_cookies_to_request (GSList * cookies, SoupMessage * msg) void _soup_cookies_free (GSList * cookies) { -#ifdef STATIC_SOUP +#ifdef LINK_SOUP soup_cookies_free (cookies); #else g_assert (gst_soup_vtable._soup_cookies_free != NULL); diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouploader.h b/subprojects/gst-plugins-good/ext/soup/gstsouploader.h index 0cedf70007..ccc7445cb4 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouploader.h +++ b/subprojects/gst-plugins-good/ext/soup/gstsouploader.h @@ -15,7 +15,7 @@ #ifndef __GST_SOUP_LOADER_H__ #define __GST_SOUP_LOADER_H__ -#ifdef STATIC_SOUP +#ifdef LINK_SOUP #include #else #include "stub/soup.h" @@ -89,10 +89,10 @@ void _soup_session_add_feature (SoupSession *session, void _soup_session_add_feature_by_type (SoupSession *session, GType feature_type); typedef struct _GstSoupUri { -#if (defined(STATIC_SOUP) && STATIC_SOUP == 3) || (!defined(STATIC_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) +#if (defined(LINK_SOUP) && LINK_SOUP == 3) || (!defined(LINK_SOUP) && GLIB_CHECK_VERSION(2, 66, 0)) GUri *uri; #endif -#if (defined(STATIC_SOUP) && STATIC_SOUP == 2) || !defined(STATIC_SOUP) +#if (defined(LINK_SOUP) && LINK_SOUP == 2) || !defined(LINK_SOUP) SoupURI *soup_uri; #endif } GstSoupUri; diff --git a/subprojects/gst-plugins-good/ext/soup/gstsouputils.h b/subprojects/gst-plugins-good/ext/soup/gstsouputils.h index 2ac84a8781..6336e3dcb1 100644 --- a/subprojects/gst-plugins-good/ext/soup/gstsouputils.h +++ b/subprojects/gst-plugins-good/ext/soup/gstsouputils.h @@ -21,7 +21,7 @@ #include #include -#ifdef STATIC_SOUP +#ifdef LINK_SOUP #include #else #include "stub/soup.h" diff --git a/subprojects/gst-plugins-good/ext/soup/meson.build b/subprojects/gst-plugins-good/ext/soup/meson.build index f542fc2127..075fe91d7b 100644 --- a/subprojects/gst-plugins-good/ext/soup/meson.build +++ b/subprojects/gst-plugins-good/ext/soup/meson.build @@ -8,36 +8,43 @@ soup_sources = [ ] soup_opt = get_option('soup') +soup_ver_opt = get_option('soup-version') if soup_opt.disabled() subdir_done() endif libdl_dep = cc.find_library('dl', required: false) -static_args = [] -static_deps = [] +soup_link_args = [] +soup_link_deps = [] +libsoup2_dep = disabler() +libsoup3_dep = disabler() default_library = get_option('default_library') -if default_library in ['static', 'both'] or get_option('soup-lookup-dep') - libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48', - required : false, fallback : ['libsoup', 'libsoup_dep'], - default_options: ['sysprof=disabled']) - libsoup3_dep = dependency('libsoup-3.0', required : false, - fallback : ['libsoup3', 'libsoup_dep']) - if not libsoup2_dep.found() and not libsoup3_dep.found() +if host_system != 'linux' or default_library in ['static', 'both'] + if soup_ver_opt in ['auto', '3'] + libsoup3_dep = dependency('libsoup-3.0', allow_fallback: true, + required: soup_ver_opt == '3' and soup_opt.enabled()) + endif + if soup_ver_opt in ['auto', '2'] + libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48', allow_fallback: true, + default_options: ['sysprof=disabled'], + required: soup_ver_opt == '2' and soup_opt.enabled()) + endif + + if libsoup3_dep.found() + soup_link_deps += libsoup3_dep + soup_link_args += '-DLINK_SOUP=3' + message('soup plugin: linking to libsoup-3.0') + elif libsoup2_dep.found() + soup_link_deps += libsoup2_dep + soup_link_args += '-DLINK_SOUP=2' + message('soup plugin: linking to libsoup-2.4') + else if soup_opt.enabled() error('Either libsoup2 or libsoup3 is needed') endif subdir_done() endif - if libsoup3_dep.found() - static_deps += libsoup3_dep - static_args += '-DSTATIC_SOUP=3' - message('soup plugin: using libsoup-3.0 for static build') - elif libsoup2_dep.found() - static_deps += libsoup2_dep - static_args += '-DSTATIC_SOUP=2' - message('soup plugin: using libsoup-2.4 for static build') - endif endif soup_library_kwargs = { @@ -50,25 +57,35 @@ soup_library_kwargs = { soup_library_deps = [gst_dep, gstbase_dep, gsttag_dep, gmodule_dep, gio_dep, libdl_dep] soup_library_c_args = gst_plugins_good_args -if default_library in ['shared', 'both'] - gstsouphttpsrc_shared = shared_library('gstsoup', - c_args : soup_library_c_args, - dependencies : soup_library_deps, +if host_system != 'linux' + gstsouphttpsrc = library('gstsoup', + c_args : soup_library_c_args + soup_link_args, + dependencies : soup_library_deps + soup_link_deps, kwargs: soup_library_kwargs, ) + gstsouphttpsrc_shared = gstsouphttpsrc + gstsouphttpsrc_static = gstsouphttpsrc +else + if default_library in ['static', 'both'] + gstsouphttpsrc_static = static_library('gstsoup', + c_args : soup_library_c_args + soup_link_args, + dependencies : soup_library_deps + soup_link_deps, + kwargs: soup_library_kwargs, + ) + endif + if default_library in ['shared', 'both'] + gstsouphttpsrc_shared = shared_library('gstsoup', + c_args : soup_library_c_args, + dependencies : soup_library_deps, + kwargs: soup_library_kwargs, + ) + endif endif -if default_library in ['static', 'both'] - gstsouphttpsrc_static = static_library('gstsoup', - c_args : soup_library_c_args + static_args, - dependencies : soup_library_deps + static_deps, - kwargs: soup_library_kwargs, - ) -endif - -# Use the static library to generate the .pc file if it's available. The shared -# library .pc file does not have a Requires: on libsoup-2.4, and we use plugin -# .pc files to generate dependencies for linking plugins statically. +# Use the static library to generate the .pc file on Linux if it's available. +# In that case, the shared library .pc file does not have a Requires: on +# libsoup-2.4, and we use plugin .pc files to generate dependencies for linking +# plugins statically. if default_library == 'shared' pkgconfig.generate(gstsouphttpsrc_shared, install_dir : plugins_pkgconfig_install_dir) else diff --git a/subprojects/gst-plugins-good/meson_options.txt b/subprojects/gst-plugins-good/meson_options.txt index 86cca25866..fc45885cf2 100644 --- a/subprojects/gst-plugins-good/meson_options.txt +++ b/subprojects/gst-plugins-good/meson_options.txt @@ -85,8 +85,8 @@ option('rpi-lib-dir', type : 'string', value : '/opt/vc/lib', description : 'Dir # soup plugin options option('soup', type : 'feature', value : 'auto', description : 'libsoup HTTP client source/sink plugin') -option('soup-lookup-dep', type : 'boolean', value : 'false', - description : 'Lookup libsoup dep at build time even when building a shared plugin') +option('soup-version', type : 'combo', value : 'auto', choices : ['auto', '2', '3'], + description: 'Force a specific libsoup version if linking to it (N/A for shared builds on Linux)') # Qt plugin options option('qt-method', type: 'combo', value: 'auto', choices: ['auto', 'pkg-config', 'qmake'], diff --git a/subprojects/gst-plugins-good/tests/check/meson.build b/subprojects/gst-plugins-good/tests/check/meson.build index 009f2e1293..8896a588de 100644 --- a/subprojects/gst-plugins-good/tests/check/meson.build +++ b/subprojects/gst-plugins-good/tests/check/meson.build @@ -150,12 +150,6 @@ if host_machine.system() != 'windows' endif if get_option('soup').allowed() - libsoup3_dep = dependency('libsoup-3.0', required : false, - fallback : ['libsoup3', 'libsoup_dep']) - libsoup2_dep = dependency('libsoup-2.4', version : '>=2.48', - required : false, fallback : ['libsoup', 'libsoup_dep'], - default_options: ['sysprof=disabled']) - if libsoup3_dep.found() good_tests += [['elements/souphttpsrc', false, [libsoup3_dep], []]] elif libsoup2_dep.found() diff --git a/subprojects/libsoup.wrap b/subprojects/libsoup.wrap index 69493f526e..4a12f2c6c1 100644 --- a/subprojects/libsoup.wrap +++ b/subprojects/libsoup.wrap @@ -4,3 +4,7 @@ source_url = https://download.gnome.org/sources/libsoup/2.74/libsoup-2.74.3.tar. source_fallback_url = https://ftp.acc.umu.se/pub/gnome/sources/libsoup/2.74/libsoup-2.74.3.tar.xz source_filename = libsoup-2.74.3.tar.xz source_hash = e4b77c41cfc4c8c5a035fcdc320c7bc6cfb75ef7c5a034153df1413fa1d92f13 + +[provide] +libsoup-2.4 = libsoup_dep +libsoup-gnome-2.4 = libsoup_gnome_dep