aboutsummaryrefslogtreecommitdiff
From e70dcd0a9f89efbdaa011c20737ad550635ea580 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
Date: Tue, 20 Oct 2020 19:51:22 -0400
Subject: [PATCH] rawudp-upnp test: Also build against new GUPnP 1.2 library if
 present

Update the configure test to match
---
 configure.ac                          | 17 +++++++++++++++++
 tests/check/Makefile.am               |  7 +++----
 tests/check/transmitter/rawudp-upnp.c | 16 ++++++++++++++--
 tests/check/transmitter/rawudp.c      |  4 ++--
 4 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 03afc96b..1efed132 100644
--- a/configure.ac
+++ b/configure.ac
@@ -370,8 +370,25 @@ fi
 
 if test "x$HAVE_GUPNP" = "xyes"; then
    AC_DEFINE(HAVE_GUPNP,,[Have the GUPnP IGD library])
+
+    PKG_CHECK_MODULES(GUPNP_CORE, [ gupnp-1.2 ],
+	[ HAVE_GUPNP_CORE_12=yes ],
+	[ HAVE_GUPNP_CORE_12=no
+	  PKG_CHECK_MODULES(GUPNP_CORE, [ gupnp-1.0 ],
+	     [ HAVE_GUPNP_CORE_10=yes ],
+	     [ HAVE_GUPNP_CORE_10=no ])
+    ])
+
+    if test "x$HAVE_GUPNP_CORE_10" = "xyes"; then
+       AC_DEFINE(HAVE_GUPNP_CORE_10,,[Have the GUPnP 1.0 library])
+    fi
+
+    if test "x$HAVE_GUPNP_CORE_12" = "xyes"; then
+       AC_DEFINE(HAVE_GUPNP_CORE_12,,[Have the GUPnP 1.2 library])
+    fi
 fi
 
+
 dnl build static plugins or not
 AC_MSG_CHECKING([whether to build static plugins or not])
 AC_ARG_ENABLE(
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index d50fc264..d21687d7 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -76,9 +76,9 @@ base_fscodec_SOURCES = \
 
 
 transmitter_rawudp_CFLAGS = $(AM_CFLAGS) \
-	$(GUPNP_CFLAGS) $(GIO_CFLAGS) $(NICE_CFLAGS)
+	$(GUPNP_CORE_CFLAGS) $(GIO_CFLAGS) $(NICE_CFLAGS)
 transmitter_rawudp_LDADD = $(LDADD) \
-	$(GUPNP_LIBS) \
+	$(GUPNP_CORE_LIBS) \
 	$(GIO_LIBS) \
 	$(NICE_LIBS)
 transmitter_rawudp_SOURCES = \
@@ -113,9 +113,8 @@ transmitter_nice_SOURCES = \
 transmitter_nice_LDADD = $(LDADD) $(GST_BASE_LIBS)
 
 
-transmitter_shm_CFLAGS = $(AM_CFLAGS) $(GUPNP_CFLAGS) $(NICE_CFLAGS)
+transmitter_shm_CFLAGS = $(AM_CFLAGS) $(NICE_CFLAGS)
 transmitter_shm_LDADD = $(LDADD) \
-	$(GUPNP_LIBS) \
 	$(NICE_LIBS)
 transmitter_shm_SOURCES = \
 	check-threadsafe.h  \
diff --git a/tests/check/transmitter/rawudp-upnp.c b/tests/check/transmitter/rawudp-upnp.c
index 4818cd28..9ccf85d8 100644
--- a/tests/check/transmitter/rawudp-upnp.c
+++ b/tests/check/transmitter/rawudp-upnp.c
@@ -37,7 +37,7 @@ get_vars (gboolean *out_got_address,
 }
 
 
-#ifdef HAVE_GUPNP
+#if defined(HAVE_GUPNP_CORE_10) || defined(HAVE_GUPNP_CORE_12)
 
 #include <libgupnp/gupnp.h>
 
@@ -126,8 +126,14 @@ start_upnp_server (void)
   GUPnPDeviceInfo *subdev1;
   GUPnPDeviceInfo *subdev2;
   const gchar *upnp_xml_path;
+  GError *gerr = NULL;
 
-  context = gupnp_context_new (NULL, NULL, 0, NULL);
+#ifdef HAVE_GUPNP_CORE_12
+  context = gupnp_context_new (NULL, 0, &gerr);
+#else
+  context = gupnp_context_new (NULL, NULL, 0, &gerr);
+#endif
+  g_assert_no_error (gerr);
   ts_fail_if (context == NULL, "Can't get gupnp context");
 
   if (g_getenv ("UPNP_XML_PATH"))
@@ -137,8 +143,14 @@ start_upnp_server (void)
 
   gupnp_context_host_path (context, upnp_xml_path, "");
 
+#ifdef HAVE_GUPNP_CORE_12
+  dev = gupnp_root_device_new (context, "InternetGatewayDevice.xml",
+      upnp_xml_path, &gerr);
+  g_assert_no_error (gerr);
+#else
   dev = gupnp_root_device_new (context, "InternetGatewayDevice.xml",
       upnp_xml_path);
+#endif
   ts_fail_if (dev == NULL, "could not get root dev");
 
   subdev1 = gupnp_device_info_get_device (GUPNP_DEVICE_INFO (dev),
diff --git a/tests/check/transmitter/rawudp.c b/tests/check/transmitter/rawudp.c
index e1936ac0..d803f347 100644
--- a/tests/check/transmitter/rawudp.c
+++ b/tests/check/transmitter/rawudp.c
@@ -637,7 +637,7 @@ GST_START_TEST (test_rawudptransmitter_stop_stream)
 }
 GST_END_TEST;
 
-#ifdef HAVE_GUPNP
+#if defined(HAVE_GUPNP_CORE_10) || defined (HAVE_GUPNP_CORE_12)
 
 GST_START_TEST (test_rawudptransmitter_run_upnp_discovery)
 {
@@ -967,7 +967,7 @@ rawudptransmitter_suite (void)
   tcase_add_test (tc_chain, test_rawudptransmitter_stop_stream);
   suite_add_tcase (s, tc_chain);
 
-#ifdef HAVE_GUPNP
+#if defined(HAVE_GUPNP_CORE_10) || defined (HAVE_GUPNP_CORE_12)
   if (g_getenv ("UPNP")) {
     gchar *multicast_addr;
 
-- 
GitLab