2021-10-04 08:31:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2021 Igalia S.L.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstsouploader.h"
|
|
|
|
#include <gmodule.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_RTLD_NOLOAD
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 16:11:50 +00:00
|
|
|
#ifdef BUILDING_ADAPTIVEDEMUX2
|
|
|
|
GST_DEBUG_CATEGORY (gst_adaptivedemux_soup_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_adaptivedemux_soup_debug
|
|
|
|
#else
|
2022-06-01 14:14:24 +00:00
|
|
|
GST_DEBUG_CATEGORY (gst_soup_debug);
|
2021-10-04 08:31:02 +00:00
|
|
|
#define GST_CAT_DEFAULT gst_soup_debug
|
2022-03-11 16:11:50 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifndef LINK_SOUP
|
2022-03-25 19:26:04 +00:00
|
|
|
|
2024-10-09 20:37:38 +00:00
|
|
|
#if !defined(G_OS_UNIX)
|
|
|
|
#error "dlopen of libsoup is only supported on UNIX"
|
2022-02-27 14:45:01 +00:00
|
|
|
#endif
|
|
|
|
|
2024-10-09 20:37:38 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#define LIBSOUP_3_SONAME "libsoup-3.0.0.dylib"
|
|
|
|
#define LIBSOUP_2_SONAME "libsoup-2.4.1.dylib"
|
|
|
|
#else
|
2024-02-20 21:00:11 +00:00
|
|
|
#define LIBSOUP_3_SONAME "libsoup-3.0.so.0"
|
|
|
|
#define LIBSOUP_2_SONAME "libsoup-2.4.so.1"
|
2024-10-09 20:37:38 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
|
|
|
|
#define LOAD_SYMBOL(name) G_STMT_START { \
|
2024-10-09 20:37:38 +00:00
|
|
|
gpointer sym = NULL; \
|
|
|
|
if (!(sym = dlsym (handle, G_STRINGIFY (name)))) { \
|
|
|
|
GST_ERROR ("Failed to load '%s' from %s, %s", G_STRINGIFY (name), \
|
|
|
|
libsoup_sonames[i], dlerror()); \
|
2021-10-04 08:31:02 +00:00
|
|
|
goto error; \
|
|
|
|
} \
|
2024-10-09 20:37:38 +00:00
|
|
|
G_PASTE (vtable->_, name) = sym; \
|
2021-10-04 08:31:02 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2024-10-09 20:37:38 +00:00
|
|
|
#define LOAD_VERSIONED_SYMBOL(version, name) G_STMT_START { \
|
|
|
|
gpointer sym = NULL; \
|
|
|
|
if (!(sym = dlsym(handle, G_STRINGIFY(name)))) { \
|
|
|
|
GST_WARNING ("Failed to load '%s' from %s, %s", G_STRINGIFY(name), \
|
|
|
|
libsoup_sonames[i], dlerror()); \
|
|
|
|
goto error; \
|
|
|
|
} \
|
|
|
|
G_PASTE(vtable->_, G_PASTE(name, G_PASTE(_, version))) = sym; \
|
2021-10-04 08:31:02 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
typedef struct _GstSoupVTable
|
|
|
|
{
|
|
|
|
gboolean loaded;
|
|
|
|
guint lib_version;
|
|
|
|
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
|
|
|
|
/* Symbols present only in libsoup 3 */
|
|
|
|
#if GLIB_CHECK_VERSION(2, 66, 0)
|
|
|
|
GUri *(*_soup_message_get_uri_3)(SoupMessage * msg);
|
|
|
|
#endif
|
2022-01-16 14:39:42 +00:00
|
|
|
SoupLogger *(*_soup_logger_new_3) (SoupLoggerLogLevel level);
|
2021-10-04 08:31:02 +00:00
|
|
|
SoupMessageHeaders *(*_soup_message_get_request_headers_3) (SoupMessage * msg);
|
|
|
|
SoupMessageHeaders *(*_soup_message_get_response_headers_3) (SoupMessage * msg);
|
|
|
|
void (*_soup_message_set_request_body_from_bytes_3) (SoupMessage * msg,
|
|
|
|
const char * content_type, GBytes * data);
|
|
|
|
const char *(*_soup_message_get_reason_phrase_3) (SoupMessage * msg);
|
|
|
|
SoupStatus (*_soup_message_get_status_3) (SoupMessage * msg);
|
|
|
|
|
|
|
|
/* Symbols present only in libsoup 2 */
|
2022-01-16 14:39:42 +00:00
|
|
|
SoupLogger *(*_soup_logger_new_2) (SoupLoggerLogLevel, int);
|
|
|
|
SoupURI *(*_soup_uri_new_2) (const char *);
|
2021-10-04 08:31:02 +00:00
|
|
|
SoupURI *(*_soup_message_get_uri_2) (SoupMessage *);
|
|
|
|
char *(*_soup_uri_to_string_2) (SoupURI *, gboolean);
|
|
|
|
void (*_soup_message_body_append_2) (SoupMessageBody *, SoupMemoryUse,
|
|
|
|
gconstpointer, gsize);
|
|
|
|
void (*_soup_uri_free_2) (SoupURI *);
|
|
|
|
void (*_soup_session_cancel_message_2) (SoupSession *, SoupMessage *, guint);
|
|
|
|
|
|
|
|
/* Symbols present in libsoup 2 and libsoup 3 */
|
|
|
|
GType (*_soup_content_decoder_get_type) (void);
|
|
|
|
GType (*_soup_cookie_jar_get_type) (void);
|
|
|
|
guint (*_soup_get_major_version) (void);
|
|
|
|
guint (*_soup_get_minor_version) (void);
|
|
|
|
guint (*_soup_get_micro_version) (void);
|
|
|
|
GType (*_soup_logger_log_level_get_type) (void);
|
|
|
|
void (*_soup_logger_set_printer) (SoupLogger * logger, SoupLoggerPrinter printer, gpointer user_data,
|
|
|
|
GDestroyNotify destroy_notify);
|
|
|
|
void (*_soup_message_disable_feature) (SoupMessage * message, GType feature_type);
|
|
|
|
void (*_soup_message_headers_append) (SoupMessageHeaders * hdrs, const char * name,
|
|
|
|
const char * value);
|
|
|
|
void (*_soup_message_headers_foreach) (SoupMessageHeaders * hdrs,
|
|
|
|
SoupMessageHeadersForeachFunc callback, gpointer user_data);
|
|
|
|
goffset (*_soup_message_headers_get_content_length) (SoupMessageHeaders * hdrs);
|
|
|
|
const char *(*_soup_message_headers_get_content_type) (SoupMessageHeaders * hdrs,
|
|
|
|
GHashTable ** value);
|
2022-03-11 16:11:50 +00:00
|
|
|
gboolean (*_soup_message_headers_get_content_range) (SoupMessageHeaders *hdrs, goffset *start,
|
|
|
|
goffset *end, goffset *total_length);
|
|
|
|
void (*_soup_message_headers_set_range) (SoupMessageHeaders *hdrs, goffset start, goffset end);
|
2021-10-04 08:31:02 +00:00
|
|
|
SoupEncoding (*_soup_message_headers_get_encoding) (SoupMessageHeaders * hdrs);
|
|
|
|
const char *(*_soup_message_headers_get_one) (SoupMessageHeaders * hdrs,
|
|
|
|
const char * name);
|
|
|
|
void (*_soup_message_headers_remove) (SoupMessageHeaders * hdrs, const char * name);
|
|
|
|
SoupMessage *(*_soup_message_new) (const char * method, const char * location);
|
|
|
|
void (*_soup_message_set_flags) (SoupMessage * msg, SoupMessageFlags flags);
|
|
|
|
void (*_soup_session_abort) (SoupSession * session);
|
|
|
|
void (*_soup_session_add_feature) (SoupSession * session, SoupSessionFeature * feature);
|
|
|
|
void (*_soup_session_add_feature_by_type) (SoupSession * session, GType feature_type);
|
|
|
|
GType (*_soup_session_get_type) (void);
|
|
|
|
|
|
|
|
void (*_soup_auth_authenticate) (SoupAuth * auth, const char *username,
|
|
|
|
const char *password);
|
|
|
|
const char *(*_soup_message_get_method_3) (SoupMessage * msg);
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
GInputStream *(*_soup_session_send_async_2) (SoupSession * session, SoupMessage * msg,
|
|
|
|
GCancellable * cancellable, GAsyncReadyCallback callback, gpointer user_data);
|
|
|
|
GInputStream *(*_soup_session_send_async_3) (SoupSession * session, SoupMessage * msg,
|
|
|
|
int io_priority, GCancellable * cancellable, GAsyncReadyCallback callback, gpointer user_data);
|
2021-10-04 08:31:02 +00:00
|
|
|
GInputStream *(*_soup_session_send_finish) (SoupSession * session,
|
|
|
|
GAsyncResult * result, GError ** error);
|
|
|
|
GInputStream *(*_soup_session_send) (SoupSession * session, SoupMessage * msg,
|
|
|
|
GCancellable * cancellable, GError ** error);
|
2024-01-11 00:10:55 +00:00
|
|
|
SoupCookie* (*_soup_cookie_parse) (const char* header, gpointer origin_uri);
|
2023-12-06 17:24:35 +00:00
|
|
|
void (*_soup_cookies_to_request) (GSList* cookies, SoupMessage* msg);
|
|
|
|
void (*_soup_cookies_free) (GSList *cookies);
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
/* *INDENT-ON* */
|
|
|
|
} GstSoupVTable;
|
|
|
|
|
|
|
|
static GstSoupVTable gst_soup_vtable = { 0, };
|
|
|
|
|
2024-10-09 20:37:38 +00:00
|
|
|
#define SOUP_NAMES 2
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_soup_load_library (void)
|
|
|
|
{
|
|
|
|
GstSoupVTable *vtable;
|
2024-10-09 20:37:38 +00:00
|
|
|
const char *libsoup_sonames[SOUP_NAMES + 1] = { 0 };
|
|
|
|
gpointer handle = NULL;
|
2021-10-04 08:31:02 +00:00
|
|
|
|
|
|
|
if (gst_soup_vtable.loaded)
|
|
|
|
return TRUE;
|
|
|
|
|
2022-03-11 16:11:50 +00:00
|
|
|
#ifdef BUILDING_ADAPTIVEDEMUX2
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_adaptivedemux_soup_debug, "adaptivedemux2-soup",
|
|
|
|
0, "adaptivedemux2-soup");
|
2022-06-01 14:14:24 +00:00
|
|
|
#else
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_soup_debug, "soup", 0, "soup");
|
2022-03-11 16:11:50 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
#ifdef HAVE_RTLD_NOLOAD
|
|
|
|
{
|
|
|
|
/* In order to avoid causing conflicts we detect if libsoup 2 or 3 is loaded already.
|
|
|
|
* If so use that. Otherwise we will try to load our own version to use preferring 3. */
|
|
|
|
|
|
|
|
if ((handle = dlopen (LIBSOUP_3_SONAME, RTLD_NOW | RTLD_NOLOAD))) {
|
|
|
|
libsoup_sonames[0] = LIBSOUP_3_SONAME;
|
|
|
|
GST_DEBUG ("LibSoup 3 found");
|
|
|
|
} else if ((handle = dlopen (LIBSOUP_2_SONAME, RTLD_NOW | RTLD_NOLOAD))) {
|
|
|
|
libsoup_sonames[0] = LIBSOUP_2_SONAME;
|
|
|
|
GST_DEBUG ("LibSoup 2 found");
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Trying all libsoups");
|
|
|
|
libsoup_sonames[0] = LIBSOUP_3_SONAME;
|
|
|
|
libsoup_sonames[1] = LIBSOUP_2_SONAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_pointer (&handle, dlclose);
|
|
|
|
}
|
2024-02-20 21:00:11 +00:00
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
libsoup_sonames[0] = LIBSOUP_3_SONAME;
|
|
|
|
libsoup_sonames[1] = LIBSOUP_2_SONAME;
|
|
|
|
#endif /* HAVE_RTLD_NOLOAD */
|
|
|
|
|
|
|
|
vtable = &gst_soup_vtable;
|
2024-10-09 20:37:38 +00:00
|
|
|
|
|
|
|
for (guint i = 0; i < SOUP_NAMES; i++) {
|
|
|
|
if (!handle)
|
|
|
|
handle = dlopen (libsoup_sonames[i], RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (handle) {
|
|
|
|
GST_DEBUG ("Loaded %s", libsoup_sonames[i]);
|
2021-10-04 08:31:02 +00:00
|
|
|
if (g_strstr_len (libsoup_sonames[i], -1, "soup-2")) {
|
|
|
|
vtable->lib_version = 2;
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_logger_new);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_message_body_append);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_uri_free);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_uri_new);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_uri_to_string);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_message_get_uri);
|
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_session_cancel_message);
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
LOAD_VERSIONED_SYMBOL (2, soup_session_send_async);
|
2021-10-04 08:31:02 +00:00
|
|
|
} else {
|
|
|
|
vtable->lib_version = 3;
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_logger_new);
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_request_headers);
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_response_headers);
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_set_request_body_from_bytes);
|
|
|
|
#if GLIB_CHECK_VERSION(2, 66, 0)
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_uri);
|
|
|
|
#endif
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_method);
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_reason_phrase);
|
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_message_get_status);
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
LOAD_VERSIONED_SYMBOL (3, soup_session_send_async);
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_SYMBOL (soup_auth_authenticate);
|
|
|
|
LOAD_SYMBOL (soup_content_decoder_get_type);
|
|
|
|
LOAD_SYMBOL (soup_cookie_jar_get_type);
|
|
|
|
LOAD_SYMBOL (soup_get_major_version);
|
|
|
|
LOAD_SYMBOL (soup_get_micro_version);
|
|
|
|
LOAD_SYMBOL (soup_get_minor_version);
|
|
|
|
LOAD_SYMBOL (soup_logger_log_level_get_type);
|
|
|
|
LOAD_SYMBOL (soup_logger_set_printer);
|
|
|
|
LOAD_SYMBOL (soup_message_disable_feature);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_append);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_foreach);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_get_content_length);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_get_content_type);
|
2022-03-11 16:11:50 +00:00
|
|
|
LOAD_SYMBOL (soup_message_headers_get_content_range);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_set_range);
|
2021-10-04 08:31:02 +00:00
|
|
|
LOAD_SYMBOL (soup_message_headers_get_encoding);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_get_one);
|
|
|
|
LOAD_SYMBOL (soup_message_headers_remove);
|
|
|
|
LOAD_SYMBOL (soup_message_new);
|
|
|
|
LOAD_SYMBOL (soup_message_set_flags);
|
|
|
|
LOAD_SYMBOL (soup_session_abort);
|
|
|
|
LOAD_SYMBOL (soup_session_add_feature);
|
|
|
|
LOAD_SYMBOL (soup_session_add_feature_by_type);
|
|
|
|
LOAD_SYMBOL (soup_session_get_type);
|
|
|
|
LOAD_SYMBOL (soup_session_send);
|
|
|
|
LOAD_SYMBOL (soup_session_send_finish);
|
2023-12-06 17:24:35 +00:00
|
|
|
LOAD_SYMBOL (soup_cookie_parse);
|
|
|
|
LOAD_SYMBOL (soup_cookies_to_request);
|
|
|
|
LOAD_SYMBOL (soup_cookies_free);
|
2021-10-04 08:31:02 +00:00
|
|
|
|
|
|
|
vtable->loaded = TRUE;
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
error:
|
|
|
|
GST_DEBUG ("Failed to find all libsoup symbols");
|
2024-10-09 20:37:38 +00:00
|
|
|
g_clear_pointer (&handle, dlclose);
|
2021-10-04 08:31:02 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Module %s not found", libsoup_sonames[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
beach:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vtable->loaded;
|
|
|
|
}
|
|
|
|
|
2024-02-20 21:00:11 +00:00
|
|
|
#endif /* !LINK_SOUP */
|
2022-03-25 19:26:04 +00:00
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
guint
|
|
|
|
gst_soup_loader_get_api_version (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
return LINK_SOUP;
|
2022-03-25 19:26:04 +00:00
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
return gst_soup_vtable.lib_version;
|
2022-03-25 19:26:04 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupSession *
|
|
|
|
_soup_session_new_with_options (const char *optname1, ...)
|
|
|
|
{
|
|
|
|
SoupSession *session;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start (ap, optname1);
|
|
|
|
session =
|
|
|
|
(SoupSession *) g_object_new_valist (_soup_session_get_type (), optname1,
|
|
|
|
ap);
|
|
|
|
va_end (ap);
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
|
|
|
|
SoupLogger *
|
|
|
|
_soup_logger_new (SoupLoggerLogLevel level)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_logger_new (level, -1);
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_logger_new (level);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 2) {
|
|
|
|
g_assert (gst_soup_vtable._soup_logger_new_2 != NULL);
|
|
|
|
return gst_soup_vtable._soup_logger_new_2 (level, -1);
|
|
|
|
}
|
|
|
|
g_assert (gst_soup_vtable._soup_logger_new_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_logger_new_3 (level);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_logger_set_printer (SoupLogger * logger, SoupLoggerPrinter printer,
|
|
|
|
gpointer printer_data, GDestroyNotify destroy)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_logger_set_printer (logger, printer, printer_data, destroy);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_logger_set_printer != NULL);
|
|
|
|
gst_soup_vtable._soup_logger_set_printer (logger, printer, printer_data,
|
|
|
|
destroy);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_session_add_feature (SoupSession * session, SoupSessionFeature * feature)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_session_add_feature (session, feature);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_add_feature != NULL);
|
|
|
|
gst_soup_vtable._soup_session_add_feature (session, feature);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstSoupUri *
|
|
|
|
gst_soup_uri_new (const char *uri_string)
|
|
|
|
{
|
|
|
|
GstSoupUri *uri = g_new0 (GstSoupUri, 1);
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
uri->soup_uri = soup_uri_new (uri_string);
|
|
|
|
#else
|
|
|
|
uri->uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS, NULL);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 2) {
|
|
|
|
g_assert (gst_soup_vtable._soup_uri_new_2 != NULL);
|
|
|
|
uri->soup_uri = gst_soup_vtable._soup_uri_new_2 (uri_string);
|
|
|
|
} else {
|
|
|
|
#if GLIB_CHECK_VERSION(2, 66, 0)
|
|
|
|
uri->uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_soup_uri_free (GstSoupUri * uri)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#if (defined(LINK_SOUP) && LINK_SOUP == 3) || (!defined(LINK_SOUP) && GLIB_CHECK_VERSION(2, 66, 0))
|
2021-10-04 08:31:02 +00:00
|
|
|
if (uri->uri) {
|
|
|
|
g_uri_unref (uri->uri);
|
|
|
|
}
|
|
|
|
#endif
|
2022-03-25 19:26:04 +00:00
|
|
|
|
2024-02-20 21:00:11 +00:00
|
|
|
#if defined(LINK_SOUP)
|
|
|
|
#if LINK_SOUP == 2
|
2021-10-04 08:31:02 +00:00
|
|
|
if (uri->soup_uri) {
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_uri_free (uri->soup_uri);
|
2022-03-25 19:26:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
2024-02-20 21:00:11 +00:00
|
|
|
#else /* !LINK_SOUP */
|
2022-03-25 19:26:04 +00:00
|
|
|
if (uri->soup_uri) {
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_uri_free_2 != NULL);
|
|
|
|
gst_soup_vtable._soup_uri_free_2 (uri->soup_uri);
|
|
|
|
}
|
2024-02-20 21:00:11 +00:00
|
|
|
#endif /* LINK_SOUP */
|
2021-10-04 08:31:02 +00:00
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
gst_soup_uri_to_string (GstSoupUri * uri)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#if (defined(LINK_SOUP) && LINK_SOUP == 3) || (!defined(LINK_SOUP) && GLIB_CHECK_VERSION(2, 66, 0))
|
2021-10-04 08:31:02 +00:00
|
|
|
if (uri->uri) {
|
|
|
|
return g_uri_to_string_partial (uri->uri, G_URI_HIDE_PASSWORD);
|
|
|
|
}
|
|
|
|
#endif
|
2022-03-25 19:26:04 +00:00
|
|
|
|
2024-02-20 21:00:11 +00:00
|
|
|
#if defined(LINK_SOUP)
|
|
|
|
#if LINK_SOUP == 2
|
2021-10-04 08:31:02 +00:00
|
|
|
if (uri->soup_uri) {
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_uri_to_string (uri->soup_uri, FALSE);
|
2022-03-25 19:26:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
2024-02-20 21:00:11 +00:00
|
|
|
#else /* !LINK_SOUP */
|
2022-03-25 19:26:04 +00:00
|
|
|
if (uri->soup_uri) {
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_uri_to_string_2 != NULL);
|
|
|
|
return gst_soup_vtable._soup_uri_to_string_2 (uri->soup_uri, FALSE);
|
|
|
|
}
|
2024-02-20 21:00:11 +00:00
|
|
|
#endif /* LINK_SOUP */
|
2022-03-25 19:26:04 +00:00
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
gst_soup_message_uri_to_string (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
SoupURI *uri = NULL;
|
|
|
|
uri = soup_message_get_uri (msg);
|
|
|
|
return soup_uri_to_string (uri, FALSE);
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
GUri *uri = NULL;
|
|
|
|
uri = soup_message_get_uri (msg);
|
|
|
|
return g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 2) {
|
|
|
|
SoupURI *uri = NULL;
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_uri_2 != NULL);
|
|
|
|
uri = gst_soup_vtable._soup_message_get_uri_2 (msg);
|
|
|
|
return gst_soup_vtable._soup_uri_to_string_2 (uri, FALSE);
|
|
|
|
} else {
|
|
|
|
#if GLIB_CHECK_VERSION(2, 66, 0)
|
|
|
|
GUri *uri = NULL;
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_uri_3 != NULL);
|
|
|
|
uri = gst_soup_vtable._soup_message_get_uri_3 (msg);
|
|
|
|
return g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
|
|
|
|
#endif
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
/*
|
|
|
|
* If we reach this, it means the plugin was built for old glib, but somehow
|
|
|
|
* we managed to load libsoup3, which requires a very recent glib. As this
|
|
|
|
* is a contradiction, we can assert, I guess?
|
|
|
|
*/
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
_soup_get_major_version (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_get_major_version ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_get_major_version != NULL);
|
|
|
|
return gst_soup_vtable._soup_get_major_version ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
_soup_get_minor_version (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_get_minor_version ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_get_minor_version != NULL);
|
|
|
|
return gst_soup_vtable._soup_get_minor_version ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
_soup_get_micro_version (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_get_micro_version ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_get_micro_version != NULL);
|
|
|
|
return gst_soup_vtable._soup_get_micro_version ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_set_request_body_from_bytes (SoupMessage * msg,
|
|
|
|
const char *content_type, GBytes * bytes)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
gsize size;
|
|
|
|
gconstpointer data = g_bytes_get_data (bytes, &size);
|
|
|
|
soup_message_body_append (msg->request_body, SOUP_MEMORY_COPY, data, size);
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_set_request_body_from_bytes (msg, content_type, bytes);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_set_request_body_from_bytes_3 !=
|
|
|
|
NULL);
|
|
|
|
gst_soup_vtable._soup_message_set_request_body_from_bytes_3 (msg,
|
|
|
|
content_type, bytes);
|
|
|
|
} else {
|
|
|
|
gsize size;
|
|
|
|
gconstpointer data = g_bytes_get_data (bytes, &size);
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
g_assert (gst_soup_vtable._soup_message_body_append_2 != NULL);
|
|
|
|
gst_soup_vtable._soup_message_body_append_2 (msg2->request_body,
|
|
|
|
SOUP_MEMORY_COPY, data, size);
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
_soup_session_get_type (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_session_get_type ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_get_type != NULL);
|
|
|
|
return gst_soup_vtable._soup_session_get_type ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
_soup_logger_log_level_get_type (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_logger_log_level_get_type ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_logger_log_level_get_type != NULL);
|
|
|
|
return gst_soup_vtable._soup_logger_log_level_get_type ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
_soup_content_decoder_get_type (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_content_decoder_get_type ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_content_decoder_get_type != NULL);
|
|
|
|
return gst_soup_vtable._soup_content_decoder_get_type ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
_soup_cookie_jar_get_type (void)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_cookie_jar_get_type ();
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_cookie_jar_get_type != NULL);
|
|
|
|
return gst_soup_vtable._soup_cookie_jar_get_type ();
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_session_abort (SoupSession * session)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_session_abort (session);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_abort != NULL);
|
|
|
|
gst_soup_vtable._soup_session_abort (session);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupMessage *
|
|
|
|
_soup_message_new (const char *method, const char *uri_string)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_new (method, uri_string);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_new != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_new (method, uri_string);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupMessageHeaders *
|
|
|
|
_soup_message_get_request_headers (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return msg->request_headers;
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_get_request_headers (msg);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_request_headers_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_get_request_headers_3 (msg);
|
|
|
|
} else {
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
return msg2->request_headers;
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupMessageHeaders *
|
|
|
|
_soup_message_get_response_headers (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return msg->response_headers;
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_get_response_headers (msg);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_response_headers_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_get_response_headers_3 (msg);
|
|
|
|
} else {
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
return msg2->response_headers;
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_headers_remove (SoupMessageHeaders * hdrs, const char *name)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_headers_remove (hdrs, name);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_remove != NULL);
|
|
|
|
gst_soup_vtable._soup_message_headers_remove (hdrs, name);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_headers_append (SoupMessageHeaders * hdrs, const char *name,
|
|
|
|
const char *value)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_headers_append (hdrs, name, value);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_append != NULL);
|
|
|
|
gst_soup_vtable._soup_message_headers_append (hdrs, name, value);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_set_flags (SoupMessage * msg, SoupMessageFlags flags)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_set_flags (msg, flags);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_set_flags != NULL);
|
|
|
|
gst_soup_vtable._soup_message_set_flags (msg, flags);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_session_add_feature_by_type (SoupSession * session, GType feature_type)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_session_add_feature_by_type (session, feature_type);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_add_feature_by_type != NULL);
|
|
|
|
gst_soup_vtable._soup_session_add_feature_by_type (session, feature_type);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_headers_foreach (SoupMessageHeaders * hdrs,
|
|
|
|
SoupMessageHeadersForeachFunc func, gpointer user_data)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_headers_foreach (hdrs, func, user_data);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_foreach != NULL);
|
|
|
|
gst_soup_vtable._soup_message_headers_foreach (hdrs, func, user_data);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupEncoding
|
|
|
|
_soup_message_headers_get_encoding (SoupMessageHeaders * hdrs)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_headers_get_encoding (hdrs);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_get_encoding != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_headers_get_encoding (hdrs);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goffset
|
|
|
|
_soup_message_headers_get_content_length (SoupMessageHeaders * hdrs)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_headers_get_content_length (hdrs);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_get_content_length != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_headers_get_content_length (hdrs);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SoupStatus
|
|
|
|
_soup_message_get_status (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return msg->status_code;
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_get_status (msg);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_status_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_get_status_3 (msg);
|
|
|
|
} else {
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
return msg2->status_code;
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_soup_message_get_reason_phrase (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return msg->reason_phrase;
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_get_reason_phrase (msg);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_reason_phrase_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_get_reason_phrase_3 (msg);
|
|
|
|
} else {
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
return msg2->reason_phrase;
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_soup_message_headers_get_one (SoupMessageHeaders * hdrs, const char *name)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_headers_get_one (hdrs, name);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_get_one != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_headers_get_one (hdrs, name);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_disable_feature (SoupMessage * msg, GType feature_type)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_message_disable_feature (msg, feature_type);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_disable_feature != NULL);
|
|
|
|
gst_soup_vtable._soup_message_disable_feature (msg, feature_type);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_soup_message_headers_get_content_type (SoupMessageHeaders * hdrs,
|
|
|
|
GHashTable ** params)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_headers_get_content_type (hdrs, params);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_get_content_type != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_headers_get_content_type (hdrs, params);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-11 16:11:50 +00:00
|
|
|
gboolean
|
|
|
|
_soup_message_headers_get_content_range (SoupMessageHeaders * hdrs,
|
|
|
|
goffset * start, goffset * end, goffset * total_length)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-03-11 16:11:50 +00:00
|
|
|
return soup_message_headers_get_content_range (hdrs, start, end,
|
|
|
|
total_length);
|
|
|
|
#else
|
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_get_content_range != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_headers_get_content_range (hdrs, start,
|
|
|
|
end, total_length);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_message_headers_set_range (SoupMessageHeaders * hdrs, goffset start,
|
|
|
|
goffset end)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-03-11 16:11:50 +00:00
|
|
|
soup_message_headers_set_range (hdrs, start, end);
|
|
|
|
#else
|
|
|
|
g_assert (gst_soup_vtable._soup_message_headers_set_range != NULL);
|
|
|
|
gst_soup_vtable._soup_message_headers_set_range (hdrs, start, end);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
void
|
|
|
|
_soup_auth_authenticate (SoupAuth * auth, const char *username,
|
|
|
|
const char *password)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
soup_auth_authenticate (auth, username, password);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_auth_authenticate != NULL);
|
|
|
|
gst_soup_vtable._soup_auth_authenticate (auth, username, password);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
_soup_message_get_method (SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-01-16 14:41:41 +00:00
|
|
|
return msg->method;
|
2024-02-20 21:00:11 +00:00
|
|
|
#elif LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_message_get_method (msg);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_message_get_method_3 != NULL);
|
|
|
|
return gst_soup_vtable._soup_message_get_method_3 (msg);
|
|
|
|
} else {
|
|
|
|
SoupMessage2 *msg2 = (SoupMessage2 *) msg;
|
|
|
|
return msg2->method;
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
void
|
|
|
|
_soup_session_send_async (SoupSession * session, SoupMessage * msg,
|
|
|
|
GCancellable * cancellable, GAsyncReadyCallback callback,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 2
|
2022-03-03 17:34:36 +00:00
|
|
|
soup_session_send_async (session, msg, cancellable, callback, user_data);
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
#else
|
2022-03-03 17:34:36 +00:00
|
|
|
soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, cancellable,
|
|
|
|
callback, user_data);
|
soup: move libsoup session into its own thread
Starting with libsoup3, there is no attempt to handle thread safety
inside the library, and it was never considered fully safe before
either. Therefore, move all session handling into its own thread.
The libsoup thread has its own context and main loop. When some
request is made or a response needs to be read, an idle source
is created to issue that; the gstreamer thread issuing that waits
for that to be complete. There is a per-src condition variable to
deal with that.
Since the thread/loop needs to be longer-lived than the soup
session itself, a wrapper object is provided to contain them. The
soup session only has a single reference, owned by the wrapper
object.
It is no longer possible to force an external session, since this
does not seem to be used anywhere within gstreamer and would be
tricky to implement; this is because one would not have to provide
just a session, but also the complete thread arrangement made in
the same way as the system currently does internally, in order to
be safe.
Messages are still built gstreamer-side. It is safe to do so until
the message is sent on the session. Headers are also processed on
the gstreamer side, which should likewise be safe.
All requests as well as reads on the libsoup thread are issued
asynchronously. That allows libsoup to schedule things with as
little blocking as possible, and means that concurrent access
to the session is possible, when sharing the session.
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/947
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1555>
2022-01-21 15:09:30 +00:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_assert (gst_soup_vtable._soup_session_send_async_3 != NULL);
|
|
|
|
gst_soup_vtable._soup_session_send_async_3 (session, msg,
|
|
|
|
G_PRIORITY_DEFAULT, cancellable, callback, user_data);
|
|
|
|
} else {
|
|
|
|
g_assert (gst_soup_vtable._soup_session_send_async_2 != NULL);
|
|
|
|
gst_soup_vtable._soup_session_send_async_2 (session, msg,
|
|
|
|
cancellable, callback, user_data);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
GInputStream *
|
|
|
|
_soup_session_send_finish (SoupSession * session,
|
|
|
|
GAsyncResult * result, GError ** error)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_session_send_finish (session, result, error);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_send_finish != NULL);
|
|
|
|
return gst_soup_vtable._soup_session_send_finish (session, result, error);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GInputStream *
|
|
|
|
_soup_session_send (SoupSession * session, SoupMessage * msg,
|
|
|
|
GCancellable * cancellable, GError ** error)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2022-01-16 14:41:41 +00:00
|
|
|
return soup_session_send (session, msg, cancellable, error);
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
g_assert (gst_soup_vtable._soup_session_send != NULL);
|
|
|
|
return gst_soup_vtable._soup_session_send (session, msg, cancellable, error);
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_soup_session_cancel_message (SoupSession * session, SoupMessage * msg,
|
|
|
|
GCancellable * cancellable)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
|
|
|
#if LINK_SOUP == 3
|
2022-01-16 14:41:41 +00:00
|
|
|
g_cancellable_cancel (cancellable);
|
|
|
|
#else
|
|
|
|
soup_session_cancel_message (session, msg, SOUP_STATUS_CANCELLED);
|
|
|
|
#endif
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
if (gst_soup_vtable.lib_version == 3) {
|
|
|
|
g_cancellable_cancel (cancellable);
|
|
|
|
} else {
|
|
|
|
g_assert (gst_soup_vtable._soup_session_cancel_message_2 != NULL);
|
|
|
|
gst_soup_vtable._soup_session_cancel_message_2 (session, msg,
|
|
|
|
SOUP_STATUS_CANCELLED);
|
|
|
|
}
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
}
|
2023-12-06 17:24:35 +00:00
|
|
|
|
|
|
|
SoupCookie *
|
|
|
|
_soup_cookie_parse (const char *header)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2023-12-06 17:24:35 +00:00
|
|
|
return soup_cookie_parse (header, NULL);
|
|
|
|
#else
|
|
|
|
g_assert (gst_soup_vtable._soup_cookie_parse != NULL);
|
|
|
|
return gst_soup_vtable._soup_cookie_parse (header, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_cookies_to_request (GSList * cookies, SoupMessage * msg)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2023-12-06 17:24:35 +00:00
|
|
|
soup_cookies_to_request (cookies, msg);
|
|
|
|
#else
|
|
|
|
g_assert (gst_soup_vtable._soup_cookies_to_request != NULL);
|
|
|
|
gst_soup_vtable._soup_cookies_to_request (cookies, msg);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_soup_cookies_free (GSList * cookies)
|
|
|
|
{
|
2024-02-20 21:00:11 +00:00
|
|
|
#ifdef LINK_SOUP
|
2023-12-06 17:24:35 +00:00
|
|
|
soup_cookies_free (cookies);
|
|
|
|
#else
|
|
|
|
g_assert (gst_soup_vtable._soup_cookies_free != NULL);
|
|
|
|
gst_soup_vtable._soup_cookies_free (cookies);
|
|
|
|
#endif
|
|
|
|
}
|