From 544f80b9dd54012a7771093717a4fdd77fe242a2 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Sat, 1 Jun 2013 12:27:17 +0100 Subject: [PATCH 1/8] - add buildsystem for embedded mdnsresponder --- .../build-bonjour-embed-android.sh | 140 +++++++ .../mDNSResponder-333.10.umundo.patch | 379 ++++++++++++++++++ 2 files changed, 519 insertions(+) create mode 100755 tools/depends/target/mdnsresponder/build-bonjour-embed-android.sh create mode 100644 tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch diff --git a/tools/depends/target/mdnsresponder/build-bonjour-embed-android.sh b/tools/depends/target/mdnsresponder/build-bonjour-embed-android.sh new file mode 100755 index 0000000000000..69da436833ca8 --- /dev/null +++ b/tools/depends/target/mdnsresponder/build-bonjour-embed-android.sh @@ -0,0 +1,140 @@ +#!/bin/bash +# fetch from http://www.opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-333.10.tar.gz +# exit on error +set -e + +ME=`basename $0` +DIR="$( cd "$( dirname "$0" )" && pwd )" +BUILD_DIR="/tmp/build-pcre-android/" +DEST_DIR="${DIR}/../prebuilt/android" + +if [ ! -d mDNSPosix ]; then + echo + echo "Cannot find mDNSPosix" + echo "Run script from within mDNSResponder directory:" + echo "mDNSResponder-333.10$ ../../../${ME}" + echo + exit +fi +mkdir -p ${DEST_DIR} &> /dev/null + +if [ -f ispatched ]; then + rm ./ispatched +else + patch -p1 < ../mDNSResponder-333.10.umundo.patch +fi + +# #ifdef TARGET_OS_ANDROID +# __android_log_print(ANDROID_LOG_VERBOSE, "umundo", "%s:%d: mDNSPlatformTimeInit returned %d\n", __FILE__, __LINE__, result); +# #endif + +touch ispatched + +mDNSEmbedded=( mDNSShared/dnssd_clientshim.c mDNSPosix/mDNSPosix.c mDNSCore/mDNS.c mDNSCore/DNSCommon.c mDNSShared/mDNSDebug.c \ + mDNSShared/GenLinkedList.c mDNSCore/uDNS.c mDNSShared/PlatformCommon.c mDNSPosix/mDNSUNP.c mDNSCore/DNSDigest.c mDNSCore/mDnsEmbedded.c ) + +CC_COMMON_FLAGS="-I. -DANDROID -DTARGET_OS_ANDROID -fno-strict-aliasing -fno-omit-frame-pointer -fno-exceptions -fdata-sections -ffunction-sections" +CC_COMMON_FLAGS="\ + ${CC_COMMON_FLAGS} \ + -ImDNSCore -ImDNSShared -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" \ + -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" -DTARGET_OS_ANDROID -DNOT_HAVE_SA_LEN -DUSES_NETLINK -fpic\ + -Wdeclaration-after-statement -Wno-unused-parameter -Wno-unused-but-set-variable -Os -llog" + +# build for x86 + +#CC_X86_FLAGS="${CC_COMMON_FLAGS} \ +#-funwind-tables \ +#-finline-limit=300" + +#X86_SYSROOT="${ANDROID_NDK}/platforms/android-9/arch-x86" +#X86_TOOLCHAIN_ROOT="${ANDROID_NDK}/toolchains/x86-4.6/prebuilt/darwin-x86" +#X86_TOOL_PREFIX="i686-linux-android" +#X86_COMMON_FLAGS="\ +#-isystem ${ANDROID_NDK}/platforms/android-9/arch-x86/usr/include \ +#-isystem ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6/include \ +#-isystem ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.6/libs/x86/include" + +#AR="${X86_TOOLCHAIN_ROOT}/bin/${X86_TOOL_PREFIX}-ar" +#CC="${X86_TOOLCHAIN_ROOT}/bin/${X86_TOOL_PREFIX}-gcc" +#LD="${X86_TOOLCHAIN_ROOT}/bin/${X86_TOOL_PREFIX}-ld" + +#if [ -d build ]; then +# rm -rf build +#fi + +#mkdir -p build/mDNSPosix &> /dev/null +#mkdir -p build/mDNSCore &> /dev/null +#mkdir -p build/mDNSShared &> /dev/null +#mkdir -p build/prod &> /dev/null + +# compile all the files +#OBJS="" +#for file in ${mDNSEmbedded[@]}; do +# if [ ! -f build/${file}.o ]; then +# echo ${CC} --sysroot=${X86_SYSROOT} ${CC_X86_FLAGS} ${X86_COMMON_FLAGS} -c ${file} -o build/${file}.o +# ${CC} --sysroot=${X86_SYSROOT} ${CC_X86_FLAGS} ${X86_COMMON_FLAGS} -c ${file} -o build/${file}.o +# OBJS="$OBJS build/${file}.o" +# fi +#done + +# echo ${CC} --sysroot=${X86_SYSROOT} -shared -o build/prod/libmDNSEmbedded.so $OBJS +# ${CC} --sysroot=${X86_SYSROOT} -shared -o build/prod/libmDNSEmbedded.so $OBJS +#echo ${AR} rvs build/prod/libmDNSEmbedded.a $OBJS +#${AR} rvs build/prod/libmDNSEmbedded.a $OBJS + +#mkdir -p ${DEST_DIR}/x86/lib &> /dev/null +#cp build/prod/*.a ${DEST_DIR}/x86/lib + + +# build for arm + +CC_ARMEABI_FLAGS="${CC_COMMON_FLAGS} \ +-D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5__ \ +-fsigned-char \ +-march=armv5te \ +-mtune=xscale \ +-msoft-float \ +-mfpu=vfp \ +-mfloat-abi=softfp \ +-fPIC \ +-finline-limit=64" + +ANDROID_NDK="/home/jenkins/android-dev/android-ndk-r8e" +ARM_SYSROOT="${ANDROID_NDK}/platforms/android-14/arch-arm" +ARMEABI_TOOLCHAIN_ROOT="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/" +ARMEABI_TOOL_PREFIX="arm-linux-androideabi" +ARMEABI_COMMON_FLAGS="\ +-isystem ${ANDROID_NDK}/platforms/android-14/arch-arm/usr/include \ +-isystem ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.7/include \ +-isystem ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include" + +AR="${ARMEABI_TOOLCHAIN_ROOT}/bin/${ARMEABI_TOOL_PREFIX}-ar" +CC="${ARMEABI_TOOLCHAIN_ROOT}/bin/${ARMEABI_TOOL_PREFIX}-gcc" +LD="${ARMEABI_TOOLCHAIN_ROOT}/bin/${ARMEABI_TOOL_PREFIX}-ld" + +if [ -d build ]; then + rm -rf build +fi + +mkdir -p build/mDNSPosix &> /dev/null +mkdir -p build/mDNSCore &> /dev/null +mkdir -p build/mDNSShared &> /dev/null +mkdir -p build/prod &> /dev/null + +# compile all the files +OBJS="" +for file in ${mDNSEmbedded[@]}; do + if [ ! -f build/${file}.o ]; then + echo ${CC} --sysroot=${X86_SYSROOT} ${CC_ARMEABI_FLAGS} ${ARMEABI_COMMON_FLAGS} -c ${file} -o build/${file}.o + ${CC} --sysroot=${X86_SYSROOT} ${CC_ARMEABI_FLAGS} ${ARMEABI_COMMON_FLAGS} -c ${file} -o build/${file}.o + OBJS="$OBJS build/${file}.o" + fi +done + +# echo ${CC} --sysroot=${X86_SYSROOT} -shared -o build/prod/libmDNSEmbedded.so $OBJS +# ${CC} --sysroot=${X86_SYSROOT} -shared -o build/prod/libmDNSEmbedded.so $OBJS +echo ${AR} rvs build/prod/libmDNSEmbedded.a $OBJS +${AR} rvs build/prod/libmDNSEmbedded.a $OBJS + +mkdir -p ${DEST_DIR}/armeabi/lib &> /dev/null +cp build/prod/*.a ${DEST_DIR}/armeabi/lib diff --git a/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch b/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch new file mode 100644 index 0000000000000..cd7a1b9c60d4c --- /dev/null +++ b/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch @@ -0,0 +1,379 @@ +diff -rupN mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h +--- mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h 2011-06-30 22:56:04.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h 2012-04-15 15:10:42.000000000 +0200 +@@ -1051,6 +1051,10 @@ enum + McastResolver_FlagNew = 2 + }; + ++// everyone loves proprietary language extensions in the global namespace ++#ifdef _MSC_VER ++#undef interface ++#endif + typedef struct McastResolver + { + struct McastResolver *next; +diff -rupN mDNSResponder-333.10/mDNSPosix/mDNSPosix.h mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h +--- mDNSResponder-333.10/mDNSPosix/mDNSPosix.h 2009-08-11 03:13:47.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h 2012-04-15 15:10:42.000000000 +0200 +@@ -25,6 +25,10 @@ + extern "C" { + #endif + ++#ifdef TARGET_OS_ANDROID ++#include ++#endif ++ + // PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo + // type that supports extra fields needed by the Posix platform. + // +diff -rupN mDNSResponder-333.10/mDNSShared/PlatformCommon.c mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c +--- mDNSResponder-333.10/mDNSShared/PlatformCommon.c 2011-04-12 00:54:35.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c 2012-04-15 15:10:42.000000000 +0200 +@@ -27,6 +27,10 @@ + #include "DNSCommon.h" + #include "PlatformCommon.h" + ++#ifdef TARGET_OS_ANDROID ++#include ++#endif ++ + #ifdef NOT_HAVE_SOCKLEN_T + typedef unsigned int socklen_t; + #endif +@@ -143,13 +147,20 @@ mDNSexport void ReadDDNSSettingsFromConf + #if MDNS_DEBUGMSGS + mDNSexport void mDNSPlatformWriteDebugMsg(const char *msg) + { ++#ifdef TARGET_OS_ANDROID ++ __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", msg); ++#else + fprintf(stderr,"%s\n", msg); + fflush(stderr); ++#endif + } + #endif + + mDNSexport void mDNSPlatformWriteLogMsg(const char *ident, const char *buffer, mDNSLogLevel_t loglevel) + { ++#ifdef TARGET_OS_ANDROID ++ __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", buffer); ++#else + #if APPLE_OSX_mDNSResponder && LogTimeStamps + extern mDNS mDNSStorage; + extern mDNSu32 mDNSPlatformClockDivisor; +@@ -193,4 +204,5 @@ mDNSexport void mDNSPlatformWriteLogMsg( + #endif + syslog(syslog_level, "%s", buffer); + } ++#endif + } +diff -rupN mDNSResponder-333.10/mDNSShared/dns_sd.h mDNSResponder-333.10.patched/mDNSShared/dns_sd.h +--- mDNSResponder-333.10/mDNSShared/dns_sd.h 2011-08-31 03:44:17.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSShared/dns_sd.h 2012-04-15 15:10:42.000000000 +0200 +@@ -93,7 +93,7 @@ + /* standard calling convention under Win32 is __stdcall */ + /* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */ + /* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */ +-#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) ++#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) && !defined(DISC_BONJOUR_EMBED) + #define DNSSD_API __stdcall + #else + #define DNSSD_API +diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c +--- mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2011-06-02 00:44:37.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c 2012-04-15 15:10:42.000000000 +0200 +@@ -25,6 +25,13 @@ + + #include "dns_sd.h" // Defines the interface to the client layer above + #include "mDNSEmbeddedAPI.h" // The interface we're building on top of ++#ifndef _MSC_VER ++#include ++#include ++#else ++#include ++#endif ++ + extern mDNS mDNSStorage; // We need to pass the address of this storage to the lower-layer functions + + #if MDNS_BUILDINGSHAREDLIBRARY || MDNS_BUILDINGSTUBLIBRARY +@@ -71,6 +78,14 @@ typedef struct + typedef struct + { + mDNS_DirectOP_Dispose *disposefn; ++ DNSServiceRef aQuery; ++ DNSServiceGetAddrInfoReply callback; ++ void *context; ++ } mDNS_DirectOP_GetAddrInfo; ++ ++typedef struct ++ { ++ mDNS_DirectOP_Dispose *disposefn; + DNSServiceResolveReply callback; + void *context; + const ResourceRecord *SRV; +@@ -659,7 +674,7 @@ DNSServiceErrorType DNSServiceQueryRecor + x->q.ExpectUnique = mDNSfalse; + x->q.ForceMCast = (flags & kDNSServiceFlagsForceMulticast) != 0; + x->q.ReturnIntermed = (flags & kDNSServiceFlagsReturnIntermediates) != 0; +- x->q.SuppressUnsable = (flags & kDNSServiceFlagsSuppressUnusable) != 0; ++ x->q.SuppressUnusable = (flags & kDNSServiceFlagsSuppressUnusable) != 0; + x->q.SearchListIndex = 0; + x->q.AppendSearchDomains = 0; + x->q.RetryWithSearchDomains = mDNSfalse; +diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_ipc.h mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h +--- mDNSResponder-333.10/mDNSShared/dnssd_ipc.h 2011-06-30 22:56:04.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h 2012-04-15 15:10:42.000000000 +0200 +@@ -29,6 +29,11 @@ + #ifndef DNSSD_IPC_H + #define DNSSD_IPC_H + ++#ifdef TARGET_OS_ANDROID ++#include ++#include ++#endif ++ + #include "dns_sd.h" + + // +diff -rupN mDNSResponder-333.10/mDNSShared/uds_daemon.h mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h +--- mDNSResponder-333.10/mDNSShared/uds_daemon.h 2011-05-18 00:18:08.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h 2012-04-15 15:10:42.000000000 +0200 +@@ -22,6 +22,11 @@ + + */ + ++#ifdef TARGET_OS_ANDROID ++#include ++#include ++#endif ++ + #include "mDNSEmbeddedAPI.h" + #include "dnssd_ipc.h" + +diff -rupN mDNSResponder-333.10/mDNSWindows/mDNSWin32.c mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c +--- mDNSResponder-333.10/mDNSWindows/mDNSWin32.c 2011-08-31 03:42:48.000000000 +0200 ++++ mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c 2012-04-15 15:17:34.000000000 +0200 +@@ -2843,10 +2843,7 @@ mDNSlocal mStatus SetupSocket( mDNS * co + sa4.sin_family = AF_INET; + sa4.sin_port = port.NotAnInteger; + sa4.sin_addr.s_addr = ipv4.NotAnInteger; +- +- err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) ); +- check_translated_errno( err == 0, errno_compat(), kUnknownErr ); +- ++ + // Turn on option to receive destination addresses and receiving interface. + + option = 1; +@@ -2887,6 +2884,9 @@ mDNSlocal mStatus SetupSocket( mDNS * co + err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &option, sizeof( option ) ); + check_translated_errno( err == 0, errno_compat(), kOptionErr ); + ++ err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) ); ++ check_translated_errno( err == 0, errno_compat(), kUnknownErr ); ++ + } + else if( inAddr->sa_family == AF_INET6 ) + { +@@ -2904,10 +2904,7 @@ mDNSlocal mStatus SetupSocket( mDNS * co + sa6.sin6_flowinfo = 0; + sa6.sin6_addr = sa6p->sin6_addr; + sa6.sin6_scope_id = sa6p->sin6_scope_id; +- +- err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) ); +- check_translated_errno( err == 0, errno_compat(), kUnknownErr ); +- ++ + // Turn on option to receive destination addresses and receiving interface. + + option = 1; +@@ -2957,6 +2954,10 @@ mDNSlocal mStatus SetupSocket( mDNS * co + option = 255; + err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &option, sizeof( option ) ); + check_translated_errno( err == 0, errno_compat(), kOptionErr ); ++ ++ err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) ); ++ check_translated_errno( err == 0, errno_compat(), kUnknownErr ); ++ + } + else + { +diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.c mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c +--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c 1970-01-01 01:00:00.000000000 +0100 ++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c 2013-06-01 13:04:44.000000000 +0100 +@@ -0,0 +1,145 @@ ++/** ++ * @file ++ * @brief Wrapper for mDNSEmbeddedAPI with Bonjour. ++ * @author 2012 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) ++ * @copyright Simplified BSD ++ * ++ * @cond ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the FreeBSD license as published by the FreeBSD ++ * project. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++ * ++ * You should have received a copy of the FreeBSD license along with this ++ * program. If not, see . ++ * @endcond ++ */ ++ ++#include ++#include ++#include ++// include order matters ++#include "mDNSEmbeddedAPI.h" ++#ifdef WIN32 ++#include "../mDNSWindows/mDNSWin32.h" // Defines the specific types needed to run mDNS on windows platforms ++#else ++#include ++#include "../mDNSPosix/mDNSPosix.h" // Defines the specific types needed to run mDNS on posix platforms ++#endif ++ ++#define RR_CACHE_SIZE 500 ++static CacheEntity rrcachestorage[RR_CACHE_SIZE]; ++mDNS mDNSStorage; ++//struct mDNS_PlatformSupport_struct {}; ++static int mDNSIsInitialized = 0; ++static mDNS_PlatformSupport platformSupport; ++ ++const char ProgramName[] = "umundo"; ++extern mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout); ++extern mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds); ++ ++// promise compiler that these will be there ++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout); ++ ++#if WIN32 ++mStatus mDNSPoll(DWORD msec); ++static void embedded_mDNSInit_ReportStatus( int inType, const char *inFormat, ... ) { ++} ++#endif ++ ++mDNSexport int embedded_mDNSInit() { ++ mStatus err; ++ if (mDNSIsInitialized != 0) { ++ return 0; ++ } ++ ++ mDNSPlatformMemZero( &mDNSStorage, sizeof(mDNSStorage)); ++ mDNSPlatformMemZero( &platformSupport, sizeof(platformSupport)); ++ ++ err = mDNS_Init( ++ &mDNSStorage, ++ &platformSupport, ++ rrcachestorage, ++ RR_CACHE_SIZE, ++ mDNS_Init_AdvertiseLocalAddresses, ++ mDNS_Init_NoInitCallback, ++ mDNS_Init_NoInitCallbackContext ++ ); ++ if (err) ++ return err; ++ ++#ifdef WIN32 ++ platformSupport.reportStatusFunc = embedded_mDNSInit_ReportStatus; ++ err = SetupInterfaceList( &mDNSStorage ); ++ if (err) ++ return err; ++ err = uDNS_SetupDNSConfig( &mDNSStorage ); ++#endif ++ ++ if (err == 0) { ++ mDNSIsInitialized = 1; ++ } ++ return err; ++} ++ ++mDNSexport void embedded_mDNSExit() { ++#ifdef WIN32 ++ struct timeval tv; ++ tv.tv_sec = 0; ++ tv.tv_usec = 0; ++// mDNS_StartExit(&mDNSStorage); ++// embedded_mDNSmainLoop(tv); ++// mDNS_FinalExit(&mDNSStorage); ++#else ++ mDNS_Close(&mDNSStorage); ++#endif ++} ++ ++#ifdef WIN32 ++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) { ++ mDNS_Execute(&mDNSStorage); ++ mDNSPoll(100); ++// Sleep(100); ++ return 0; ++} ++ ++#else ++ ++// From /ExampleClientApp.c ++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) { ++ int nfds = 0; ++ fd_set readfds; ++ int result; ++ ++ // 1. Set up the fd_set as usual here. ++ // This example client has no file descriptors of its own, ++ // but a real application would call FD_SET to add them to the set here ++ FD_ZERO(&readfds); ++ ++ // 2. Set up the timeout. ++ // This example client has no other work it needs to be doing, ++ // so we set an effectively infinite timeout ++// timeout.tv_sec = 0x3FFFFFFF; ++// timeout.tv_usec = 0; ++ ++ assert(timeout.tv_sec < 10); ++ // 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout ++ mDNSPosixGetFDSet(&mDNSStorage, &nfds, &readfds, &timeout); ++ ++ // 4. Call select as normal ++ result = select(nfds, &readfds, NULL, NULL, &timeout); ++ ++ if (result > 0) { ++ // 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work ++ mDNSPosixProcessFDSet(&mDNSStorage, &readfds); ++ ++ // 6. This example client has no other work it needs to be doing, ++ // but a real client would do its work here ++ // ... (do work) ... ++ } ++ return result; ++} ++#endif +diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.h mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h +--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 1970-01-01 01:00:00.000000000 +0100 ++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 2013-06-01 13:00:29.000000000 +0100 +@@ -0,0 +1,26 @@ ++/* ++ * Copyright (C) 2005-2013 Team XBMC ++ * http://www.xbmc.org ++ * ++ * This Program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2, or (at your option) ++ * any later version. ++ * ++ * This Program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with XBMC; see the file COPYING. If not, see ++ * . ++ * ++ */ ++ ++#ifndef _MDNSEMBEDDED_H_ ++#define _MDNSEMBEDDED_H_ ++int embedded_mDNSInit(); ++void embedded_mDNSExit(); ++int embedded_mDNSmainLoop(struct timeval timeout); ++#endif //_MDNSEMBEDDED_H_ From 771fd7546c550ecd0baea34442ae134e08fa2580 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Sat, 1 Jun 2013 13:41:34 +0100 Subject: [PATCH 2/8] - for receiving multicast packets (which is needed for zeroconf browsing) we need the permission to toggle the multicast lock --- tools/android/packaging/xbmc/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/android/packaging/xbmc/AndroidManifest.xml b/tools/android/packaging/xbmc/AndroidManifest.xml index 9c4bbb33c6ba6..d371cc3fd91b3 100644 --- a/tools/android/packaging/xbmc/AndroidManifest.xml +++ b/tools/android/packaging/xbmc/AndroidManifest.xml @@ -12,7 +12,7 @@ - + Date: Sat, 1 Jun 2013 13:43:27 +0100 Subject: [PATCH 3/8] - on android check for libmDNSEmbedded.a for zeroconf support --- configure.in | 12 ++++++++++++ xbmc/system.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/configure.in b/configure.in index c0542b255a803..d09b82a0aaac3 100644 --- a/configure.in +++ b/configure.in @@ -135,6 +135,7 @@ halstorage_not_found="== Could not find hal-storage. HAL support disabled. ==" hal_disabled="== HAL support disabled. ==" avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. ==" avahi_disabled="== Avahi support disabled. ==" +mdnsembedded_not_found="== Could not find mDNSEmbedded - zeroconf will be disabled. ==" vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. ==" vdpau_disabled="== VDPAU support manually disabled. ==" vaapi_not_found="== Could not find libva. VAAPI support disabled. ==" @@ -1262,6 +1263,11 @@ else fi fi +if test "$target_platform" = "target_android" ; then + AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],use_mdnsembedded=yes;AC_DEFINE(HAVE_LIBMDNSEMBEDDED), + use_mdnsembedded=no;AC_MSG_RESULT($mdnsembedded_not_found)) +fi + # X11 if test "$use_x11" = "yes" && test "$host_vendor" != "apple"; then AC_MSG_NOTICE($x11_enabled) @@ -2213,6 +2219,12 @@ else final_message="$final_message\n Avahi:\tNo" fi +if test "$use_mdnsembedded" = "yes"; then + final_message="$final_message\n mDNSEmbedded:\tYes" +else + final_message="$final_message\n mDNSEmbedded:\tNo" +fi + if test "$use_nonfree" = "yes"; then final_message="$final_message\n Non-free:\tYes" HAVE_XBMC_NONFREE=1 diff --git a/xbmc/system.h b/xbmc/system.h index 1bd0c98f51986..457581b3ede94 100644 --- a/xbmc/system.h +++ b/xbmc/system.h @@ -239,6 +239,9 @@ #if defined(TARGET_ANDROID) #undef HAS_LINUX_EVENTS #undef HAS_LIRC +#if defined(HAVE_LIBMDNSEMBEDDED) +#define HAS_ZEROCONF +#endif #endif // EGL detected. Dont use GLX! From 4d5f17176b3b2b1a9297d483d8bf695da99045e3 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Sat, 1 Jun 2013 13:54:38 +0100 Subject: [PATCH 4/8] - quick&dirty use win32 implementation of zeroconf in android aswell --- xbmc/network/Makefile.in | 5 +++ xbmc/network/Zeroconf.cpp | 8 ++--- xbmc/network/ZeroconfBrowser.cpp | 8 ++--- xbmc/network/windows/ZeroconfBrowserWIN.cpp | 40 ++++++++++++++++++++- xbmc/network/windows/ZeroconfBrowserWIN.h | 8 ++++- xbmc/network/windows/ZeroconfWIN.cpp | 7 ++++ 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/xbmc/network/Makefile.in b/xbmc/network/Makefile.in index c80651c4eb2ff..4593abe51cb3f 100644 --- a/xbmc/network/Makefile.in +++ b/xbmc/network/Makefile.in @@ -23,6 +23,11 @@ ifeq (@USE_AIRTUNES@, 1) SRCS += AirTunesServer.cpp endif +ifeq (@USE_ANDROID@,1) +SRCS += windows/ZeroconfBrowserWIN.cpp +SRCS += windows/ZeroconfWIN.cpp +endif + LIB = network.a include @abs_top_srcdir@/Makefile.include diff --git a/xbmc/network/Zeroconf.cpp b/xbmc/network/Zeroconf.cpp index e2c30260add32..a3de61981b9fe 100644 --- a/xbmc/network/Zeroconf.cpp +++ b/xbmc/network/Zeroconf.cpp @@ -22,14 +22,14 @@ #include "Zeroconf.h" #include "settings/Settings.h" -#ifdef _LINUX +#if defined(_LINUX) && !defined(TARGET_ANDROID) #if !defined(TARGET_DARWIN) #include "linux/ZeroconfAvahi.h" #else //on osx use the native implementation #include "osx/ZeroconfOSX.h" #endif -#elif defined(TARGET_WINDOWS) +#elif defined(TARGET_WINDOWS) || defined(TARGET_ANDROID) #include "windows/ZeroconfWIN.h" #endif @@ -137,9 +137,9 @@ CZeroconf* CZeroconf::GetInstance() #else #if defined(TARGET_DARWIN) smp_instance = new CZeroconfOSX; -#elif defined(_LINUX) +#elif defined(_LINUX) && !defined(TARGET_ANDROID) smp_instance = new CZeroconfAvahi; -#elif defined(TARGET_WINDOWS) +#elif defined(TARGET_WINDOWS) || defined(TARGET_ANDROID) smp_instance = new CZeroconfWIN; #endif #endif diff --git a/xbmc/network/ZeroconfBrowser.cpp b/xbmc/network/ZeroconfBrowser.cpp index de94b5973338b..d3fbbd1cc377e 100644 --- a/xbmc/network/ZeroconfBrowser.cpp +++ b/xbmc/network/ZeroconfBrowser.cpp @@ -22,14 +22,14 @@ #include #include "utils/log.h" -#ifdef _LINUX +#if defined (_LINUX) && !defined(TARGET_ANDROID) #if !defined(TARGET_DARWIN) #include "linux/ZeroconfBrowserAvahi.h" #else //on osx use the native implementation #include "osx/ZeroconfBrowserOSX.h" #endif -#elif defined(TARGET_WINDOWS) +#elif defined(TARGET_WINDOWS) || defined(TARGET_ANDROID) #include "windows/ZeroconfBrowserWIN.h" #endif @@ -158,9 +158,9 @@ CZeroconfBrowser* CZeroconfBrowser::GetInstance() #else #if defined(TARGET_DARWIN) smp_instance = new CZeroconfBrowserOSX; -#elif defined(_LINUX) +#elif defined(_LINUX) && !defined(TARGET_ANDROID) smp_instance = new CZeroconfBrowserAvahi; -#elif defined(TARGET_WINDOWS) +#elif defined(TARGET_WINDOWS) || defined(TARGET_ANDROID) smp_instance = new CZeroconfBrowserWIN; #endif #endif diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.cpp b/xbmc/network/windows/ZeroconfBrowserWIN.cpp index ce921f1dac999..0e5dd6768b388 100644 --- a/xbmc/network/windows/ZeroconfBrowserWIN.cpp +++ b/xbmc/network/windows/ZeroconfBrowserWIN.cpp @@ -24,14 +24,48 @@ #include "guilib/GUIWindowManager.h" #include "guilib/GUIMessage.h" #include "GUIUserMessages.h" +#if defined(TARGET_WINDOWS) #include "win32/WIN32Util.h" +#else +#include +#endif //TARGET_WINDOWS #include "network/DNSNameCache.h" #pragma comment(lib, "dnssd.lib") extern HWND g_hWnd; -CZeroconfBrowserWIN::CZeroconfBrowserWIN() + +void CZeroconfBrowserWIN::OnStartup() +{ +#if defined(TARGET_ANDROID) + CLog::Log(LOGDEBUG, "ZeroconfBrowserThread started"); + embedded_mDNSInit(); +#endif //TARGET_ANDROID + +} + +void CZeroconfBrowserWIN::OnExit() +{ +#if defined(TARGET_ANDROID) + CLog::Log(LOGDEBUG, "ZeroconfBrowserThread exited"); + embedded_mDNSExit(); +#endif //TARGET_ANDROID + +} + +void CZeroconfBrowserWIN::Process() +{ +#if defined(TARGET_ANDROID) + struct timeval timeout; + timeout.tv_sec = 1; + while (( !m_bStop )) + embedded_mDNSmainLoop(timeout); +#endif //TARGET_ANDROID + +} + +CZeroconfBrowserWIN::CZeroconfBrowserWIN() : CThread("ZerocconfEmbedded") { m_browser = NULL; } @@ -43,7 +77,9 @@ CZeroconfBrowserWIN::~CZeroconfBrowserWIN() for(tBrowserMap::iterator it = m_service_browsers.begin(); it != m_service_browsers.end(); ++it ) doRemoveServiceType(it->first); +#if defined(TARGET_WINDOWS) WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 ); +#endif //TARGET_WINDOWS DNSServiceRefDeallocate(m_browser); m_browser = NULL; } @@ -202,9 +238,11 @@ bool CZeroconfBrowserWIN::doAddServiceType(const CStdString& fcr_service_type) CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceCreateConnection failed with error = %ld", (int) err); return false; } +#if defined(TARGET_WINDOWS) err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE ); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfBrowserWIN: WSAAsyncSelect failed with error = %ld", (int) err); +#endif //TARGET_WINDOWS } { diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.h b/xbmc/network/windows/ZeroconfBrowserWIN.h index 4c3205b3806bb..e46b85bba8b20 100644 --- a/xbmc/network/windows/ZeroconfBrowserWIN.h +++ b/xbmc/network/windows/ZeroconfBrowserWIN.h @@ -26,14 +26,20 @@ #include "threads/Thread.h" #include "threads/CriticalSection.h" #include +#include "threads/Thread.h" //platform specific implementation of zeroconfbrowser interface using native os x APIs -class CZeroconfBrowserWIN : public CZeroconfBrowser +class CZeroconfBrowserWIN : public CZeroconfBrowser, public CThread { public: CZeroconfBrowserWIN(); ~CZeroconfBrowserWIN(); + //CThread + virtual void OnStartup(); + virtual void OnExit(); + virtual void Process(); + private: ///implementation if CZeroconfBrowser interface ///@{ diff --git a/xbmc/network/windows/ZeroconfWIN.cpp b/xbmc/network/windows/ZeroconfWIN.cpp index e84bc6eafb069..566091d6912b2 100644 --- a/xbmc/network/windows/ZeroconfWIN.cpp +++ b/xbmc/network/windows/ZeroconfWIN.cpp @@ -26,7 +26,9 @@ #include #include "dialogs/GUIDialogKaiToast.h" #include "guilib/LocalizeStrings.h" +#if defined(TARGET_WINDOWS) #include "win32/WIN32Util.h" +#endif //TARGET_WINDOWS #pragma comment(lib, "dnssd.lib") @@ -77,9 +79,11 @@ bool CZeroconfWIN::doPublishService(const std::string& fcr_identifier, CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceCreateConnection failed with error = %ld", (int) err); return false; } +#if defined(TARGET_WINDOWS) err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE ); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfWIN: WSAAsyncSelect failed with error = %ld", (int) err); +#endif //TARGET_WINDOWS } CLog::Log(LOGDEBUG, "ZeroconfWIN: identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port); @@ -149,7 +153,10 @@ void CZeroconfWIN::doStop() } { CSingleLock lock(m_data_guard); +#if defined(TARGET_WINDOWS) WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, 0 ); +#endif //TARGET_WINDOWS + DNSServiceRefDeallocate(m_service); m_service = NULL; } From b394aab160c32f15fe8f1b58fbf6052ec1909ec3 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Sat, 1 Jun 2013 15:39:36 +0200 Subject: [PATCH 5/8] configure fix --- configure.in | 3 ++- xbmc/system.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index d09b82a0aaac3..dc7b11c942279 100644 --- a/configure.in +++ b/configure.in @@ -1264,7 +1264,8 @@ else fi if test "$target_platform" = "target_android" ; then - AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],use_mdnsembedded=yes;AC_DEFINE(HAVE_LIBMDNSEMBEDDED), + use_mdnsembedded=yes + AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],, use_mdnsembedded=no;AC_MSG_RESULT($mdnsembedded_not_found)) fi diff --git a/xbmc/system.h b/xbmc/system.h index 457581b3ede94..db76e2c42bd3a 100644 --- a/xbmc/system.h +++ b/xbmc/system.h @@ -240,7 +240,7 @@ #undef HAS_LINUX_EVENTS #undef HAS_LIRC #if defined(HAVE_LIBMDNSEMBEDDED) -#define HAS_ZEROCONF +#define HAS_ZEROCONF #endif #endif From c917bf9b687c27c9002a50c49c9bc02248b759d7 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Mon, 3 Jun 2013 21:09:04 +0100 Subject: [PATCH 6/8] fix1 --- .../mDNSResponder-333.10.umundo.patch | 14 ++++++++++---- xbmc/network/windows/ZeroconfWIN.cpp | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch b/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch index cd7a1b9c60d4c..8c1dcfa3fd9e6 100644 --- a/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch +++ b/tools/depends/target/mdnsresponder/mDNSResponder-333.10.umundo.patch @@ -350,7 +350,7 @@ diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.c mDNSResponder-333.10 diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.h mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h --- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 1970-01-01 01:00:00.000000000 +0100 +++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h 2013-06-01 13:00:29.000000000 +0100 -@@ -0,0 +1,26 @@ +@@ -0,0 +1,32 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://www.xbmc.org @@ -373,7 +373,13 @@ diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.h mDNSResponder-333.10 + +#ifndef _MDNSEMBEDDED_H_ +#define _MDNSEMBEDDED_H_ -+int embedded_mDNSInit(); -+void embedded_mDNSExit(); -+int embedded_mDNSmainLoop(struct timeval timeout); ++#ifdef __cplusplus ++ extern "C" { ++#endif ++extern int embedded_mDNSInit(); ++extern void embedded_mDNSExit(); ++extern int embedded_mDNSmainLoop(struct timeval timeout); ++#ifdef __cplusplus ++ } ++#endif +#endif //_MDNSEMBEDDED_H_ diff --git a/xbmc/network/windows/ZeroconfWIN.cpp b/xbmc/network/windows/ZeroconfWIN.cpp index 566091d6912b2..943acd33b248c 100644 --- a/xbmc/network/windows/ZeroconfWIN.cpp +++ b/xbmc/network/windows/ZeroconfWIN.cpp @@ -48,6 +48,7 @@ bool CZeroconfWIN::IsZCdaemonRunning() { uint32_t version; uint32_t size = sizeof(version); +#if defined(TARGET_WINDOWS) DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size); if(err != kDNSServiceErr_NoError) { @@ -55,6 +56,7 @@ bool CZeroconfWIN::IsZCdaemonRunning() CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(34300), g_localizeStrings.Get(34301), 10000, true); return false; } +#endif //TARGET_WINDOWS CLog::Log(LOGDEBUG, "ZeroconfWIN:Bonjour version is %d.%d", version / 10000, version / 100 % 100); return true; } From 87c127753c77997eeb4e49fe917684cb7e185619 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Mon, 3 Jun 2013 22:26:16 +0200 Subject: [PATCH 7/8] fixup --- xbmc/network/windows/ZeroconfBrowserWIN.cpp | 4 ++-- xbmc/network/windows/ZeroconfWIN.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.cpp b/xbmc/network/windows/ZeroconfBrowserWIN.cpp index 0e5dd6768b388..129a64fa31244 100644 --- a/xbmc/network/windows/ZeroconfBrowserWIN.cpp +++ b/xbmc/network/windows/ZeroconfBrowserWIN.cpp @@ -232,13 +232,13 @@ bool CZeroconfBrowserWIN::doAddServiceType(const CStdString& fcr_service_type) if(m_browser == NULL) { +#if defined(TARGET_WINDOWS) err = DNSServiceCreateConnection(&m_browser); if (err != kDNSServiceErr_NoError) { CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceCreateConnection failed with error = %ld", (int) err); return false; } -#if defined(TARGET_WINDOWS) err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE ); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfBrowserWIN: WSAAsyncSelect failed with error = %ld", (int) err); @@ -346,4 +346,4 @@ void CZeroconfBrowserWIN::ProcessResults() DNSServiceErrorType err = DNSServiceProcessResult(m_browser); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err); -} \ No newline at end of file +} diff --git a/xbmc/network/windows/ZeroconfWIN.cpp b/xbmc/network/windows/ZeroconfWIN.cpp index 943acd33b248c..52125e06fc655 100644 --- a/xbmc/network/windows/ZeroconfWIN.cpp +++ b/xbmc/network/windows/ZeroconfWIN.cpp @@ -75,13 +75,13 @@ bool CZeroconfWIN::doPublishService(const std::string& fcr_identifier, if(m_service == NULL) { - err = DNSServiceCreateConnection(&m_service); +#if defined(TARGET_WINDOWS) + err = DNSServicecCreateConnection(&m_service); if (err != kDNSServiceErr_NoError) { CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceCreateConnection failed with error = %ld", (int) err); return false; } -#if defined(TARGET_WINDOWS) err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE ); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfWIN: WSAAsyncSelect failed with error = %ld", (int) err); @@ -189,4 +189,4 @@ void CZeroconfWIN::ProcessResults() DNSServiceErrorType err = DNSServiceProcessResult(m_service); if (err != kDNSServiceErr_NoError) CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err); -} \ No newline at end of file +} From 6e4cdedaa3e34a2ed86473c6bbeba5e16061f1ce Mon Sep 17 00:00:00 2001 From: Memphiz Date: Mon, 3 Jun 2013 22:53:42 +0200 Subject: [PATCH 8/8] fixup thread --- xbmc/network/windows/ZeroconfBrowserWIN.cpp | 33 +-------------------- xbmc/network/windows/ZeroconfBrowserWIN.h | 8 +---- xbmc/network/windows/ZeroconfWIN.cpp | 26 +++++++++++++++- xbmc/network/windows/ZeroconfWIN.h | 6 +++- 4 files changed, 32 insertions(+), 41 deletions(-) diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.cpp b/xbmc/network/windows/ZeroconfBrowserWIN.cpp index 129a64fa31244..a90a66e0e95c7 100644 --- a/xbmc/network/windows/ZeroconfBrowserWIN.cpp +++ b/xbmc/network/windows/ZeroconfBrowserWIN.cpp @@ -26,8 +26,6 @@ #include "GUIUserMessages.h" #if defined(TARGET_WINDOWS) #include "win32/WIN32Util.h" -#else -#include #endif //TARGET_WINDOWS #include "network/DNSNameCache.h" @@ -36,36 +34,7 @@ extern HWND g_hWnd; -void CZeroconfBrowserWIN::OnStartup() -{ -#if defined(TARGET_ANDROID) - CLog::Log(LOGDEBUG, "ZeroconfBrowserThread started"); - embedded_mDNSInit(); -#endif //TARGET_ANDROID - -} - -void CZeroconfBrowserWIN::OnExit() -{ -#if defined(TARGET_ANDROID) - CLog::Log(LOGDEBUG, "ZeroconfBrowserThread exited"); - embedded_mDNSExit(); -#endif //TARGET_ANDROID - -} - -void CZeroconfBrowserWIN::Process() -{ -#if defined(TARGET_ANDROID) - struct timeval timeout; - timeout.tv_sec = 1; - while (( !m_bStop )) - embedded_mDNSmainLoop(timeout); -#endif //TARGET_ANDROID - -} - -CZeroconfBrowserWIN::CZeroconfBrowserWIN() : CThread("ZerocconfEmbedded") +CZeroconfBrowserWIN::CZeroconfBrowserWIN() { m_browser = NULL; } diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.h b/xbmc/network/windows/ZeroconfBrowserWIN.h index e46b85bba8b20..4c3205b3806bb 100644 --- a/xbmc/network/windows/ZeroconfBrowserWIN.h +++ b/xbmc/network/windows/ZeroconfBrowserWIN.h @@ -26,20 +26,14 @@ #include "threads/Thread.h" #include "threads/CriticalSection.h" #include -#include "threads/Thread.h" //platform specific implementation of zeroconfbrowser interface using native os x APIs -class CZeroconfBrowserWIN : public CZeroconfBrowser, public CThread +class CZeroconfBrowserWIN : public CZeroconfBrowser { public: CZeroconfBrowserWIN(); ~CZeroconfBrowserWIN(); - //CThread - virtual void OnStartup(); - virtual void OnExit(); - virtual void Process(); - private: ///implementation if CZeroconfBrowser interface ///@{ diff --git a/xbmc/network/windows/ZeroconfWIN.cpp b/xbmc/network/windows/ZeroconfWIN.cpp index 52125e06fc655..53a39d8e8cff8 100644 --- a/xbmc/network/windows/ZeroconfWIN.cpp +++ b/xbmc/network/windows/ZeroconfWIN.cpp @@ -28,20 +28,44 @@ #include "guilib/LocalizeStrings.h" #if defined(TARGET_WINDOWS) #include "win32/WIN32Util.h" +#else +#include #endif //TARGET_WINDOWS #pragma comment(lib, "dnssd.lib") extern HWND g_hWnd; -CZeroconfWIN::CZeroconfWIN() +void CZeroconfWIN::Process() +{ +#if defined(TARGET_ANDROID) + CLog::Log(LOGDEBUG, "ZeroconfEmbedded - processing..."); + struct timeval timeout; + timeout.tv_sec = 1; + while (( !m_bStop )) + embedded_mDNSmainLoop(timeout); +#endif //TARGET_ANDROID + +} + + +CZeroconfWIN::CZeroconfWIN() : CThread("ZerocconfEmbedded") { m_service = NULL; +#if defined(TARGET_ANDROID) + CLog::Log(LOGDEBUG, "ZeroconfBrowserThread started"); + embedded_mDNSInit(); + Create(); +#endif //TARGET_ANDROID } CZeroconfWIN::~CZeroconfWIN() { doStop(); +#if defined(TARGET_ANDROID) + CLog::Log(LOGDEBUG, "ZeroconfBrowserThread exited"); + embedded_mDNSExit(); +#endif //TARGET_ANDROID } bool CZeroconfWIN::IsZCdaemonRunning() diff --git a/xbmc/network/windows/ZeroconfWIN.h b/xbmc/network/windows/ZeroconfWIN.h index bea0079f2e5bd..461a07c0f897d 100644 --- a/xbmc/network/windows/ZeroconfWIN.h +++ b/xbmc/network/windows/ZeroconfWIN.h @@ -24,13 +24,17 @@ #include "network/Zeroconf.h" #include "threads/CriticalSection.h" #include +#include "threads/Thread.h" -class CZeroconfWIN : public CZeroconf +class CZeroconfWIN : public CZeroconf,public CThread { public: CZeroconfWIN(); ~CZeroconfWIN(); + protected: + + void Process(); //implement base CZeroConf interface bool doPublishService(const std::string& fcr_identifier, const std::string& fcr_type,