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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_SOUP_LOADER_H__
|
|
|
|
#define __GST_SOUP_LOADER_H__
|
|
|
|
|
2022-01-16 14:41:41 +00:00
|
|
|
#ifdef STATIC_SOUP
|
|
|
|
#include <libsoup/soup.h>
|
|
|
|
#else
|
2021-10-04 08:31:02 +00:00
|
|
|
#include "stub/soup.h"
|
2022-01-16 14:41:41 +00:00
|
|
|
#endif
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
gboolean gst_soup_load_library (void);
|
|
|
|
guint gst_soup_loader_get_api_version (void);
|
|
|
|
|
|
|
|
SoupSession *_soup_session_new_with_options (const char *optname1, ...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
|
|
SoupLogger *_soup_logger_new (SoupLoggerLogLevel);
|
|
|
|
|
|
|
|
void _soup_logger_set_printer (SoupLogger *logger, SoupLoggerPrinter printer,
|
|
|
|
gpointer printer_data, GDestroyNotify destroy);
|
|
|
|
|
|
|
|
void _soup_session_add_feature (SoupSession *session,
|
|
|
|
SoupSessionFeature *feature);
|
|
|
|
void _soup_session_add_feature_by_type (SoupSession *session, GType feature_type);
|
|
|
|
|
|
|
|
typedef struct _GstSoupUri {
|
2022-03-25 19:26:04 +00:00
|
|
|
#if (defined(STATIC_SOUP) && STATIC_SOUP == 3) || (!defined(STATIC_SOUP) && GLIB_CHECK_VERSION(2, 66, 0))
|
2021-10-04 08:31:02 +00:00
|
|
|
GUri *uri;
|
|
|
|
#endif
|
2022-03-25 19:26:04 +00:00
|
|
|
#if (defined(STATIC_SOUP) && STATIC_SOUP == 2) || !defined(STATIC_SOUP)
|
2021-10-04 08:31:02 +00:00
|
|
|
SoupURI *soup_uri;
|
2022-03-25 19:26:04 +00:00
|
|
|
#endif
|
2021-10-04 08:31:02 +00:00
|
|
|
} GstSoupUri;
|
|
|
|
|
|
|
|
GstSoupUri *gst_soup_uri_new (const char *uri_string);
|
|
|
|
void gst_soup_uri_free (GstSoupUri *uri);
|
|
|
|
char *gst_soup_uri_to_string (GstSoupUri *uri);
|
|
|
|
|
|
|
|
char *gst_soup_message_uri_to_string (SoupMessage* msg);
|
|
|
|
|
|
|
|
guint _soup_get_major_version (void);
|
|
|
|
guint _soup_get_minor_version (void);
|
|
|
|
guint _soup_get_micro_version (void);
|
|
|
|
|
|
|
|
void _soup_message_set_request_body_from_bytes (SoupMessage *msg,
|
|
|
|
const char *content_type,
|
|
|
|
GBytes *bytes);
|
|
|
|
|
|
|
|
GType _soup_session_get_type (void);
|
|
|
|
GType _soup_logger_log_level_get_type (void);
|
|
|
|
GType _soup_content_decoder_get_type (void);
|
|
|
|
GType _soup_cookie_jar_get_type (void);
|
|
|
|
|
|
|
|
void _soup_session_abort (SoupSession * session);
|
|
|
|
SoupMessage *_soup_message_new (const char *method, const char *uri_string);
|
|
|
|
SoupMessageHeaders *_soup_message_get_request_headers (SoupMessage *msg);
|
|
|
|
SoupMessageHeaders *_soup_message_get_response_headers (SoupMessage *msg);
|
|
|
|
|
|
|
|
void _soup_message_headers_remove (SoupMessageHeaders *hdrs, const char *name);
|
|
|
|
void _soup_message_headers_append (SoupMessageHeaders *hdrs, const char *name,
|
|
|
|
const char *value);
|
|
|
|
void _soup_message_set_flags (SoupMessage *msg, SoupMessageFlags flags);
|
|
|
|
|
|
|
|
void _soup_message_headers_foreach (SoupMessageHeaders *hdrs,
|
|
|
|
SoupMessageHeadersForeachFunc func,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
SoupEncoding _soup_message_headers_get_encoding (SoupMessageHeaders *hdrs);
|
|
|
|
|
|
|
|
goffset _soup_message_headers_get_content_length (SoupMessageHeaders *hdrs);
|
|
|
|
|
|
|
|
SoupStatus _soup_message_get_status (SoupMessage *msg);
|
|
|
|
const char *_soup_message_get_reason_phrase (SoupMessage *msg);
|
|
|
|
|
|
|
|
const char *_soup_message_headers_get_one (SoupMessageHeaders *hdrs,
|
|
|
|
const char *name);
|
|
|
|
void _soup_message_disable_feature (SoupMessage *msg, GType feature_type);
|
|
|
|
|
|
|
|
const char *_soup_message_headers_get_content_type (SoupMessageHeaders *hdrs,
|
|
|
|
GHashTable **params);
|
|
|
|
|
2022-03-11 16:11:50 +00:00
|
|
|
#ifdef BUILDING_ADAPTIVEDEMUX2
|
|
|
|
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);
|
|
|
|
#endif
|
|
|
|
|
2021-10-04 08:31:02 +00:00
|
|
|
void _soup_auth_authenticate (SoupAuth *auth, const char *username,
|
|
|
|
const char *password);
|
|
|
|
|
|
|
|
const char *_soup_message_get_method (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
|
|
|
void _soup_session_send_async (SoupSession *session,
|
|
|
|
SoupMessage *msg,
|
|
|
|
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) G_GNUC_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
void gst_soup_session_cancel_message (SoupSession *session, SoupMessage *msg, GCancellable *cancellable);
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_SOUP_LOADER_H__ */
|