vlc/vlc-3.0 | branch: master | Luca Barbato <[email protected]> | Sat May 18 16:41:32 2019 +0200| [30a62bacd9d9b1f05915287243aecc16919cf756] | committer: Felix Paul Kühne
upnp: implement getPreferedAdapter for macOS Signed-off-by: Felix Paul Kühne <[email protected]> (cherry picked from commit d041a6cd3c7c7d29c8b36aeeab528d417738b532) > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=30a62bacd9d9b1f05915287243aecc16919cf756 --- modules/services_discovery/Makefile.am | 3 +++ modules/services_discovery/upnp.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/modules/services_discovery/Makefile.am b/modules/services_discovery/Makefile.am index efd9cf6708..e070d6463b 100644 --- a/modules/services_discovery/Makefile.am +++ b/modules/services_discovery/Makefile.am @@ -33,6 +33,9 @@ libupnp_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(sddir)' libupnp_plugin_la_LIBADD = $(UPNP_LIBS) EXTRA_LTLIBRARIES += libupnp_plugin.la sd_LTLIBRARIES += $(LTLIBupnp) +if HAVE_OSX +libupnp_plugin_la_LDFLAGS += -Wl,-framework,CoreFoundation,-framework,SystemConfiguration +endif libpulselist_plugin_la_SOURCES = services_discovery/pulse.c libpulselist_plugin_la_CFLAGS = $(AM_CFLAGS) $(PULSE_CFLAGS) diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp index 127f562837..168c005ff7 100644 --- a/modules/services_discovery/upnp.cpp +++ b/modules/services_discovery/upnp.cpp @@ -1542,11 +1542,39 @@ 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 = (CFDictionaryRef) SCDynamicStoreCopyValue(session, CFSTR("State:/Network/Global/IPv4")); + char *returnValue = NULL; + + if (q != NULL) { + const void *val; + if (CFDictionaryGetValueIfPresent(q, CFSTR("PrimaryInterface"), &val)) { + returnValue = FromCFString((CFStringRef)val, kCFStringEncodingUTF8); + } + } + CFRelease(q); + CFRelease(session); + + return returnValue; +} +#else + static char *getPreferedAdapter() { return NULL; } +#endif #else static char *getIpv4ForMulticast() _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
