Skip to content

Commit

Permalink
Bump to 2014-08-26
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Gaufman committed Sep 10, 2014
1 parent 678b141 commit 6b87f7f
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _BASICUSAGEENVIRONMENT_VERSION_HH
#define _BASICUSAGEENVIRONMENT_VERSION_HH

#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_STRING "2014.07.18"
#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_INT 1405641600
#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_STRING "2014.08.26"
#define BASICUSAGEENVIRONMENT_LIBRARY_VERSION_INT 1409011200

#endif
4 changes: 2 additions & 2 deletions UsageEnvironment/include/UsageEnvironment_version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _USAGEENVIRONMENT_VERSION_HH
#define _USAGEENVIRONMENT_VERSION_HH

#define USAGEENVIRONMENT_LIBRARY_VERSION_STRING "2014.07.18"
#define USAGEENVIRONMENT_LIBRARY_VERSION_INT 1405641600
#define USAGEENVIRONMENT_LIBRARY_VERSION_STRING "2014.08.26"
#define USAGEENVIRONMENT_LIBRARY_VERSION_INT 1409011200

#endif
5 changes: 5 additions & 0 deletions UsageEnvironment/include/strDup.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
// This generates a char* that can be deleted using "delete[]"
// Header

#include <string.h>

char* strDup(char const* str);
// Note: strDup(NULL) returns NULL

char* strDupSize(char const* str);
// Like "strDup()", except that it *doesn't* copy the original.
// (Instead, it just allocates a string of the same size as the original.)

char* strDupSize(char const* str, size_t& resultBufSize);
// An alternative form of "strDupSize()" that also returns the size of the allocated buffer.

#endif
18 changes: 13 additions & 5 deletions UsageEnvironment/strDup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
// Implementation

#include "strDup.hh"
#include "string.h"

char* strDup(char const* str) {
if (str == NULL) return NULL;
Expand All @@ -33,10 +32,19 @@ char* strDup(char const* str) {
}

char* strDupSize(char const* str) {
if (str == NULL) return NULL;
size_t len = strlen(str) + 1;
char* copy = new char[len];
size_t dummy;

return copy;
return strDupSize(str, dummy);
}

char* strDupSize(char const* str, size_t& resultBufSize) {
if (str == NULL) {
resultBufSize = 0;
return NULL;
}

resultBufSize = strlen(str) + 1;
char* copy = new char[resultBufSize];

return copy;
}
8 changes: 4 additions & 4 deletions config.linux-with-shared-libraries
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# At least one interface changes, or is removed => CURRENT += 1; REVISION = 0; AGE = 0
# One or more interfaces were added, but no existing interfaces were changed or removed => CURRENT += 1; REVISION = 0; AGE += 1

libliveMedia_VERSION_CURRENT=33
libliveMedia_VERSION_REVISION=1
libliveMedia_VERSION_CURRENT=35
libliveMedia_VERSION_REVISION=0
libliveMedia_VERSION_AGE=0
libliveMedia_LIB_SUFFIX=so.$(shell expr $(libliveMedia_VERSION_CURRENT) - $(libliveMedia_VERSION_AGE)).$(libliveMedia_VERSION_AGE).$(libliveMedia_VERSION_REVISION)

Expand All @@ -13,9 +13,9 @@ libBasicUsageEnvironment_VERSION_REVISION=3
libBasicUsageEnvironment_VERSION_AGE=0
libBasicUsageEnvironment_LIB_SUFFIX=so.$(shell expr $(libBasicUsageEnvironment_VERSION_CURRENT) - $(libBasicUsageEnvironment_VERSION_AGE)).$(libBasicUsageEnvironment_VERSION_AGE).$(libBasicUsageEnvironment_VERSION_REVISION)

libUsageEnvironment_VERSION_CURRENT=2
libUsageEnvironment_VERSION_CURRENT=3
libUsageEnvironment_VERSION_REVISION=0
libUsageEnvironment_VERSION_AGE=0
libUsageEnvironment_VERSION_AGE=1
libUsageEnvironment_LIB_SUFFIX=so.$(shell expr $(libUsageEnvironment_VERSION_CURRENT) - $(libUsageEnvironment_VERSION_AGE)).$(libUsageEnvironment_VERSION_AGE).$(libUsageEnvironment_VERSION_REVISION)

libgroupsock_VERSION_CURRENT=3
Expand Down
2 changes: 1 addition & 1 deletion config.solaris-32bit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPILE_OPTS = $(INCLUDES) -I. -O -DSOLARIS -DSOCKLEN_T=socklen_t
COMPILE_OPTS = $(INCLUDES) -I. -O -DSOLARIS -DXLOCALE_NOT_USED -DSOCKLEN_T=socklen_t
C = c
C_COMPILER = cc
C_FLAGS = $(COMPILE_OPTS)
Expand Down
2 changes: 1 addition & 1 deletion config.solaris-64bit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPILE_OPTS = $(INCLUDES) -m64 -I. -O -DSOLARIS -DSOCKLEN_T=socklen_t
COMPILE_OPTS = $(INCLUDES) -m64 -I. -O -DSOLARIS -DXLOCALE_NOT_USED -DSOCKLEN_T=socklen_t
C = c
C_COMPILER = cc
C_FLAGS = $(COMPILE_OPTS)
Expand Down
4 changes: 2 additions & 2 deletions groupsock/include/groupsock_version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _GROUPSOCK_VERSION_HH
#define _GROUPSOCK_VERSION_HH

#define GROUPSOCK_LIBRARY_VERSION_STRING "2014.07.18"
#define GROUPSOCK_LIBRARY_VERSION_INT 1405641600
#define GROUPSOCK_LIBRARY_VERSION_STRING "2014.08.26"
#define GROUPSOCK_LIBRARY_VERSION_INT 1409011200

#endif
28 changes: 23 additions & 5 deletions liveMedia/MediaSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,13 @@ class SDPAttribute {
virtual ~SDPAttribute();

char const* strValue() const { return fStrValue; }
char const* strValueToLower() const { return fStrValueToLower; }
int intValue() const { return fIntValue; }
Boolean valueIsHexadecimal() const { return fValueIsHexadecimal; }

private:
char* fStrValue;
char* fStrValueToLower;
int fIntValue;
Boolean fValueIsHexadecimal;
};
Expand Down Expand Up @@ -873,6 +875,13 @@ char const* MediaSubsession::attrVal_str(char const* attrName) const {
return attr->strValue();
}

char const* MediaSubsession::attrVal_strToLower(char const* attrName) const {
SDPAttribute* attr = (SDPAttribute*)(fAttributeTable->Lookup(attrName));
if (attr == NULL) return "";

return attr->strValueToLower();
}

unsigned MediaSubsession::attrVal_int(char const* attrName) const {
SDPAttribute* attr = (SDPAttribute*)(fAttributeTable->Lookup(attrName));
if (attr == NULL) return 0;
Expand Down Expand Up @@ -1279,7 +1288,7 @@ Boolean MediaSubsession::createSourceObjects(int useSpecialRTPoffset) {
= MPEG4GenericRTPSource::createNew(env(), fRTPSocket,
fRTPPayloadFormat,
fRTPTimestampFrequency,
fMediumName, attrVal_str("mode"),
fMediumName, attrVal_strToLower("mode"),
attrVal_unsigned("sizelength"),
attrVal_unsigned("indexlength"),
attrVal_unsigned("indexdeltalength"));
Expand Down Expand Up @@ -1411,18 +1420,27 @@ Boolean MediaSubsession::createSourceObjects(int useSpecialRTPoffset) {
////////// SDPAttribute implementation //////////

SDPAttribute::SDPAttribute(char const* strValue, Boolean valueIsHexadecimal)
: fStrValue(strDup(strValue)), fValueIsHexadecimal(valueIsHexadecimal) {
if (strValue == NULL) {
: fStrValue(strDup(strValue)), fStrValueToLower(NULL), fValueIsHexadecimal(valueIsHexadecimal) {
if (fStrValue == NULL) {
// No value was given for this attribute, so consider it to be a Boolean, with value True:
fIntValue = 1;
} else {
// Try to parse "strValue" as an integer. If we can't, assume an integer value of 0:
if (sscanf(strValue, valueIsHexadecimal ? "%x" : "%d", &fIntValue) != 1) {
// Create a 'tolower' version of "fStrValue", in case it's needed:
Locale l("POSIX");
size_t strSize;

fStrValueToLower = strDupSize(fStrValue, strSize);
for (unsigned i = 0; i < strSize-1; ++i) fStrValueToLower[i] = tolower(fStrValue[i]);
fStrValueToLower[strSize-1] = '\0';

// Try to parse "fStrValueToLower" as an integer. If we can't, assume an integer value of 0:
if (sscanf(fStrValueToLower, valueIsHexadecimal ? "%x" : "%d", &fIntValue) != 1) {
fIntValue = 0;
}
}
}

SDPAttribute::~SDPAttribute() {
delete[] fStrValue;
delete[] fStrValueToLower;
}
10 changes: 8 additions & 2 deletions liveMedia/MultiFramedRTPSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,16 @@ Boolean BufferedPacket::fillInData(RTPInterface& rtpInterface, struct sockaddr_i
Boolean& packetReadWasIncomplete) {
if (!packetReadWasIncomplete) reset();

unsigned numBytesRead;
unsigned const maxBytesToRead = bytesAvailable();
if (maxBytesToRead == 0) return False; // exceeded buffer size when reading over TCP
if (!rtpInterface.handleRead(&fBuf[fTail], maxBytesToRead, numBytesRead, fromAddress, packetReadWasIncomplete)) {

unsigned numBytesRead;
int tcpSocketNum; // not used
unsigned char tcpStreamChannelId; // not used
if (!rtpInterface.handleRead(&fBuf[fTail], maxBytesToRead,
numBytesRead, fromAddress,
tcpSocketNum, tcpStreamChannelId,
packetReadWasIncomplete)) {
return False;
}
fTail += numBytesRead;
Expand Down
2 changes: 1 addition & 1 deletion liveMedia/ProxyServerMediaSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ ::createNewRTPSink(Groupsock* rtpGroupsock, unsigned char rtpPayloadTypeIfDynami
newSink = MPEG4GenericRTPSink::createNew(envir(), rtpGroupsock,
rtpPayloadTypeIfDynamic, fClientMediaSubsession.rtpTimestampFrequency(),
fClientMediaSubsession.mediumName(),
fClientMediaSubsession.attrVal_str("mode"),
fClientMediaSubsession.attrVal_strToLower("mode"),
fClientMediaSubsession.fmtp_config(), fClientMediaSubsession.numChannels());
} else if (strcmp(codecName, "MPV") == 0) {
newSink = MPEG1or2VideoRTPSink::createNew(envir(), rtpGroupsock);
Expand Down
42 changes: 25 additions & 17 deletions liveMedia/RTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ void RTCPInstance
::injectReport(u_int8_t const* packet, unsigned packetSize, struct sockaddr_in const& fromAddress) {
if (packetSize > maxRTCPPacketSize) packetSize = maxRTCPPacketSize;
memmove(fInBuf, packet, packetSize);
processIncomingReport(packetSize, fromAddress);

processIncomingReport(packetSize, fromAddress, -1, 0xFF); // assume report received over UDP
}

static unsigned const IP_UDP_HDR_SIZE = 28;
Expand All @@ -331,17 +332,23 @@ void RTCPInstance::incomingReportHandler(RTCPInstance* instance,

void RTCPInstance::incomingReportHandler1() {
do {
unsigned packetSize = 0;
unsigned numBytesRead;
struct sockaddr_in fromAddress;
Boolean packetReadWasIncomplete;
if (fNumBytesAlreadyRead >= maxRTCPPacketSize) {
envir() << "RTCPInstance error: Hit limit when reading incoming packet over TCP. Increase \"maxRTCPPacketSize\"\n";
break;
}

unsigned numBytesRead;
struct sockaddr_in fromAddress;
int tcpSocketNum;
unsigned char tcpStreamChannelId;
Boolean packetReadWasIncomplete;
Boolean readResult
= fRTCPInterface.handleRead(&fInBuf[fNumBytesAlreadyRead], maxRTCPPacketSize - fNumBytesAlreadyRead,
numBytesRead, fromAddress, packetReadWasIncomplete);
numBytesRead, fromAddress,
tcpSocketNum, tcpStreamChannelId,
packetReadWasIncomplete);

unsigned packetSize = 0;
if (packetReadWasIncomplete) {
fNumBytesAlreadyRead += numBytesRead;
return; // more reads are needed to get the entire packet
Expand Down Expand Up @@ -391,25 +398,26 @@ void RTCPInstance::incomingReportHandler1() {
fLastPacketSentSize = packetSize;
}

processIncomingReport(packetSize, fromAddress);
processIncomingReport(packetSize, fromAddress, tcpSocketNum, tcpStreamChannelId);
} while (0);
}

void RTCPInstance
::processIncomingReport(unsigned packetSize, struct sockaddr_in const& fromAddress) {
::processIncomingReport(unsigned packetSize, struct sockaddr_in const& fromAddress,
int tcpSocketNum, unsigned char tcpStreamChannelId) {
do {
Boolean callByeHandler = False;
int tcpReadStreamSocketNum = fRTCPInterface.nextTCPReadStreamSocketNum();
unsigned char tcpReadStreamChannelId = fRTCPInterface.nextTCPReadStreamChannelId();
unsigned char* pkt = fInBuf;

#ifdef DEBUG
fprintf(stderr, "[%p]saw incoming RTCP packet", this);
if (tcpReadStreamSocketNum < 0) {
fprintf(stderr, "[%p]saw incoming RTCP packet (from ", this);
if (tcpSocketNum < 0) {
// Note that "fromAddress" is valid only if we're receiving over UDP (not over TCP):
fprintf(stderr, " (from address %s, port %d)", AddressString(fromAddress).val(), ntohs(fromAddress.sin_port));
fprintf(stderr, "address %s, port %d", AddressString(fromAddress).val(), ntohs(fromAddress.sin_port));
} else {
fprintf(stderr, "TCP socket #%d, stream channel id %d", tcpSocketNum, tcpStreamChannelId);
}
fprintf(stderr, "\n");
fprintf(stderr, ")\n");
for (unsigned i = 0; i < packetSize; ++i) {
if (i%4 == 0) fprintf(stderr, " ");
fprintf(stderr, "%02x", pkt[i]);
Expand Down Expand Up @@ -511,15 +519,15 @@ ::processIncomingReport(unsigned packetSize, struct sockaddr_in const& fromAddre
if (fSpecificRRHandlerTable != NULL) {
netAddressBits fromAddr;
portNumBits fromPortNum;
if (tcpReadStreamSocketNum < 0) {
if (tcpSocketNum < 0) {
// Normal case: We read the RTCP packet over UDP
fromAddr = fromAddress.sin_addr.s_addr;
fromPortNum = ntohs(fromAddress.sin_port);
} else {
// Special case: We read the RTCP packet over TCP (interleaved)
// Hack: Use the TCP socket and channel id to look up the handler
fromAddr = tcpReadStreamSocketNum;
fromPortNum = tcpReadStreamChannelId;
fromAddr = tcpSocketNum;
fromPortNum = tcpStreamChannelId;
}
Port fromPort(fromPortNum);
RRHandlerRecord* rrHandler
Expand Down
16 changes: 12 additions & 4 deletions liveMedia/RTPInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ Boolean RTPInterface::sendPacket(unsigned char* packet, unsigned packetSize) {
if (!fGS->output(envir(), fGS->ttl(), packet, packetSize)) success = False;

// Also, send over each of our TCP sockets:
for (tcpStreamRecord* streams = fTCPStreams; streams != NULL;
streams = streams->fNext) {
tcpStreamRecord* nextStream;
for (tcpStreamRecord* stream = fTCPStreams; stream != NULL; stream = nextStream) {
nextStream = stream->fNext; // Set this now, in case the following deletes "stream":
if (!sendRTPorRTCPPacketOverTCP(packet, packetSize,
streams->fStreamSocketNum, streams->fStreamChannelId)) {
stream->fStreamSocketNum, stream->fStreamChannelId)) {
success = False;
}
}
Expand All @@ -245,14 +246,20 @@ ::startNetworkReading(TaskScheduler::BackgroundHandlerProc* handlerProc) {
}

Boolean RTPInterface::handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead, struct sockaddr_in& fromAddress, Boolean& packetReadWasIncomplete) {
unsigned& bytesRead, struct sockaddr_in& fromAddress,
int& tcpSocketNum, unsigned char& tcpStreamChannelId,
Boolean& packetReadWasIncomplete) {
packetReadWasIncomplete = False; // by default
Boolean readSuccess;
if (fNextTCPReadStreamSocketNum < 0) {
// Normal case: read from the (datagram) 'groupsock':
tcpSocketNum = -1;
readSuccess = fGS->handleRead(buffer, bufferMaxSize, bytesRead, fromAddress);
} else {
// Read from the TCP connection:
tcpSocketNum = fNextTCPReadStreamSocketNum;
tcpStreamChannelId = fNextTCPReadStreamChannelId;

bytesRead = 0;
unsigned totBytesToRead = fNextTCPReadSize;
if (totBytesToRead > bufferMaxSize) totBytesToRead = bufferMaxSize;
Expand All @@ -278,6 +285,7 @@ Boolean RTPInterface::handleRead(unsigned char* buffer, unsigned bufferMaxSize,
packetReadWasIncomplete = True;
return True;
}
fNextTCPReadStreamSocketNum = -1; // default, for next time
}

if (readSuccess && fAuxReadHandlerFunc != NULL) {
Expand Down
2 changes: 2 additions & 0 deletions liveMedia/include/MediaSession.hh
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public:
// General SDP attribute accessor functions:
char const* attrVal_str(char const* attrName) const;
// returns "" if attribute doesn't exist (and has no default value), or is not a string
char const* attrVal_strToLower(char const* attrName) const;
// returns "" if attribute doesn't exist (and has no default value), or is not a string
unsigned attrVal_int(char const* attrName) const;
// also returns 0 if attribute doesn't exist (and has no default value)
unsigned attrVal_unsigned(char const* attrName) const { return (unsigned)attrVal_int(attrName); }
Expand Down
3 changes: 2 additions & 1 deletion liveMedia/include/RTCP.hh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private:

static void incomingReportHandler(RTCPInstance* instance, int /*mask*/);
void incomingReportHandler1();
void processIncomingReport(unsigned packetSize, struct sockaddr_in const& fromAddress);
void processIncomingReport(unsigned packetSize, struct sockaddr_in const& fromAddress,
int tcpSocketNum, unsigned char tcpStreamChannelId);
void onReceive(int typeOfPacket, int totPacketSize, u_int32_t ssrc);

private:
Expand Down
14 changes: 9 additions & 5 deletions liveMedia/include/RTPInterface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ public:
void startNetworkReading(TaskScheduler::BackgroundHandlerProc*
handlerProc);
Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead, struct sockaddr_in& fromAddress, Boolean& packetReadWasIncomplete);
// out parameters:
unsigned& bytesRead, struct sockaddr_in& fromAddress,
int& tcpSocketNum, unsigned char& tcpStreamChannelId,
Boolean& packetReadWasIncomplete);
// Note: If "tcpSocketNum" < 0, then the packet was received over UDP, and "tcpStreamChannelId"
// is undefined (and irrelevant).
// Otherwise (if "tcpSocketNum" >= 0), the packet was received (interleaved) over TCP, and
// "tcpStreamChannelId" will return the channel id.

void stopNetworkReading();

UsageEnvironment& envir() const { return fOwner->envir(); }
Expand All @@ -81,10 +89,6 @@ public:
fAuxReadHandlerClientData = handlerClientData;
}

// A hack for supporting handlers for RTCP packets arriving interleaved over TCP:
int nextTCPReadStreamSocketNum() const { return fNextTCPReadStreamSocketNum; }
unsigned char nextTCPReadStreamChannelId() const { return fNextTCPReadStreamChannelId; }

private:
// Helper functions for sending a RTP or RTCP packet over a TCP connection:
Boolean sendRTPorRTCPPacketOverTCP(unsigned char* packet, unsigned packetSize,
Expand Down
Loading

0 comments on commit 6b87f7f

Please sign in to comment.