Commit a73694c6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

contribs: add live555

parent 68d90163
e0103eec4d97478d437f9c7ad19a29bc3ea0cb3926b88ac92008fe6c73e0f72d4696b1fc702cea5732aa4d6884a302f91ce26e3a06e314adea6bb995cd577337 live555-latest.tar.gz
Copyright (C) 2010 Rémi Denis-Courmont.
Licensed under GNU General Public License version 2 or higher.
diff -ru live.orig//groupsock/GroupsockHelper.cpp live//groupsock/GroupsockHelper.cpp
--- live.orig//groupsock/GroupsockHelper.cpp 2010-04-09 22:27:39.000000000 +0300
+++ live//groupsock/GroupsockHelper.cpp 2010-04-17 20:18:11.000000000 +0300
@@ -625,25 +625,29 @@
#include <hostLib.h>
if (ERROR == (ourAddress = hostGetByName( hostname ))) break;
#else
- struct hostent* hstent
- = (struct hostent*)gethostbyname(hostname);
- if (hstent == NULL || hstent->h_length != 4) {
- env.setResultErrMsg("initial gethostbyname() failed");
+ struct addrinfo hints, *res;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_UDP;
+ if (getaddrinfo(hostname, NULL, &hints, &res)) {
+ env.setResultErrMsg("initial getaddrinfo() failed");
break;
}
// Take the first address that's not bad
// (This code, like many others, won't handle IPv6)
netAddressBits addr = 0;
- for (unsigned i = 0; ; ++i) {
- char* addrPtr = hstent->h_addr_list[i];
- if (addrPtr == NULL) break;
+ for (const struct addrinfo *p = res; p; p = p->ai_next) {
+ const struct in_addr in =
+ ((const struct sockaddr_in *)p->ai_addr)->sin_addr;
- netAddressBits a = *(netAddressBits*)addrPtr;
+ netAddressBits a = in.s_addr;
if (!badAddress(a)) {
addr = a;
break;
}
}
+ freeaddrinfo(res);
if (addr != 0) {
fromAddr.sin_addr.s_addr = addr;
} else {
diff -ru live.orig//groupsock/inet.c live//groupsock/inet.c
--- live.orig//groupsock/inet.c 2010-04-09 22:27:39.000000000 +0300
+++ live//groupsock/inet.c 2010-04-17 20:14:07.000000000 +0300
@@ -83,16 +83,6 @@
#define NULL 0
#endif
-#if !defined(VXWORKS)
-struct hostent* our_gethostbyname(name)
- char* name;
-{
- if (!initializeWinsockIfNecessary()) return NULL;
-
- return (struct hostent*) gethostbyname(name);
-}
-#endif
-
#ifndef USE_OUR_RANDOM
/* Use the system-supplied "random()" and "srandom()" functions */
#include <stdlib.h>
diff -ru live.orig//groupsock/NetAddress.cpp live//groupsock/NetAddress.cpp
--- live.orig//groupsock/NetAddress.cpp 2010-04-09 22:27:39.000000000 +0300
+++ live//groupsock/NetAddress.cpp 2010-04-17 20:13:29.000000000 +0300
@@ -83,15 +83,12 @@
NetAddressList::NetAddressList(char const* hostname)
: fNumAddresses(0), fAddressArray(NULL) {
- struct hostent* host;
+
+ struct addrinfo *res;
// Check first whether "hostname" is an IP address string:
netAddressBits addr = our_inet_addr((char*)hostname);
if (addr != INADDR_NONE) { // yes it was an IP address string
- //##### host = gethostbyaddr((char*)&addr, sizeof (netAddressBits), AF_INET);
- host = NULL; // don't bother calling gethostbyaddr(); we only want 1 addr
-
- if (host == NULL) {
// For some unknown reason, gethostbyaddr() failed, so just
// return a 1-element list with the address we were given:
fNumAddresses = 1;
@@ -101,41 +98,40 @@
fAddressArray[0] = new NetAddress((u_int8_t*)&addr,
sizeof (netAddressBits));
return;
- }
} else { // Try resolving "hostname" as a real host name
-#if defined(VXWORKS)
- char hostentBuf[512];
- host = (struct hostent*)resolvGetHostByName((char*)hostname,(char*)&hostentBuf,sizeof hostentBuf);
-#else
- host = our_gethostbyname((char*)hostname);
-#endif
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_DGRAM; /* be sure to not get dups! */
+ hints.ai_protocol = IPPROTO_UDP;
- if (host == NULL) {
+ if (getaddrinfo(hostname, NULL, &hints, &res))
// It was a host name, and we couldn't resolve it. We're SOL.
return;
- }
}
- u_int8_t const** const hAddrPtr
- = (u_int8_t const**)host->h_addr_list;
- if (hAddrPtr != NULL) {
- // First, count the number of addresses:
- u_int8_t const** hAddrPtr1 = hAddrPtr;
- while (*hAddrPtr1 != NULL) {
- ++fNumAddresses;
- ++hAddrPtr1;
- }
-
- // Next, set up the list:
- fAddressArray = new NetAddress*[fNumAddresses];
- if (fAddressArray == NULL) return;
-
- for (unsigned i = 0; i < fNumAddresses; ++i) {
- fAddressArray[i]
- = new NetAddress(hAddrPtr[i], host->h_length);
- }
+ // First, count the number of addresses:
+ for (const struct addrinfo *p = res; p; p = p->ai_next)
+ fNumAddresses++;
+
+ // Next, set up the list:
+ fAddressArray = new NetAddress*[fNumAddresses];
+
+ unsigned i = 0;
+ for (const struct addrinfo *p = res; p; p = p->ai_next) {
+ union
+ {
+ struct in_addr ip4;
+ uint8_t b[4];
+ } buf;
+ const struct sockaddr_in *sin =
+ (const struct sockaddr_in *)p->ai_addr;
+
+ buf.ip4 = sin->sin_addr;
+ fAddressArray[i++] = new NetAddress(buf.b, 4);
}
+ freeaddrinfo(res);
}
NetAddressList::NetAddressList(NetAddressList const& orig) {
This diff is collapsed.
Copyright (C) 2008 Rémi Denis-Courmont, adaptation by Felix Kühne (C) 2009.
Licensed under GNU General Public License version 2 or higher.
diff -urN live.orig/liveMedia/include/Locale.hh live/liveMedia/include/Locale.hh
--- live.orig/liveMedia/include/Locale.hh 2009-03-23 01:26:16 +0300
+++ live/liveMedia/include/Locale.hh 2009-03-26 19:17:43 +0300
@@ -27,23 +27,26 @@
#ifndef LOCALE_NOT_USED
#include <locale.h>
+#ifdef __APPLE__
+#include <xlocale.h>
+#endif
#else
-#ifndef LC_ALL
-#define LC_ALL 0
+#ifndef LC_ALL_MASK
+#define LC_ALL_MASK 0
#endif
-#ifndef LC_NUMERIC
-#define LC_NUMERIC 4
+#ifndef LC_NUMERIC_MASK
+#define LC_NUMERIC_MASK 0
#endif
+typedef int locale_t;
#endif
class Locale {
public:
- Locale(char const* newLocale, int category = LC_ALL);
+ Locale(char const* newLocale, int category = LC_ALL_MASK);
virtual ~Locale();
private:
- int fCategory;
- char* fPrevLocale;
+ locale_t fLocale, fPrevLocale;
};
#endif
diff -urN live.orig/liveMedia/Locale.cpp live/liveMedia/Locale.cpp
--- live.orig/liveMedia/Locale.cpp 2009-03-23 01:26:16 +0300
+++ live/liveMedia/Locale.cpp 2009-03-26 19:17:43 +0300
@@ -22,19 +22,18 @@
#include "Locale.hh"
#include <strDup.hh>
-Locale::Locale(char const* newLocale, int category)
- : fCategory(category) {
+Locale::Locale(char const* newLocale, int category) {
#ifndef LOCALE_NOT_USED
- fPrevLocale = strDup(setlocale(category, NULL));
- setlocale(category, newLocale);
+ fLocale = newlocale(category, newLocale, NULL);
+ fPrevLocale = uselocale(fLocale);
#endif
}
Locale::~Locale() {
#ifndef LOCALE_NOT_USED
- if (fPrevLocale != NULL) {
- setlocale(fCategory, fPrevLocale);
- delete[] fPrevLocale;
+ if (fLocale != (locale_t)0) {
+ uselocale(fPrevLocale);
+ freelocale(fLocale);
}
#endif
}
--- live.orig/liveMedia/RTSPClient.cpp 2010-03-16 03:09:46.000000000 +0100
+++ live/liveMedia/RTSPClient.cpp 2010-08-24 15:04:31.000000000 +0200
@@ -1019,7 +1019,7 @@
// This is the default value; we don't need a "Scale:" header:
buf[0] = '\0';
} else {
- Locale l("C", LC_NUMERIC);
+ Locale l("C", LC_NUMERIC_MASK);
sprintf(buf, "Scale: %f\r\n", scale);
}
@@ -1033,11 +1033,11 @@
buf[0] = '\0';
} else if (end < 0) {
// There's no end time:
- Locale l("C", LC_NUMERIC);
+ Locale l("C", LC_NUMERIC_MASK);
sprintf(buf, "Range: npt=%.3f-\r\n", start);
} else {
// There's both a start and an end time; include them both in the "Range:" hdr
- Locale l("C", LC_NUMERIC);
+ Locale l("C", LC_NUMERIC_MASK);
sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
}
--- live/liveMedia/RTSPClient.cpp 2010-08-24 17:05:46.000000000 +0200
+++ live.new/liveMedia/RTSPClient.cpp 2010-08-24 17:04:50.000000000 +0200
@@ -935,7 +935,7 @@
}
Boolean RTSPClient::parseScaleParam(char const* paramStr, float& scale) {
- Locale l("C", LC_NUMERIC);
+ Locale l("C", LC_NUMERIC_MASK);
return sscanf(paramStr, "%f", &scale) == 1;
}
--- live/liveMedia/RTSPCommon.cpp.orig 2011-01-06 01:26:50.000000000 +0100
+++ live/liveMedia/RTSPCommon.cpp 2011-01-09 16:32:24.142645155 +0100
@@ -137,7 +137,7 @@
Boolean parseRangeParam(char const* paramStr, double& rangeStart, double& rangeEnd) {
double start, end;
int numCharsMatched = 0;
- Locale l("C", LC_NUMERIC);
+ Locale l("C", LC_NUMERIC_MASK);
if (sscanf(paramStr, "npt = %lf - %lf", &start, &end) == 2) {
rangeStart = start;
rangeEnd = end;
diff -ruN live/BasicUsageEnvironment/BasicHashTable.cpp live.new/BasicUsageEnvironment/BasicHashTable.cpp
--- live/BasicUsageEnvironment/BasicHashTable.cpp 2009-07-28 03:05:14.000000000 +0200
+++ live.new/BasicUsageEnvironment/BasicHashTable.cpp 2009-08-19 00:58:32.000000000 +0200
@@ -26,6 +26,7 @@
#endif
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
// When there are this many entries per bucket, on average, rebuild
// the table to increase the number of buckets
@@ -253,17 +254,17 @@
}
unsigned BasicHashTable::hashIndexFromKey(char const* key) const {
- unsigned result = 0;
+ uintptr_t result = 0;
if (fKeyType == STRING_HASH_KEYS) {
while (1) {
char c = *key++;
if (c == 0) break;
- result += (result<<3) + (unsigned)c;
+ result += (result<<3) + (uintptr_t)c;
}
result &= fMask;
} else if (fKeyType == ONE_WORD_HASH_KEYS) {
- result = randomIndex((unsigned long)key);
+ result = randomIndex((uintptr_t)key);
} else {
unsigned* k = (unsigned*)key;
unsigned long sum = 0;
diff -ruN live/BasicUsageEnvironment/BasicTaskScheduler0.cpp live.new/BasicUsageEnvironment/BasicTaskScheduler0.cpp
--- live/BasicUsageEnvironment/BasicTaskScheduler0.cpp 2009-07-28 03:05:14.000000000 +0200
+++ live.new/BasicUsageEnvironment/BasicTaskScheduler0.cpp 2009-08-19 00:58:04.000000000 +0200
@@ -19,6 +19,7 @@
#include "BasicUsageEnvironment0.hh"
#include "HandlerSet.hh"
+#include <stdint.h>
////////// A subclass of DelayQueueEntry,
////////// used to implement BasicTaskScheduler0::scheduleDelayedTask()
@@ -64,7 +65,7 @@
}
void BasicTaskScheduler0::unscheduleDelayedTask(TaskToken& prevTask) {
- DelayQueueEntry* alarmHandler = fDelayQueue.removeEntry((long)prevTask);
+ DelayQueueEntry* alarmHandler = fDelayQueue.removeEntry((intptr_t)prevTask);
prevTask = NULL;
delete alarmHandler;
}
diff -ruN live/groupsock/Groupsock.cpp live.new/groupsock/Groupsock.cpp
--- live/groupsock/Groupsock.cpp 2009-07-28 03:05:14.000000000 +0200
+++ live.new/groupsock/Groupsock.cpp 2009-08-19 00:57:14.000000000 +0200
@@ -17,6 +17,7 @@
// 'Group sockets'
// Implementation
+#include <stdint.h>
#include "Groupsock.hh"
#include "GroupsockHelper.hh"
//##### Eventually fix the following #include; we shouldn't know about tunnels
@@ -403,7 +404,7 @@
= (TunnelEncapsulationTrailer*)&data[size];
TunnelEncapsulationTrailer* trailer;
- Boolean misaligned = ((unsigned long)trailerInPacket & 3) != 0;
+ Boolean misaligned = ((uintptr_t)trailerInPacket & 3) != 0;
unsigned trailerOffset;
u_int8_t tunnelCmd;
if (isSSM()) {
diff -ruN live/liveMedia/MP3StreamState.cpp live.new/liveMedia/MP3StreamState.cpp
--- live/liveMedia/MP3StreamState.cpp 2009-07-28 03:05:14.000000000 +0200
+++ live.new/liveMedia/MP3StreamState.cpp 2009-08-19 00:56:37.000000000 +0200
@@ -20,6 +20,7 @@
#include "MP3StreamState.hh"
#include "GroupsockHelper.hh"
+#include <stdint.h>
#if defined(__WIN32__) || defined(_WIN32)
#define snprintf _snprintf
@@ -35,8 +36,8 @@
// Close our open file or socket:
if (fFid != NULL && fFid != stdin) {
if (fFidIsReallyASocket) {
- long fid_long = (long)fFid;
- closeSocket((int)fid_long);
+ intptr_t fid_long = (intptr_t)fFid;
+ closeSocket((int)(intptr_t)fid_long);
} else {
fclose(fFid);
}
@@ -201,8 +202,8 @@
char const* const getCmdFmt = "GET %s HTTP/1.1\r\nHost: %s:%d\r\n\r\n";
if (fFidIsReallyASocket) {
- long fid_long = (long)fFid;
- int sock = (int)fid_long;
+ intptr_t fid_long = (intptr_t)fFid;
+ int sock = (int)(intptr_t)fid_long;
char writeBuf[100];
#if defined(IRIX) || defined(ALPHA) || defined(_QNX4) || defined(IMN_PIM) || defined(CRIS)
/* snprintf() isn't defined, so just use sprintf() */
@@ -412,8 +413,8 @@
unsigned numChars) {
// Hack for doing socket I/O instead of file I/O (e.g., on Windows)
if (fFidIsReallyASocket) {
- long fid_long = (long)fFid;
- int sock = (int)fid_long;
+ intptr_t fid_long = (intptr_t)fFid;
+ int sock = (int)(intptr_t)fid_long;
unsigned totBytesRead = 0;
do {
waitUntilSocketIsReadable(fEnv, sock);
diff -ruN live/liveMedia/RTCP.cpp live.new/liveMedia/RTCP.cpp
--- live/liveMedia/RTCP.cpp 2009-07-28 03:05:14.000000000 +0200
+++ live.new/liveMedia/RTCP.cpp 2009-08-19 00:57:01.000000000 +0200
@@ -18,6 +18,7 @@
// RTCP
// Implementation
+#include <stdint.h>
#include "RTCP.hh"
#include "GroupsockHelper.hh"
#include "rtcp_from_spec.h"
@@ -81,14 +82,14 @@
HashTable::Iterator* iter
= HashTable::Iterator::create(*fTable);
- unsigned long timeCount;
+ uintptr_t timeCount;
char const* key;
- while ((timeCount = (unsigned long)(iter->next(key))) != 0) {
+ while ((timeCount = (uintptr_t)(iter->next(key))) != 0) {
#ifdef DEBUG
fprintf(stderr, "reap: checking SSRC 0x%lx: %ld (threshold %d)\n", (unsigned long)key, timeCount, threshold);
#endif
- if (timeCount < (unsigned long)threshold) { // this SSRC is old
- unsigned long ssrc = (unsigned long)key;
+ if (timeCount < (uintptr_t)threshold) { // this SSRC is old
+ intptr_t ssrc = (uintptr_t)key;
oldSSRC = (unsigned)ssrc;
foundOldMember = True;
}
--- live/BasicUsageEnvironment/include/BasicHashTable.hh 2009-07-28 03:05:14.000000000 +0200
+++ live.new/BasicUsageEnvironment/include/BasicHashTable.hh 2009-08-19 19:00:05.000000000 +0200
@@ -24,6 +24,8 @@
#include "HashTable.hh"
#endif
+#include <stdint.h>
+
// A simple hash table implementation, inspired by the hash table
// implementation used in Tcl 7.6: <http://www.tcl.tk/>
@@ -87,7 +89,7 @@
unsigned hashIndexFromKey(char const* key) const;
// used to implement many of the routines above
- unsigned randomIndex(unsigned long i) const {
+ unsigned randomIndex(uintptr_t i) const {
return (((i*1103515245) >> fDownShift) & fMask);
}
diff -ruN live/groupsock/include/NetCommon.h live.new/groupsock/include/NetCommon.h
--- live/groupsock/include/NetCommon.h 2009-07-28 03:05:14.000000000 +0200
+++ live.new/groupsock/include/NetCommon.h 2009-08-19 19:00:59.000000000 +0200
@@ -37,8 +37,12 @@
#define closeSocket closesocket
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEWOULDBLOCK
-#define EAGAIN WSAEWOULDBLOCK
-#define EINTR WSAEINTR
+#ifndef EAGAIN
+ #define EAGAIN WSAEWOULDBLOCK
+#endif
+#ifndef EINTR
+ #define EINTR WSAEINTR
+#endif
#if defined(_WIN32_WCE)
#define NO_STRSTREAM 1
# live555
LIVEDOTCOM_URL := http://live555.com/liveMedia/public/live555-latest.tar.gz
PKGS += live555
$(TARBALLS)/live555-latest.tar.gz:
$(DOWNLOAD) $(LIVEDOTCOM_URL)
.sum-live555: $(TARBALLS)/live555-latest.tar.gz
$(CHECK_SHA512)
touch $@
live555: $(TARBALLS)/live555-latest.tar.gz .sum-live555
$(UNPACK_GZ)
patch -p0 < $(SRC)/live555/live-uselocale.patch
patch -p0 < $(SRC)/live555/live-inet_ntop.patch
ifdef HAVE_WIN64
patch -p0 < $(SRC)/live555/live-win64.patch
endif
ifndef HAVE_WIN32
ifndef HAVE_WINCE
patch -p0 < $(SRC)/live555/live-getaddrinfo.patch
endif
endif
mv live $@
touch $@
LIVE_TARGET = $(error live555 target not defined!)
ifdef HAVE_LINUX
LIVE_TARGET := linux
endif
ifdef HAVE_WIN32
LIVE_TARGET := mingw
endif
ifdef HAVE_WINCE
LIVE_TARGET := mingw
endif
ifdef HAVE_MACOSX
LIVE_TARGET := macosx
endif
.live555: live555
ifdef HAVE_WINCE
cd $< && sed -e 's/-lws2_32/-lws2/g' -i.orig config.mingw
endif
cd $< && sed \
-e 's%-DBSD=1%-DBSD=1\ $(EXTRA_CFLAGS)\ $(EXTRA_LDFLAGS)%' \
-e 's%cc%$(CC)%' \
-e 's%c++%$(CXX)\ $(EXTRA_LDFLAGS)%' \
-i.orig config.macosx
cd $< && sed -e 's%-D_FILE_OFFSET_BITS=64%-D_FILE_OFFSET_BITS=64\ -fPIC\ -DPIC%' -i.orig config.linux
cd $< && ./genMakefiles $(LIVE_TARGET)
cd $< && $(MAKE) $(HOSTVARS)
mkdir -p -- "$(PREFIX)/lib" "$(PREFIX)/include"
cp \
$</groupsock/libgroupsock.a \
$</liveMedia/libliveMedia.a \
$</UsageEnvironment/libUsageEnvironment.a \
$</BasicUsageEnvironment/libBasicUsageEnvironment.a \
"$(PREFIX)/lib"
cp \
$</groupsock/include/*.hh \
$</groupsock/include/*.h \
$</liveMedia/include/*.hh \
$</UsageEnvironment/include/*.hh \
$</BasicUsageEnvironment/include/*.hh \
"$(PREFIX)/include"
touch $@
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment