diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c212fa..3cd69fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ endif() project(jrtplib) set(VERSION_MAJOR 3) set(VERSION_MINOR 11) -set(VERSION_DEBUG 1) +set(VERSION_DEBUG 2) set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_DEBUG}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") @@ -87,6 +87,30 @@ else (SRTP_ENABLED) set(RTP_SUPPORT_SRTP "// No SRTP support") endif (SRTP_ENABLED) +find_package(LIBSRTP2) +if (LIBSRTP2_FOUND) + set(V "ON") +else (LIBSRTP2_FOUND) + set(V "OFF") +endif (LIBSRTP2_FOUND) + +option(SRTP2_ENABLED "Secure RTP 2 (SRTP2) support" ${V}) +if (SRTP2_ENABLED) + set(RTP_SUPPORT_SRTP2 "#define RTP_SUPPORT_SRTP2") + if (LIBSRTP2_FOUND) + save_paths(JRTPLIB_EXTERNAL_INCLUDES "${LIBSRTP2_INCLUDE_DIR}") + save_paths(JRTPLIB_LINK_LIBS "${LIBSRTP2_LIBRARY_DIR}") + endif (LIBSRTP2_FOUND) +else (SRTP2_ENABLED) + set(RTP_SUPPORT_SRTP2 "// No SRTP2 support") +endif (SRTP2_ENABLED) + +if (SRTP2_ENABLED) + if (SRTP_ENABLED) + message(FATAL_ERROR "Can't enable both SRTP and SRTP2 at the same time") + endif() +endif () + if (CMAKE_CROSSCOMPILING) option (JRTPLIB_USE_BIGENDIAN "Target platform is big endian" ON) if (JRTPLIB_USE_BIGENDIAN) @@ -107,7 +131,7 @@ option(JRTPLIB_COMPILE_TESTS "Compile various tests in the 'tests' subdirectory" option(JRTPLIB_COMPILE_EXAMPLES "Compile various examples in the 'examples' subdirectory" YES) # Check winsock first -set(TESTDEFS "") +set(TESTDEFS "" CACHE STRING "Preprocessor definitions of feature tests") set(EMPTYWSSTRING "// Not using winsock sockets") jrtplib_test_feature(winsocktest RTP_SOCKETTYPE_WINSOCK FALSE "${EMPTYWSSTRING}" "${TESTDEFS}") if ("${RTP_SOCKETTYPE_WINSOCK}" STREQUAL "${EMPTYWSSTRING}") diff --git a/ChangeLog b/ChangeLog index 046805a..db468ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,15 @@ JRTPLIB ChangeLog ----------------- - ? (?): + 3.11.2 (April 2020): * Taking EINTR in nanosleep, poll and select calls into account. Thanks to Filippo Guerzoni (filippo.guerzoni@gmail.com) for bringing this to my attention. + * Disabled some copy constructors + * Bugfix in RTPExternalTransmitter: a buffer could fill up causing the + an operation to fail to get aborted + * Added constructor to RTPRawPacket to guess RTP/RTCP type + * Bugfixed regarding some calles being cut short due to an EINTR 3.11.1 (March 2017) * Bugfix in rtpsources.cpp: if the RTP packet got deleted in diff --git a/README.md b/README.md index 720593e..f606ece 100644 --- a/README.md +++ b/README.md @@ -1,149 +1,24 @@ -JRTPLIB -======= - -> Developed at the [Expertise Centre for Digital Media (EDM)](http://www.edm.uhasselt.be), -> a research institute of the [Hasselt University](http://www.uhasselt.be) - -Library location and contact ----------------------------- - -Normally, you should be able to download the latest version of the library -from this url: [http://research.edm.uhasselt.be/jori/jrtplib](http://research.edm.uhasselt.be/jori/jrtplib) - -Documentation can be found at [jrtplib.readthedocs.io](http://jrtplib.readthedocs.io) - -If you have questions about the library, you can mail me at: -[jori.liesenborgs@gmail.com](mailto:jori.liesenborgs@gmail.com) - -Acknowledgment --------------- - -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. -Special thanks go to Wim Lamotte for getting me started on the RTP -journey many years ago. - -Disclaimer & Copyright ----------------------- - - 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. - -Installation notes ------------------- - -* Use the [CMake](https://cmake.org/) build system to compile the library. - In case extra include directories or libraries are needed, you can use the - `ADDITIONAL_` CMake variables to specify these. They will be stored in both - the resulting JRTPLIB CMake configuration file and the pkg-config file. - -* The library documentation can be generated using Doxygen. An on-line - version can be found at [http://jrtplib.readthedocs.io](http://jrtplib.readthedocs.io) - -* For systems with low memory or for applications which will involve only - a few participants at a time: - You can set the `HASHSIZE` defines in `rtpsources.h`, `rtpudpv4transmitter.h` - and `rtpudpv6transmitter.h` to a lower value to avoid memory being wasted. - Note that the library will have to be recompiled. - -* Used defines: - - - `WIN32`: For compilation on an Win32 platform. - - - `_WIN32_WCE`: Define needed for compilation on a WinCE platform - - - `RTP_HAVE_SYS_FILIO`: Set if `` exists. - - - `RTP_HAVE_SYS_SOCKIO`: Set if `` exists. - - - `RTP_BIG_ENDIAN`: If set, assume big-endian byte ordering. - - - `RTP_SOCKLENTYPE_UINT`: Indicates that getsockname used an unsigned int - as its third parameter. - - - `RTP_HAVE_SOCKADDR_LEN`: Indicates that struct sockaddr has an sa_len - field. - - - `RTP_SUPPORT_IPV4MULTICAST`: Enables support for IPv4 multicasting. - - - `RTP_SUPPORT_THREAD`: Enables support for JThread. - - - `RTP_SUPPORT_SDESPRIV`: Enables support for RTCP SDES private items. - - - `RTP_SUPPORT_PROBATION`: If set, a few consecutive RTP packets are - needed to validate a member. - - - `RTP_SUPPORT_GETLOGINR`: If set, the library will use getlogin_r instead - of getlogin. - - - `RTP_SUPPORT_IPV6`: If set, IPv6 support is enabled. - - - `RTP_SUPPORT_IPV6MULTICAST`: If set, IPv6 multicasting support is enabled. - - - `RTP_SUPPORT_SENDAPP`: If set, sending of RTCP app packets is enabled. - - - `RTP_SUPPORT_MEMORYMANAGEMENT`: If set, the memory management system is - enabled. - - - `RTP_SUPPORT_RTCPUNKNOWN`: If set, sending of unknown RTCP packets is - enabled. - - - `RTPDEBUG`: Enables some memory tracking functions and some debug - routines. - -Cross-compilation of JThread & JRTPLIB for Android --------------------------------------------------- - -**Warning:** When cross-compiling, the configuration defaults to big-endian. -But since most Android systems are little-endian, you should probably change -this setting in the CMake configuration. - -The approach I follow for cross-compiling these libraries for the Android -platform is sketched below. The following lines are stored in a file called -`toolchain.cmake` (for example): - - set(CMAKE_SYSTEM_NAME Android) - set(CMAKE_SYSTEM_VERSION 21) # API level - set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) - set(CMAKE_ANDROID_NDK /path/to/ndk-bundle/) - set(CMAKE_ANDROID_STL_TYPE gnustl_static) - - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -When starting CMake, first for JThread and afterwards for JRTPLIB, I then manually -add the following entries: - - CMAKE_TOOLCHAIN_FILE /path/to/toolchain.cmake - CMAKE_INSTALL_PREFIX /path/to/installation/directory - CMAKE_FIND_ROOT_PATH /path/to/installation/directory - -For example, I like to use the `ccmake` program, which would yield -the following command line: - - ccmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake \ - -DCMAKE_INSTALL_PREFIX=/path/to/installation/directory \ - -DCMAKE_FIND_ROOT_PATH=/path/to/installation/directory \ - /path/to/main/CMakeLists.txt - -After configuring JThread this way, just build and install it. The same CMake -procedure for JRTPLIB should then automatically detect the correct JThread -(so the one that's installed in your cross-compilation installation directory), -after which you can again build and install the RTP library. +(For the original README file, see [README2.md](README2.md)) + +End of development +================== + +I find that this is a difficult decision, and I can't really think of a way +to present all the thoughts that have convinced me that this is a step I +need to make. This library started as my first real open source project way +back in 1999, when I was still very much a student, and it was the first time +I actually shared any kind of code with the outside world. Needless to say, +it will always be linked to many good memories, and as such is hard to let +go. + +Times change however, and I feel I haven't been able to give this project the +attention it deserves for quite some time now, even though it probably does +not really require that many interventions. As other things have come along +that captured my interest, and as some health issues have come along that +further captured some time, I think the time has come to make this difficult +decision. + +So it is with mixed emotions, both sadness as well as a feeling of relief, +that I say goodbye to JRTPLIB. + +Jori diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..720593e --- /dev/null +++ b/README2.md @@ -0,0 +1,149 @@ +JRTPLIB +======= + +> Developed at the [Expertise Centre for Digital Media (EDM)](http://www.edm.uhasselt.be), +> a research institute of the [Hasselt University](http://www.uhasselt.be) + +Library location and contact +---------------------------- + +Normally, you should be able to download the latest version of the library +from this url: [http://research.edm.uhasselt.be/jori/jrtplib](http://research.edm.uhasselt.be/jori/jrtplib) + +Documentation can be found at [jrtplib.readthedocs.io](http://jrtplib.readthedocs.io) + +If you have questions about the library, you can mail me at: +[jori.liesenborgs@gmail.com](mailto:jori.liesenborgs@gmail.com) + +Acknowledgment +-------------- + +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. +Special thanks go to Wim Lamotte for getting me started on the RTP +journey many years ago. + +Disclaimer & Copyright +---------------------- + + 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. + +Installation notes +------------------ + +* Use the [CMake](https://cmake.org/) build system to compile the library. + In case extra include directories or libraries are needed, you can use the + `ADDITIONAL_` CMake variables to specify these. They will be stored in both + the resulting JRTPLIB CMake configuration file and the pkg-config file. + +* The library documentation can be generated using Doxygen. An on-line + version can be found at [http://jrtplib.readthedocs.io](http://jrtplib.readthedocs.io) + +* For systems with low memory or for applications which will involve only + a few participants at a time: + You can set the `HASHSIZE` defines in `rtpsources.h`, `rtpudpv4transmitter.h` + and `rtpudpv6transmitter.h` to a lower value to avoid memory being wasted. + Note that the library will have to be recompiled. + +* Used defines: + + - `WIN32`: For compilation on an Win32 platform. + + - `_WIN32_WCE`: Define needed for compilation on a WinCE platform + + - `RTP_HAVE_SYS_FILIO`: Set if `` exists. + + - `RTP_HAVE_SYS_SOCKIO`: Set if `` exists. + + - `RTP_BIG_ENDIAN`: If set, assume big-endian byte ordering. + + - `RTP_SOCKLENTYPE_UINT`: Indicates that getsockname used an unsigned int + as its third parameter. + + - `RTP_HAVE_SOCKADDR_LEN`: Indicates that struct sockaddr has an sa_len + field. + + - `RTP_SUPPORT_IPV4MULTICAST`: Enables support for IPv4 multicasting. + + - `RTP_SUPPORT_THREAD`: Enables support for JThread. + + - `RTP_SUPPORT_SDESPRIV`: Enables support for RTCP SDES private items. + + - `RTP_SUPPORT_PROBATION`: If set, a few consecutive RTP packets are + needed to validate a member. + + - `RTP_SUPPORT_GETLOGINR`: If set, the library will use getlogin_r instead + of getlogin. + + - `RTP_SUPPORT_IPV6`: If set, IPv6 support is enabled. + + - `RTP_SUPPORT_IPV6MULTICAST`: If set, IPv6 multicasting support is enabled. + + - `RTP_SUPPORT_SENDAPP`: If set, sending of RTCP app packets is enabled. + + - `RTP_SUPPORT_MEMORYMANAGEMENT`: If set, the memory management system is + enabled. + + - `RTP_SUPPORT_RTCPUNKNOWN`: If set, sending of unknown RTCP packets is + enabled. + + - `RTPDEBUG`: Enables some memory tracking functions and some debug + routines. + +Cross-compilation of JThread & JRTPLIB for Android +-------------------------------------------------- + +**Warning:** When cross-compiling, the configuration defaults to big-endian. +But since most Android systems are little-endian, you should probably change +this setting in the CMake configuration. + +The approach I follow for cross-compiling these libraries for the Android +platform is sketched below. The following lines are stored in a file called +`toolchain.cmake` (for example): + + set(CMAKE_SYSTEM_NAME Android) + set(CMAKE_SYSTEM_VERSION 21) # API level + set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) + set(CMAKE_ANDROID_NDK /path/to/ndk-bundle/) + set(CMAKE_ANDROID_STL_TYPE gnustl_static) + + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +When starting CMake, first for JThread and afterwards for JRTPLIB, I then manually +add the following entries: + + CMAKE_TOOLCHAIN_FILE /path/to/toolchain.cmake + CMAKE_INSTALL_PREFIX /path/to/installation/directory + CMAKE_FIND_ROOT_PATH /path/to/installation/directory + +For example, I like to use the `ccmake` program, which would yield +the following command line: + + ccmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=/path/to/installation/directory \ + -DCMAKE_FIND_ROOT_PATH=/path/to/installation/directory \ + /path/to/main/CMakeLists.txt + +After configuring JThread this way, just build and install it. The same CMake +procedure for JRTPLIB should then automatically detect the correct JThread +(so the one that's installed in your cross-compilation installation directory), +after which you can again build and install the RTP library. diff --git a/cmake/FindLIBSRTP2.cmake b/cmake/FindLIBSRTP2.cmake new file mode 100644 index 0000000..9990c90 --- /dev/null +++ b/cmake/FindLIBSRTP2.cmake @@ -0,0 +1,33 @@ +INCLUDE(FindPkgConfig OPTIONAL) + +IF(PKG_CONFIG_FOUND) + INCLUDE(FindPkgConfig) + PKG_CHECK_MODULES(LIBSRTP2 srtp2) +ENDIF(PKG_CONFIG_FOUND) + +IF(NOT LIBSRTP2_FOUND) + FIND_PATH(LIBSRTP2_INCLUDE_DIR srtp2/srtp.h + /usr/local/include + /usr/include + ) + + FIND_LIBRARY(LIBSRTP2_LIBRARY_DIR + NAMES srtp2 + PATH + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + ) + MESSAGE(STATUS "Found LIBSRTP2: ${LIBSRTP2_LIBRARY_DIR} ${LIBSRTP2_INCLUDE_DIR}") +ENDIF(NOT LIBSRTP2_FOUND) + +IF(LIBSRTP2_LIBRARY_DIR AND LIBSRTP2_INCLUDE_DIR) + SET(LIBSRTP2_FOUND TRUE) +ENDIF(LIBSRTP2_LIBRARY_DIR AND LIBSRTP2_INCLUDE_DIR) + +IF(NOT LIBSRTP2_FOUND) + IF(LIBSRTP2_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find LIBSRTP2") + ENDIF(LIBSRTP2_FIND_REQUIRED) +ENDIF(NOT LIBSRTP2_FOUND) diff --git a/src/rtpconfig.h.in b/src/rtpconfig.h.in index 11eabd6..033dea7 100644 --- a/src/rtpconfig.h.in +++ b/src/rtpconfig.h.in @@ -104,6 +104,8 @@ ${RTP_HAVE_STRNCPY_S} ${RTP_SUPPORT_SRTP} +${RTP_SUPPORT_SRTP2} + ${RTP_HAVE_CLOCK_GETTIME} ${RTP_HAVE_POLL} diff --git a/src/rtperrors.cpp b/src/rtperrors.cpp index e9c1945..53a8f0d 100644 --- a/src/rtperrors.cpp +++ b/src/rtperrors.cpp @@ -69,7 +69,7 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE, "The specified maximum packet size for the RTP packet builder is invalid"}, { ERR_RTP_PACKBUILD_NOTINIT, "The RTP packet builder is not initialized"}, { ERR_RTP_PACKET_BADPAYLOADTYPE, "Invalid payload type"}, - { ERR_RTP_PACKET_DATAEXCEEDSMAXSIZE, "Tried to create an RTP packet which whould exceed the specified maximum packet size"}, + { ERR_RTP_PACKET_DATAEXCEEDSMAXSIZE, "Tried to create an RTP packet which would exceed the specified maximum packet size"}, { ERR_RTP_PACKET_EXTERNALBUFFERNULL, "Illegal value (null) passed as external buffer for the RTP packet"}, { ERR_RTP_PACKET_ILLEGALBUFFERSIZE, "Illegal buffer size specified for the RTP packet"}, { ERR_RTP_PACKET_INVALIDPACKET, "Invalid RTP packet format"}, @@ -117,7 +117,7 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_SOURCES_ILLEGALSDESTYPE, "Illegal SDES type specified for processing into the source table"}, { ERR_RTP_SOURCES_SSRCEXISTS, "Can't create own SSRC because this SSRC identifier is already in the source table"}, { ERR_RTP_UDPV4TRANS_ALREADYCREATED, "The transmitter was already created"}, - { ERR_RTP_UDPV4TRANS_ALREADYINIT, "The transmitter was already initialize"}, + { ERR_RTP_UDPV4TRANS_ALREADYINIT, "The transmitter was already initialized"}, { ERR_RTP_UDPV4TRANS_ALREADYWAITING, "The transmitter is already waiting for incoming data"}, { ERR_RTP_UDPV4TRANS_CANTBINDRTCPSOCKET, "The 'bind' call for the RTCP socket failed"}, { ERR_RTP_UDPV4TRANS_CANTBINDRTPSOCKET, "The 'bind' call for the RTP socket failed"}, @@ -128,7 +128,7 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_UDPV4TRANS_CANTSETRTPRECEIVEBUF, "Couldn't set the receive buffer size for the RTP socket"}, { ERR_RTP_UDPV4TRANS_CANTSETRTPTRANSMITBUF, "Couldn't set the transmission buffer size for the RTP socket"}, { ERR_RTP_UDPV4TRANS_COULDNTJOINMULTICASTGROUP, "Unable to join the specified multicast group"}, - { ERR_RTP_UDPV4TRANS_DIFFERENTRECEIVEMODE, "The function called doens't match the current receive mode"}, + { ERR_RTP_UDPV4TRANS_DIFFERENTRECEIVEMODE, "The function called doesn't match the current receive mode"}, { ERR_RTP_UDPV4TRANS_ILLEGALPARAMETERS, "Illegal parameters type passed to the transmitter"}, { ERR_RTP_UDPV4TRANS_INVALIDADDRESSTYPE, "Specified address type isn't compatible with this transmitter"}, { ERR_RTP_UDPV4TRANS_NOLOCALIPS, "Couldn't determine the local host name since the local IP list is empty"}, @@ -141,7 +141,7 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_UDPV4TRANS_PORTBASENOTEVEN, "The specified port base is not an even number"}, { ERR_RTP_UDPV4TRANS_SPECIFIEDSIZETOOBIG, "The maximum packet size is too big for this transmitter"}, { ERR_RTP_UDPV6TRANS_ALREADYCREATED, "The transmitter was already created"}, - { ERR_RTP_UDPV6TRANS_ALREADYINIT, "The transmitter was already initialize"}, + { ERR_RTP_UDPV6TRANS_ALREADYINIT, "The transmitter was already initialized"}, { ERR_RTP_UDPV6TRANS_ALREADYWAITING, "The transmitter is already waiting for incoming data"}, { ERR_RTP_UDPV6TRANS_CANTBINDRTCPSOCKET, "The 'bind' call for the RTCP socket failed"}, { ERR_RTP_UDPV6TRANS_CANTBINDRTPSOCKET, "The 'bind' call for the RTP socket failed"}, @@ -152,7 +152,7 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_UDPV6TRANS_CANTSETRTPRECEIVEBUF, "Couldn't set the receive buffer size for the RTP socket"}, { ERR_RTP_UDPV6TRANS_CANTSETRTPTRANSMITBUF, "Couldn't set the transmission buffer size for the RTP socket"}, { ERR_RTP_UDPV6TRANS_COULDNTJOINMULTICASTGROUP, "Unable to join the specified multicast group"}, - { ERR_RTP_UDPV6TRANS_DIFFERENTRECEIVEMODE, "The function called doens't match the current receive mode"}, + { ERR_RTP_UDPV6TRANS_DIFFERENTRECEIVEMODE, "The function called doesn't match the current receive mode"}, { ERR_RTP_UDPV6TRANS_ILLEGALPARAMETERS, "Illegal parameters type passed to the transmitter"}, { ERR_RTP_UDPV6TRANS_INVALIDADDRESSTYPE, "Specified address type isn't compatible with this transmitter"}, { ERR_RTP_UDPV6TRANS_NOLOCALIPS, "Couldn't determine the local host name since the local IP list is empty"}, @@ -168,10 +168,10 @@ static RTPErrorInfo ErrorDescriptions[]= { ERR_RTP_SDES_MAXPRIVITEMS,"The maximum number of SDES private item prefixes was reached"}, { ERR_RTP_INTERNALSOURCEDATA_INVALIDPROBATIONTYPE,"An invalid probation type was specified"}, { ERR_RTP_FAKETRANS_ALREADYCREATED, "The transmitter was already created"}, - { ERR_RTP_FAKETRANS_ALREADYINIT, "The transmitter was already initialize"}, + { ERR_RTP_FAKETRANS_ALREADYINIT, "The transmitter was already initialized"}, { ERR_RTP_FAKETRANS_CANTINITMUTEX, "Failed to initialize a mutex used by the transmitter"}, { ERR_RTP_FAKETRANS_COULDNTJOINMULTICASTGROUP, "Unable to join the specified multicast group"}, - { ERR_RTP_FAKETRANS_DIFFERENTRECEIVEMODE, "The function called doens't match the current receive mode"}, + { ERR_RTP_FAKETRANS_DIFFERENTRECEIVEMODE, "The function called doesn't match the current receive mode"}, { ERR_RTP_FAKETRANS_ILLEGALPARAMETERS, "Illegal parameters type passed to the transmitter"}, { ERR_RTP_FAKETRANS_INVALIDADDRESSTYPE, "Specified address type isn't compatible with this transmitter"}, { ERR_RTP_FAKETRANS_NOLOCALIPS, "Couldn't determine the local host name since the local IP list is empty"}, diff --git a/src/rtpsecuresession.cpp b/src/rtpsecuresession.cpp index 163329e..8581a19 100644 --- a/src/rtpsecuresession.cpp +++ b/src/rtpsecuresession.cpp @@ -32,13 +32,22 @@ #include "rtpsecuresession.h" -#ifdef RTP_SUPPORT_SRTP +#if defined(RTP_SUPPORT_SRTP) || defined(RTP_SUPPORT_SRTP2) #include "rtprawpacket.h" #ifdef RTP_SUPPORT_THREAD #include #endif -#include + +#ifdef RTP_SUPPORT_SRTP2 + #include + + #define err_status_t srtp_err_status_t + #define err_status_ok srtp_err_status_ok +#else + #include +#endif + #include #include @@ -283,5 +292,5 @@ void RTPSecureSession::OnSentRTPOrRTCPData(void *senddata, size_t sendlen, bool } // end namespace -#endif // RTP_SUPPORT_SRTP +#endif // RTP_SUPPORT_SRTP || RTP_SUPPORT_SRTP2 diff --git a/src/rtpsecuresession.h b/src/rtpsecuresession.h index 26a04ff..cdbdd6f 100644 --- a/src/rtpsecuresession.h +++ b/src/rtpsecuresession.h @@ -40,7 +40,7 @@ #include "rtpconfig.h" -#ifdef RTP_SUPPORT_SRTP +#if defined(RTP_SUPPORT_SRTP) || defined(RTP_SUPPORT_SRTP2) #include "rtpsession.h" @@ -48,7 +48,12 @@ #include #endif // RTP_SUPPORT_THREAD +#ifdef RTP_SUPPORT_SRTP2 +struct srtp_ctx_t_; +typedef struct srtp_ctx_t_ srtp_ctx_t; +#else struct srtp_ctx_t; +#endif namespace jrtplib { @@ -126,7 +131,7 @@ inline void RTPSecureSession::OnErrorChangeIncomingData(int, int) { } } // end namespace -#endif // RTP_SUPPORT_SRTP +#endif // RTP_SUPPORT_SRTP || RTP_SUPPORT_SRTP2 #endif // RTPSECURESESSION_H diff --git a/tests/srtptest.cpp b/tests/srtptest.cpp index 70af44c..1e77c8e 100644 --- a/tests/srtptest.cpp +++ b/tests/srtptest.cpp @@ -3,7 +3,7 @@ using namespace std; -#ifdef RTP_SUPPORT_SRTP +#if defined(RTP_SUPPORT_SRTP) || defined(RTP_SUPPORT_SRTP2) #include "rtpsecuresession.h" #include "rtpudpv4transmitter.h" @@ -15,7 +15,15 @@ using namespace std; #include "rtprawpacket.h" #include #include +#ifdef RTP_SUPPORT_SRTP2 +#include +#define SRTP_ERR_T srtp_err_status_t +#define SRTP_ERR_OK srtp_err_status_ok +#else #include +#define SRTP_ERR_T err_status_t +#define SRTP_ERR_OK err_status_ok +#endif // RTP_SUPPORT_SRTP2 #include using namespace jrtplib; @@ -67,11 +75,19 @@ class MyRTPSession : public RTPSecureSession memset(&policyIn, 0, sizeof(srtp_policy_t)); memset(&policyOut, 0, sizeof(srtp_policy_t)); +#ifdef RTP_SUPPORT_SRTP2 + srtp_crypto_policy_set_rtp_default(&policyIn.rtp); + srtp_crypto_policy_set_rtcp_default(&policyIn.rtcp); + + srtp_crypto_policy_set_rtp_default(&policyOut.rtp); + srtp_crypto_policy_set_rtcp_default(&policyOut.rtcp); +#else crypto_policy_set_rtp_default(&policyIn.rtp); crypto_policy_set_rtcp_default(&policyIn.rtcp); crypto_policy_set_rtp_default(&policyOut.rtp); crypto_policy_set_rtcp_default(&policyOut.rtcp); +#endif policyIn.ssrc.type = ssrc_any_inbound; policyIn.key = (uint8_t *)key.c_str(); @@ -88,14 +104,14 @@ class MyRTPSession : public RTPSecureSession cerr << "Unable to get/lock srtp context" << endl; return false; } - err_status_t err = srtp_add_stream(ctx, &policyIn); - if (err == err_status_ok) + SRTP_ERR_T err = srtp_add_stream(ctx, &policyIn); + if (err == SRTP_ERR_OK) err = srtp_add_stream(ctx, &policyOut); UnlockSRTPContext(); - if (err != err_status_ok) + if (err != SRTP_ERR_OK) { - cerr << "libsrtp error while adding stream: " << err << endl; + cerr << "libsrtp(2) error while adding stream: " << err << endl; return false; } return true; @@ -151,7 +167,7 @@ class MyRTPSession : public RTPSecureSession void OnErrorChangeIncomingData(int errcode, int libsrtperrorcode) { printf("SSRC %x JRTPLIB Error: %s\n", GetLocalSSRC(), RTPGetErrorString(errcode).c_str()); - if (libsrtperrorcode != err_status_ok) + if (libsrtperrorcode != SRTP_ERR_OK) printf("libsrtp error: %d\n", libsrtperrorcode); printf("\n"); } @@ -243,4 +259,4 @@ int main(void) return 0; } -#endif // RTP_SUPPORT_SRTP +#endif // RTP_SUPPORT_SRTP || RTP_SUPPORT_SRTP2