diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 066adf10..eafa07fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: sudo apt update sudo apt install automake libtool pkg-config libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt install libglib2.0-dev libjson-glib-dev gtk-doc-tools libedit-dev libncursesw5-dev - sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup2.4-dev + sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup-3.0-dev - name: Generate run: ./autogen.sh - name: Configure @@ -72,7 +72,7 @@ jobs: sudo apt update sudo apt install automake libtool pkg-config libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt install libglib2.0-dev libjson-glib-dev gtk-doc-tools libedit-dev libncursesw5-dev - sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup2.4-dev + sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup-3.0-dev sudo apt install ninja-build python3-wheel sudo pip3 install meson diff --git a/configure.ac b/configure.ac index ef171801..3233ad43 100644 --- a/configure.ac +++ b/configure.ac @@ -85,7 +85,7 @@ PKG_CHECK_MODULES(GST, [ ]) ]) -PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.32]) +PKG_CHECK_MODULES(LIBSOUP, [libsoup-3.0 >= 2.99]) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS) diff --git a/libgstd/gstd_http.c b/libgstd/gstd_http.c index ef4a20f5..bbc5c9b2 100644 --- a/libgstd/gstd_http.c +++ b/libgstd/gstd_http.c @@ -39,7 +39,7 @@ GST_DEBUG_CATEGORY_STATIC (gstd_http_debug); typedef struct _GstdHttpRequest { SoupServer *server; - SoupMessage *msg; + SoupServerMessage *msg; GstdSession *session; const char *path; GHashTable *query; @@ -73,19 +73,18 @@ static GstdReturnCode gstd_http_stop (GstdIpc * base); static gboolean gstd_http_init_get_option_group (GstdIpc * base, GOptionGroup ** group); static SoupStatus get_status_code (GstdReturnCode ret); -static GstdReturnCode do_get (SoupServer * server, SoupMessage * msg, +static GstdReturnCode do_get (SoupServer * server, SoupServerMessage * msg, char **output, const char *path, GstdSession * session); -static GstdReturnCode do_post (SoupServer * server, SoupMessage * msg, +static GstdReturnCode do_post (SoupServer * server, SoupServerMessage * msg, char *name, char *description, char **output, const char *path, GstdSession * session); -static GstdReturnCode do_put (SoupServer * server, SoupMessage * msg, +static GstdReturnCode do_put (SoupServer * server, SoupServerMessage * msg, char *name, char **output, const char *path, GstdSession * session); -static GstdReturnCode do_delete (SoupServer * server, SoupMessage * msg, +static GstdReturnCode do_delete (SoupServer * server, SoupServerMessage * msg, char *name, char **output, const char *path, GstdSession * session); static void do_request (gpointer data_request, gpointer eval); -static void server_callback (SoupServer * server, SoupMessage * msg, - const char *path, GHashTable * query, SoupClientContext * context, - gpointer data); +static void server_callback (SoupServer * server, SoupServerMessage * msg, + const char *path, GHashTable * query, gpointer data); static void gstd_http_class_init (GstdHttpClass * klass) @@ -168,7 +167,7 @@ get_status_code (GstdReturnCode ret) } static GstdReturnCode -do_get (SoupServer * server, SoupMessage * msg, char **output, const char *path, +do_get (SoupServer * server, SoupServerMessage * msg, char **output, const char *path, GstdSession * session) { gchar *message = NULL; @@ -189,7 +188,7 @@ do_get (SoupServer * server, SoupMessage * msg, char **output, const char *path, } static GstdReturnCode -do_post (SoupServer * server, SoupMessage * msg, char *name, +do_post (SoupServer * server, SoupServerMessage * msg, char *name, char *description, char **output, const char *path, GstdSession * session) { gchar *message = NULL; @@ -224,7 +223,7 @@ do_post (SoupServer * server, SoupMessage * msg, char *name, } static GstdReturnCode -do_put (SoupServer * server, SoupMessage * msg, char *name, char **output, +do_put (SoupServer * server, SoupServerMessage * msg, char *name, char **output, const char *path, GstdSession * session) { gchar *message = NULL; @@ -254,7 +253,7 @@ do_put (SoupServer * server, SoupMessage * msg, char *name, char **output, } static GstdReturnCode -do_delete (SoupServer * server, SoupMessage * msg, char *name, +do_delete (SoupServer * server, SoupServerMessage * msg, char *name, char **output, const char *path, GstdSession * session) { gchar *message = NULL; @@ -294,11 +293,12 @@ do_request (gpointer data_request, gpointer eval) const gchar *description = NULL; SoupStatus status = SOUP_STATUS_OK; SoupServer *server = NULL; - SoupMessage *msg = NULL; + SoupServerMessage *msg = NULL; GstdSession *session = NULL; const char *path = NULL; GHashTable *query = NULL; GstdHttpRequest *data_request_local = NULL; + const char *method; g_return_if_fail (data_request); @@ -316,15 +316,16 @@ do_request (gpointer data_request, gpointer eval) description_pipe = g_hash_table_lookup (query, "description"); } - if (msg->method == SOUP_METHOD_GET) { + method = soup_server_message_get_method (msg); + if (method == SOUP_METHOD_GET) { ret = do_get (server, msg, &output, path, session); - } else if (msg->method == SOUP_METHOD_POST) { + } else if (method == SOUP_METHOD_POST) { ret = do_post (server, msg, name, description_pipe, &output, path, session); - } else if (msg->method == SOUP_METHOD_PUT) { + } else if (method == SOUP_METHOD_PUT) { ret = do_put (server, msg, name, &output, path, session); - } else if (msg->method == SOUP_METHOD_DELETE) { + } else if (method == SOUP_METHOD_DELETE) { ret = do_delete (server, msg, name, &output, path, session); - } else if (msg->method == SOUP_METHOD_OPTIONS) { + } else if (method == SOUP_METHOD_OPTIONS) { ret = GSTD_EOK; } @@ -336,15 +337,15 @@ do_request (gpointer data_request, gpointer eval) g_free (output); output = NULL; - soup_message_set_response (msg, "application/json", SOUP_MEMORY_COPY, + soup_server_message_set_response (msg, "application/json", SOUP_MEMORY_COPY, response, strlen (response)); g_free (response); response = NULL; status = get_status_code (ret); - soup_message_set_status (msg, status); + soup_server_message_set_status (msg, status, NULL); g_mutex_lock (data_request_local->mutex); - soup_server_unpause_message (server, msg); + soup_server_message_unpause (msg); g_mutex_unlock (data_request_local->mutex); if (query != NULL) { @@ -357,13 +358,14 @@ do_request (gpointer data_request, gpointer eval) } static void -server_callback (SoupServer * server, SoupMessage * msg, +server_callback (SoupServer * server, SoupServerMessage * msg, const char *path, GHashTable * query, - SoupClientContext * context, gpointer data) + gpointer data) { GstdSession *session = NULL; GstdHttp *self = NULL; GstdHttpRequest *data_request = NULL; + SoupMessageHeaders *response_headers = NULL; g_return_if_fail (server); g_return_if_fail (msg); @@ -385,14 +387,15 @@ server_callback (SoupServer * server, SoupMessage * msg, } data_request->mutex = &self->mutex; - soup_message_headers_append (msg->response_headers, + response_headers = soup_server_message_get_request_headers (msg); + soup_message_headers_append (response_headers, "Access-Control-Allow-Origin", "*"); - soup_message_headers_append (msg->response_headers, + soup_message_headers_append (response_headers, "Access-Control-Allow-Headers", "origin,range,content-type"); - soup_message_headers_append (msg->response_headers, + soup_message_headers_append (response_headers, "Access-Control-Allow-Methods", "PUT, GET, POST, DELETE"); g_mutex_lock (&self->mutex); - soup_server_pause_message (server, msg); + soup_server_message_pause (msg); g_mutex_unlock (&self->mutex); if (!g_thread_pool_push (self->pool, (gpointer) data_request, NULL)) { GST_ERROR_OBJECT (self->pool, "Thread pool push failed"); @@ -420,7 +423,7 @@ gstd_http_start (GstdIpc * base, GstdSession * session) gstd_http_stop (base); GST_DEBUG_OBJECT (self, "Initializing HTTP server"); - self->server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "Gstd-1.0", NULL); + self->server = soup_server_new ("server-header", "Gstd-1.0", NULL); if (!self->server) { goto noconnection; } diff --git a/meson.build b/meson.build index 43addf9a..ae0767e8 100644 --- a/meson.build +++ b/meson.build @@ -27,7 +27,7 @@ json_glib_dep = dependency('json-glib-1.0', version : '>=0.16.2') libd_dep = dependency('libdaemon', version : '>=0.14') jansson_dep = dependency('jansson', version : '>=2.7') thread_dep = dependency('threads') -libsoup_dep = dependency('libsoup-2.4', version : '>=2.4') +libsoup_dep = dependency('libsoup-3.0', version : '>=2.99') libedit_dep = dependency('libedit', version : '>=3.0') gst_check_required = get_option('enable-tests').enabled()