[vlc-devel] [PATCH] Implement getPreferedAdapter for macOS

Luca Barbato lu_zero at gentoo.org
Sat May 18 16:41:32 CEST 2019


---

So Felix can test it.

 modules/services_discovery/upnp-wrapper.hpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/services_discovery/upnp-wrapper.hpp b/modules/services_discovery/upnp-wrapper.hpp
index 417f15a6dd..c96e54e3a3 100644
--- a/modules/services_discovery/upnp-wrapper.hpp
+++ b/modules/services_discovery/upnp-wrapper.hpp
@@ -334,11 +334,38 @@ done:

 #ifdef UPNP_ENABLE_IPV6

+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
+#if defined(TARGET_OS_MAC) && TARGET_OS_MAC
+#include <SystemConfiguration/SystemConfiguration.h>
+#include "vlc_charset.h"
+
 inline char *getPreferedAdapter()
 {
+    SCDynamicStoreRef session = SCDynamicStoreCreate(NULL, CFSTR("session"), NULL, NULL);
+    CFDictionaryRef q = SCDynamicStoreCopyValue(session, CFSTR("State:/Network/Global/IPv4"));
+
+    if (q != NULL) {
+        CFStringRef val;
+        if (CFDictionaryGetValueIfPresent(q, CFSTR("PrimaryInterface"), val)) {
+            FromCFString(val, kCFStringEncodingUTF8);
+        } else {
+            return NULL;
+        }
+    }
+
+    return NULL;
+}
+#else
+
+inline char *getIpv4ForMulticast()
+{
     return NULL;
 }

+#endif
 #else

 inline char *getIpv4ForMulticast()
--
2.12.2



More information about the vlc-devel mailing list