gst-examples: Port all webrtc examples to libsoup-3.0
Also do some indent changes, and add `static` while we're at it. And move the libsoup wrap to 3.6.5, add nghttp2 wrap We need to disable libsoup 3.0 tests because they fail to build on Windows. Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1115 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8753>
This commit is contained in:
parent
b8f8e4391c
commit
a7c92cbcab
@ -1,8 +1,8 @@
|
||||
gst_req = '>= 1.14.0'
|
||||
gst_req = '>= 1.24.0'
|
||||
gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
|
||||
allow_fallback: true)
|
||||
|
||||
libsoup_dep = dependency('libsoup-2.4', version : '>=2.48',
|
||||
libsoup_dep = dependency('libsoup-3.0', version: '>=3.2', default_options: {'tests': false},
|
||||
include_type: 'system', allow_fallback: true, required: false)
|
||||
json_glib_dep = dependency('json-glib-1.0',
|
||||
include_type: 'system', allow_fallback: true, required: false)
|
||||
|
@ -925,12 +925,16 @@ connect_to_websocket_server_async (void)
|
||||
SoupSession *session;
|
||||
const char *https_aliases[] = { "wss", NULL };
|
||||
|
||||
session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, strict_ssl,
|
||||
SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
|
||||
//SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt",
|
||||
SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);
|
||||
session = soup_session_new_with_options ("ssl-strict", strict_ssl,
|
||||
"ssl-use-system-ca-file", TRUE,
|
||||
//"ssl-ca-file", "/etc/ssl/certs/ca-bundle.crt",
|
||||
"http-aliases", https_aliases, NULL);
|
||||
|
||||
#if SOUP_CHECK_VERSION(3,0,0)
|
||||
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
|
||||
#else
|
||||
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
|
||||
#endif
|
||||
soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
|
||||
g_object_unref (logger);
|
||||
|
||||
@ -939,8 +943,11 @@ connect_to_websocket_server_async (void)
|
||||
gst_print ("Connecting to server...\n");
|
||||
|
||||
/* Once connected, we will register */
|
||||
soup_session_websocket_connect_async (session, message, NULL, NULL, NULL,
|
||||
(GAsyncReadyCallback) on_server_connected, message);
|
||||
soup_session_websocket_connect_async (session, message, NULL, NULL,
|
||||
#if SOUP_CHECK_VERSION(3,0,0)
|
||||
G_PRIORITY_DEFAULT,
|
||||
#endif
|
||||
NULL, (GAsyncReadyCallback) on_server_connected, message);
|
||||
app_state = SERVER_CONNECTING;
|
||||
}
|
||||
|
||||
|
@ -25,31 +25,32 @@
|
||||
#define STUN_SERVER "stun.l.google.com:19302"
|
||||
|
||||
|
||||
|
||||
typedef struct _ReceiverEntry ReceiverEntry;
|
||||
|
||||
ReceiverEntry *create_receiver_entry (SoupWebsocketConnection * connection);
|
||||
void destroy_receiver_entry (gpointer receiver_entry_ptr);
|
||||
static ReceiverEntry *create_receiver_entry (SoupWebsocketConnection *
|
||||
connection);
|
||||
static void destroy_receiver_entry (gpointer receiver_entry_ptr);
|
||||
|
||||
GstPadProbeReturn payloader_caps_event_probe_cb (GstPad * pad,
|
||||
GstPadProbeInfo * info, gpointer user_data);
|
||||
|
||||
void on_offer_created_cb (GstPromise * promise, gpointer user_data);
|
||||
void on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data);
|
||||
void on_ice_candidate_cb (GstElement * webrtcbin, guint mline_index,
|
||||
static void on_offer_created_cb (GstPromise * promise, gpointer user_data);
|
||||
static void on_negotiation_needed_cb (GstElement * webrtcbin,
|
||||
gpointer user_data);
|
||||
static void on_ice_candidate_cb (GstElement * webrtcbin, guint mline_index,
|
||||
gchar * candidate, gpointer user_data);
|
||||
|
||||
void soup_websocket_message_cb (SoupWebsocketConnection * connection,
|
||||
static void soup_websocket_message_cb (SoupWebsocketConnection * connection,
|
||||
SoupWebsocketDataType data_type, GBytes * message, gpointer user_data);
|
||||
void soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
static void soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
gpointer user_data);
|
||||
|
||||
void soup_http_handler (SoupServer * soup_server, SoupMessage * message,
|
||||
const char *path, GHashTable * query, SoupClientContext * client_context,
|
||||
static void soup_http_handler (SoupServer * soup_server,
|
||||
SoupServerMessage * msg, const char *path, GHashTable * query,
|
||||
gpointer user_data);
|
||||
static void soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupServerMessage * msg, const char *path, SoupWebsocketConnection * conn,
|
||||
gpointer user_data);
|
||||
void soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupWebsocketConnection * connection, const char *path,
|
||||
SoupClientContext * client_context, gpointer user_data);
|
||||
|
||||
static gchar *get_string_from_json_object (JsonObject * object);
|
||||
|
||||
@ -190,7 +191,7 @@ handle_media_stream (GstPad * pad, GstElement * pipe, const char *convert_name,
|
||||
GstElement *q, *conv, *resample, *sink;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
gst_print ("Trying to handle stream with %s ! %s", convert_name, sink_name);
|
||||
gst_println ("Trying to handle stream with %s ! %s", convert_name, sink_name);
|
||||
|
||||
q = gst_element_factory_make ("queue", NULL);
|
||||
g_assert_nonnull (q);
|
||||
@ -308,7 +309,7 @@ bus_watch_cb (GstBus * bus, GstMessage * message, gpointer user_data)
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
ReceiverEntry *
|
||||
static ReceiverEntry *
|
||||
create_receiver_entry (SoupWebsocketConnection * connection)
|
||||
{
|
||||
GError *error;
|
||||
@ -384,7 +385,7 @@ cleanup:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
destroy_receiver_entry (gpointer receiver_entry_ptr)
|
||||
{
|
||||
ReceiverEntry *receiver_entry = (ReceiverEntry *) receiver_entry_ptr;
|
||||
@ -412,7 +413,7 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
{
|
||||
gchar *sdp_string;
|
||||
@ -436,7 +437,7 @@ on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
gst_promise_unref (local_desc_promise);
|
||||
|
||||
sdp_string = gst_sdp_message_as_text (offer->sdp);
|
||||
gst_print ("Negotiation offer created:\n%s\n", sdp_string);
|
||||
gst_println ("Negotiation offer created:\n%s", sdp_string);
|
||||
|
||||
sdp_json = json_object_new ();
|
||||
json_object_set_string_member (sdp_json, "type", "sdp");
|
||||
@ -457,13 +458,13 @@ on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data)
|
||||
{
|
||||
GstPromise *promise;
|
||||
ReceiverEntry *receiver_entry = (ReceiverEntry *) user_data;
|
||||
|
||||
gst_print ("Creating negotiation offer\n");
|
||||
gst_println ("Creating negotiation offer");
|
||||
|
||||
promise = gst_promise_new_with_change_func (on_offer_created_cb,
|
||||
(gpointer) receiver_entry, NULL);
|
||||
@ -471,7 +472,7 @@ on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_ice_candidate_cb (G_GNUC_UNUSED GstElement * webrtcbin, guint mline_index,
|
||||
gchar * candidate, gpointer user_data)
|
||||
{
|
||||
@ -496,7 +497,7 @@ on_ice_candidate_cb (G_GNUC_UNUSED GstElement * webrtcbin, guint mline_index,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
SoupWebsocketDataType data_type, GBytes * message, gpointer user_data)
|
||||
{
|
||||
@ -573,7 +574,7 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
}
|
||||
sdp_string = json_object_get_string_member (data_json_object, "sdp");
|
||||
|
||||
gst_print ("Received SDP:\n%s\n", sdp_string);
|
||||
gst_println ("Received SDP:\n%s", sdp_string);
|
||||
|
||||
ret = gst_sdp_message_new (&sdp);
|
||||
g_assert_cmphex (ret, ==, GST_SDP_OK);
|
||||
@ -614,7 +615,7 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
candidate_string = json_object_get_string_member (data_json_object,
|
||||
"candidate");
|
||||
|
||||
gst_print ("Received ICE candidate with mline index %u; candidate: %s\n",
|
||||
gst_println ("Received ICE candidate with mline index %u; candidate: %s",
|
||||
mline_index, candidate_string);
|
||||
|
||||
g_signal_emit_by_name (receiver_entry->webrtcbin, "add-ice-candidate",
|
||||
@ -633,60 +634,53 @@ unknown_message:
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
GHashTable *receiver_entry_table = (GHashTable *) user_data;
|
||||
g_hash_table_remove (receiver_entry_table, connection);
|
||||
gst_print ("Closed websocket connection %p\n", (gpointer) connection);
|
||||
gst_println ("Closed websocket connection %p", (gpointer) connection);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_http_handler (G_GNUC_UNUSED SoupServer * soup_server,
|
||||
SoupMessage * message, const char *path, G_GNUC_UNUSED GHashTable * query,
|
||||
G_GNUC_UNUSED SoupClientContext * client_context,
|
||||
SoupServerMessage * msg, const char *path, G_GNUC_UNUSED GHashTable * query,
|
||||
G_GNUC_UNUSED gpointer user_data)
|
||||
{
|
||||
SoupBuffer *soup_buffer;
|
||||
|
||||
if ((g_strcmp0 (path, "/") != 0) && (g_strcmp0 (path, "/index.html") != 0)) {
|
||||
soup_message_set_status (message, SOUP_STATUS_NOT_FOUND);
|
||||
if (soup_server_message_get_method (msg) != SOUP_METHOD_GET) {
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
soup_buffer =
|
||||
soup_buffer_new (SOUP_MEMORY_STATIC, html_source, strlen (html_source));
|
||||
if ((g_strcmp0 (path, "/") != 0) && (g_strcmp0 (path, "/index.html") != 0)) {
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_NOT_FOUND, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
soup_message_headers_set_content_type (message->response_headers, "text/html",
|
||||
NULL);
|
||||
soup_message_body_append_buffer (message->response_body, soup_buffer);
|
||||
soup_buffer_free (soup_buffer);
|
||||
soup_server_message_set_response (msg, "text/html", SOUP_MEMORY_STATIC,
|
||||
html_source, strlen (html_source));
|
||||
|
||||
soup_message_set_status (message, SOUP_STATUS_OK);
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupWebsocketConnection * connection, G_GNUC_UNUSED const char *path,
|
||||
G_GNUC_UNUSED SoupClientContext * client_context, gpointer user_data)
|
||||
SoupServerMessage * msg, const char *path, SoupWebsocketConnection * conn,
|
||||
gpointer user_data)
|
||||
{
|
||||
ReceiverEntry *receiver_entry;
|
||||
GHashTable *receiver_entry_table = (GHashTable *) user_data;
|
||||
|
||||
gst_print ("Processing new websocket connection %p", (gpointer) connection);
|
||||
gst_println ("Processing new websocket connection %p", (gpointer) conn);
|
||||
|
||||
g_signal_connect (G_OBJECT (connection), "closed",
|
||||
g_signal_connect (G_OBJECT (conn), "closed",
|
||||
G_CALLBACK (soup_websocket_closed_cb), (gpointer) receiver_entry_table);
|
||||
|
||||
receiver_entry = create_receiver_entry (connection);
|
||||
g_hash_table_replace (receiver_entry_table, connection, receiver_entry);
|
||||
receiver_entry = create_receiver_entry (conn);
|
||||
g_hash_table_replace (receiver_entry_table, conn, receiver_entry);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
get_string_from_json_object (JsonObject * object)
|
||||
{
|
||||
@ -707,10 +701,10 @@ get_string_from_json_object (JsonObject * object)
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean
|
||||
static gboolean
|
||||
exit_sighandler (gpointer user_data)
|
||||
{
|
||||
gst_print ("Caught signal, stopping mainloop\n");
|
||||
gst_println ("Caught signal, stopping mainloop");
|
||||
GMainLoop *mainloop = (GMainLoop *) user_data;
|
||||
g_main_loop_quit (mainloop);
|
||||
return TRUE;
|
||||
@ -739,15 +733,14 @@ main (int argc, char *argv[])
|
||||
g_unix_signal_add (SIGTERM, exit_sighandler, mainloop);
|
||||
#endif
|
||||
|
||||
soup_server =
|
||||
soup_server_new (SOUP_SERVER_SERVER_HEADER, "webrtc-soup-server", NULL);
|
||||
soup_server = soup_server_new ("server-header", "webrtc-soup-server", NULL);
|
||||
soup_server_add_handler (soup_server, "/", soup_http_handler, NULL, NULL);
|
||||
soup_server_add_websocket_handler (soup_server, "/ws", NULL, NULL,
|
||||
soup_websocket_handler, (gpointer) receiver_entry_table, NULL);
|
||||
soup_server_listen_all (soup_server, SOUP_HTTP_PORT,
|
||||
(SoupServerListenOptions) 0, NULL);
|
||||
|
||||
gst_print ("WebRTC page link: http://127.0.0.1:%d/\n", (gint) SOUP_HTTP_PORT);
|
||||
gst_println ("WebRTC page link: http://127.0.0.1:%d/", (gint) SOUP_HTTP_PORT);
|
||||
|
||||
g_main_loop_run (mainloop);
|
||||
|
||||
|
@ -25,31 +25,33 @@
|
||||
#define VIDEO_SRC "v4l2src"
|
||||
#endif
|
||||
|
||||
gchar *video_priority = NULL;
|
||||
gchar *audio_priority = NULL;
|
||||
static gchar *video_priority = NULL;
|
||||
static gchar *audio_priority = NULL;
|
||||
|
||||
|
||||
typedef struct _ReceiverEntry ReceiverEntry;
|
||||
|
||||
ReceiverEntry *create_receiver_entry (SoupWebsocketConnection * connection);
|
||||
void destroy_receiver_entry (gpointer receiver_entry_ptr);
|
||||
static ReceiverEntry *create_receiver_entry (SoupWebsocketConnection *
|
||||
connection);
|
||||
static void destroy_receiver_entry (gpointer receiver_entry_ptr);
|
||||
|
||||
void on_offer_created_cb (GstPromise * promise, gpointer user_data);
|
||||
void on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data);
|
||||
void on_ice_candidate_cb (GstElement * webrtcbin, guint mline_index,
|
||||
static void on_offer_created_cb (GstPromise * promise, gpointer user_data);
|
||||
static void on_negotiation_needed_cb (GstElement * webrtcbin,
|
||||
gpointer user_data);
|
||||
static void on_ice_candidate_cb (GstElement * webrtcbin, guint mline_index,
|
||||
gchar * candidate, gpointer user_data);
|
||||
|
||||
void soup_websocket_message_cb (SoupWebsocketConnection * connection,
|
||||
static void soup_websocket_message_cb (SoupWebsocketConnection * connection,
|
||||
SoupWebsocketDataType data_type, GBytes * message, gpointer user_data);
|
||||
void soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
static void soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
gpointer user_data);
|
||||
|
||||
void soup_http_handler (SoupServer * soup_server, SoupMessage * message,
|
||||
const char *path, GHashTable * query, SoupClientContext * client_context,
|
||||
static void soup_http_handler (SoupServer * soup_server,
|
||||
SoupServerMessage * msg, const char *path, GHashTable * query,
|
||||
gpointer user_data);
|
||||
static void soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupServerMessage * msg, const char *path, SoupWebsocketConnection * conn,
|
||||
gpointer user_data);
|
||||
void soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupWebsocketConnection * connection, const char *path,
|
||||
SoupClientContext * client_context, gpointer user_data);
|
||||
|
||||
static gchar *get_string_from_json_object (JsonObject * object);
|
||||
|
||||
@ -222,7 +224,7 @@ _priority_from_string (const gchar * s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ReceiverEntry *
|
||||
static ReceiverEntry *
|
||||
create_receiver_entry (SoupWebsocketConnection * connection)
|
||||
{
|
||||
GError *error;
|
||||
@ -318,7 +320,7 @@ cleanup:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
destroy_receiver_entry (gpointer receiver_entry_ptr)
|
||||
{
|
||||
ReceiverEntry *receiver_entry = (ReceiverEntry *) receiver_entry_ptr;
|
||||
@ -346,7 +348,7 @@ destroy_receiver_entry (gpointer receiver_entry_ptr)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
{
|
||||
gchar *sdp_string;
|
||||
@ -370,7 +372,7 @@ on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
gst_promise_unref (local_desc_promise);
|
||||
|
||||
sdp_string = gst_sdp_message_as_text (offer->sdp);
|
||||
gst_print ("Negotiation offer created:\n%s\n", sdp_string);
|
||||
gst_println ("Negotiation offer created:\n%s", sdp_string);
|
||||
|
||||
sdp_json = json_object_new ();
|
||||
json_object_set_string_member (sdp_json, "type", "sdp");
|
||||
@ -391,13 +393,13 @@ on_offer_created_cb (GstPromise * promise, gpointer user_data)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data)
|
||||
{
|
||||
GstPromise *promise;
|
||||
ReceiverEntry *receiver_entry = (ReceiverEntry *) user_data;
|
||||
|
||||
gst_print ("Creating negotiation offer\n");
|
||||
gst_println ("Creating negotiation offer");
|
||||
|
||||
promise = gst_promise_new_with_change_func (on_offer_created_cb,
|
||||
(gpointer) receiver_entry, NULL);
|
||||
@ -405,7 +407,7 @@ on_negotiation_needed_cb (GstElement * webrtcbin, gpointer user_data)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
on_ice_candidate_cb (G_GNUC_UNUSED GstElement * webrtcbin, guint mline_index,
|
||||
gchar * candidate, gpointer user_data)
|
||||
{
|
||||
@ -430,7 +432,7 @@ on_ice_candidate_cb (G_GNUC_UNUSED GstElement * webrtcbin, guint mline_index,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
SoupWebsocketDataType data_type, GBytes * message, gpointer user_data)
|
||||
{
|
||||
@ -507,7 +509,7 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
}
|
||||
sdp_string = json_object_get_string_member (data_json_object, "sdp");
|
||||
|
||||
gst_print ("Received SDP:\n%s\n", sdp_string);
|
||||
gst_println ("Received SDP:\n%s", sdp_string);
|
||||
|
||||
ret = gst_sdp_message_new (&sdp);
|
||||
g_assert_cmphex (ret, ==, GST_SDP_OK);
|
||||
@ -548,7 +550,7 @@ soup_websocket_message_cb (G_GNUC_UNUSED SoupWebsocketConnection * connection,
|
||||
candidate_string = json_object_get_string_member (data_json_object,
|
||||
"candidate");
|
||||
|
||||
gst_print ("Received ICE candidate with mline index %u; candidate: %s\n",
|
||||
gst_println ("Received ICE candidate with mline index %u; candidate: %s",
|
||||
mline_index, candidate_string);
|
||||
|
||||
g_signal_emit_by_name (receiver_entry->webrtcbin, "add-ice-candidate",
|
||||
@ -567,60 +569,53 @@ unknown_message:
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_closed_cb (SoupWebsocketConnection * connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
GHashTable *receiver_entry_table = (GHashTable *) user_data;
|
||||
g_hash_table_remove (receiver_entry_table, connection);
|
||||
gst_print ("Closed websocket connection %p\n", (gpointer) connection);
|
||||
gst_println ("Closed websocket connection %p", (gpointer) connection);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_http_handler (G_GNUC_UNUSED SoupServer * soup_server,
|
||||
SoupMessage * message, const char *path, G_GNUC_UNUSED GHashTable * query,
|
||||
G_GNUC_UNUSED SoupClientContext * client_context,
|
||||
SoupServerMessage * msg, const char *path, G_GNUC_UNUSED GHashTable * query,
|
||||
G_GNUC_UNUSED gpointer user_data)
|
||||
{
|
||||
SoupBuffer *soup_buffer;
|
||||
|
||||
if ((g_strcmp0 (path, "/") != 0) && (g_strcmp0 (path, "/index.html") != 0)) {
|
||||
soup_message_set_status (message, SOUP_STATUS_NOT_FOUND);
|
||||
if (soup_server_message_get_method (msg) != SOUP_METHOD_GET) {
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
soup_buffer =
|
||||
soup_buffer_new (SOUP_MEMORY_STATIC, html_source, strlen (html_source));
|
||||
if ((g_strcmp0 (path, "/") != 0) && (g_strcmp0 (path, "/index.html") != 0)) {
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_NOT_FOUND, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
soup_message_headers_set_content_type (message->response_headers, "text/html",
|
||||
NULL);
|
||||
soup_message_body_append_buffer (message->response_body, soup_buffer);
|
||||
soup_buffer_free (soup_buffer);
|
||||
soup_server_message_set_response (msg, "text/html", SOUP_MEMORY_STATIC,
|
||||
html_source, strlen (html_source));
|
||||
|
||||
soup_message_set_status (message, SOUP_STATUS_OK);
|
||||
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
soup_websocket_handler (G_GNUC_UNUSED SoupServer * server,
|
||||
SoupWebsocketConnection * connection, G_GNUC_UNUSED const char *path,
|
||||
G_GNUC_UNUSED SoupClientContext * client_context, gpointer user_data)
|
||||
SoupServerMessage * msg, const char *path, SoupWebsocketConnection * conn,
|
||||
gpointer user_data)
|
||||
{
|
||||
ReceiverEntry *receiver_entry;
|
||||
GHashTable *receiver_entry_table = (GHashTable *) user_data;
|
||||
|
||||
gst_print ("Processing new websocket connection %p", (gpointer) connection);
|
||||
gst_println ("Processing new websocket connection %p", (gpointer) conn);
|
||||
|
||||
g_signal_connect (G_OBJECT (connection), "closed",
|
||||
g_signal_connect (G_OBJECT (conn), "closed",
|
||||
G_CALLBACK (soup_websocket_closed_cb), (gpointer) receiver_entry_table);
|
||||
|
||||
receiver_entry = create_receiver_entry (connection);
|
||||
g_hash_table_replace (receiver_entry_table, connection, receiver_entry);
|
||||
receiver_entry = create_receiver_entry (conn);
|
||||
g_hash_table_replace (receiver_entry_table, conn, receiver_entry);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
get_string_from_json_object (JsonObject * object)
|
||||
{
|
||||
@ -641,10 +636,10 @@ get_string_from_json_object (JsonObject * object)
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
gboolean
|
||||
static gboolean
|
||||
exit_sighandler (gpointer user_data)
|
||||
{
|
||||
gst_print ("Caught signal, stopping mainloop\n");
|
||||
gst_println ("Caught signal, stopping mainloop");
|
||||
GMainLoop *mainloop = (GMainLoop *) user_data;
|
||||
g_main_loop_quit (mainloop);
|
||||
return TRUE;
|
||||
@ -693,15 +688,14 @@ main (int argc, char *argv[])
|
||||
g_unix_signal_add (SIGTERM, exit_sighandler, mainloop);
|
||||
#endif
|
||||
|
||||
soup_server =
|
||||
soup_server_new (SOUP_SERVER_SERVER_HEADER, "webrtc-soup-server", NULL);
|
||||
soup_server = soup_server_new ("server-header", "webrtc-soup-server", NULL);
|
||||
soup_server_add_handler (soup_server, "/", soup_http_handler, NULL, NULL);
|
||||
soup_server_add_websocket_handler (soup_server, "/ws", NULL, NULL,
|
||||
soup_websocket_handler, (gpointer) receiver_entry_table, NULL);
|
||||
soup_server_listen_all (soup_server, SOUP_HTTP_PORT,
|
||||
(SoupServerListenOptions) 0, NULL);
|
||||
|
||||
gst_print ("WebRTC page link: http://127.0.0.1:%d/\n", (gint) SOUP_HTTP_PORT);
|
||||
gst_println ("WebRTC page link: http://127.0.0.1:%d/", (gint) SOUP_HTTP_PORT);
|
||||
|
||||
g_main_loop_run (mainloop);
|
||||
|
||||
|
@ -984,13 +984,16 @@ connect_to_websocket_server_async (void)
|
||||
SoupSession *session;
|
||||
const char *https_aliases[] = { "wss", NULL };
|
||||
|
||||
session =
|
||||
soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, !disable_ssl,
|
||||
SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
|
||||
//SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt",
|
||||
SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);
|
||||
session = soup_session_new_with_options ("ssl-strict", !disable_ssl,
|
||||
"ssl-use-system-ca-file", TRUE,
|
||||
//"ssl-ca-file", "/etc/ssl/certs/ca-bundle.crt",
|
||||
"http-aliases", https_aliases, NULL);
|
||||
|
||||
#if SOUP_CHECK_VERSION(3,0,0)
|
||||
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
|
||||
#else
|
||||
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
|
||||
#endif
|
||||
soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
|
||||
g_object_unref (logger);
|
||||
|
||||
@ -999,8 +1002,11 @@ connect_to_websocket_server_async (void)
|
||||
gst_print ("Connecting to server...\n");
|
||||
|
||||
/* Once connected, we will register */
|
||||
soup_session_websocket_connect_async (session, message, NULL, NULL, NULL,
|
||||
(GAsyncReadyCallback) on_server_connected, message);
|
||||
soup_session_websocket_connect_async (session, message, NULL, NULL,
|
||||
#if SOUP_CHECK_VERSION(3,0,0)
|
||||
G_PRIORITY_DEFAULT,
|
||||
#endif
|
||||
NULL, (GAsyncReadyCallback) on_server_connected, message);
|
||||
app_state = SERVER_CONNECTING;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,8 @@ exif_dep = dependency('libexif', version : '>= 0.6.16', required : false)
|
||||
nalutils_dep = gstcodecparsers_dep.partial_dependency (compile_args: true, includes: true)
|
||||
|
||||
enable_gst_play_tests = get_option('gst_play_tests')
|
||||
libsoup_dep = dependency('libsoup-3.0', include_type: 'system', required: enable_gst_play_tests)
|
||||
libsoup_dep = dependency('libsoup-3.0', include_type: 'system', required: enable_gst_play_tests,
|
||||
default_options: {'tests': false})
|
||||
|
||||
# name, condition when to skip the test and extra dependencies
|
||||
base_tests = [
|
||||
|
@ -24,7 +24,8 @@ soup_dlopen_target_kwargs = {}
|
||||
if get_option('soup').allowed() or get_option('adaptivedemux2').allowed()
|
||||
if soup_ver_opt in ['auto', '3']
|
||||
libsoup3_dep = dependency('libsoup-3.0', allow_fallback: true, include_type: 'system',
|
||||
required: soup_ver_opt == '3' and soup_lookup_dep)
|
||||
required: soup_ver_opt == '3' and soup_lookup_dep,
|
||||
default_options: {'tests': false})
|
||||
endif
|
||||
if soup_ver_opt in ['auto', '2']
|
||||
libsoup2_dep = dependency('libsoup-2.4', version: '>=2.48', allow_fallback: true,
|
||||
|
@ -1,11 +1,9 @@
|
||||
[wrap-file]
|
||||
directory = libsoup-2.74.3
|
||||
source_url = https://download.gnome.org/sources/libsoup/2.74/libsoup-2.74.3.tar.xz
|
||||
source_fallback_url = https://deb.debian.org/debian/pool/main/libs/libsoup2.4/libsoup2.4_2.74.3.orig.tar.xz
|
||||
source_filename = libsoup-2.74.3.tar.xz
|
||||
source_hash = e4b77c41cfc4c8c5a035fcdc320c7bc6cfb75ef7c5a034153df1413fa1d92f13
|
||||
diff_files = libsoup-2.74.3/0001-Workaround-MinGW-build-werror.patch
|
||||
directory = libsoup-3.6.5
|
||||
source_url = https://download.gnome.org/sources/libsoup/3.6/libsoup-3.6.5.tar.xz
|
||||
source_fallback_url = https://deb.debian.org/debian/pool/main/libs/libsoup3/libsoup3_3.6.5.orig.tar.xz
|
||||
source_filename = libsoup-3.6.5.tar.xz
|
||||
source_hash = 6891765aac3e949017945c3eaebd8cc8216df772456dc9f460976fbdb7ada234
|
||||
|
||||
[provide]
|
||||
libsoup-2.4 = libsoup_dep
|
||||
libsoup-gnome-2.4 = libsoup_gnome_dep
|
||||
libsoup-3.0 = libsoup_dep
|
||||
|
13
subprojects/nghttp2.wrap
Normal file
13
subprojects/nghttp2.wrap
Normal file
@ -0,0 +1,13 @@
|
||||
[wrap-file]
|
||||
directory = nghttp2-1.62.1
|
||||
source_url = https://github.com/nghttp2/nghttp2/releases/download/v1.62.1/nghttp2-1.62.1.tar.xz
|
||||
source_filename = nghttp2-1.62.1.tar.xz
|
||||
source_hash = 2345d4dc136fda28ce243e0bb21f2e7e8ef6293d62c799abbf6f633a6887af72
|
||||
patch_filename = nghttp2_1.62.1-2_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/nghttp2_1.62.1-2/get_patch
|
||||
patch_hash = 9bbc38da6ebb57ccecbbf0f719f8b3dd3a1632e1b6b1f898665fb342d6a6647c
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/nghttp2_1.62.1-2/nghttp2-1.62.1.tar.xz
|
||||
wrapdb_version = 1.62.1-2
|
||||
|
||||
[provide]
|
||||
dependency_names = libnghttp2
|
Loading…
x
Reference in New Issue
Block a user