update to jrtp 3.5.2 and jthread 1.2.0

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@954 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2006-03-28 15:58:06 +00:00
parent ee0dd13ca7
commit 2f322f615f
45 changed files with 1076 additions and 939 deletions

View File

@ -1,10 +1,35 @@
January 19, 2006 March 26, 2006
JRTPLIB ChangeLog JRTPLIB ChangeLog
----------- -----------
3.5.2 (March 2006)
* Fixed bug in the random number functions which are used with
MS Visual Studio 2005. Thanks to Jun Ohasi (jun@jnb.odn.ne.jp)
for bringing the incorrect use of rand_s to my attention.
* Changed types like u_int32_t to types like uint32_t in the
documentation.
3.5.1 (March 2006)
* Fixed bug in RTCP scheduler. Due to -= operation on an RTPTime
instance, an incredibly large scheduling interval could be
calculated.
3.5.0 (March 2006)
* Now, the define RTP_SNPRINTF is used instead of snprintf,
_snprintf or _snprintf_s.
* In the RTPSources member function MultipleTimeouts, I neglected
to call the OnRemoveSource virtual function. Thanks to Adam Love
(alove@exceptionalinnovation.com) for bringing this to my attention.
* Added a OnSendRTCPCompoundPacket member function to the RTPSession
class. Useful for inspecting outgoing data.
* Modified the templates somewhat. Should cause less compiler problems
this way. Thanks tot Chris Hamilton (chamilton@cs.dal.ca) for
providing this solution.
* On Win32, if possible the functions rand_s and srand_s are now used.
3.4.0 (January 2006) 3.4.0 (January 2006)
* Changed u_int32_t like types to uint32_t like types. Thanks to * Changed u_int32_t like types to uint32_t like types. Thanks to
Panagiotis Issaris (takis.issaris@uhasselt.be) for informing me Panagiotis Issaris (takis.issaris@uhasselt.be) for informing me

View File

@ -1,8 +1,8 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
January 19, 2006 March 26, 2006
JRTPLIB (v3.4.0) JRTPLIB (v3.5.2)
Developed at the The Expertise Centre for Developed at the The Expertise Centre for
@ -15,6 +15,7 @@
LIBRARY LOCATION AND CONTACT LIBRARY LOCATION AND CONTACT
============================ ============================
Normally, you should be able to download the latest version of the library Normally, you should be able to download the latest version of the library
from this url: from this url:
http://research.edm.uhasselt.be/jori/jrtplib/jrtplib.html http://research.edm.uhasselt.be/jori/jrtplib/jrtplib.html
@ -29,6 +30,7 @@ instructions.
ACKNOWLEDGMENT ACKNOWLEDGMENT
============== ==============
I would like thank the people at the Expertise Centre for Digital Media I would like thank the people at the Expertise Centre for Digital Media
for giving me the opportunity to create this rewrite of the library. for giving me the opportunity to create this rewrite of the library.
@ -104,9 +106,6 @@ INSTALLATION NOTES
Enables support for JThread. Enables support for JThread.
- RTP_SUPPORT_SDESPRIV: - RTP_SUPPORT_SDESPRIV:
Enables support for RTCP SDES private items. Enables support for RTCP SDES private items.
- RTP_SUPPORT_INLINETEMPLATEPARAM:
If set, the compiler should be able to handle an inline
function as a template parameter.
- RTP_SUPPORT_PROBATION: - RTP_SUPPORT_PROBATION:
If set, a few consecutive RTP packets are needed to validate If set, a few consecutive RTP packets are needed to validate
a member. a member.

View File

@ -1804,7 +1804,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE=jrtplib PACKAGE=jrtplib
VERSION=3.4.0 VERSION=3.5.2
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -1944,7 +1944,6 @@ RTP_SUPPORT_IPV4MULTICAST="// No IPv4 multicasting support"
RTP_SUPPORT_IPV6MULTICAST="// No IPv6 multicasting support" RTP_SUPPORT_IPV6MULTICAST="// No IPv6 multicasting support"
RTP_SUPPORT_THREAD="// No support for jthread" RTP_SUPPORT_THREAD="// No support for jthread"
RTP_SUPPORT_SDESPRIV="// No support for SDES PRIV items" RTP_SUPPORT_SDESPRIV="// No support for SDES PRIV items"
RTP_SUPPORT_INLINETEMPLATEPARAM="// Compiler doesn't support inline functions as template parameter"
RTP_SUPPORT_PROBATION="// Do not wait for a number of consecutive packets to validate source" RTP_SUPPORT_PROBATION="// Do not wait for a number of consecutive packets to validate source"
RTP_SUPPORT_GNUDRAND="// Not using drand48_r and srand48_r" RTP_SUPPORT_GNUDRAND="// Not using drand48_r and srand48_r"
RTP_SUPPORT_RANDR="// Not using rand_r" RTP_SUPPORT_RANDR="// Not using rand_r"
@ -20546,62 +20545,6 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: checking if compiler supports an inline function as a template argument" >&5
echo $ECHO_N "checking if compiler supports an inline function as a template argument... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include "src/rtphashtable.h"
inline int GetIndex(const int &elem) { return elem%10; }
int
main ()
{
RTPHashTable<int,GetIndex,10> table;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
RTP_SUPPORT_INLINETEMPLATEPARAM="#define RTP_SUPPORT_INLINETEMPLATEPARAM"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: checking if types like uint32_t exist" >&5 echo "$as_me:$LINENO: checking if types like uint32_t exist" >&5
echo $ECHO_N "checking if types like uint32_t exist... $ECHO_C" >&6 echo $ECHO_N "checking if types like uint32_t exist... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF

View File

@ -1,5 +1,5 @@
AC_INIT(configure.in) AC_INIT(configure.in)
AM_INIT_AUTOMAKE(jrtplib,3.4.0) AM_INIT_AUTOMAKE(jrtplib,3.5.2)
RTP_FILIO="// Don't have <sys/filio.h>" RTP_FILIO="// Don't have <sys/filio.h>"
RTP_SOCKIO="// Don't have <sys/sockio.h>" RTP_SOCKIO="// Don't have <sys/sockio.h>"
@ -10,7 +10,6 @@ RTP_SUPPORT_IPV4MULTICAST="// No IPv4 multicasting support"
RTP_SUPPORT_IPV6MULTICAST="// No IPv6 multicasting support" RTP_SUPPORT_IPV6MULTICAST="// No IPv6 multicasting support"
RTP_SUPPORT_THREAD="// No support for jthread" RTP_SUPPORT_THREAD="// No support for jthread"
RTP_SUPPORT_SDESPRIV="// No support for SDES PRIV items" RTP_SUPPORT_SDESPRIV="// No support for SDES PRIV items"
RTP_SUPPORT_INLINETEMPLATEPARAM="// Compiler doesn't support inline functions as template parameter"
RTP_SUPPORT_PROBATION="// Do not wait for a number of consecutive packets to validate source" RTP_SUPPORT_PROBATION="// Do not wait for a number of consecutive packets to validate source"
RTP_SUPPORT_GNUDRAND="// Not using drand48_r and srand48_r" RTP_SUPPORT_GNUDRAND="// Not using drand48_r and srand48_r"
RTP_SUPPORT_RANDR="// Not using rand_r" RTP_SUPPORT_RANDR="// Not using rand_r"
@ -201,21 +200,7 @@ AC_TRY_COMPILE([
]) ])
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl Check if compiler can handle inline function in template argument dnl Check for uint32_t etc
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING(if compiler supports an inline function as a template argument)
AC_TRY_COMPILE([
#include "src/rtphashtable.h"
inline int GetIndex(const int &elem) { return elem%10; }],[
RTPHashTable<int,GetIndex,10> table; ],
[AC_MSG_RESULT(yes)
RTP_SUPPORT_INLINETEMPLATEPARAM="#define RTP_SUPPORT_INLINETEMPLATEPARAM"],
AC_MSG_RESULT(no)
)
dnl ---------------------------------------------------------------------------
dnl Check for u_int32_t etc
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING(if types like uint32_t exist) AC_MSG_CHECKING(if types like uint32_t exist)

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\jthread-1.1.2\src" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\jthread-1.2.0\src" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x813 /d "NDEBUG" # ADD BASE RSC /l 0x813 /d "NDEBUG"
# ADD RSC /l 0x813 /d "NDEBUG" # ADD RSC /l 0x813 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -64,7 +64,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\jthread-1.1.2\src" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\jthread-1.2.0\src" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x813 /d "_DEBUG" # ADD BASE RSC /l 0x813 /d "_DEBUG"
# ADD RSC /l 0x813 /d "_DEBUG" # ADD RSC /l 0x813 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@ -5,7 +5,6 @@
Name="jrtplib_wce" Name="jrtplib_wce"
ProjectGUID="{93374307-119F-404E-9B09-3642C6FC96C1}" ProjectGUID="{93374307-119F-404E-9B09-3642C6FC96C1}"
Keyword="Win32Proj" Keyword="Win32Proj"
SignManifests="true"
> >
<Platforms> <Platforms>
<Platform <Platform
@ -41,10 +40,10 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
ExecutionBucket="7" ExecutionBucket="7"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="../jthread-1.1.2/src" AdditionalIncludeDirectories="../jthread-1.2.0/src"
PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);_DEBUG;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE" PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);_DEBUG;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
MinimalRebuild="true" MinimalRebuild="true"
RuntimeLibrary="1" RuntimeLibrary="3"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3" DebugInformationFormat="3"
@ -116,12 +115,12 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
ExecutionBucket="7" ExecutionBucket="7"
Optimization="2" Optimization="2"
AdditionalIncludeDirectories="../jthread-1.1.2/src" AdditionalIncludeDirectories="../jthread-1.2.0/src"
PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);NDEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE" PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);NDEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
RuntimeLibrary="0" RuntimeLibrary="2"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3" DebugInformationFormat="0"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"

View File

@ -16,7 +16,7 @@ libjrtp_la_SOURCES = rtpdebug.cpp rtpsession.cpp rtpconfig_win.h \
rtpudpv6transmitter.cpp rtptimeutilities.cpp \ rtpudpv6transmitter.cpp rtptimeutilities.cpp \
extratransmitters/rtpfaketransmitter.cpp \ extratransmitters/rtpfaketransmitter.cpp \
pthread/jmutex.cpp pthread/jthread.cpp pthread/jmutex.cpp pthread/jthread.cpp
libjrtp_la_LDFLAGS = -release 3.4.0 @RTP_LINKLIBS@ libjrtp_la_LDFLAGS = -release 3.5.2 @RTP_LINKLIBS@
libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \ libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \
rtcpcompoundpacketbuilder.h rtcppacket.h rtcppacketbuilder.h \ rtcpcompoundpacketbuilder.h rtcppacket.h rtcppacketbuilder.h \
rtcprrpacket.h rtcpscheduler.h rtcpsdesinfo.h rtcpsdespacket.h \ rtcprrpacket.h rtcpscheduler.h rtcpsdesinfo.h rtcpsdespacket.h \
@ -31,7 +31,7 @@ libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \
rtpcollisionlist.h rtpipv6address.h rtpipv6destination.h \ rtpcollisionlist.h rtpipv6address.h rtpipv6destination.h \
rtpudpv6transmitter.h rtptypes.h rtptypes_unix.h \ rtpudpv6transmitter.h rtptypes.h rtptypes_unix.h \
extratransmitters/rtpfaketransmitter.h \ extratransmitters/rtpfaketransmitter.h \
jmutex.h jthread.h jrtp4c.h jmutex.h jthread.h jrtp4c.h jmutexautolock.h
EXTRA_DIST = rtpconfig_unix.h.in win32/jthread.cpp win32/jmutex.cpp EXTRA_DIST = rtpconfig_unix.h.in win32/jthread.cpp win32/jmutex.cpp
libjrtpincludedir = ${includedir}/jrtplib3 libjrtpincludedir = ${includedir}/jrtplib3

View File

@ -229,7 +229,7 @@ libjrtp_la_SOURCES = rtpdebug.cpp rtpsession.cpp rtpconfig_win.h \
extratransmitters/rtpfaketransmitter.cpp \ extratransmitters/rtpfaketransmitter.cpp \
pthread/jmutex.cpp pthread/jthread.cpp pthread/jmutex.cpp pthread/jthread.cpp
libjrtp_la_LDFLAGS = -release 3.4.0 @RTP_LINKLIBS@ libjrtp_la_LDFLAGS = -release 3.5.2 @RTP_LINKLIBS@
libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \ libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \
rtcpcompoundpacketbuilder.h rtcppacket.h rtcppacketbuilder.h \ rtcpcompoundpacketbuilder.h rtcppacket.h rtcppacketbuilder.h \
rtcprrpacket.h rtcpscheduler.h rtcpsdesinfo.h rtcpsdespacket.h \ rtcprrpacket.h rtcpscheduler.h rtcpsdesinfo.h rtcpsdespacket.h \
@ -244,7 +244,7 @@ libjrtpinclude_HEADERS = rtcpapppacket.h rtcpbyepacket.h rtcpcompoundpacket.h \
rtpcollisionlist.h rtpipv6address.h rtpipv6destination.h \ rtpcollisionlist.h rtpipv6address.h rtpipv6destination.h \
rtpudpv6transmitter.h rtptypes.h rtptypes_unix.h \ rtpudpv6transmitter.h rtptypes.h rtptypes_unix.h \
extratransmitters/rtpfaketransmitter.h \ extratransmitters/rtpfaketransmitter.h \
jmutex.h jthread.h jrtp4c.h jmutex.h jthread.h jrtp4c.h jmutexautolock.h
EXTRA_DIST = rtpconfig_unix.h.in win32/jthread.cpp win32/jmutex.cpp EXTRA_DIST = rtpconfig_unix.h.in win32/jthread.cpp win32/jmutex.cpp
libjrtpincludedir = ${includedir}/jrtplib3 libjrtpincludedir = ${includedir}/jrtplib3

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -30,18 +30,19 @@
#define JMUTEX_H #define JMUTEX_H
#if (defined(WIN32) || defined(_WIN32_WCE)) #if (defined(WIN32) || defined(_WIN32_WCE))
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#include <process.h> #include <process.h>
#endif // _WIN32_WCE #endif // _WIN32_WCE
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
//#define JMUTEX_CRITICALSECTION
#else // using pthread #else // using pthread
#include <pthread.h> #include <pthread.h>
#endif // WIN32 #endif // WIN32
#define ERR_JMUTEX_ALREADYINIT -1 #define ERR_JMUTEX_ALREADYINIT -1
#define ERR_JMUTEX_NOTINIT -2 #define ERR_JMUTEX_NOTINIT -2
#define ERR_JMUTEX_CANTCREATEMUTEX -3 #define ERR_JMUTEX_CANTCREATEMUTEX -3
class JMutex class JMutex
@ -55,7 +56,11 @@ public:
bool IsInitialized() { return initialized; } bool IsInitialized() { return initialized; }
private: private:
#if (defined(WIN32) || defined(_WIN32_WCE)) #if (defined(WIN32) || defined(_WIN32_WCE))
#ifdef JMUTEX_CRITICALSECTION
CRITICAL_SECTION mutex;
#else // Use standard mutex
HANDLE mutex; HANDLE mutex;
#endif // JMUTEX_CRITICALSECTION
#else // pthread mutex #else // pthread mutex
pthread_mutex_t mutex; pthread_mutex_t mutex;
#endif // WIN32 #endif // WIN32

View File

@ -0,0 +1,43 @@
/*
This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef JMUTEXAUTOLOCK_H
#define JMUTEXAUTOLOCK_H
#include "jmutex.h"
class JMutexAutoLock
{
public:
JMutexAutoLock(JMutex &m) : mutex(m) { mutex.Lock(); }
~JMutexAutoLock() { mutex.Unlock(); }
private:
JMutex &mutex;
};
#endif // JMUTEXAUTOLOCK_H

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -26,6 +26,8 @@
*/ */
#include "jthread.h" #include "jthread.h"
#include <sys/time.h>
#include <time.h>
#include <stdlib.h> #include <stdlib.h>
JThread::JThread() JThread::JThread()
@ -86,6 +88,13 @@ int JThread::Start()
while (!running) while (!running)
{ {
runningmutex.Unlock(); runningmutex.Unlock();
struct timespec req,rem;
req.tv_sec = 0;
req.tv_nsec = 1000000;
nanosleep(&req,&rem);
runningmutex.Lock(); runningmutex.Lock();
} }
runningmutex.Unlock(); runningmutex.Unlock();

View File

@ -284,7 +284,7 @@ int RTCPCompoundPacketBuilder::AddSDESNormalItem(RTCPSDESPacket::ItemType t,cons
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(buf); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(buf);
sdeshdr->id = itemid; sdeshdr->sdesid = itemid;
sdeshdr->length = itemlength; sdeshdr->length = itemlength;
if (itemlength != 0) if (itemlength != 0)
memcpy((buf + sizeof(RTCPSDESHeader)),itemdata,(size_t)itemlength); memcpy((buf + sizeof(RTCPSDESHeader)),itemdata,(size_t)itemlength);
@ -322,7 +322,7 @@ int RTCPCompoundPacketBuilder::AddSDESPrivateItem(const void *prefixdata,uint8_t
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(buf); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(buf);
sdeshdr->id = RTCP_SDES_ID_PRIVATE; sdeshdr->sdesid = RTCP_SDES_ID_PRIVATE;
sdeshdr->length = itemlength; sdeshdr->length = itemlength;
buf[sizeof(RTCPSDESHeader)] = prefixlength; buf[sizeof(RTCPSDESHeader)] = prefixlength;

View File

@ -186,6 +186,11 @@ bool RTCPScheduler::IsTime()
RTPTime currenttime = RTPTime::CurrentTime(); RTPTime currenttime = RTPTime::CurrentTime();
// // TODO: for debugging
// double diff = nextrtcptime.GetDouble() - currenttime.GetDouble();
//
// std::cout << "Delay till next RTCP interval: " << diff << std::endl;
if (currenttime < nextrtcptime) // timer has not yet expired if (currenttime < nextrtcptime) // timer has not yet expired
return false; return false;
@ -204,6 +209,8 @@ bool RTCPScheduler::IsTime()
else else
checktime = CalculateBYETransmissionInterval(); checktime = CalculateBYETransmissionInterval();
// std::cout << "Calculated checktime: " << checktime.GetDouble() << std::endl;
checktime += prevrtcptime; checktime += prevrtcptime;
if (checktime <= currenttime) // Okay if (checktime <= currenttime) // Okay
@ -215,6 +222,8 @@ bool RTCPScheduler::IsTime()
return true; return true;
} }
// std::cout << "New delay: " << nextrtcptime.GetDouble() - currenttime.GetDouble() << std::endl;
nextrtcptime = checktime; nextrtcptime = checktime;
pmembers = sources.GetActiveMemberCount(); pmembers = sources.GetActiveMemberCount();
@ -238,6 +247,10 @@ RTPTime RTCPScheduler::CalculateDeterministicInterval(bool sender /* = false */)
int numsenders = sources.GetSenderCount(); int numsenders = sources.GetSenderCount();
int numtotal = sources.GetActiveMemberCount(); int numtotal = sources.GetActiveMemberCount();
// std::cout << "CalculateDeterministicInterval" << std::endl;
// std::cout << " numsenders: " << numsenders << std::endl;
// std::cout << " numtotal: " << numtotal << std::endl;
// Try to avoid division by zero: // Try to avoid division by zero:
if (numtotal == 0) if (numtotal == 0)
numtotal++; numtotal++;
@ -273,6 +286,9 @@ RTPTime RTCPScheduler::CalculateDeterministicInterval(bool sender /* = false */)
double ntimesC = n*C; double ntimesC = n*C;
double Td = (tmin>ntimesC)?tmin:ntimesC; double Td = (tmin>ntimesC)?tmin:ntimesC;
// TODO: for debugging
// std::cout << " Td: " << Td << std::endl;
return RTPTime(Td); return RTPTime(Td);
} }
@ -281,10 +297,16 @@ RTPTime RTCPScheduler::CalculateTransmissionInterval(bool sender)
RTPTime Td = CalculateDeterministicInterval(sender); RTPTime Td = CalculateDeterministicInterval(sender);
double td,mul,T; double td,mul,T;
// std::cout << "CalculateTransmissionInterval" << std::endl;
td = Td.GetDouble(); td = Td.GetDouble();
mul = rtprand.GetRandomDouble()+0.5; // gives random value between 0.5 and 1.5 mul = rtprand.GetRandomDouble()+0.5; // gives random value between 0.5 and 1.5
T = (td*mul)/1.21828; // see RFC 3550 p 30 T = (td*mul)/1.21828; // see RFC 3550 p 30
// std::cout << " Td: " << td << std::endl;
// std::cout << " mul: " << mul << std::endl;
// std::cout << " T: " << T << std::endl;
return RTPTime(T); return RTPTime(T);
} }
@ -298,9 +320,22 @@ void RTCPScheduler::PerformReverseReconsideration()
RTPTime tc = RTPTime::CurrentTime(); RTPTime tc = RTPTime::CurrentTime();
RTPTime tn_min_tc = nextrtcptime; RTPTime tn_min_tc = nextrtcptime;
tn_min_tc -= tc;
if (tn_min_tc > tc)
tn_min_tc -= tc;
else
tn_min_tc = RTPTime(0,0);
// std::cout << "+tn_min_tc0 " << nextrtcptime.GetDouble()-tc.GetDouble() << std::endl;
// std::cout << "-tn_min_tc0 " << -nextrtcptime.GetDouble()+tc.GetDouble() << std::endl;
// std::cout << "tn_min_tc " << tn_min_tc.GetDouble() << std::endl;
RTPTime tc_min_tp = tc; RTPTime tc_min_tp = tc;
tc_min_tp -= prevrtcptime;
if (tc_min_tp > prevrtcptime)
tc_min_tp -= prevrtcptime;
else
tc_min_tp = 0;
if (pmembers == 0) // avoid division by zero if (pmembers == 0) // avoid division by zero
pmembers++; pmembers++;

View File

@ -92,7 +92,7 @@ RTCPSDESPacket::RTCPSDESPacket(uint8_t *data,size_t datalength)
return; return;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(chunk+chunkoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(chunk+chunkoffset);
if (sdeshdr->id == 0) // end of item list if (sdeshdr->sdesid == 0) // end of item list
{ {
len--; len--;
chunkoffset++; chunkoffset++;

View File

@ -114,7 +114,7 @@ inline bool RTCPSDESPacket::GotoNextChunk()
size_t offset = sizeof(uint32_t); size_t offset = sizeof(uint32_t);
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+sizeof(uint32_t)); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+sizeof(uint32_t));
while (sdeshdr->id != 0) while (sdeshdr->sdesid != 0)
{ {
offset += sizeof(RTCPSDESHeader); offset += sizeof(RTCPSDESHeader);
offset += (size_t)(sdeshdr->length); offset += (size_t)(sdeshdr->length);
@ -147,7 +147,7 @@ inline bool RTCPSDESPacket::GotoFirstItem()
return false; return false;
itemoffset = sizeof(uint32_t); itemoffset = sizeof(uint32_t);
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id == 0) if (sdeshdr->sdesid == 0)
return false; return false;
return true; return true;
} }
@ -160,14 +160,14 @@ inline bool RTCPSDESPacket::GotoNextItem()
return false; return false;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id == 0) if (sdeshdr->sdesid == 0)
return false; return false;
size_t offset = itemoffset; size_t offset = itemoffset;
offset += sizeof(RTCPSDESHeader); offset += sizeof(RTCPSDESHeader);
offset += (size_t)(sdeshdr->length); offset += (size_t)(sdeshdr->length);
sdeshdr = (RTCPSDESHeader *)(currentchunk+offset); sdeshdr = (RTCPSDESHeader *)(currentchunk+offset);
if (sdeshdr->id == 0) if (sdeshdr->sdesid == 0)
return false; return false;
itemoffset = offset; itemoffset = offset;
return true; return true;
@ -180,7 +180,7 @@ inline RTCPSDESPacket::ItemType RTCPSDESPacket::GetItemType() const
if (currentchunk == 0) if (currentchunk == 0)
return None; return None;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
switch (sdeshdr->id) switch (sdeshdr->sdesid)
{ {
case 0: case 0:
return None; return None;
@ -213,7 +213,7 @@ inline size_t RTCPSDESPacket::GetItemLength() const
if (currentchunk == 0) if (currentchunk == 0)
return None; return None;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id == 0) if (sdeshdr->sdesid == 0)
return 0; return 0;
return (size_t)(sdeshdr->length); return (size_t)(sdeshdr->length);
} }
@ -225,7 +225,7 @@ inline uint8_t *RTCPSDESPacket::GetItemData()
if (currentchunk == 0) if (currentchunk == 0)
return 0; return 0;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id == 0) if (sdeshdr->sdesid == 0)
return 0; return 0;
return (currentchunk+itemoffset+sizeof(RTCPSDESHeader)); return (currentchunk+itemoffset+sizeof(RTCPSDESHeader));
} }
@ -238,7 +238,7 @@ inline size_t RTCPSDESPacket::GetPRIVPrefixLength() const
if (currentchunk == 0) if (currentchunk == 0)
return 0; return 0;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id != RTCP_SDES_ID_PRIVATE) if (sdeshdr->sdesid != RTCP_SDES_ID_PRIVATE)
return 0; return 0;
if (sdeshdr->length == 0) if (sdeshdr->length == 0)
return 0; return 0;
@ -256,7 +256,7 @@ inline uint8_t *RTCPSDESPacket::GetPRIVPrefixData()
if (currentchunk == 0) if (currentchunk == 0)
return 0; return 0;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id != RTCP_SDES_ID_PRIVATE) if (sdeshdr->sdesid != RTCP_SDES_ID_PRIVATE)
return 0; return 0;
if (sdeshdr->length == 0) if (sdeshdr->length == 0)
return 0; return 0;
@ -276,7 +276,7 @@ inline size_t RTCPSDESPacket::GetPRIVValueLength() const
if (currentchunk == 0) if (currentchunk == 0)
return 0; return 0;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id != RTCP_SDES_ID_PRIVATE) if (sdeshdr->sdesid != RTCP_SDES_ID_PRIVATE)
return 0; return 0;
if (sdeshdr->length == 0) if (sdeshdr->length == 0)
return 0; return 0;
@ -294,7 +294,7 @@ inline uint8_t *RTCPSDESPacket::GetPRIVValueData()
if (currentchunk == 0) if (currentchunk == 0)
return 0; return 0;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset); RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(currentchunk+itemoffset);
if (sdeshdr->id != RTCP_SDES_ID_PRIVATE) if (sdeshdr->sdesid != RTCP_SDES_ID_PRIVATE)
return 0; return 0;
if (sdeshdr->length == 0) if (sdeshdr->length == 0)
return 0; return 0;

View File

@ -72,4 +72,15 @@
#define RTCP_DEFAULTIMMEDIATEBYE true #define RTCP_DEFAULTIMMEDIATEBYE true
#define RTCP_DEFAULTSRBYE true #define RTCP_DEFAULTSRBYE true
#if (defined(WIN32) || defined(_WIN32_WCE))
#if (!defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >= 1400 )
#define RTP_SNPRINTF _snprintf_s
#else
#define RTP_SNPRINTF _snprintf
#endif
#else
#define RTP_SNPRINTF snprintf
#endif // WIN32 || _WIN32_WCE
#endif // RTPDEFINES_H #endif // RTPDEFINES_H

View File

@ -31,6 +31,7 @@
*/ */
#include "rtperrors.h" #include "rtperrors.h"
#include "rtpdefines.h"
#include "rtpdebug.h" #include "rtpdebug.h"
@ -219,12 +220,11 @@ std::string RTPGetErrorString(int errcode)
return std::string(ErrorDescriptions[i].description); return std::string(ErrorDescriptions[i].description);
i++; i++;
} }
char str[16]; char str[16];
#if defined(WIN32) || defined(_WIN32_WCE)
_snprintf(str,16,"(%d)",errcode); RTP_SNPRINTF(str,16,"(%d)",errcode);
#else
snprintf(str,16,"(%d)",errcode);
#endif // WIN32 || _WIN32_WCE
return std::string("Unknown error code") + std::string(str); return std::string("Unknown error code") + std::string(str);
} }

View File

@ -40,7 +40,8 @@
#include <iostream> #include <iostream>
#endif // RTPDEBUG #endif // RTPDEBUG
template<class Element,int GetIndex(const Element &k),int hashsize> //template<class Element,int GetIndex(const Element &k),int hashsize>
template<class Element,class GetIndex,int hashsize>
class RTPHashTable class RTPHashTable
{ {
public: public:
@ -87,7 +88,7 @@ private:
HashElement *curhashelem; HashElement *curhashelem;
}; };
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline RTPHashTable<Element,GetIndex,hashsize>::RTPHashTable() inline RTPHashTable<Element,GetIndex,hashsize>::RTPHashTable()
{ {
for (int i = 0 ; i < hashsize ; i++) for (int i = 0 ; i < hashsize ; i++)
@ -96,7 +97,7 @@ inline RTPHashTable<Element,GetIndex,hashsize>::RTPHashTable()
lasthashelem = 0; lasthashelem = 0;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteCurrentElement() inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteCurrentElement()
{ {
if (curhashelem) if (curhashelem)
@ -152,13 +153,13 @@ inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteCurrentElement()
return 0; return 0;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline int RTPHashTable<Element,GetIndex,hashsize>::GotoElement(const Element &e) inline int RTPHashTable<Element,GetIndex,hashsize>::GotoElement(const Element &e)
{ {
int index; int index;
bool found; bool found;
index = GetIndex(e); index = GetIndex::GetIndex(e);
if (index >= hashsize) if (index >= hashsize)
return ERR_RTP_HASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX; return ERR_RTP_HASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX;
@ -176,14 +177,14 @@ inline int RTPHashTable<Element,GetIndex,hashsize>::GotoElement(const Element &e
return 0; return 0;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline bool RTPHashTable<Element,GetIndex,hashsize>::HasElement(const Element &e) inline bool RTPHashTable<Element,GetIndex,hashsize>::HasElement(const Element &e)
{ {
int index; int index;
bool found; bool found;
HashElement *tmp; HashElement *tmp;
index = GetIndex(e); index = GetIndex::GetIndex(e);
if (index >= hashsize) if (index >= hashsize)
return false; return false;
@ -199,21 +200,21 @@ inline bool RTPHashTable<Element,GetIndex,hashsize>::HasElement(const Element &e
return found; return found;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline void RTPHashTable<Element,GetIndex,hashsize>::GotoNextElement() inline void RTPHashTable<Element,GetIndex,hashsize>::GotoNextElement()
{ {
if (curhashelem) if (curhashelem)
curhashelem = curhashelem->listnext; curhashelem = curhashelem->listnext;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline void RTPHashTable<Element,GetIndex,hashsize>::GotoPreviousElement() inline void RTPHashTable<Element,GetIndex,hashsize>::GotoPreviousElement()
{ {
if (curhashelem) if (curhashelem)
curhashelem = curhashelem->listprev; curhashelem = curhashelem->listprev;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline void RTPHashTable<Element,GetIndex,hashsize>::Clear() inline void RTPHashTable<Element,GetIndex,hashsize>::Clear()
{ {
HashElement *tmp1,*tmp2; HashElement *tmp1,*tmp2;
@ -232,14 +233,14 @@ inline void RTPHashTable<Element,GetIndex,hashsize>::Clear()
lasthashelem = 0; lasthashelem = 0;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline int RTPHashTable<Element,GetIndex,hashsize>::AddElement(const Element &elem) inline int RTPHashTable<Element,GetIndex,hashsize>::AddElement(const Element &elem)
{ {
int index; int index;
bool found; bool found;
HashElement *e,*newelem; HashElement *e,*newelem;
index = GetIndex(elem); index = GetIndex::GetIndex(elem);
if (index >= hashsize) if (index >= hashsize)
return ERR_RTP_HASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX; return ERR_RTP_HASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX;
@ -283,7 +284,7 @@ inline int RTPHashTable<Element,GetIndex,hashsize>::AddElement(const Element &el
return 0; return 0;
} }
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteElement(const Element &elem) inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteElement(const Element &elem)
{ {
int status; int status;
@ -295,7 +296,7 @@ inline int RTPHashTable<Element,GetIndex,hashsize>::DeleteElement(const Element
} }
#ifdef RTPDEBUG #ifdef RTPDEBUG
template<class Element,int GetIndex(const Element &e),int hashsize> template<class Element,class GetIndex,int hashsize>
inline void RTPHashTable<Element,GetIndex,hashsize>::Dump() inline void RTPHashTable<Element,GetIndex,hashsize>::Dump()
{ {
HashElement *e; HashElement *e;

View File

@ -171,13 +171,13 @@ int RTPInternalSourceData::ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &re
return 0; return 0;
} }
int RTPInternalSourceData::ProcessSDESItem(uint8_t id,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis) int RTPInternalSourceData::ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis)
{ {
*cnamecollis = false; *cnamecollis = false;
stats.SetLastMessageTime(receivetime); stats.SetLastMessageTime(receivetime);
switch(id) switch(sdesid)
{ {
case RTCP_SDES_ID_CNAME: case RTCP_SDES_ID_CNAME:
{ {

View File

@ -53,7 +53,7 @@ public:
uint32_t jitter,uint32_t lsr,uint32_t dlsr, uint32_t jitter,uint32_t lsr,uint32_t dlsr,
const RTPTime &receivetime) { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); } const RTPTime &receivetime) { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); }
void UpdateMessageTime(const RTPTime &receivetime) { stats.SetLastMessageTime(receivetime); } void UpdateMessageTime(const RTPTime &receivetime) { stats.SetLastMessageTime(receivetime); }
int ProcessSDESItem(uint8_t id,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis); int ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis);
#ifdef RTP_SUPPORT_SDESPRIV #ifdef RTP_SUPPORT_SDESPRIV
int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime); int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime);
#endif // RTP_SUPPORT_SDESPRIV #endif // RTP_SUPPORT_SDESPRIV

View File

@ -32,6 +32,7 @@
#include "rtpipv4address.h" #include "rtpipv4address.h"
#ifdef RTPDEBUG #ifdef RTPDEBUG
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#endif // RTPDEBUG #endif // RTPDEBUG
@ -74,7 +75,7 @@ std::string RTPIPv4Address::GetAddressString() const
{ {
char str[24]; char str[24];
snprintf(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF), RTP_SNPRINTF(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),
(int)(ip&0xFF),(int)port); (int)(ip&0xFF),(int)port);
return std::string(str); return std::string(str);
} }

View File

@ -39,6 +39,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif // WIN32 #endif // WIN32
#ifdef RTPDEBUG #ifdef RTPDEBUG
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#endif // RTPDEBUG #endif // RTPDEBUG
@ -71,7 +72,7 @@ inline std::string RTPIPv4Destination::GetDestinationString() const
uint32_t ip = ipaddr_hbo; uint32_t ip = ipaddr_hbo;
uint16_t portbase = ntohs(rtpport_nbo); uint16_t portbase = ntohs(rtpport_nbo);
snprintf(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF),(int)(portbase)); RTP_SNPRINTF(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF),(int)(portbase));
return std::string(str); return std::string(str);
} }
#endif // RTPDEBUG #endif // RTPDEBUG

View File

@ -35,6 +35,7 @@
#ifdef RTP_SUPPORT_IPV6 #ifdef RTP_SUPPORT_IPV6
#ifdef RTPDEBUG #ifdef RTPDEBUG
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#endif // RTPDEBUG #endif // RTPDEBUG
@ -97,7 +98,7 @@ std::string RTPIPv6Address::GetAddressString() const
ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]);
} }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)port); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)port);
return std::string(str); return std::string(str);
} }
#endif // RTPDEBUG #endif // RTPDEBUG

View File

@ -44,6 +44,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif // WIN32 #endif // WIN32
#ifdef RTPDEBUG #ifdef RTPDEBUG
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#endif // RTPDEBUG #endif // RTPDEBUG
@ -72,7 +73,7 @@ inline std::string RTPIPv6Destination::GetDestinationString() const
uint16_t portbase = ntohs(rtpport_nbo); uint16_t portbase = ntohs(rtpport_nbo);
int i,j; int i,j;
for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); } for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)portbase); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)portbase);
return std::string(str); return std::string(str);
} }
#endif // RTPDEBUG #endif // RTPDEBUG

View File

@ -41,7 +41,7 @@
#include <iostream> #include <iostream>
#endif // RTPDEBUG #endif // RTPDEBUG
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
class RTPKeyHashTable class RTPKeyHashTable
{ {
public: public:
@ -91,7 +91,7 @@ private:
HashElement *curhashelem; HashElement *curhashelem;
}; };
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline RTPKeyHashTable<Key,Element,GetIndex,hashsize>::RTPKeyHashTable() inline RTPKeyHashTable<Key,Element,GetIndex,hashsize>::RTPKeyHashTable()
{ {
for (int i = 0 ; i < hashsize ; i++) for (int i = 0 ; i < hashsize ; i++)
@ -100,7 +100,7 @@ inline RTPKeyHashTable<Key,Element,GetIndex,hashsize>::RTPKeyHashTable()
lasthashelem = 0; lasthashelem = 0;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteCurrentElement() inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteCurrentElement()
{ {
if (curhashelem) if (curhashelem)
@ -156,13 +156,13 @@ inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteCurrentElement(
return 0; return 0;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoElement(const Key &k) inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoElement(const Key &k)
{ {
int index; int index;
bool found; bool found;
index = GetIndex(k); index = GetIndex::GetIndex(k);
if (index >= hashsize) if (index >= hashsize)
return ERR_RTP_KEYHASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX; return ERR_RTP_KEYHASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX;
@ -180,14 +180,14 @@ inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoElement(const Key
return 0; return 0;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline bool RTPKeyHashTable<Key,Element,GetIndex,hashsize>::HasElement(const Key &k) inline bool RTPKeyHashTable<Key,Element,GetIndex,hashsize>::HasElement(const Key &k)
{ {
int index; int index;
bool found; bool found;
HashElement *tmp; HashElement *tmp;
index = GetIndex(k); index = GetIndex::GetIndex(k);
if (index >= hashsize) if (index >= hashsize)
return false; return false;
@ -203,21 +203,21 @@ inline bool RTPKeyHashTable<Key,Element,GetIndex,hashsize>::HasElement(const Key
return found; return found;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoNextElement() inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoNextElement()
{ {
if (curhashelem) if (curhashelem)
curhashelem = curhashelem->listnext; curhashelem = curhashelem->listnext;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoPreviousElement() inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::GotoPreviousElement()
{ {
if (curhashelem) if (curhashelem)
curhashelem = curhashelem->listprev; curhashelem = curhashelem->listprev;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::Clear() inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::Clear()
{ {
HashElement *tmp1,*tmp2; HashElement *tmp1,*tmp2;
@ -236,14 +236,14 @@ inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::Clear()
lasthashelem = 0; lasthashelem = 0;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::AddElement(const Key &k,const Element &elem) inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::AddElement(const Key &k,const Element &elem)
{ {
int index; int index;
bool found; bool found;
HashElement *e,*newelem; HashElement *e,*newelem;
index = GetIndex(k); index = GetIndex::GetIndex(k);
if (index >= hashsize) if (index >= hashsize)
return ERR_RTP_KEYHASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX; return ERR_RTP_KEYHASHTABLE_FUNCTIONRETURNEDINVALIDHASHINDEX;
@ -287,7 +287,7 @@ inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::AddElement(const Key
return 0; return 0;
} }
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteElement(const Key &k) inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteElement(const Key &k)
{ {
int status; int status;
@ -299,7 +299,7 @@ inline int RTPKeyHashTable<Key,Element,GetIndex,hashsize>::DeleteElement(const K
} }
#ifdef RTPDEBUG #ifdef RTPDEBUG
template<class Key,class Element,int GetIndex(const Key &k),int hashsize> template<class Key,class Element,class GetIndex,int hashsize>
inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::Dump() inline void RTPKeyHashTable<Key,Element,GetIndex,hashsize>::Dump()
{ {
HashElement *e; HashElement *e;

View File

@ -31,9 +31,20 @@
*/ */
#include "rtplibraryversion.h" #include "rtplibraryversion.h"
#include "rtpdefines.h"
RTPLibraryVersion RTPLibraryVersion::GetVersion() RTPLibraryVersion RTPLibraryVersion::GetVersion()
{ {
return RTPLibraryVersion(3,4,0); return RTPLibraryVersion(3,5,2);
} }
std::string RTPLibraryVersion::GetVersionString() const
{
char str[16];
RTP_SNPRINTF(str,16,"%d.%d.%d",majornr,minornr,debugnr);
return std::string(str);
}

View File

@ -52,17 +52,5 @@ private:
int debugnr,minornr,majornr; int debugnr,minornr,majornr;
}; };
inline std::string RTPLibraryVersion::GetVersionString() const
{
char str[16];
#if (defined(WIN32) || defined(_WIN32_WCE))
_snprintf(str,16,"%d.%d.%d",majornr,minornr,debugnr);
#else
snprintf(str,16,"%d.%d.%d",majornr,minornr,debugnr);
#endif // WIN32 || _WIN32_WCE
return std::string(str);
}
#endif // RTPLIBRARYVERSION_H #endif // RTPLIBRARYVERSION_H

View File

@ -175,7 +175,7 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
RTPPacket::hasextension = hasextension; RTPPacket::hasextension = hasextension;
if (hasextension) if (hasextension)
{ {
RTPPacket::extid = ntohs(rtpextheader->id); RTPPacket::extid = ntohs(rtpextheader->extid);
RTPPacket::extensionlength = ((int)ntohs(rtpextheader->length))*sizeof(uint32_t); RTPPacket::extensionlength = ((int)ntohs(rtpextheader->length))*sizeof(uint32_t);
RTPPacket::extension = ((uint8_t *)rtpextheader)+sizeof(RTPExtensionHeader); RTPPacket::extension = ((uint8_t *)rtpextheader)+sizeof(RTPExtensionHeader);
} }
@ -305,7 +305,7 @@ int RTPPacket::BuildPacket(uint8_t payloadtype,const void *payloaddata,size_t pa
{ {
RTPExtensionHeader *rtpexthdr = (RTPExtensionHeader *)payload; RTPExtensionHeader *rtpexthdr = (RTPExtensionHeader *)payload;
rtpexthdr->id = htons(extensionid); rtpexthdr->extid = htons(extensionid);
rtpexthdr->length = htons((uint16_t)extensionlen_numwords); rtpexthdr->length = htons((uint16_t)extensionlen_numwords);
payload += sizeof(RTPExtensionHeader); payload += sizeof(RTPExtensionHeader);

View File

@ -30,6 +30,10 @@
*/ */
#if defined(WIN32) && !defined(_WIN32_WCE)
#define _CRT_RAND_S
#endif // WIN32 || _WIN32_WCE
#include "rtprandom.h" #include "rtprandom.h"
#include <time.h> #include <time.h>
#ifndef WIN32 #ifndef WIN32
@ -46,30 +50,29 @@
#include "rtpdebug.h" #include "rtpdebug.h"
#if !defined(RTP_SUPPORT_GNUDRAND) && !defined(RTP_SUPPORT_RANDR) #if (!defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >= 1400 )
bool RTPRandom::init = false; #define RTP_SUPPORT_RANDS
#endif // WIN32 #endif
RTPRandom::RTPRandom() RTPRandom::RTPRandom()
{ {
#ifndef RTP_SUPPORT_RANDS
#if defined(RTP_SUPPORT_GNUDRAND) || defined(RTP_SUPPORT_RANDR) #if defined(RTP_SUPPORT_GNUDRAND) || defined(RTP_SUPPORT_RANDR)
uint32_t x; uint32_t x;
x = (uint32_t)getpid(); x = (uint32_t)getpid();
x += (uint32_t)time(0); x += (uint32_t)time(0);
x -= (uint32_t)clock(); x -= (uint32_t)clock();
x ^= (uint32_t)(this); x ^= (uint32_t)((uint8_t *)this - (uint8_t *)0);
#ifdef RTP_SUPPORT_GNUDRAND #ifdef RTP_SUPPORT_GNUDRAND
srand48_r(x,&drandbuffer); srand48_r(x,&drandbuffer);
#else #else
state = (unsigned int)x; state = (unsigned int)x;
#endif #endif // RTP_SUPPORT_GNUDRAND
#else // use simple rand and srand functions #else // use simple rand and srand functions
if (init)
return;
uint32_t x; uint32_t x;
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
@ -87,18 +90,20 @@ RTPRandom::RTPRandom()
x += ft.dwLowDateTime; x += ft.dwLowDateTime;
#endif // _WIN32_WCE #endif // _WIN32_WCE
x ^= (uint32_t)(this); x ^= (uint32_t)((uint8_t *)this - (uint8_t *)0);
srand((unsigned int)x); srand((unsigned int)x);
#endif // RTP_SUPPORT_GNUDRAND || RTP_SUPPORT_RANDR
init = true; #endif // RTP_SUPPORT_RANDS
#endif
// Note: the rand_s function does not require initialization of a seed
} }
RTPRandom::~RTPRandom() RTPRandom::~RTPRandom()
{ {
} }
#ifdef RTP_SUPPORT_GNUDRAND #if defined(RTP_SUPPORT_GNUDRAND)
uint8_t RTPRandom::GetRandom8() uint8_t RTPRandom::GetRandom8()
{ {
@ -131,8 +136,7 @@ double RTPRandom::GetRandomDouble()
return x; return x;
} }
#else #elif defined(RTP_SUPPORT_RANDR)
#ifdef RTP_SUPPORT_RANDR
uint8_t RTPRandom::GetRandom8() uint8_t RTPRandom::GetRandom8()
{ {
@ -170,7 +174,56 @@ double RTPRandom::GetRandomDouble()
return x; return x;
} }
#else #elif defined(RTP_SUPPORT_RANDS)
uint8_t RTPRandom::GetRandom8()
{
uint8_t x;
unsigned int r;
rand_s(&r);
x = (uint8_t)(256.0*((double)r)/((double)UINT_MAX+1.0));
return x;
}
uint16_t RTPRandom::GetRandom16()
{
uint16_t x;
unsigned int r;
rand_s(&r);
x = (uint16_t)(65536.0*((double)r)/((double)UINT_MAX+1.0));
return x;
}
uint32_t RTPRandom::GetRandom32()
{
uint32_t x,y;
unsigned int r;
rand_s(&r);
x = (uint32_t)(65536.0*((double)r)/((double)UINT_MAX+1.0));
y = x;
rand_s(&r);
x = (uint32_t)(65536.0*((double)r)/((double)UINT_MAX+1.0));
y ^= (x<<8);
rand_s(&r);
x = (uint32_t)(65536.0*((double)r)/((double)UINT_MAX+1.0));
y ^= (x<<16);
return y;
}
double RTPRandom::GetRandomDouble()
{
unsigned int r;
rand_s(&r);
double x = ((double)r)/((double)UINT_MAX+1.0);
return x;
}
#else // use rand()
uint8_t RTPRandom::GetRandom8() uint8_t RTPRandom::GetRandom8()
{ {
@ -208,6 +261,5 @@ double RTPRandom::GetRandomDouble()
return x; return x;
} }
#endif // RTP_SUPPORT_RANDR
#endif // RTP_SUPPORT_GNUDRAND #endif // RTP_SUPPORT_GNUDRAND

View File

@ -48,15 +48,12 @@ public:
uint32_t GetRandom32(); uint32_t GetRandom32();
double GetRandomDouble(); // returns random value between 0.0 and 1.0 double GetRandomDouble(); // returns random value between 0.0 and 1.0
private: private:
#ifdef RTP_SUPPORT_GNUDRAND #if defined(RTP_SUPPORT_GNUDRAND)
struct drand48_data drandbuffer; struct drand48_data drandbuffer;
#else #elif defined(RTP_SUPPORT_RANDR)
#ifdef RTP_SUPPORT_RANDR
unsigned int state; unsigned int state;
#else
static bool init;
#endif // RTP_SUPPORT_RANDR
#endif // RTP_SUPPORT_GNUDRAND #endif // RTP_SUPPORT_GNUDRAND
}; };
#endif // RTPRANDOM_H #endif // RTPRANDOM_H

View File

@ -380,6 +380,9 @@ void RTPSession::BYEDestroy(const RTPTime &maxwaittime,const void *reason,size_t
byepackets.pop_front(); byepackets.pop_front();
rtptrans->SendRTCPData(pack->GetCompoundPacketData(),pack->GetCompoundPacketLength()); rtptrans->SendRTCPData(pack->GetCompoundPacketData(),pack->GetCompoundPacketLength());
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
delete pack; delete pack;
if (!byepackets.empty()) // more bye packets to send, schedule them if (!byepackets.empty()) // more bye packets to send, schedule them
rtcpsched.ScheduleBYEPacket((*(byepackets.begin()))->GetCompoundPacketLength()); rtcpsched.ScheduleBYEPacket((*(byepackets.begin()))->GetCompoundPacketLength());
@ -1178,6 +1181,8 @@ int RTPSession::ProcessPolledData()
delete pack; delete pack;
return status; return status;
} }
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
} }
else else
{ {
@ -1191,6 +1196,8 @@ int RTPSession::ProcessPolledData()
return status; return status;
} }
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
if (!byepackets.empty()) // more bye packets to send, schedule them if (!byepackets.empty()) // more bye packets to send, schedule them
{ {
SCHED_LOCK SCHED_LOCK
@ -1250,9 +1257,14 @@ int RTPSession::CreateCNAME(uint8_t *buffer,size_t *bufferlength,bool resolve)
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
DWORD len = *bufferlength; DWORD len = *bufferlength;
if (!GetUserName((LPTSTR)buffer,&len)) if (!GetUserName((LPTSTR)buffer,&len))
strcpy((char *)buffer,"unknown"); #if (defined(_MSC_VER) && _MSC_VER >= 1400 ) // Check if we can use the secure strncpy_s
strncpy_s((char *)buffer,*bufferlength,"unknown",_TRUNCATE);
#else #else
strcpy((char *)buffer,"unknown"); strncpy((char *)buffer,"unknown",*bufferlength);
#endif // Less secure version
#else
strncpy((char *)buffer,"unknown",*bufferlength);
#endif // _WIN32_WCE #endif // _WIN32_WCE
#endif // WIN32 #endif // WIN32
@ -1276,9 +1288,17 @@ int RTPSession::CreateCNAME(uint8_t *buffer,size_t *bufferlength,bool resolve)
{ {
char hostname[1024]; char hostname[1024];
strcpy(hostname,"localhost"); // just in case gethostname fails #if defined(WIN32) && !defined(_WIN32_WCE) && (defined(_MSC_VER) && _MSC_VER >= 1400 ) // Check if we can use the secure strncpy_s
strncpy_s(hostname,1024,"localhost",_TRUNCATE); // just in case gethostname fails
#else
strncpy(hostname,"localhost",1024); // just in case gethostname fails
#endif
gethostname(hostname,1024); gethostname(hostname,1024);
#if defined(WIN32) && !defined(_WIN32_WCE) && (defined(_MSC_VER) && _MSC_VER >= 1400 ) // Check if we can use the secure strncpy_s
strncpy_s((char *)(buffer+offset),buflen2,hostname,_TRUNCATE);
#else
strncpy((char *)(buffer+offset),hostname,buflen2); strncpy((char *)(buffer+offset),hostname,buflen2);
#endif
*bufferlength = offset+strlen(hostname); *bufferlength = offset+strlen(hostname);
} }
if (*bufferlength > RTCP_SDES_MAXITEMLENGTH) if (*bufferlength > RTCP_SDES_MAXITEMLENGTH)

View File

@ -173,8 +173,7 @@ protected:
virtual void OnInvalidRawPacketType(RTPRawPacket *rawpacket, jrtp_socket_t socket) { } virtual void OnInvalidRawPacketType(RTPRawPacket *rawpacket, jrtp_socket_t socket) { }
virtual void OnNoteTimeout(RTPSourceData *srcdat) { } virtual void OnNoteTimeout(RTPSourceData *srcdat) { }
virtual void OnBYEPacket(RTPSourceData *srcdat) { } virtual void OnBYEPacket(RTPSourceData *srcdat) { }
virtual void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack) { }
#ifdef RTP_SUPPORT_THREAD #ifdef RTP_SUPPORT_THREAD
virtual void OnPollThreadError(int errcode) { } virtual void OnPollThreadError(int errcode) { }
virtual void OnPollThreadStep() { } virtual void OnPollThreadStep() { }
@ -214,6 +213,7 @@ private:
friend class RTPPollThread; friend class RTPPollThread;
#endif // RTP_SUPPORT_THREAD #endif // RTP_SUPPORT_THREAD
friend class RTPSessionSources; friend class RTPSessionSources;
friend class RTCPSessionPacketBuilder;
}; };
#endif // RTPSESSION_H #endif // RTPSESSION_H

View File

@ -90,7 +90,7 @@ public:
private: private:
bool acceptown; bool acceptown;
bool usepollthread; bool usepollthread;
int maxpacksize; size_t maxpacksize;
double owntsunit; double owntsunit;
RTPTransmitter::ReceiveMode receivemode; RTPTransmitter::ReceiveMode receivemode;
bool resolvehostname; bool resolvehostname;

View File

@ -51,10 +51,6 @@
#include "rtpdebug.h" #include "rtpdebug.h"
#ifndef RTP_SUPPORT_INLINETEMPLATEPARAM
int RTPSources_GetHashIndex(const uint32_t &ssrc) { return ssrc%RTPSOURCES_HASHSIZE; }
#endif // !RTP_SUPPORT_INLINETEMPLATEPARAM
RTPSources::RTPSources(ProbationType probtype) RTPSources::RTPSources(ProbationType probtype)
{ {
totalcount = 0; totalcount = 0;
@ -693,31 +689,31 @@ int RTPSources::ProcessSDESNormalItem(uint32_t ssrc,RTCPSDESPacket::ItemType t,s
RTPInternalSourceData *srcdat; RTPInternalSourceData *srcdat;
bool created,cnamecollis; bool created,cnamecollis;
int status; int status;
uint8_t id; uint8_t sdesid;
bool prevactive; bool prevactive;
switch(t) switch(t)
{ {
case RTCPSDESPacket::CNAME: case RTCPSDESPacket::CNAME:
id = RTCP_SDES_ID_CNAME; sdesid = RTCP_SDES_ID_CNAME;
break; break;
case RTCPSDESPacket::NAME: case RTCPSDESPacket::NAME:
id = RTCP_SDES_ID_NAME; sdesid = RTCP_SDES_ID_NAME;
break; break;
case RTCPSDESPacket::EMAIL: case RTCPSDESPacket::EMAIL:
id = RTCP_SDES_ID_EMAIL; sdesid = RTCP_SDES_ID_EMAIL;
break; break;
case RTCPSDESPacket::PHONE: case RTCPSDESPacket::PHONE:
id = RTCP_SDES_ID_PHONE; sdesid = RTCP_SDES_ID_PHONE;
break; break;
case RTCPSDESPacket::LOC: case RTCPSDESPacket::LOC:
id = RTCP_SDES_ID_LOCATION; sdesid = RTCP_SDES_ID_LOCATION;
break; break;
case RTCPSDESPacket::TOOL: case RTCPSDESPacket::TOOL:
id = RTCP_SDES_ID_TOOL; sdesid = RTCP_SDES_ID_TOOL;
break; break;
case RTCPSDESPacket::NOTE: case RTCPSDESPacket::NOTE:
id = RTCP_SDES_ID_NOTE; sdesid = RTCP_SDES_ID_NOTE;
break; break;
default: default:
return ERR_RTP_SOURCES_ILLEGALSDESTYPE; return ERR_RTP_SOURCES_ILLEGALSDESTYPE;
@ -730,7 +726,7 @@ int RTPSources::ProcessSDESNormalItem(uint32_t ssrc,RTCPSDESPacket::ItemType t,s
return 0; return 0;
prevactive = srcdat->IsActive(); prevactive = srcdat->IsActive();
status = srcdat->ProcessSDESItem(id,(const uint8_t *)itemdata,itemlength,receivetime,&cnamecollis); status = srcdat->ProcessSDESItem(sdesid,(const uint8_t *)itemdata,itemlength,receivetime,&cnamecollis);
if (!prevactive && srcdat->IsActive()) if (!prevactive && srcdat->IsActive())
activecount++; activecount++;
@ -1233,6 +1229,7 @@ void RTPSources::MultipleTimeouts(const RTPTime &curtime,const RTPTime &senderti
OnBYETimeout(srcdat); OnBYETimeout(srcdat);
if (normaltimeout) if (normaltimeout)
OnTimeout(srcdat); OnTimeout(srcdat);
OnRemoveSource(srcdat);
delete srcdat; delete srcdat;
} }
} }

View File

@ -41,11 +41,11 @@
#define RTPSOURCES_HASHSIZE 8317 #define RTPSOURCES_HASHSIZE 8317
#ifdef RTP_SUPPORT_INLINETEMPLATEPARAM class RTPSources_GetHashIndex
inline int RTPSources_GetHashIndex(const uint32_t &ssrc) { return ssrc%RTPSOURCES_HASHSIZE; } {
#else // can't use inline function as template parameter public:
int RTPSources_GetHashIndex(const uint32_t &ssrc); static int GetIndex(const uint32_t &ssrc) { return ssrc%RTPSOURCES_HASHSIZE; }
#endif // RTP_SUPPORT_INLINETEMPLATEPARAM };
class RTPNTPTime; class RTPNTPTime;
class RTPTransmitter; class RTPTransmitter;

View File

@ -64,7 +64,7 @@ struct RTPHeader
struct RTPExtensionHeader struct RTPExtensionHeader
{ {
uint16_t id; uint16_t extid;
uint16_t length; uint16_t length;
}; };
@ -111,7 +111,7 @@ struct RTCPReceiverReport
struct RTCPSDESHeader struct RTCPSDESHeader
{ {
uint8_t id; uint8_t sdesid;
uint8_t length; uint8_t length;
}; };

View File

@ -34,6 +34,7 @@
#include "rtprawpacket.h" #include "rtprawpacket.h"
#include "rtpipv4address.h" #include "rtpipv4address.h"
#include "rtptimeutilities.h" #include "rtptimeutilities.h"
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#if (defined(WIN32) || defined(_WIN32_WCE)) #if (defined(WIN32) || defined(_WIN32_WCE))
#define RTPSOCKERR INVALID_SOCKET #define RTPSOCKERR INVALID_SOCKET
@ -104,11 +105,6 @@
mreq.imr_interface.s_addr = htonl(mcastifaceIP);\ mreq.imr_interface.s_addr = htonl(mcastifaceIP);\
status = setsockopt(socket,IPPROTO_IP,type,(const char *)&mreq,sizeof(struct ip_mreq));\ status = setsockopt(socket,IPPROTO_IP,type,(const char *)&mreq,sizeof(struct ip_mreq));\
} }
#ifndef RTP_SUPPORT_INLINETEMPLATEPARAM
int RTPUDPv4Trans_GetHashIndex_IPv4Dest(const RTPIPv4Destination &d) { return d.GetIP_HBO()%RTPUDPV4TRANS_HASHSIZE; }
int RTPUDPv4Trans_GetHashIndex_uint32_t(const uint32_t &k) { return k%RTPUDPV4TRANS_HASHSIZE; }
#endif // !RTP_SUPPORT_INLINETEMPLATEPARAM
#ifdef RTP_SUPPORT_THREAD #ifdef RTP_SUPPORT_THREAD
#define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); }
#define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); }
@ -512,11 +508,7 @@ int RTPUDPv4Transmitter::GetLocalHostName(uint8_t *buffer,size_t *bufferlength)
it = localIPs.begin(); it = localIPs.begin();
ip = (*it); ip = (*it);
#if (defined(WIN32) || defined(_WIN32_WCE)) RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
_snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
#else
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
#endif // WIN32 || _WIN32_WCE
len = strlen(str); len = strlen(str);
localhostnamelength = len; localhostnamelength = len;
@ -1360,7 +1352,7 @@ int RTPUDPv4Transmitter::PollSocket(bool rtp)
{ {
RTPTime curtime = RTPTime::CurrentTime(); RTPTime curtime = RTPTime::CurrentTime();
fromlen = sizeof(struct sockaddr_in); fromlen = sizeof(struct sockaddr_in);
recvlen = recvfrom(sock,packetbuffer,(int)len,0,(struct sockaddr *)&srcaddr,&fromlen); recvlen = recvfrom(sock,packetbuffer,RTPUDPV4TRANS_MAXPACKSIZE,0,(struct sockaddr *)&srcaddr,&fromlen);
if (recvlen > 0) if (recvlen > 0)
{ {
bool acceptdata; bool acceptdata;
@ -1918,16 +1910,16 @@ void RTPUDPv4Transmitter::Dump()
std::cout << "RTP socket descriptor: " << rtpsock << std::endl; std::cout << "RTP socket descriptor: " << rtpsock << std::endl;
std::cout << "RTCP socket descriptor: " << rtcpsock << std::endl; std::cout << "RTCP socket descriptor: " << rtcpsock << std::endl;
ip = bindIP; ip = bindIP;
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF)); RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
std::cout << "Bind IP address: " << str << std::endl; std::cout << "Bind IP address: " << str << std::endl;
ip = mcastifaceIP; ip = mcastifaceIP;
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF)); RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
std::cout << "Multicast interface IP address: " << str << std::endl; std::cout << "Multicast interface IP address: " << str << std::endl;
std::cout << "Local IP addresses:" << std::endl; std::cout << "Local IP addresses:" << std::endl;
for (it = localIPs.begin() ; it != localIPs.end() ; it++) for (it = localIPs.begin() ; it != localIPs.end() ; it++)
{ {
ip = (*it); ip = (*it);
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF)); RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
std::cout << " " << str << std::endl; std::cout << " " << str << std::endl;
} }
std::cout << "Multicast TTL: " << (int)multicastTTL << std::endl; std::cout << "Multicast TTL: " << (int)multicastTTL << std::endl;
@ -1950,7 +1942,7 @@ void RTPUDPv4Transmitter::Dump()
while(acceptignoreinfo.HasCurrentElement()) while(acceptignoreinfo.HasCurrentElement())
{ {
ip = acceptignoreinfo.GetCurrentKey(); ip = acceptignoreinfo.GetCurrentKey();
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF)); RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
PortInfo *pinfo = acceptignoreinfo.GetCurrentElement(); PortInfo *pinfo = acceptignoreinfo.GetCurrentElement();
std::cout << " " << str << ": "; std::cout << " " << str << ": ";
if (pinfo->all) if (pinfo->all)
@ -2004,7 +1996,7 @@ void RTPUDPv4Transmitter::Dump()
do do
{ {
ip = multicastgroups.GetCurrentElement(); ip = multicastgroups.GetCurrentElement();
snprintf(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF)); RTP_SNPRINTF(str,16,"%d.%d.%d.%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF));
std::cout << " " << str << std::endl; std::cout << " " << str << std::endl;
multicastgroups.GotoNextElement(); multicastgroups.GotoNextElement();
} while (multicastgroups.HasCurrentElement()); } while (multicastgroups.HasCurrentElement());

View File

@ -85,13 +85,17 @@ private:
jrtp_socket_t rtpsocket,rtcpsocket; jrtp_socket_t rtpsocket,rtcpsocket;
}; };
#ifdef RTP_SUPPORT_INLINETEMPLATEPARAM class RTPUDPv4Trans_GetHashIndex_IPv4Dest
inline int RTPUDPv4Trans_GetHashIndex_IPv4Dest(const RTPIPv4Destination &d) { return d.GetIP_HBO()%RTPUDPV4TRANS_HASHSIZE; } {
inline int RTPUDPv4Trans_GetHashIndex_uint32_t(const uint32_t &k) { return k%RTPUDPV4TRANS_HASHSIZE; } public:
#else // No support for inline function as template parameter static int GetIndex(const RTPIPv4Destination &d) { return d.GetIP_HBO()%RTPUDPV4TRANS_HASHSIZE; }
int RTPUDPv4Trans_GetHashIndex_IPv4Dest(const RTPIPv4Destination &d); };
int RTPUDPv4Trans_GetHashIndex_uint32_t(const uint32_t &k);
#endif // RTP_SUPPORT_INLINETEMPLATEPARAM class RTPUDPv4Trans_GetHashIndex_uint32_t
{
public:
static int GetIndex(const uint32_t &k) { return k%RTPUDPV4TRANS_HASHSIZE; }
};
#define RTPUDPV4TRANS_HEADERSIZE (20+8) #define RTPUDPV4TRANS_HEADERSIZE (20+8)

View File

@ -37,6 +37,7 @@
#include "rtprawpacket.h" #include "rtprawpacket.h"
#include "rtpipv6address.h" #include "rtpipv6address.h"
#include "rtptimeutilities.h" #include "rtptimeutilities.h"
#include "rtpdefines.h"
#include <stdio.h> #include <stdio.h>
#if (defined(WIN32) || defined(_WIN32_WCE)) #if (defined(WIN32) || defined(_WIN32_WCE))
#define RTPSOCKERR INVALID_SOCKET #define RTPSOCKERR INVALID_SOCKET
@ -103,11 +104,6 @@
mreq.ipv6mr_interface = mcastifidx;\ mreq.ipv6mr_interface = mcastifidx;\
status = setsockopt(socket,IPPROTO_IPV6,type,(const char *)&mreq,sizeof(struct ipv6_mreq));\ status = setsockopt(socket,IPPROTO_IPV6,type,(const char *)&mreq,sizeof(struct ipv6_mreq));\
} }
#ifndef RTP_SUPPORT_INLINETEMPLATEPARAM
int RTPUDPv6Trans_GetHashIndex_IPv6Dest(const RTPIPv6Destination &d) { in6_addr ip = d.GetIP(); return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; }
int RTPUDPv6Trans_GetHashIndex_in6_addr(const in6_addr &ip) { return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; }
#endif // !RTP_SUPPORT_INLINETEMPLATEPARAM
#ifdef RTP_SUPPORT_THREAD #ifdef RTP_SUPPORT_THREAD
#define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); }
#define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); }
@ -522,11 +518,7 @@ int RTPUDPv6Transmitter::GetLocalHostName(uint8_t *buffer,size_t *bufferlength)
ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]);
} }
#if (defined(WIN32) || defined(_WIN32_WCE)) RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
_snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
#else
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
#endif // WIN32 || _WIN32_WCE
len = strlen(str); len = strlen(str);
localhostnamelength = len; localhostnamelength = len;
@ -1373,7 +1365,7 @@ int RTPUDPv6Transmitter::PollSocket(bool rtp)
{ {
RTPTime curtime = RTPTime::CurrentTime(); RTPTime curtime = RTPTime::CurrentTime();
fromlen = sizeof(struct sockaddr_in6); fromlen = sizeof(struct sockaddr_in6);
recvlen = recvfrom(sock,packetbuffer,(int)len,0,(struct sockaddr *)&srcaddr,&fromlen); recvlen = recvfrom(sock,packetbuffer,RTPUDPV6TRANS_MAXPACKSIZE,0,(struct sockaddr *)&srcaddr,&fromlen);
if (recvlen > 0) if (recvlen > 0)
{ {
bool acceptdata; bool acceptdata;
@ -1874,7 +1866,7 @@ void RTPUDPv6Transmitter::Dump()
std::cout << "RTCP socket descriptor: " << rtcpsock << std::endl; std::cout << "RTCP socket descriptor: " << rtcpsock << std::endl;
ip = bindIP; ip = bindIP;
for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); } for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
std::cout << "Bind IP address: " << str << std::endl; std::cout << "Bind IP address: " << str << std::endl;
std::Cout << "Multicast interface index: " << mcastifidx << std::endl; std::Cout << "Multicast interface index: " << mcastifidx << std::endl;
std::cout << "Local IP addresses:" << std::endl; std::cout << "Local IP addresses:" << std::endl;
@ -1882,7 +1874,7 @@ void RTPUDPv6Transmitter::Dump()
{ {
ip = (*it); ip = (*it);
for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); } for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
std::cout << " " << str << std::endl; std::cout << " " << str << std::endl;
} }
std::cout << "Multicast TTL: " << (int)multicastTTL << std::endl; std::cout << "Multicast TTL: " << (int)multicastTTL << std::endl;
@ -1906,7 +1898,7 @@ void RTPUDPv6Transmitter::Dump()
{ {
ip = acceptignoreinfo.GetCurrentKey(); ip = acceptignoreinfo.GetCurrentKey();
for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); } for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
PortInfo *pinfo = acceptignoreinfo.GetCurrentElement(); PortInfo *pinfo = acceptignoreinfo.GetCurrentElement();
std::cout << " " << str << ": "; std::cout << " " << str << ": ";
if (pinfo->all) if (pinfo->all)
@ -1961,7 +1953,7 @@ void RTPUDPv6Transmitter::Dump()
{ {
ip = multicastgroups.GetCurrentElement(); ip = multicastgroups.GetCurrentElement();
for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); } for (i = 0,j = 0 ; j < 8 ; j++,i += 2) { ip16[j] = (((uint16_t)ip.s6_addr[i])<<8); ip16[j] |= ((uint16_t)ip.s6_addr[i+1]); }
snprintf(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]); RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7]);
std::cout << " " << str << std::endl; std::cout << " " << str << std::endl;
multicastgroups.GotoNextElement(); multicastgroups.GotoNextElement();
} while (multicastgroups.HasCurrentElement()); } while (multicastgroups.HasCurrentElement());

View File

@ -93,13 +93,17 @@ private:
jrtp_socket_t rtpsocket,rtcpsocket; jrtp_socket_t rtpsocket,rtcpsocket;
}; };
#ifdef RTP_SUPPORT_INLINETEMPLATEPARAM class RTPUDPv6Trans_GetHashIndex_IPv6Dest
inline int RTPUDPv6Trans_GetHashIndex_IPv6Dest(const RTPIPv6Destination &d) { in6_addr ip = d.GetIP(); return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; } {
inline int RTPUDPv6Trans_GetHashIndex_in6_addr(const in6_addr &ip) { return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; } public:
#else // No support for inline function as template parameter static int GetIndex(const RTPIPv6Destination &d) { in6_addr ip = d.GetIP(); return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; }
int RTPUDPv6Trans_GetHashIndex_IPv6Dest(const RTPIPv6Destination &d); };
int RTPUDPv6Trans_GetHashIndex_in6_addr(const in6_addr &ip);
#endif // RTP_SUPPORT_INLINETEMPLATEPARAM class RTPUDPv6Trans_GetHashIndex_in6_addr
{
public:
static int GetIndex(const in6_addr &ip) { return ((((uint32_t)ip.s6_addr[12])<<24)|(((uint32_t)ip.s6_addr[13])<<16)|(((uint32_t)ip.s6_addr[14])<<8)|((uint32_t)ip.s6_addr[15]))%RTPUDPV6TRANS_HASHSIZE; }
};
#define RTPUDPV6TRANS_HEADERSIZE (40+8) #define RTPUDPV6TRANS_HEADERSIZE (40+8)

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -35,16 +35,24 @@ JMutex::JMutex()
JMutex::~JMutex() JMutex::~JMutex()
{ {
if (initialized) if (initialized)
#ifdef JMUTEX_CRITICALSECTION
DeleteCriticalSection(&mutex);
#else
CloseHandle(mutex); CloseHandle(mutex);
#endif // JMUTEX_CRITICALSECTION
} }
int JMutex::Init() int JMutex::Init()
{ {
if (initialized) if (initialized)
return ERR_JMUTEX_ALREADYINIT; return ERR_JMUTEX_ALREADYINIT;
#ifdef JMUTEX_CRITICALSECTION
InitializeCriticalSection(&mutex);
#else
mutex = CreateMutex(NULL,FALSE,NULL); mutex = CreateMutex(NULL,FALSE,NULL);
if (mutex == NULL) if (mutex == NULL)
return ERR_JMUTEX_CANTCREATEMUTEX; return ERR_JMUTEX_CANTCREATEMUTEX;
#endif // JMUTEX_CRITICALSECTION
initialized = true; initialized = true;
return 0; return 0;
} }
@ -53,7 +61,11 @@ int JMutex::Lock()
{ {
if (!initialized) if (!initialized)
return ERR_JMUTEX_NOTINIT; return ERR_JMUTEX_NOTINIT;
#ifdef JMUTEX_CRITICALSECTION
EnterCriticalSection(&mutex);
#else
WaitForSingleObject(mutex,INFINITE); WaitForSingleObject(mutex,INFINITE);
#endif // JMUTEX_CRITICALSECTION
return 0; return 0;
} }
@ -61,6 +73,11 @@ int JMutex::Unlock()
{ {
if (!initialized) if (!initialized)
return ERR_JMUTEX_NOTINIT; return ERR_JMUTEX_NOTINIT;
#ifdef JMUTEX_CRITICALSECTION
LeaveCriticalSection(&mutex);
#else
ReleaseMutex(mutex); ReleaseMutex(mutex);
#endif // JMUTEX_CRITICALSECTION
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
This file is a part of the JThread package, which contains some object- This file is a part of the JThread package, which contains some object-
oriented thread wrappers for different thread implementations. oriented thread wrappers for different thread implementations.
Copyright (c) 2000-2005 Jori Liesenborgs (jori@lumumba.uhasselt.be) Copyright (c) 2000-2006 Jori Liesenborgs (jori@lumumba.uhasselt.be)
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -90,6 +90,7 @@ int JThread::Start()
while (!running) while (!running)
{ {
runningmutex.Unlock(); runningmutex.Unlock();
Sleep(1);
runningmutex.Lock(); runningmutex.Lock();
} }
runningmutex.Unlock(); runningmutex.Unlock();