play: Port tests to libsoup 3
authorSebastian Dröge <sebastian@centricular.com>
Thu, 10 Oct 2024 19:54:04 +0000 (15:54 -0400)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 28 Dec 2024 09:49:42 +0000 (11:49 +0200)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7650>

subprojects/gst-plugins-bad/tests/check/libs/play.c
subprojects/gst-plugins-bad/tests/check/meson.build

index ced2d023a67814b1c2c08f52864a035724978a7f..72d5357d84e63f4170d8cc6dbe5a5464a593c011 100644 (file)
 # include <valgrind/valgrind.h>
 #endif
 
-#define SOUP_VERSION_MIN_REQUIRED (SOUP_VERSION_2_40)
 #include <libsoup/soup.h>
-#if !defined(SOUP_MINOR_VERSION) || SOUP_MINOR_VERSION < 44
-#define SoupStatus SoupKnownStatusCode
-#endif
 
 #include <gst/check/gstcheck.h>
 
@@ -1566,18 +1562,19 @@ START_TEST (test_restart)
 END_TEST;
 
 static void
-do_get (SoupMessage * msg, const char *path)
+do_get (SoupServerMessage * msg, const char *path)
 {
   char *uri;
   SoupStatus status = SOUP_STATUS_OK;
 
-  uri = soup_uri_to_string (soup_message_get_uri (msg), FALSE);
+  uri = g_uri_to_string (soup_server_message_get_uri (msg));
   GST_DEBUG ("request: \"%s\"", uri);
 
   if (status != (SoupStatus) SOUP_STATUS_OK)
     goto beach;
 
-  if (msg->method == SOUP_METHOD_GET) {
+  if (soup_server_message_get_method (msg) == SOUP_METHOD_GET) {
+    SoupMessageBody *response_body;
     char *full_path = g_strconcat (TEST_PATH, path, NULL);
     char *buf;
     gsize buflen;
@@ -1589,31 +1586,35 @@ do_get (SoupMessage * msg, const char *path)
     }
 
     g_free (full_path);
-    soup_message_body_append (msg->response_body, SOUP_MEMORY_TAKE,
-        buf, buflen);
+    response_body = soup_server_message_get_response_body (msg);
+    soup_message_body_append (response_body, SOUP_MEMORY_TAKE, buf, buflen);
   }
 
 beach:
-  soup_message_set_status (msg, status);
+  soup_server_message_set_status (msg, status, NULL);
   g_free (uri);
 }
 
 static void
-server_callback (SoupServer * server, SoupMessage * msg,
-    const char *path, GHashTable * query,
-    SoupClientContext * context, gpointer data)
+server_callback (SoupServer * server, SoupServerMessage * msg,
+    const char *path, GHashTable * query, gpointer data)
 {
-  GST_DEBUG ("%s %s HTTP/1.%d", msg->method, path,
-      soup_message_get_http_version (msg));
-  if (msg->request_body->length)
-    GST_DEBUG ("%s", msg->request_body->data);
+  SoupMessageBody *request_body;
+
+  GST_DEBUG ("%s %s HTTP/1.%d", soup_server_message_get_method (msg),
+      path, soup_server_message_get_http_version (msg));
+  if ((request_body = soup_server_message_get_request_body (msg))
+      && request_body->length > 0) {
+    GST_DEBUG ("%s", request_body->data);
+  }
 
-  if (msg->method == SOUP_METHOD_GET)
+  if (soup_server_message_get_method (msg) == SOUP_METHOD_GET)
     do_get (msg, path);
   else
-    soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
+    soup_server_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED, NULL);
 
-  GST_DEBUG ("  -> %d %s", msg->status_code, msg->reason_phrase);
+  GST_DEBUG ("  -> %d %s", soup_server_message_get_status (msg),
+      soup_server_message_get_reason_phrase (msg));
 }
 
 static guint
@@ -1624,8 +1625,8 @@ get_port_from_server (SoupServer * server)
 
   uris = soup_server_get_uris (server);
   g_assert (g_slist_length (uris) == 1);
-  port = soup_uri_get_port (uris->data);
-  g_slist_free_full (uris, (GDestroyNotify) soup_uri_free);
+  port = g_uri_get_port (uris->data);
+  g_slist_free_full (uris, (GDestroyNotify) g_uri_unref);
 
   return port;
 }
@@ -1668,9 +1669,7 @@ http_main (gpointer data)
     GError *err = NULL;
     SoupServerListenOptions listen_flags = 0;
 
-    address =
-        g_inet_socket_address_new_from_string ("0.0.0.0",
-        SOUP_ADDRESS_ANY_PORT);
+    address = g_inet_socket_address_new_from_string ("0.0.0.0", 0);
     soup_server_listen (context->server, address, listen_flags, &err);
     g_object_unref (address);
 
index 65c1021c6add61d7cd48cec1dcc93c2a4f3e3a53..dabe2f8ec9a66f1a7effe4fa329d6aba35f7a4b1 100644 (file)
@@ -16,7 +16,7 @@ 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-2.4', version: '>=2.48', required: enable_gst_play_tests)
+libsoup_dep = dependency('libsoup-3.0', required : enable_gst_play_tests)
 
 # name, condition when to skip the test and extra dependencies
 base_tests = [