Skip to content

Commit

Permalink
VLC2: add a fix for < 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed Oct 11, 2024
1 parent 4c7410d commit 4e2ea46
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions multimedia/VLC2/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ if {(${subport} eq ${name}) || (${subport} eq "lib${name}")} {
# Make 10.12 and later ignore all QTKit code in modules/gui/macosx/open.m
patchfiles-append patch-really-no-qtkit.diff

# Only needed on < 10.6, since kCFNetworkProxiesHTTPProxy and kCFNetworkProxiesHTTPPort
# are unavailable. We fall back to an earlier code, which needs to link
# against SystemConfiguration. Not needed on any version of 10.6 ppc.
if {${os.platform} eq "darwin" && ${os.major} < 10} {
patchfiles-append \
patch-SystemConfiguration.diff
}

if {![info exists replaced_by]} {
post-patch {
if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} == "libc++"} {
Expand Down
81 changes: 81 additions & 0 deletions multimedia/VLC2/files/patch-SystemConfiguration.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
--- configure.ac
+++ configure.ac 2024-10-11 19:59:30
@@ -163,7 +163,7 @@
OBJCFLAGS="${OBJCFLAGS} -D_INTL_REDIRECT_MACROS -std=gnu99"
LDFLAGS="${LDFLAGS} -Wl,-headerpad_max_install_names"
VLC_ADD_LIBS([libvlc vlc],[-Wl,-undefined,dynamic_lookup,-framework,AppKit])
- VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation,-framework,CoreServices])
+ VLC_ADD_LIBS([libvlccore],[-Wl,-framework,CoreFoundation,-framework,CoreServices,-framework,SystemConfiguration])

AC_EGREP_CPP(yes,
[#import <TargetConditionals.h>

--- src/darwin/netconf.c
+++ src/darwin/netconf.c 2024-10-11 17:09:51
@@ -45,6 +45,7 @@
char *vlc_getProxyUrl(const char *url)
{
VLC_UNUSED(url);
+#if TARGET_OS_IPHONE
char *proxy_url = NULL;
CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();
if (NULL != dicRef) {
@@ -73,4 +74,58 @@
}

return proxy_url;
+#else
+ CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL);
+ char *proxy_url = NULL;
+
+ if (proxies) {
+ CFNumberRef cfn_httpProxyOn =
+ (CFNumberRef)CFDictionaryGetValue(proxies,
+ kSCPropNetProxiesHTTPEnable);
+ if (cfn_httpProxyOn) {
+ int i_httpProxyOn;
+ CFNumberGetValue(cfn_httpProxyOn, kCFNumberIntType, &i_httpProxyOn);
+ CFRelease(cfn_httpProxyOn);
+
+ if (i_httpProxyOn == 1) // http proxy is on
+ {
+ CFStringRef httpProxy =
+ (CFStringRef)CFDictionaryGetValue(proxies,
+ kSCPropNetProxiesHTTPProxy);
+
+ if (httpProxy) {
+ CFNumberRef cfn_httpProxyPort =
+ (CFNumberRef)CFDictionaryGetValue(proxies,
+ kSCPropNetProxiesHTTPPort);
+ int i_httpProxyPort;
+ CFNumberGetValue(cfn_httpProxyPort,
+ kCFNumberIntType,
+ &i_httpProxyPort);
+ CFRelease(cfn_httpProxyPort);
+
+ CFMutableStringRef outputURL =
+ CFStringCreateMutableCopy(kCFAllocatorDefault,
+ 0,
+ httpProxy);
+ if (i_httpProxyPort > 0)
+ CFStringAppendFormat(outputURL,
+ NULL,
+ CFSTR(":%i"),
+ i_httpProxyPort);
+
+ char buffer[4096];
+ if (CFStringGetCString(outputURL, buffer, sizeof(buffer),
+ kCFStringEncodingUTF8))
+ proxy_url = strdup(buffer);
+
+ CFRelease(outputURL);
+ }
+ CFRelease(httpProxy);
+ }
+ }
+ CFRelease(proxies);
+ }
+
+ return proxy_url;
+#endif
}

0 comments on commit 4e2ea46

Please sign in to comment.