├── RtspClient ├── Makefile ├── ReadMe.txt ├── examples │ └── Main.cpp ├── lib │ ├── include │ │ ├── jrtplib3 │ │ │ ├── rtcpapppacket.h │ │ │ ├── rtcpbyepacket.h │ │ │ ├── rtcpcompoundpacket.h │ │ │ ├── rtcpcompoundpacketbuilder.h │ │ │ ├── rtcppacket.h │ │ │ ├── rtcppacketbuilder.h │ │ │ ├── rtcprrpacket.h │ │ │ ├── rtcpscheduler.h │ │ │ ├── rtcpsdesinfo.h │ │ │ ├── rtcpsdespacket.h │ │ │ ├── rtcpsrpacket.h │ │ │ ├── rtcpunknownpacket.h │ │ │ ├── rtpabortdescriptors.h │ │ │ ├── rtpaddress.h │ │ │ ├── rtpbyteaddress.h │ │ │ ├── rtpcollisionlist.h │ │ │ ├── rtpconfig.h │ │ │ ├── rtpdebug.h │ │ │ ├── rtpdefines.h │ │ │ ├── rtperrors.h │ │ │ ├── rtpexternaltransmitter.h │ │ │ ├── rtpfaketransmitter.h │ │ │ ├── rtphashtable.h │ │ │ ├── rtpinternalsourcedata.h │ │ │ ├── rtpipv4address.h │ │ │ ├── rtpipv4destination.h │ │ │ ├── rtpipv6address.h │ │ │ ├── rtpipv6destination.h │ │ │ ├── rtpkeyhashtable.h │ │ │ ├── rtplibraryversion.h │ │ │ ├── rtpmemorymanager.h │ │ │ ├── rtpmemoryobject.h │ │ │ ├── rtppacket.h │ │ │ ├── rtppacketbuilder.h │ │ │ ├── rtppollthread.h │ │ │ ├── rtprandom.h │ │ │ ├── rtprandomrand48.h │ │ │ ├── rtprandomrands.h │ │ │ ├── rtprandomurandom.h │ │ │ ├── rtprawpacket.h │ │ │ ├── rtpsecuresession.h │ │ │ ├── rtpselect.h │ │ │ ├── rtpsession.h │ │ │ ├── rtpsessionparams.h │ │ │ ├── rtpsessionsources.h │ │ │ ├── rtpsocketutil.h │ │ │ ├── rtpsourcedata.h │ │ │ ├── rtpsources.h │ │ │ ├── rtpstructs.h │ │ │ ├── rtptcpaddress.h │ │ │ ├── rtptcptransmitter.h │ │ │ ├── rtptimeutilities.h │ │ │ ├── rtptransmitter.h │ │ │ ├── rtptypes.h │ │ │ ├── rtptypes_win.h │ │ │ ├── rtpudpv4transmitter.h │ │ │ └── rtpudpv6transmitter.h │ │ └── jthread │ │ │ ├── jmutex.h │ │ │ ├── jmutexautolock.h │ │ │ ├── jthread.h │ │ │ └── jthreadconfig.h │ ├── libjrtp.a │ ├── libjrtp.so │ ├── libjrtp.so.3.11.1 │ ├── libjthread.a │ ├── libjthread.so │ └── libjthread.so.1.3.3 └── src │ ├── MediaSession.cpp │ ├── RtpPacketType.cpp │ ├── RtspClient.cpp │ ├── TcpSocket.cpp │ ├── base64 │ ├── Base64.cpp │ ├── include │ │ ├── Base64.hh │ │ ├── Boolean.hh │ │ └── strDup.hh │ └── strDup.cpp │ └── include │ ├── Definition.h │ ├── MediaSession.h │ ├── RtpPacketType.h │ ├── RtspClient.h │ └── TcpSocket.h └── RtspServer ├── Makefile ├── ReadMe.txt ├── copy.bat ├── examples └── Main.cpp ├── sintel.h264 └── src ├── RtpPacket.cpp ├── RtpSession.cpp ├── RtspServer.cpp ├── TcpSocket.cpp ├── Tools.cpp ├── UdpSocket.cpp ├── base64 ├── Base64.cpp ├── include │ ├── Base64.hh │ ├── Boolean.hh │ └── strDup.hh └── strDup.cpp ├── include ├── Definition.h ├── RtpPacket.h ├── RtpSession.h ├── RtspServer.h ├── TcpSocket.h ├── Tools.h └── UdpSocket.h └── media ├── MediaHandle.cpp ├── RawAudioHandle.cpp ├── RawAudioHandle.h ├── RawVideoHandle.cpp ├── RawVideoHandle.h └── include └── MediaHandle.h /RtspClient/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/Makefile -------------------------------------------------------------------------------- /RtspClient/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/ReadMe.txt -------------------------------------------------------------------------------- /RtspClient/examples/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/examples/Main.cpp -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpapppacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpapppacket.h 35 | */ 36 | 37 | #ifndef RTCPAPPPACKET_H 38 | 39 | #define RTCPAPPPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtcppacket.h" 43 | #include "rtpstructs.h" 44 | #ifdef RTP_SUPPORT_NETINET_IN 45 | #include 46 | #endif // RTP_SUPPORT_NETINET_IN 47 | 48 | namespace jrtplib 49 | { 50 | 51 | class RTCPCompoundPacket; 52 | 53 | /** Describes an RTCP APP packet. */ 54 | class JRTPLIB_IMPORTEXPORT RTCPAPPPacket : public RTCPPacket 55 | { 56 | public: 57 | /** Creates an instance based on the data in \c data with length \c datalen. 58 | * Creates an instance based on the data in \c data with length \c datalen. Since the \c data pointer 59 | * is referenced inside the class (no copy of the data is made) one must make sure that the memory it 60 | * points to is valid as long as the class instance exists. 61 | */ 62 | RTCPAPPPacket(uint8_t *data,size_t datalen); 63 | ~RTCPAPPPacket() { } 64 | 65 | /** Returns the subtype contained in the APP packet. */ 66 | uint8_t GetSubType() const; 67 | 68 | /** Returns the SSRC of the source which sent this packet. */ 69 | uint32_t GetSSRC() const; 70 | 71 | /** Returns the name contained in the APP packet. 72 | * Returns the name contained in the APP packet. This alway consists of four bytes and is not NULL-terminated. 73 | */ 74 | uint8_t *GetName(); 75 | 76 | /** Returns a pointer to the actual data. */ 77 | uint8_t *GetAPPData(); 78 | 79 | /** Returns the length of the actual data. */ 80 | size_t GetAPPDataLength() const; 81 | #ifdef RTPDEBUG 82 | void Dump(); 83 | #endif // RTPDEBUG 84 | private: 85 | size_t appdatalen; 86 | }; 87 | 88 | inline uint8_t RTCPAPPPacket::GetSubType() const 89 | { 90 | if (!knownformat) 91 | return 0; 92 | RTCPCommonHeader *hdr = (RTCPCommonHeader *)data; 93 | return hdr->count; 94 | } 95 | 96 | inline uint32_t RTCPAPPPacket::GetSSRC() const 97 | { 98 | if (!knownformat) 99 | return 0; 100 | 101 | uint32_t *ssrc = (uint32_t *)(data+sizeof(RTCPCommonHeader)); 102 | return ntohl(*ssrc); 103 | } 104 | 105 | inline uint8_t *RTCPAPPPacket::GetName() 106 | { 107 | if (!knownformat) 108 | return 0; 109 | 110 | return (data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); 111 | } 112 | 113 | inline uint8_t *RTCPAPPPacket::GetAPPData() 114 | { 115 | if (!knownformat) 116 | return 0; 117 | if (appdatalen == 0) 118 | return 0; 119 | return (data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)*2); 120 | } 121 | 122 | inline size_t RTCPAPPPacket::GetAPPDataLength() const 123 | { 124 | if (!knownformat) 125 | return 0; 126 | return appdatalen; 127 | } 128 | 129 | } // end namespace 130 | 131 | #endif // RTCPAPPPACKET_H 132 | 133 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpbyepacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpbyepacket.h 35 | */ 36 | 37 | #ifndef RTCPBYEPACKET_H 38 | 39 | #define RTCPBYEPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtcppacket.h" 43 | #include "rtpstructs.h" 44 | #ifdef RTP_SUPPORT_NETINET_IN 45 | #include 46 | #endif // RTP_SUPPORT_NETINET_IN 47 | 48 | namespace jrtplib 49 | { 50 | 51 | class RTCPCompoundPacket; 52 | 53 | /** Describes an RTCP BYE packet. */ 54 | class JRTPLIB_IMPORTEXPORT RTCPBYEPacket : public RTCPPacket 55 | { 56 | public: 57 | /** Creates an instance based on the data in \c data with length \c datalen. 58 | * Creates an instance based on the data in \c data with length \c datalen. Since the \c data pointer 59 | * is referenced inside the class (no copy of the data is made) one must make sure that the memory it 60 | * points to is valid as long as the class instance exists. 61 | */ 62 | RTCPBYEPacket(uint8_t *data,size_t datalen); 63 | ~RTCPBYEPacket() { } 64 | 65 | /** Returns the number of SSRC identifiers present in this BYE packet. */ 66 | int GetSSRCCount() const; 67 | 68 | /** Returns the SSRC described by \c index which may have a value from 0 to GetSSRCCount()-1 69 | * (note that no check is performed to see if \c index is valid). 70 | */ 71 | uint32_t GetSSRC(int index) const; // note: no check is performed to see if index is valid! 72 | 73 | /** Returns true if the BYE packet contains a reason for leaving. */ 74 | bool HasReasonForLeaving() const; 75 | 76 | /** Returns the length of the string which describes why the source(s) left. */ 77 | size_t GetReasonLength() const; 78 | 79 | /** Returns the actual reason for leaving data. */ 80 | uint8_t *GetReasonData(); 81 | 82 | #ifdef RTPDEBUG 83 | void Dump(); 84 | #endif // RTPDEBUG 85 | private: 86 | size_t reasonoffset; 87 | }; 88 | 89 | inline int RTCPBYEPacket::GetSSRCCount() const 90 | { 91 | if (!knownformat) 92 | return 0; 93 | 94 | RTCPCommonHeader *hdr = (RTCPCommonHeader *)data; 95 | return (int)(hdr->count); 96 | } 97 | 98 | inline uint32_t RTCPBYEPacket::GetSSRC(int index) const 99 | { 100 | if (!knownformat) 101 | return 0; 102 | uint32_t *ssrc = (uint32_t *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)*index); 103 | return ntohl(*ssrc); 104 | } 105 | 106 | inline bool RTCPBYEPacket::HasReasonForLeaving() const 107 | { 108 | if (!knownformat) 109 | return false; 110 | if (reasonoffset == 0) 111 | return false; 112 | return true; 113 | } 114 | 115 | inline size_t RTCPBYEPacket::GetReasonLength() const 116 | { 117 | if (!knownformat) 118 | return 0; 119 | if (reasonoffset == 0) 120 | return 0; 121 | uint8_t *reasonlen = (data+reasonoffset); 122 | return (size_t)(*reasonlen); 123 | } 124 | 125 | inline uint8_t *RTCPBYEPacket::GetReasonData() 126 | { 127 | if (!knownformat) 128 | return 0; 129 | if (reasonoffset == 0) 130 | return 0; 131 | uint8_t *reasonlen = (data+reasonoffset); 132 | if ((*reasonlen) == 0) 133 | return 0; 134 | return (data+reasonoffset+1); 135 | } 136 | 137 | } // end namespace 138 | 139 | #endif // RTCPBYEPACKET_H 140 | 141 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpcompoundpacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpcompoundpacket.h 35 | */ 36 | 37 | #ifndef RTCPCOMPOUNDPACKET_H 38 | 39 | #define RTCPCOMPOUNDPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | #include "rtpmemoryobject.h" 44 | #include 45 | 46 | namespace jrtplib 47 | { 48 | 49 | class RTPRawPacket; 50 | class RTCPPacket; 51 | 52 | /** Represents an RTCP compound packet. */ 53 | class JRTPLIB_IMPORTEXPORT RTCPCompoundPacket : public RTPMemoryObject 54 | { 55 | public: 56 | /** Creates an RTCPCompoundPacket instance from the data in \c rawpack, installing a memory manager if specified. */ 57 | RTCPCompoundPacket(RTPRawPacket &rawpack, RTPMemoryManager *memmgr = 0); 58 | 59 | /** Creates an RTCPCompoundPacket instance from the data in \c packet}, with size \c len. 60 | * Creates an RTCPCompoundPacket instance from the data in \c packet}, with size \c len. The \c deletedata 61 | * flag specifies if the data in \c packet should be deleted when the compound packet is destroyed. If 62 | * specified, a memory manager will be installed. 63 | */ 64 | RTCPCompoundPacket(uint8_t *packet, size_t len, bool deletedata = true, RTPMemoryManager *memmgr = 0); 65 | protected: 66 | RTCPCompoundPacket(RTPMemoryManager *memmgr); // this is for the compoundpacket builder 67 | public: 68 | virtual ~RTCPCompoundPacket(); 69 | 70 | /** Checks if the RTCP compound packet was created successfully. 71 | * If the raw packet data in the constructor could not be parsed, this function returns the error code of 72 | * what went wrong. If the packet had an invalid format, the return value is \c ERR_RTP_RTCPCOMPOUND_INVALIDPACKET. 73 | */ 74 | int GetCreationError() { return error; } 75 | 76 | /** Returns a pointer to the data of the entire RTCP compound packet. */ 77 | uint8_t *GetCompoundPacketData() { return compoundpacket; } 78 | 79 | /** Returns the size of the entire RTCP compound packet. */ 80 | size_t GetCompoundPacketLength() { return compoundpacketlength; } 81 | 82 | /** Starts the iteration over the individual RTCP packets in the RTCP compound packet. */ 83 | void GotoFirstPacket() { rtcppackit = rtcppacklist.begin(); } 84 | 85 | /** Returns a pointer to the next individual RTCP packet. 86 | * Returns a pointer to the next individual RTCP packet. Note that no \c delete call may be done 87 | * on the RTCPPacket instance which is returned. 88 | */ 89 | RTCPPacket *GetNextPacket() { if (rtcppackit == rtcppacklist.end()) return 0; RTCPPacket *p = *rtcppackit; rtcppackit++; return p; } 90 | 91 | #ifdef RTPDEBUG 92 | void Dump(); 93 | #endif // RTPDEBUG 94 | protected: 95 | void ClearPacketList(); 96 | int ParseData(uint8_t *packet, size_t len); 97 | 98 | int error; 99 | 100 | uint8_t *compoundpacket; 101 | size_t compoundpacketlength; 102 | bool deletepacket; 103 | 104 | std::list rtcppacklist; 105 | std::list::const_iterator rtcppackit; 106 | }; 107 | 108 | } // end namespace 109 | 110 | #endif // RTCPCOMPOUNDPACKET_H 111 | 112 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcppacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcppacket.h 35 | */ 36 | 37 | #ifndef RTCPPACKET_H 38 | 39 | #define RTCPPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | class RTCPCompoundPacket; 48 | 49 | /** Base class for specific types of RTCP packets. */ 50 | class JRTPLIB_IMPORTEXPORT RTCPPacket 51 | { 52 | public: 53 | /** Identifies the specific kind of RTCP packet. */ 54 | enum PacketType 55 | { 56 | SR, /**< An RTCP sender report. */ 57 | RR, /**< An RTCP receiver report. */ 58 | SDES, /**< An RTCP source description packet. */ 59 | BYE, /**< An RTCP bye packet. */ 60 | APP, /**< An RTCP packet containing application specific data. */ 61 | Unknown /**< The type of RTCP packet was not recognized. */ 62 | }; 63 | protected: 64 | RTCPPacket(PacketType t,uint8_t *d,size_t dlen) : data(d),datalen(dlen),packettype(t) { knownformat = false; } 65 | public: 66 | virtual ~RTCPPacket() { } 67 | 68 | /** Returns \c true if the subclass was able to interpret the data and \c false otherwise. */ 69 | bool IsKnownFormat() const { return knownformat; } 70 | 71 | /** Returns the actual packet type which the subclass implements. */ 72 | PacketType GetPacketType() const { return packettype; } 73 | 74 | /** Returns a pointer to the data of this RTCP packet. */ 75 | uint8_t *GetPacketData() { return data; } 76 | 77 | /** Returns the length of this RTCP packet. */ 78 | size_t GetPacketLength() const { return datalen; } 79 | 80 | #ifdef RTPDEBUG 81 | virtual void Dump(); 82 | #endif // RTPDEBUG 83 | protected: 84 | uint8_t *data; 85 | size_t datalen; 86 | bool knownformat; 87 | private: 88 | const PacketType packettype; 89 | }; 90 | 91 | } // end namespace 92 | 93 | #endif // RTCPPACKET_H 94 | 95 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcprrpacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcprrpacket.h 35 | */ 36 | 37 | #ifndef RTCPRRPACKET_H 38 | 39 | #define RTCPRRPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtcppacket.h" 43 | #include "rtpstructs.h" 44 | #ifdef RTP_SUPPORT_NETINET_IN 45 | #include 46 | #endif // RTP_SUPPORT_NETINET_IN 47 | 48 | namespace jrtplib 49 | { 50 | 51 | class RTCPCompoundPacket; 52 | 53 | /** Describes an RTCP receiver report packet. */ 54 | class JRTPLIB_IMPORTEXPORT RTCPRRPacket : public RTCPPacket 55 | { 56 | public: 57 | /** Creates an instance based on the data in \c data with length \c datalen. 58 | * Creates an instance based on the data in \c data with length \c datalen. Since the \c data pointer 59 | * is referenced inside the class (no copy of the data is made) one must make sure that the memory it points 60 | * to is valid as long as the class instance exists. 61 | */ 62 | RTCPRRPacket(uint8_t *data,size_t datalen); 63 | ~RTCPRRPacket() { } 64 | 65 | /** Returns the SSRC of the participant who sent this packet. */ 66 | uint32_t GetSenderSSRC() const; 67 | 68 | /** Returns the number of reception report blocks present in this packet. */ 69 | int GetReceptionReportCount() const; 70 | 71 | /** Returns the SSRC of the reception report block described by \c index which may have a value 72 | * from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 73 | * valid). 74 | */ 75 | uint32_t GetSSRC(int index) const; 76 | 77 | /** Returns the `fraction lost' field of the reception report described by \c index which may have 78 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 79 | * valid). 80 | */ 81 | uint8_t GetFractionLost(int index) const; 82 | 83 | /** Returns the number of lost packets in the reception report block described by \c index which may have 84 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 85 | * valid). 86 | */ 87 | int32_t GetLostPacketCount(int index) const; 88 | 89 | /** Returns the extended highest sequence number of the reception report block described by \c index which may have 90 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 91 | * valid). 92 | */ 93 | uint32_t GetExtendedHighestSequenceNumber(int index) const; 94 | 95 | /** Returns the jitter field of the reception report block described by \c index which may have 96 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 97 | * valid). 98 | */ 99 | uint32_t GetJitter(int index) const; 100 | 101 | /** Returns the LSR field of the reception report block described by \c index which may have 102 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 103 | * valid). 104 | */ 105 | uint32_t GetLSR(int index) const; 106 | 107 | /** Returns the DLSR field of the reception report block described by \c index which may have 108 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 109 | * valid). 110 | */ 111 | uint32_t GetDLSR(int index) const; 112 | 113 | 114 | #ifdef RTPDEBUG 115 | void Dump(); 116 | #endif // RTPDEBUG 117 | private: 118 | RTCPReceiverReport *GotoReport(int index) const; 119 | }; 120 | 121 | inline uint32_t RTCPRRPacket::GetSenderSSRC() const 122 | { 123 | if (!knownformat) 124 | return 0; 125 | 126 | uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader)); 127 | return ntohl(*ssrcptr); 128 | } 129 | inline int RTCPRRPacket::GetReceptionReportCount() const 130 | { 131 | if (!knownformat) 132 | return 0; 133 | RTCPCommonHeader *hdr = (RTCPCommonHeader *)data; 134 | return ((int)hdr->count); 135 | } 136 | 137 | inline RTCPReceiverReport *RTCPRRPacket::GotoReport(int index) const 138 | { 139 | RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+index*sizeof(RTCPReceiverReport)); 140 | return r; 141 | } 142 | 143 | inline uint32_t RTCPRRPacket::GetSSRC(int index) const 144 | { 145 | if (!knownformat) 146 | return 0; 147 | RTCPReceiverReport *r = GotoReport(index); 148 | return ntohl(r->ssrc); 149 | } 150 | 151 | inline uint8_t RTCPRRPacket::GetFractionLost(int index) const 152 | { 153 | if (!knownformat) 154 | return 0; 155 | RTCPReceiverReport *r = GotoReport(index); 156 | return r->fractionlost; 157 | } 158 | 159 | inline int32_t RTCPRRPacket::GetLostPacketCount(int index) const 160 | { 161 | if (!knownformat) 162 | return 0; 163 | RTCPReceiverReport *r = GotoReport(index); 164 | uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16); 165 | if ((count&0x00800000) != 0) // test for negative number 166 | count |= 0xFF000000; 167 | int32_t *count2 = (int32_t *)(&count); 168 | return (*count2); 169 | } 170 | 171 | inline uint32_t RTCPRRPacket::GetExtendedHighestSequenceNumber(int index) const 172 | { 173 | if (!knownformat) 174 | return 0; 175 | RTCPReceiverReport *r = GotoReport(index); 176 | return ntohl(r->exthighseqnr); 177 | } 178 | 179 | inline uint32_t RTCPRRPacket::GetJitter(int index) const 180 | { 181 | if (!knownformat) 182 | return 0; 183 | RTCPReceiverReport *r = GotoReport(index); 184 | return ntohl(r->jitter); 185 | } 186 | 187 | inline uint32_t RTCPRRPacket::GetLSR(int index) const 188 | { 189 | if (!knownformat) 190 | return 0; 191 | RTCPReceiverReport *r = GotoReport(index); 192 | return ntohl(r->lsr); 193 | } 194 | 195 | inline uint32_t RTCPRRPacket::GetDLSR(int index) const 196 | { 197 | if (!knownformat) 198 | return 0; 199 | RTCPReceiverReport *r = GotoReport(index); 200 | return ntohl(r->dlsr); 201 | } 202 | 203 | } // end namespace 204 | 205 | #endif // RTCPRRPACKET_H 206 | 207 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpscheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpscheduler.h 35 | */ 36 | 37 | #ifndef RTCPSCHEDULER_H 38 | 39 | #define RTCPSCHEDULER_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptimeutilities.h" 43 | #include "rtprandom.h" 44 | 45 | namespace jrtplib 46 | { 47 | 48 | class RTCPCompoundPacket; 49 | class RTPPacket; 50 | class RTPSources; 51 | 52 | /** Describes parameters used by the RTCPScheduler class. */ 53 | class JRTPLIB_IMPORTEXPORT RTCPSchedulerParams 54 | { 55 | public: 56 | RTCPSchedulerParams(); 57 | ~RTCPSchedulerParams(); 58 | 59 | /** Sets the RTCP bandwidth to be used to \c bw (in bytes per second). */ 60 | int SetRTCPBandwidth(double bw); 61 | 62 | /** Returns the used RTCP bandwidth in bytes per second (default is 1000). */ 63 | double GetRTCPBandwidth() const { return bandwidth; } 64 | 65 | /** Sets the fraction of the RTCP bandwidth reserved for senders to \c fraction. */ 66 | int SetSenderBandwidthFraction(double fraction); 67 | 68 | /** Returns the fraction of the RTCP bandwidth reserved for senders (default is 25%). */ 69 | double GetSenderBandwidthFraction() const { return senderfraction; } 70 | 71 | /** Sets the minimum (deterministic) interval between RTCP compound packets to \c t. */ 72 | int SetMinimumTransmissionInterval(const RTPTime &t); 73 | 74 | /** Returns the minimum RTCP transmission interval (default is 5 seconds). */ 75 | RTPTime GetMinimumTransmissionInterval() const { return mininterval; } 76 | 77 | /** If \c usehalf is \c true, only use half the minimum interval before sending the first RTCP compound packet. */ 78 | void SetUseHalfAtStartup(bool usehalf) { usehalfatstartup = usehalf; } 79 | 80 | /** Returns \c true if only half the minimum interval should be used before sending the first RTCP compound packet 81 | * (defualt is \c true). 82 | */ 83 | bool GetUseHalfAtStartup() const { return usehalfatstartup; } 84 | 85 | /** If \c v is \c true, the scheduler will schedule a BYE packet to be sent immediately if allowed. */ 86 | void SetRequestImmediateBYE(bool v) { immediatebye = v; } 87 | 88 | /** Returns if the scheduler will schedule a BYE packet to be sent immediately if allowed 89 | * (default is \c true). 90 | */ 91 | bool GetRequestImmediateBYE() const { return immediatebye; } 92 | private: 93 | double bandwidth; 94 | double senderfraction; 95 | RTPTime mininterval; 96 | bool usehalfatstartup; 97 | bool immediatebye; 98 | }; 99 | 100 | /** This class determines when RTCP compound packets should be sent. */ 101 | class JRTPLIB_IMPORTEXPORT RTCPScheduler 102 | { 103 | public: 104 | /** Creates an instance which will use the source table RTPSources to determine when RTCP compound 105 | * packets should be scheduled. 106 | * Creates an instance which will use the source table RTPSources to determine when RTCP compound 107 | * packets should be scheduled. Note that for correct operation the \c sources instance should have information 108 | * about the own SSRC (added by RTPSources::CreateOwnSSRC). You must also supply a random number 109 | * generator \c rtprand which will be used for adding randomness to the RTCP intervals. 110 | */ 111 | RTCPScheduler(RTPSources &sources, RTPRandom &rtprand); 112 | ~RTCPScheduler(); 113 | 114 | /** Resets the scheduler. */ 115 | void Reset(); 116 | 117 | /** Sets the scheduler parameters to be used to \c params. */ 118 | void SetParameters(const RTCPSchedulerParams ¶ms) { schedparams = params; } 119 | 120 | /** Returns the currently used scheduler parameters. */ 121 | RTCPSchedulerParams GetParameters() const { return schedparams; } 122 | 123 | /** Sets the header overhead from underlying protocols (for example UDP and IP) to \c numbytes. */ 124 | void SetHeaderOverhead(size_t numbytes) { headeroverhead = numbytes; } 125 | 126 | /** Returns the currently used header overhead. */ 127 | size_t GetHeaderOverhead() const { return headeroverhead; } 128 | 129 | /** For each incoming RTCP compound packet, this function has to be called for the scheduler to work correctly. */ 130 | void AnalyseIncoming(RTCPCompoundPacket &rtcpcomppack); 131 | 132 | /** For each outgoing RTCP compound packet, this function has to be called for the scheduler to work correctly. */ 133 | void AnalyseOutgoing(RTCPCompoundPacket &rtcpcomppack); 134 | 135 | /** This function has to be called each time a member times out or sends a BYE packet. */ 136 | void ActiveMemberDecrease(); 137 | 138 | /** Asks the scheduler to schedule an RTCP compound packet containing a BYE packetl; the compound packet 139 | * has size \c packetsize. 140 | */ 141 | void ScheduleBYEPacket(size_t packetsize); 142 | 143 | /** Returns the delay after which an RTCP compound will possibly have to be sent. 144 | * Returns the delay after which an RTCP compound will possibly have to be sent. The IsTime member function 145 | * should be called afterwards to make sure that it actually is time to send an RTCP compound packet. 146 | */ 147 | RTPTime GetTransmissionDelay(); 148 | 149 | /** This function returns \c true if it's time to send an RTCP compound packet and \c false otherwise. 150 | * This function returns \c true if it's time to send an RTCP compound packet and \c false otherwise. 151 | * If the function returns \c true, it will also have calculated the next time at which a packet should 152 | * be sent, so if it is called again right away, it will return \c false. 153 | */ 154 | bool IsTime(); 155 | 156 | /** Calculates the deterministic interval at this time. 157 | * Calculates the deterministic interval at this time. This is used - in combination with a certain multiplier - 158 | * to time out members, senders etc. 159 | */ 160 | RTPTime CalculateDeterministicInterval(bool sender = false); 161 | private: 162 | void CalculateNextRTCPTime(); 163 | void PerformReverseReconsideration(); 164 | RTPTime CalculateBYETransmissionInterval(); 165 | RTPTime CalculateTransmissionInterval(bool sender); 166 | 167 | RTPSources &sources; 168 | RTCPSchedulerParams schedparams; 169 | size_t headeroverhead; 170 | size_t avgrtcppacksize; 171 | bool hassentrtcp; 172 | bool firstcall; 173 | RTPTime nextrtcptime; 174 | RTPTime prevrtcptime; 175 | int pmembers; 176 | 177 | // for BYE packet scheduling 178 | bool byescheduled; 179 | int byemembers,pbyemembers; 180 | size_t avgbyepacketsize; 181 | bool sendbyenow; 182 | 183 | RTPRandom &rtprand; 184 | }; 185 | 186 | } // end namespace 187 | 188 | #endif // RTCPSCHEDULER_H 189 | 190 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpsrpacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpsrpacket.h 35 | */ 36 | 37 | #ifndef RTCPSRPACKET_H 38 | 39 | #define RTCPSRPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtcppacket.h" 43 | #include "rtptimeutilities.h" 44 | #include "rtpstructs.h" 45 | #ifdef RTP_SUPPORT_NETINET_IN 46 | #include 47 | #endif // RTP_SUPPORT_NETINET_IN 48 | 49 | namespace jrtplib 50 | { 51 | 52 | class RTCPCompoundPacket; 53 | 54 | /** Describes an RTCP sender report packet. */ 55 | class JRTPLIB_IMPORTEXPORT RTCPSRPacket : public RTCPPacket 56 | { 57 | public: 58 | /** Creates an instance based on the data in \c data with length \c datalen. 59 | * Creates an instance based on the data in \c data with length \c datalen. Since the \c data pointer 60 | * is referenced inside the class (no copy of the data is made) one must make sure that the memory it 61 | * points to is valid as long as the class instance exists. 62 | */ 63 | RTCPSRPacket(uint8_t *data,size_t datalength); 64 | ~RTCPSRPacket() { } 65 | 66 | /** Returns the SSRC of the participant who sent this packet. */ 67 | uint32_t GetSenderSSRC() const; 68 | 69 | /** Returns the NTP timestamp contained in the sender report. */ 70 | RTPNTPTime GetNTPTimestamp() const; 71 | 72 | /** Returns the RTP timestamp contained in the sender report. */ 73 | uint32_t GetRTPTimestamp() const; 74 | 75 | /** Returns the sender's packet count contained in the sender report. */ 76 | uint32_t GetSenderPacketCount() const; 77 | 78 | /** Returns the sender's octet count contained in the sender report. */ 79 | uint32_t GetSenderOctetCount() const; 80 | 81 | /** Returns the number of reception report blocks present in this packet. */ 82 | int GetReceptionReportCount() const; 83 | 84 | /** Returns the SSRC of the reception report block described by \c index which may have a value 85 | * from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 86 | * valid). 87 | */ 88 | uint32_t GetSSRC(int index) const; 89 | 90 | /** Returns the `fraction lost' field of the reception report described by \c index which may have 91 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 92 | * valid). 93 | */ 94 | uint8_t GetFractionLost(int index) const; 95 | 96 | /** Returns the number of lost packets in the reception report block described by \c index which may have 97 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 98 | * valid). 99 | */ 100 | int32_t GetLostPacketCount(int index) const; 101 | 102 | /** Returns the extended highest sequence number of the reception report block described by \c index which may have 103 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 104 | * valid). 105 | */ 106 | uint32_t GetExtendedHighestSequenceNumber(int index) const; 107 | 108 | /** Returns the jitter field of the reception report block described by \c index which may have 109 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 110 | * valid). 111 | */ 112 | uint32_t GetJitter(int index) const; 113 | 114 | /** Returns the LSR field of the reception report block described by \c index which may have 115 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 116 | * valid). 117 | */ 118 | uint32_t GetLSR(int index) const; 119 | 120 | /** Returns the DLSR field of the reception report block described by \c index which may have 121 | * a value from 0 to GetReceptionReportCount()-1 (note that no check is performed to see if \c index is 122 | * valid). 123 | */ 124 | uint32_t GetDLSR(int index) const; 125 | 126 | #ifdef RTPDEBUG 127 | void Dump(); 128 | #endif // RTPDEBUG 129 | private: 130 | RTCPReceiverReport *GotoReport(int index) const; 131 | }; 132 | 133 | inline uint32_t RTCPSRPacket::GetSenderSSRC() const 134 | { 135 | if (!knownformat) 136 | return 0; 137 | 138 | uint32_t *ssrcptr = (uint32_t *)(data+sizeof(RTCPCommonHeader)); 139 | return ntohl(*ssrcptr); 140 | } 141 | 142 | inline RTPNTPTime RTCPSRPacket::GetNTPTimestamp() const 143 | { 144 | if (!knownformat) 145 | return RTPNTPTime(0,0); 146 | 147 | RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); 148 | return RTPNTPTime(ntohl(sr->ntptime_msw),ntohl(sr->ntptime_lsw)); 149 | } 150 | 151 | inline uint32_t RTCPSRPacket::GetRTPTimestamp() const 152 | { 153 | if (!knownformat) 154 | return 0; 155 | RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); 156 | return ntohl(sr->rtptimestamp); 157 | } 158 | 159 | inline uint32_t RTCPSRPacket::GetSenderPacketCount() const 160 | { 161 | if (!knownformat) 162 | return 0; 163 | RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); 164 | return ntohl(sr->packetcount); 165 | } 166 | 167 | inline uint32_t RTCPSRPacket::GetSenderOctetCount() const 168 | { 169 | if (!knownformat) 170 | return 0; 171 | RTCPSenderReport *sr = (RTCPSenderReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); 172 | return ntohl(sr->octetcount); 173 | } 174 | 175 | inline int RTCPSRPacket::GetReceptionReportCount() const 176 | { 177 | if (!knownformat) 178 | return 0; 179 | RTCPCommonHeader *hdr = (RTCPCommonHeader *)data; 180 | return ((int)hdr->count); 181 | } 182 | 183 | inline RTCPReceiverReport *RTCPSRPacket::GotoReport(int index) const 184 | { 185 | RTCPReceiverReport *r = (RTCPReceiverReport *)(data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)+sizeof(RTCPSenderReport)+index*sizeof(RTCPReceiverReport)); 186 | return r; 187 | } 188 | 189 | inline uint32_t RTCPSRPacket::GetSSRC(int index) const 190 | { 191 | if (!knownformat) 192 | return 0; 193 | RTCPReceiverReport *r = GotoReport(index); 194 | return ntohl(r->ssrc); 195 | } 196 | 197 | inline uint8_t RTCPSRPacket::GetFractionLost(int index) const 198 | { 199 | if (!knownformat) 200 | return 0; 201 | RTCPReceiverReport *r = GotoReport(index); 202 | return r->fractionlost; 203 | } 204 | 205 | inline int32_t RTCPSRPacket::GetLostPacketCount(int index) const 206 | { 207 | if (!knownformat) 208 | return 0; 209 | RTCPReceiverReport *r = GotoReport(index); 210 | uint32_t count = ((uint32_t)r->packetslost[2])|(((uint32_t)r->packetslost[1])<<8)|(((uint32_t)r->packetslost[0])<<16); 211 | if ((count&0x00800000) != 0) // test for negative number 212 | count |= 0xFF000000; 213 | int32_t *count2 = (int32_t *)(&count); 214 | return (*count2); 215 | } 216 | 217 | inline uint32_t RTCPSRPacket::GetExtendedHighestSequenceNumber(int index) const 218 | { 219 | if (!knownformat) 220 | return 0; 221 | RTCPReceiverReport *r = GotoReport(index); 222 | return ntohl(r->exthighseqnr); 223 | } 224 | 225 | inline uint32_t RTCPSRPacket::GetJitter(int index) const 226 | { 227 | if (!knownformat) 228 | return 0; 229 | RTCPReceiverReport *r = GotoReport(index); 230 | return ntohl(r->jitter); 231 | } 232 | 233 | inline uint32_t RTCPSRPacket::GetLSR(int index) const 234 | { 235 | if (!knownformat) 236 | return 0; 237 | RTCPReceiverReport *r = GotoReport(index); 238 | return ntohl(r->lsr); 239 | } 240 | 241 | inline uint32_t RTCPSRPacket::GetDLSR(int index) const 242 | { 243 | if (!knownformat) 244 | return 0; 245 | RTCPReceiverReport *r = GotoReport(index); 246 | return ntohl(r->dlsr); 247 | } 248 | 249 | } // end namespace 250 | 251 | #endif // RTCPSRPACKET_H 252 | 253 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtcpunknownpacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtcpunknownpacket.h 35 | */ 36 | 37 | #ifndef RTCPUNKNOWNPACKET_H 38 | 39 | #define RTCPUNKNOWNPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtcppacket.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | class RTCPCompoundPacket; 48 | 49 | /** Describes an RTCP packet of unknown type. 50 | * Describes an RTCP packet of unknown type. This class doesn't have any extra member functions besides 51 | * the ones it inherited. Note that since an unknown packet type doesn't have any format to check 52 | * against, the IsKnownFormat function will trivially return \c true. 53 | */ 54 | class JRTPLIB_IMPORTEXPORT RTCPUnknownPacket : public RTCPPacket 55 | { 56 | public: 57 | /** Creates an instance based on the data in \c data with length \c datalen. 58 | * Creates an instance based on the data in \c data with length \c datalen. Since the \c data pointer 59 | * is referenced inside the class (no copy of the data is made) one must make sure that the memory it 60 | * points to is valid as long as the class instance exists. 61 | */ 62 | RTCPUnknownPacket(uint8_t *data,size_t datalen) : RTCPPacket(Unknown,data,datalen) 63 | { 64 | // Since we don't expect a format, we'll trivially put knownformat = true 65 | knownformat = true; 66 | } 67 | ~RTCPUnknownPacket() { } 68 | }; 69 | 70 | } // end namespace 71 | 72 | #endif // RTCPUNKNOWNPACKET_H 73 | 74 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpabortdescriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpabortdescriptors.h 35 | */ 36 | 37 | #ifndef RTPABORTDESCRIPTORS_H 38 | 39 | #define RTPABORTDESCRIPTORS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpsocketutil.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | /** 48 | * Helper class for several RTPTransmitter instances, to be able to cancel a 49 | * call to 'select', 'poll' or 'WSAPoll'. 50 | * 51 | * This is a helper class for several RTPTransmitter instances. Typically a 52 | * call to 'select' (or 'poll' or 'WSAPoll', depending on the platform) is used 53 | * to wait for incoming data for a certain time. To be able to cancel this wait 54 | * from another thread, this class provides a socket descriptor that's compatible 55 | * with e.g. the 'select' call, and to which data can be sent using 56 | * RTPAbortDescriptors::SendAbortSignal. If the descriptor is included in the 57 | * 'select' call, the function will detect incoming data and the function stops 58 | * waiting for incoming data. 59 | * 60 | * The class can be useful in case you'd like to create an implementation which 61 | * uses a single poll thread for several RTPSession and RTPTransmitter instances. 62 | * This idea is further illustrated in `example8.cpp`. 63 | */ 64 | class JRTPLIB_IMPORTEXPORT RTPAbortDescriptors 65 | { 66 | public: 67 | RTPAbortDescriptors(); 68 | ~RTPAbortDescriptors(); 69 | 70 | /** Initializes this instance. */ 71 | int Init(); 72 | 73 | /** Returns the socket descriptor that can be included in a call to 74 | * 'select' (for example).*/ 75 | SocketType GetAbortSocket() const { return m_descriptors[0]; } 76 | 77 | /** Returns a flag indicating if this instance was initialized. */ 78 | bool IsInitialized() const { return m_init; } 79 | 80 | /** De-initializes this instance. */ 81 | void Destroy(); 82 | 83 | /** Send a signal to the socket that's returned by RTPAbortDescriptors::GetAbortSocket, 84 | * causing the 'select' call to detect that data is available, making the call 85 | * end. */ 86 | int SendAbortSignal(); 87 | 88 | /** For each RTPAbortDescriptors::SendAbortSignal function that's called, a call 89 | * to this function can be made to clear the state again. */ 90 | int ReadSignallingByte(); 91 | 92 | /** Similar to ReadSignallingByte::ReadSignallingByte, this function clears the signalling 93 | * state, but this also works independently from the amount of times that 94 | * RTPAbortDescriptors::SendAbortSignal was called. */ 95 | int ClearAbortSignal(); 96 | private: 97 | SocketType m_descriptors[2]; 98 | bool m_init; 99 | }; 100 | 101 | } // end namespace 102 | 103 | #endif // RTPABORTDESCRIPTORS_H 104 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpaddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpaddress.h 35 | */ 36 | 37 | #ifndef RTPADDRESS_H 38 | 39 | #define RTPADDRESS_H 40 | 41 | #include "rtpconfig.h" 42 | #include 43 | 44 | namespace jrtplib 45 | { 46 | 47 | class RTPMemoryManager; 48 | 49 | /** This class is an abstract class which is used to specify destinations, multicast groups etc. */ 50 | class JRTPLIB_IMPORTEXPORT RTPAddress 51 | { 52 | public: 53 | /** Identifies the actual implementation being used. */ 54 | enum AddressType 55 | { 56 | IPv4Address, /**< Used by the UDP over IPv4 transmitter. */ 57 | IPv6Address, /**< Used by the UDP over IPv6 transmitter. */ 58 | ByteAddress, /**< A very general type of address, consisting of a port number and a number of bytes representing the host address. */ 59 | UserDefinedAddress, /**< Can be useful for a user-defined transmitter. */ 60 | TCPAddress /**< Used by the TCP transmitter. */ 61 | }; 62 | 63 | /** Returns the type of address the actual implementation represents. */ 64 | AddressType GetAddressType() const { return addresstype; } 65 | 66 | /** Creates a copy of the RTPAddress instance. 67 | * Creates a copy of the RTPAddress instance. If \c mgr is not NULL, the 68 | * corresponding memory manager will be used to allocate the memory for the address 69 | * copy. 70 | */ 71 | virtual RTPAddress *CreateCopy(RTPMemoryManager *mgr) const = 0; 72 | 73 | /** Checks if the address \c addr is the same address as the one this instance represents. 74 | * Checks if the address \c addr is the same address as the one this instance represents. 75 | * Implementations must be able to handle a NULL argument. 76 | */ 77 | virtual bool IsSameAddress(const RTPAddress *addr) const = 0; 78 | 79 | /** Checks if the address \c addr represents the same host as this instance. 80 | * Checks if the address \c addr represents the same host as this instance. Implementations 81 | * must be able to handle a NULL argument. 82 | */ 83 | virtual bool IsFromSameHost(const RTPAddress *addr) const = 0; 84 | 85 | #ifdef RTPDEBUG 86 | virtual std::string GetAddressString() const = 0; 87 | #endif // RTPDEBUG 88 | 89 | virtual ~RTPAddress() { } 90 | protected: 91 | // only allow subclasses to be created 92 | RTPAddress(const AddressType t) : addresstype(t) { } 93 | private: 94 | const AddressType addresstype; 95 | }; 96 | 97 | } // end namespace 98 | 99 | #endif // RTPADDRESS_H 100 | 101 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpbyteaddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpbyteaddress.h 35 | */ 36 | 37 | #ifndef RTPBYTEADDRESS_H 38 | 39 | #define RTPBYTEADDRESS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpaddress.h" 43 | #include "rtptypes.h" 44 | #include 45 | 46 | #define RTPBYTEADDRESS_MAXLENGTH 128 47 | 48 | namespace jrtplib 49 | { 50 | 51 | class RTPMemoryManager; 52 | 53 | /** A very general kind of address consisting of a port number and a number of bytes describing the host address. 54 | * A very general kind of address, consisting of a port number and a number of bytes describing the host address. 55 | */ 56 | class JRTPLIB_IMPORTEXPORT RTPByteAddress : public RTPAddress 57 | { 58 | public: 59 | /** Creates an instance of the class using \c addrlen bytes of \c hostaddress as host identification, 60 | * and using \c port as the port number. */ 61 | RTPByteAddress(const uint8_t hostaddress[RTPBYTEADDRESS_MAXLENGTH], size_t addrlen, uint16_t port = 0) : RTPAddress(ByteAddress) { if (addrlen > RTPBYTEADDRESS_MAXLENGTH) addrlen = RTPBYTEADDRESS_MAXLENGTH; memcpy(RTPByteAddress::hostaddress, hostaddress, addrlen); RTPByteAddress::addresslength = addrlen; RTPByteAddress::port = port; } 62 | 63 | /** Sets the host address to the first \c addrlen bytes of \c hostaddress. */ 64 | void SetHostAddress(const uint8_t hostaddress[RTPBYTEADDRESS_MAXLENGTH], size_t addrlen) { if (addrlen > RTPBYTEADDRESS_MAXLENGTH) addrlen = RTPBYTEADDRESS_MAXLENGTH; memcpy(RTPByteAddress::hostaddress, hostaddress, addrlen); RTPByteAddress::addresslength = addrlen; } 65 | 66 | /** Sets the port number to \c port. */ 67 | void SetPort(uint16_t port) { RTPByteAddress::port = port; } 68 | 69 | /** Returns a pointer to the stored host address. */ 70 | const uint8_t *GetHostAddress() const { return hostaddress; } 71 | 72 | /** Returns the length in bytes of the stored host address. */ 73 | size_t GetHostAddressLength() const { return addresslength; } 74 | 75 | /** Returns the port number stored in this instance. */ 76 | uint16_t GetPort() const { return port; } 77 | 78 | RTPAddress *CreateCopy(RTPMemoryManager *mgr) const; 79 | bool IsSameAddress(const RTPAddress *addr) const; 80 | bool IsFromSameHost(const RTPAddress *addr) const; 81 | #ifdef RTPDEBUG 82 | std::string GetAddressString() const; 83 | #endif // RTPDEBUG 84 | private: 85 | uint8_t hostaddress[RTPBYTEADDRESS_MAXLENGTH]; 86 | size_t addresslength; 87 | uint16_t port; 88 | }; 89 | 90 | } // end namespace 91 | 92 | #endif // RTPBYTEADDRESS_H 93 | 94 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpcollisionlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpcollisionlist.h 35 | */ 36 | 37 | #ifndef RTPCOLLISIONLIST_H 38 | 39 | #define RTPCOLLISIONLIST_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpaddress.h" 43 | #include "rtptimeutilities.h" 44 | #include "rtpmemoryobject.h" 45 | #include 46 | 47 | namespace jrtplib 48 | { 49 | 50 | class RTPAddress; 51 | 52 | /** This class represents a list of addresses from which SSRC collisions were detected. */ 53 | class JRTPLIB_IMPORTEXPORT RTPCollisionList : public RTPMemoryObject 54 | { 55 | public: 56 | /** Constructs an instance, optionally installing a memory manager. */ 57 | RTPCollisionList(RTPMemoryManager *mgr = 0); 58 | ~RTPCollisionList() { Clear(); } 59 | 60 | /** Clears the list of addresses. */ 61 | void Clear(); 62 | 63 | /** Updates the entry for address \c addr to indicate that a collision was detected at time \c receivetime. 64 | * Updates the entry for address \c addr to indicate that a collision was detected at time \c receivetime. 65 | * If the entry did not exist yet, the flag \c created is set to \c true, otherwise it is set to \c false. 66 | */ 67 | int UpdateAddress(const RTPAddress *addr,const RTPTime &receivetime,bool *created); 68 | 69 | /** Returns \c true} if the address \c addr appears in the list. */ 70 | bool HasAddress(const RTPAddress *addr) const; 71 | 72 | /** Assuming that the current time is given by \c currenttime, this function times out entries which 73 | * haven't been updated in the previous time interval specified by \c timeoutdelay. 74 | */ 75 | void Timeout(const RTPTime ¤ttime,const RTPTime &timeoutdelay); 76 | #ifdef RTPDEBUG 77 | void Dump(); 78 | #endif // RTPDEBUG 79 | private: 80 | class AddressAndTime 81 | { 82 | public: 83 | AddressAndTime(RTPAddress *a,const RTPTime &t) : addr(a),recvtime(t) { } 84 | 85 | RTPAddress *addr; 86 | RTPTime recvtime; 87 | }; 88 | 89 | std::list addresslist; 90 | }; 91 | 92 | } // end namespace 93 | 94 | #endif // RTPCOLLISIONLIST_H 95 | 96 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | #ifndef RTPCONFIG_UNIX_H 34 | 35 | #define RTPCONFIG_UNIX_H 36 | 37 | #ifndef JRTPLIB_UNUSED 38 | /** 39 | * Provide a macro to use for marking method parameters as unused. 40 | */ 41 | #define JRTPLIB_UNUSED(x) (void)(x) 42 | #endif // JRTPLIB_UNUSED 43 | 44 | #define JRTPLIB_IMPORT 45 | #define JRTPLIB_EXPORT 46 | #ifdef JRTPLIB_COMPILING 47 | #define JRTPLIB_IMPORTEXPORT JRTPLIB_EXPORT 48 | #else 49 | #define JRTPLIB_IMPORTEXPORT JRTPLIB_IMPORT 50 | #endif // JRTPLIB_COMPILING 51 | 52 | // Don't have 53 | 54 | // Don't have 55 | 56 | // Little endian system 57 | 58 | #define RTP_SOCKLENTYPE_UINT 59 | 60 | // No sa_len member in struct sockaddr 61 | 62 | #define RTP_SUPPORT_IPV4MULTICAST 63 | 64 | // No support for JThread was enabled 65 | 66 | #define RTP_SUPPORT_SDESPRIV 67 | 68 | #define RTP_SUPPORT_PROBATION 69 | 70 | #define RTP_SUPPORT_GETLOGINR 71 | 72 | #define RTP_SUPPORT_IPV6 73 | 74 | #define RTP_SUPPORT_IPV6MULTICAST 75 | 76 | #define RTP_SUPPORT_IFADDRS 77 | 78 | #define RTP_SUPPORT_SENDAPP 79 | 80 | #define RTP_SUPPORT_MEMORYMANAGEMENT 81 | 82 | // No support for sending unknown RTCP packets 83 | 84 | #define RTP_SUPPORT_NETINET_IN 85 | 86 | // Not using winsock sockets 87 | 88 | // No QueryPerformanceCounter support 89 | 90 | // No ui64 suffix 91 | 92 | // Stdio snprintf version 93 | 94 | #define RTP_HAVE_ARRAYALLOC 95 | 96 | // No rand_s support 97 | 98 | // No strncpy_s support 99 | 100 | // No SRTP support 101 | 102 | // No clock_gettime support 103 | 104 | #define RTP_HAVE_POLL 105 | 106 | // No 'WSAPoll' support 107 | 108 | #define RTP_HAVE_MSG_NOSIGNAL 109 | 110 | #endif // RTPCONFIG_UNIX_H 111 | 112 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpdebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | #ifndef RTPDEBUG_H 34 | 35 | #define RTPDEBUG_H 36 | 37 | #include "rtpconfig.h" 38 | 39 | #ifdef RTPDEBUG 40 | #include "rtptypes.h" 41 | 42 | void *operator new(size_t s,char filename[],int line); 43 | #ifdef RTP_HAVE_ARRAYALLOC 44 | void *operator new[](size_t s,char filename[],int line); 45 | #define new new ((char*)__FILE__,__LINE__) 46 | #else 47 | #define new new ((char*)__FILE__,__LINE__) 48 | #endif // RTP_HAVE_ARRAYALLOC 49 | #endif // RTPDEBUG 50 | 51 | #endif // RTPDEBUG_H 52 | 53 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpdefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | #ifndef RTPDEFINES_H 34 | 35 | #define RTPDEFINES_H 36 | 37 | #define RTP_VERSION 2 38 | #define RTP_MAXCSRCS 15 39 | #define RTP_MINPACKETSIZE 600 40 | #define RTP_DEFAULTPACKETSIZE 1400 41 | #define RTP_PROBATIONCOUNT 2 42 | #define RTP_MAXPRIVITEMS 256 43 | #define RTP_SENDERTIMEOUTMULTIPLIER 2 44 | #define RTP_BYETIMEOUTMULTIPLIER 1 45 | #define RTP_MEMBERTIMEOUTMULTIPLIER 5 46 | #define RTP_COLLISIONTIMEOUTMULTIPLIER 10 47 | #define RTP_NOTETTIMEOUTMULTIPLIER 25 48 | #define RTP_DEFAULTSESSIONBANDWIDTH 10000.0 49 | 50 | #define RTP_RTCPTYPE_SR 200 51 | #define RTP_RTCPTYPE_RR 201 52 | #define RTP_RTCPTYPE_SDES 202 53 | #define RTP_RTCPTYPE_BYE 203 54 | #define RTP_RTCPTYPE_APP 204 55 | 56 | #define RTCP_SDES_ID_CNAME 1 57 | #define RTCP_SDES_ID_NAME 2 58 | #define RTCP_SDES_ID_EMAIL 3 59 | #define RTCP_SDES_ID_PHONE 4 60 | #define RTCP_SDES_ID_LOCATION 5 61 | #define RTCP_SDES_ID_TOOL 6 62 | #define RTCP_SDES_ID_NOTE 7 63 | #define RTCP_SDES_ID_PRIVATE 8 64 | #define RTCP_SDES_NUMITEMS_NONPRIVATE 7 65 | #define RTCP_SDES_MAXITEMLENGTH 255 66 | 67 | #define RTCP_BYE_MAXREASONLENGTH 255 68 | #define RTCP_DEFAULTMININTERVAL 5.0 69 | #define RTCP_DEFAULTBANDWIDTHFRACTION 0.05 70 | #define RTCP_DEFAULTSENDERFRACTION 0.25 71 | #define RTCP_DEFAULTHALFATSTARTUP true 72 | #define RTCP_DEFAULTIMMEDIATEBYE true 73 | #define RTCP_DEFAULTSRBYE true 74 | 75 | #endif // RTPDEFINES_H 76 | 77 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpinternalsourcedata.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpinternalsourcedata.h 35 | */ 36 | 37 | #ifndef RTPINTERNALSOURCEDATA_H 38 | 39 | #define RTPINTERNALSOURCEDATA_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpsourcedata.h" 43 | #include "rtpaddress.h" 44 | #include "rtptimeutilities.h" 45 | #include "rtpsources.h" 46 | 47 | namespace jrtplib 48 | { 49 | 50 | class JRTPLIB_IMPORTEXPORT RTPInternalSourceData : public RTPSourceData 51 | { 52 | public: 53 | RTPInternalSourceData(uint32_t ssrc, RTPSources::ProbationType probtype, RTPMemoryManager *mgr = 0); 54 | ~RTPInternalSourceData(); 55 | 56 | int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,bool *stored, RTPSources *sources); 57 | void ProcessSenderInfo(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t packetcount, 58 | uint32_t octetcount,const RTPTime &receivetime) { SRprevinf = SRinf; SRinf.Set(ntptime,rtptime,packetcount,octetcount,receivetime); stats.SetLastMessageTime(receivetime); } 59 | void ProcessReportBlock(uint8_t fractionlost,int32_t lostpackets,uint32_t exthighseqnr, 60 | uint32_t jitter,uint32_t lsr,uint32_t dlsr, 61 | const RTPTime &receivetime) { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); } 62 | void UpdateMessageTime(const RTPTime &receivetime) { stats.SetLastMessageTime(receivetime); } 63 | int ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis); 64 | #ifdef RTP_SUPPORT_SDESPRIV 65 | int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime); 66 | #endif // RTP_SUPPORT_SDESPRIV 67 | int ProcessBYEPacket(const uint8_t *reason,size_t reasonlen,const RTPTime &receivetime); 68 | 69 | int SetRTPDataAddress(const RTPAddress *a); 70 | int SetRTCPDataAddress(const RTPAddress *a); 71 | 72 | void ClearSenderFlag() { issender = false; } 73 | void SentRTPPacket() { if (!ownssrc) return; RTPTime t = RTPTime::CurrentTime(); issender = true; stats.SetLastRTPPacketTime(t); stats.SetLastMessageTime(t); } 74 | void SetOwnSSRC() { ownssrc = true; validated = true; } 75 | void SetCSRC() { validated = true; iscsrc = true; } 76 | void ClearNote() { SDESinf.SetNote(0,0); } 77 | 78 | #ifdef RTP_SUPPORT_PROBATION 79 | private: 80 | RTPSources::ProbationType probationtype; 81 | #endif // RTP_SUPPORT_PROBATION 82 | }; 83 | 84 | inline int RTPInternalSourceData::SetRTPDataAddress(const RTPAddress *a) 85 | { 86 | if (a == 0) 87 | { 88 | if (rtpaddr) 89 | { 90 | RTPDelete(rtpaddr,GetMemoryManager()); 91 | rtpaddr = 0; 92 | } 93 | } 94 | else 95 | { 96 | RTPAddress *newaddr = a->CreateCopy(GetMemoryManager()); 97 | if (newaddr == 0) 98 | return ERR_RTP_OUTOFMEM; 99 | 100 | if (rtpaddr && a != rtpaddr) 101 | RTPDelete(rtpaddr,GetMemoryManager()); 102 | rtpaddr = newaddr; 103 | } 104 | isrtpaddrset = true; 105 | return 0; 106 | } 107 | 108 | inline int RTPInternalSourceData::SetRTCPDataAddress(const RTPAddress *a) 109 | { 110 | if (a == 0) 111 | { 112 | if (rtcpaddr) 113 | { 114 | RTPDelete(rtcpaddr,GetMemoryManager()); 115 | rtcpaddr = 0; 116 | } 117 | } 118 | else 119 | { 120 | RTPAddress *newaddr = a->CreateCopy(GetMemoryManager()); 121 | if (newaddr == 0) 122 | return ERR_RTP_OUTOFMEM; 123 | 124 | if (rtcpaddr && a != rtcpaddr) 125 | RTPDelete(rtcpaddr,GetMemoryManager()); 126 | rtcpaddr = newaddr; 127 | } 128 | isrtcpaddrset = true; 129 | return 0; 130 | } 131 | 132 | } // end namespace 133 | 134 | #endif // RTPINTERNALSOURCEDATA_H 135 | 136 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpipv4address.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpipv4address.h 35 | */ 36 | 37 | #ifndef RTPIPV4ADDRESS_H 38 | 39 | #define RTPIPV4ADDRESS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpaddress.h" 43 | #include "rtptypes.h" 44 | 45 | namespace jrtplib 46 | { 47 | 48 | class RTPMemoryManager; 49 | 50 | /** Represents an IPv4 IP address and port. 51 | * This class is used by the UDP over IPv4 transmission component. 52 | * When an RTPIPv4Address is used in one of the multicast functions of the transmitter, the port 53 | * number is ignored. When an instance is used in one of the accept or ignore functions of the 54 | * transmitter, a zero port number represents all ports for the specified IP address. 55 | */ 56 | class JRTPLIB_IMPORTEXPORT RTPIPv4Address : public RTPAddress 57 | { 58 | public: 59 | /** Creates an instance with IP address \c ip and port number \c port (both 60 | * are interpreted in host byte order), and possibly sets the RTCP multiplex flag 61 | * (see RTPIPv4Address::UseRTCPMultiplexingOnTransmission). */ 62 | RTPIPv4Address(uint32_t ip = 0, uint16_t port = 0,bool rtcpmux = false):RTPAddress(IPv4Address) 63 | { 64 | RTPIPv4Address::ip = ip; 65 | RTPIPv4Address::port = port; 66 | if (rtcpmux) 67 | rtcpsendport = port; 68 | else 69 | rtcpsendport = port+1; 70 | } 71 | 72 | /** Creates an instance with IP address \c ip and port number \c port (both 73 | * are interpreted in host byte order), and sets a specific port to 74 | * send RTCP packets to (see RTPIPv4Address::GetRTCPSendPort). */ 75 | RTPIPv4Address(uint32_t ip, uint16_t port, uint16_t rtcpsendport):RTPAddress(IPv4Address) 76 | { 77 | RTPIPv4Address::ip = ip; 78 | RTPIPv4Address::port = port; 79 | RTPIPv4Address::rtcpsendport = rtcpsendport; 80 | } 81 | 82 | /** Creates an instance with IP address \c ip and port number \c port (\c port is 83 | * interpreted in host byte order) and possibly sets the RTCP multiplex flag 84 | * (see RTPIPv4Address::UseRTCPMultiplexingOnTransmission). */ 85 | RTPIPv4Address(const uint8_t ip[4],uint16_t port = 0,bool rtcpmux = false):RTPAddress(IPv4Address) 86 | { 87 | RTPIPv4Address::ip = (uint32_t)ip[3]; 88 | RTPIPv4Address::ip |= (((uint32_t)ip[2])<<8); 89 | RTPIPv4Address::ip |= (((uint32_t)ip[1])<<16); 90 | RTPIPv4Address::ip |= (((uint32_t)ip[0])<<24); 91 | 92 | RTPIPv4Address::port = port; 93 | if (rtcpmux) 94 | rtcpsendport = port; 95 | else 96 | rtcpsendport = port+1; 97 | } 98 | 99 | /** Creates an instance with IP address \c ip and port number \c port (both 100 | * are interpreted in host byte order), and sets a specific port to 101 | * send RTCP packets to (see RTPIPv4Address::GetRTCPSendPort). */ 102 | RTPIPv4Address(const uint8_t ip[4],uint16_t port,uint16_t rtcpsendport):RTPAddress(IPv4Address) 103 | { 104 | RTPIPv4Address::ip = (uint32_t)ip[3]; 105 | RTPIPv4Address::ip |= (((uint32_t)ip[2])<<8); 106 | RTPIPv4Address::ip |= (((uint32_t)ip[1])<<16); 107 | RTPIPv4Address::ip |= (((uint32_t)ip[0])<<24); 108 | 109 | RTPIPv4Address::port = port; 110 | RTPIPv4Address::rtcpsendport = rtcpsendport; 111 | } 112 | 113 | ~RTPIPv4Address() { } 114 | 115 | /** Sets the IP address for this instance to \c ip which is assumed to be in host byte order. */ 116 | void SetIP(uint32_t ip) { RTPIPv4Address::ip = ip; } 117 | 118 | /** Sets the IP address of this instance to \c ip. */ 119 | void SetIP(const uint8_t ip[4]) { RTPIPv4Address::ip = (uint32_t)ip[3]; RTPIPv4Address::ip |= (((uint32_t)ip[2])<<8); RTPIPv4Address::ip |= (((uint32_t)ip[1])<<16); RTPIPv4Address::ip |= (((uint32_t)ip[0])<<24); } 120 | 121 | /** Sets the port number for this instance to \c port which is interpreted in host byte order. */ 122 | void SetPort(uint16_t port) { RTPIPv4Address::port = port; } 123 | 124 | /** Returns the IP address contained in this instance in host byte order. */ 125 | uint32_t GetIP() const { return ip; } 126 | 127 | /** Returns the port number of this instance in host byte order. */ 128 | uint16_t GetPort() const { return port; } 129 | 130 | /** For outgoing packets, this indicates to which port RTCP packets will be sent (can, 131 | * be the same port as the RTP packets in case RTCP multiplexing is used). */ 132 | uint16_t GetRTCPSendPort() const { return rtcpsendport; } 133 | 134 | RTPAddress *CreateCopy(RTPMemoryManager *mgr) const; 135 | 136 | // Note that these functions are only used for received packets, and for those 137 | // the rtcpsendport variable is not important and should be ignored. 138 | bool IsSameAddress(const RTPAddress *addr) const; 139 | bool IsFromSameHost(const RTPAddress *addr) const; 140 | #ifdef RTPDEBUG 141 | std::string GetAddressString() const; 142 | #endif // RTPDEBUG 143 | private: 144 | uint32_t ip; 145 | uint16_t port; 146 | uint16_t rtcpsendport; 147 | }; 148 | 149 | } // end namespace 150 | 151 | #endif // RTPIPV4ADDRESS_H 152 | 153 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpipv4destination.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpipv4destination.h 35 | */ 36 | 37 | #ifndef RTPIPV4DESTINATION_H 38 | 39 | #define RTPIPV4DESTINATION_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | #include "rtpipv4address.h" 44 | #ifndef RTP_SOCKETTYPE_WINSOCK 45 | #include 46 | #include 47 | #include 48 | #endif // RTP_SOCKETTYPE_WINSOCK 49 | #include 50 | #include 51 | 52 | namespace jrtplib 53 | { 54 | 55 | class JRTPLIB_IMPORTEXPORT RTPIPv4Destination 56 | { 57 | public: 58 | RTPIPv4Destination() 59 | { 60 | ip = 0; 61 | memset(&rtpaddr,0,sizeof(struct sockaddr_in)); 62 | memset(&rtcpaddr,0,sizeof(struct sockaddr_in)); 63 | } 64 | 65 | RTPIPv4Destination(uint32_t ip,uint16_t rtpport,uint16_t rtcpport) 66 | { 67 | memset(&rtpaddr,0,sizeof(struct sockaddr_in)); 68 | memset(&rtcpaddr,0,sizeof(struct sockaddr_in)); 69 | 70 | rtpaddr.sin_family = AF_INET; 71 | rtpaddr.sin_port = htons(rtpport); 72 | rtpaddr.sin_addr.s_addr = htonl(ip); 73 | 74 | rtcpaddr.sin_family = AF_INET; 75 | rtcpaddr.sin_port = htons(rtcpport); 76 | rtcpaddr.sin_addr.s_addr = htonl(ip); 77 | 78 | RTPIPv4Destination::ip = ip; 79 | } 80 | 81 | bool operator==(const RTPIPv4Destination &src) const 82 | { 83 | if (rtpaddr.sin_addr.s_addr == src.rtpaddr.sin_addr.s_addr && rtpaddr.sin_port == src.rtpaddr.sin_port) 84 | return true; 85 | return false; 86 | } 87 | uint32_t GetIP() const { return ip; } 88 | // nbo = network byte order 89 | uint32_t GetIP_NBO() const { return rtpaddr.sin_addr.s_addr; } 90 | uint16_t GetRTPPort_NBO() const { return rtpaddr.sin_port; } 91 | uint16_t GetRTCPPort_NBO() const { return rtcpaddr.sin_port; } 92 | const struct sockaddr_in *GetRTPSockAddr() const { return &rtpaddr; } 93 | const struct sockaddr_in *GetRTCPSockAddr() const { return &rtcpaddr; } 94 | std::string GetDestinationString() const; 95 | 96 | static bool AddressToDestination(const RTPAddress &addr, RTPIPv4Destination &dest) 97 | { 98 | if (addr.GetAddressType() != RTPAddress::IPv4Address) 99 | return false; 100 | 101 | const RTPIPv4Address &address = (const RTPIPv4Address &)addr; 102 | uint16_t rtpport = address.GetPort(); 103 | uint16_t rtcpport = address.GetRTCPSendPort(); 104 | 105 | dest = RTPIPv4Destination(address.GetIP(),rtpport,rtcpport); 106 | return true; 107 | } 108 | 109 | private: 110 | uint32_t ip; 111 | struct sockaddr_in rtpaddr; 112 | struct sockaddr_in rtcpaddr; 113 | }; 114 | 115 | } // end namespace 116 | 117 | #endif // RTPIPV4DESTINATION_H 118 | 119 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpipv6address.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpipv6address.h 35 | */ 36 | 37 | #ifndef RTPIPV6ADDRESS_H 38 | 39 | #define RTPIPV6ADDRESS_H 40 | 41 | #include "rtpconfig.h" 42 | 43 | #ifdef RTP_SUPPORT_IPV6 44 | 45 | #include "rtpaddress.h" 46 | #include "rtptypes.h" 47 | #ifdef RTP_SUPPORT_NETINET_IN 48 | #include 49 | #endif // RTP_SUPPORT_NETINET_IN 50 | 51 | namespace jrtplib 52 | { 53 | 54 | /** Represents an IPv6 IP address and port. 55 | * This class is used by the UDP over IPv4 transmission component. 56 | * When an RTPIPv6Address is used in one of the multicast functions of the 57 | * transmitter, the port number is ignored. When an instance is used in one of 58 | * the accept or ignore functions of the transmitter, a zero port number represents 59 | * all ports for the specified IP address. 60 | */ 61 | class JRTPLIB_IMPORTEXPORT RTPIPv6Address : public RTPAddress 62 | { 63 | public: 64 | /** Creates an instance with IP address and port number set to zero. */ 65 | RTPIPv6Address():RTPAddress(IPv6Address) { for (int i = 0 ; i < 16 ; i++) ip.s6_addr[i] = 0; port = 0; } 66 | 67 | /** Creates an instance with IP address \c ip and port number \c port (the port number is assumed to be in 68 | * host byte order). */ 69 | RTPIPv6Address(const uint8_t ip[16],uint16_t port = 0):RTPAddress(IPv6Address) { SetIP(ip); RTPIPv6Address::port = port; } 70 | 71 | /** Creates an instance with IP address \c ip and port number \c port (the port number is assumed to be in 72 | * host byte order). */ 73 | RTPIPv6Address(in6_addr ip,uint16_t port = 0):RTPAddress(IPv6Address) { RTPIPv6Address::ip = ip; RTPIPv6Address::port = port; } 74 | ~RTPIPv6Address() { } 75 | 76 | /** Sets the IP address for this instance to \c ip. */ 77 | void SetIP(in6_addr ip) { RTPIPv6Address::ip = ip; } 78 | 79 | /** Sets the IP address for this instance to \c ip. */ 80 | void SetIP(const uint8_t ip[16]) { for (int i = 0 ; i < 16 ; i++) RTPIPv6Address::ip.s6_addr[i] = ip[i]; } 81 | 82 | /** Sets the port number for this instance to \c port, which is interpreted in host byte order. */ 83 | void SetPort(uint16_t port) { RTPIPv6Address::port = port; } 84 | 85 | /** Copies the IP address of this instance in \c ip. */ 86 | void GetIP(uint8_t ip[16]) const { for (int i = 0 ; i < 16 ; i++) ip[i] = RTPIPv6Address::ip.s6_addr[i]; } 87 | 88 | /** Returns the IP address of this instance. */ 89 | in6_addr GetIP() const { return ip; } 90 | 91 | /** Returns the port number contained in this instance in host byte order. */ 92 | uint16_t GetPort() const { return port; } 93 | 94 | RTPAddress *CreateCopy(RTPMemoryManager *mgr) const; 95 | bool IsSameAddress(const RTPAddress *addr) const; 96 | bool IsFromSameHost(const RTPAddress *addr) const; 97 | #ifdef RTPDEBUG 98 | std::string GetAddressString() const; 99 | #endif // RTPDEBUG 100 | private: 101 | in6_addr ip; 102 | uint16_t port; 103 | }; 104 | 105 | } // end namespace 106 | 107 | #endif // RTP_SUPPORT_IPV6 108 | 109 | #endif // RTPIPV6ADDRESS_H 110 | 111 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpipv6destination.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpipv6destination.h 35 | */ 36 | 37 | #ifndef RTPIPV6DESTINATION_H 38 | 39 | #define RTPIPV6DESTINATION_H 40 | 41 | #include "rtpconfig.h" 42 | 43 | #ifdef RTP_SUPPORT_IPV6 44 | 45 | #include "rtptypes.h" 46 | #include 47 | #include 48 | #ifndef RTP_SOCKETTYPE_WINSOCK 49 | #include 50 | #include 51 | #include 52 | #endif // RTP_SOCKETTYPE_WINSOCK 53 | 54 | namespace jrtplib 55 | { 56 | 57 | class JRTPLIB_IMPORTEXPORT RTPIPv6Destination 58 | { 59 | public: 60 | RTPIPv6Destination(in6_addr ip,uint16_t portbase) 61 | { 62 | memset(&rtpaddr,0,sizeof(struct sockaddr_in6)); 63 | memset(&rtcpaddr,0,sizeof(struct sockaddr_in6)); 64 | rtpaddr.sin6_family = AF_INET6; 65 | rtpaddr.sin6_port = htons(portbase); 66 | rtpaddr.sin6_addr = ip; 67 | rtcpaddr.sin6_family = AF_INET6; 68 | rtcpaddr.sin6_port = htons(portbase+1); 69 | rtcpaddr.sin6_addr = ip; 70 | } 71 | in6_addr GetIP() const { return rtpaddr.sin6_addr; } 72 | bool operator==(const RTPIPv6Destination &src) const 73 | { 74 | if (rtpaddr.sin6_port == src.rtpaddr.sin6_port && (memcmp(&(src.rtpaddr.sin6_addr),&(rtpaddr.sin6_addr),sizeof(in6_addr)) == 0)) 75 | return true; 76 | return false; 77 | } 78 | const struct sockaddr_in6 *GetRTPSockAddr() const { return &rtpaddr; } 79 | const struct sockaddr_in6 *GetRTCPSockAddr() const { return &rtcpaddr; } 80 | std::string GetDestinationString() const; 81 | private: 82 | struct sockaddr_in6 rtpaddr; 83 | struct sockaddr_in6 rtcpaddr; 84 | }; 85 | 86 | } // end namespace 87 | 88 | #endif // RTP_SUPPORT_IPV6 89 | 90 | #endif // RTPIPV6DESTINATION_H 91 | 92 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtplibraryversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtplibraryversion.h 35 | */ 36 | 37 | #ifndef RTPLIBRARYVERSION_H 38 | 39 | #define RTPLIBRARYVERSION_H 40 | 41 | #include "rtpconfig.h" 42 | #include 43 | #include 44 | 45 | namespace jrtplib 46 | { 47 | 48 | /** 49 | * Used to provide information about the version of the library. 50 | */ 51 | class JRTPLIB_IMPORTEXPORT RTPLibraryVersion 52 | { 53 | public: 54 | /** Returns an instance of RTPLibraryVersion describing the version of the library. */ 55 | static RTPLibraryVersion GetVersion(); 56 | private: 57 | RTPLibraryVersion(int major,int minor,int debug) { majornr = major; minornr = minor; debugnr = debug; } 58 | public: 59 | /** Returns the major version number. */ 60 | int GetMajorNumber() const { return majornr; } 61 | 62 | /** Returns the minor version number. */ 63 | int GetMinorNumber() const { return minornr; } 64 | 65 | /** Returns the debug version number. */ 66 | int GetDebugNumber() const { return debugnr; } 67 | 68 | /** Returns a string describing the library version. */ 69 | std::string GetVersionString() const; 70 | private: 71 | int debugnr,minornr,majornr; 72 | }; 73 | 74 | } // end namespace 75 | 76 | #endif // RTPLIBRARYVERSION_H 77 | 78 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpmemorymanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpmemorymanager.h 35 | */ 36 | 37 | #ifndef RTPMEMORYMANAGER_H 38 | 39 | #define RTPMEMORYMANAGER_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | 44 | /** Used to indicate a general kind of memory block. */ 45 | #define RTPMEM_TYPE_OTHER 0 46 | 47 | /** Buffer to store an incoming RTP packet. */ 48 | #define RTPMEM_TYPE_BUFFER_RECEIVEDRTPPACKET 1 49 | 50 | /** Buffer to store an incoming RTCP packet. */ 51 | #define RTPMEM_TYPE_BUFFER_RECEIVEDRTCPPACKET 2 52 | 53 | /** Buffer to store an RTCP APP packet. */ 54 | #define RTPMEM_TYPE_BUFFER_RTCPAPPPACKET 3 55 | 56 | /** Buffer to store an RTCP BYE packet. */ 57 | #define RTPMEM_TYPE_BUFFER_RTCPBYEPACKET 4 58 | 59 | /** Buffer to store a BYE reason. */ 60 | #define RTPMEM_TYPE_BUFFER_RTCPBYEREASON 5 61 | 62 | /** Buffer to store an RTCP compound packet. */ 63 | #define RTPMEM_TYPE_BUFFER_RTCPCOMPOUNDPACKET 6 64 | 65 | /** Buffer to store an SDES block. */ 66 | #define RTPMEM_TYPE_BUFFER_RTCPSDESBLOCK 7 67 | 68 | /** Buffer to store an RTP packet. */ 69 | #define RTPMEM_TYPE_BUFFER_RTPPACKET 8 70 | 71 | /** Buffer used by an RTPPacketBuilder instance. */ 72 | #define RTPMEM_TYPE_BUFFER_RTPPACKETBUILDERBUFFER 9 73 | 74 | /** Buffer to store an SDES item. */ 75 | #define RTPMEM_TYPE_BUFFER_SDESITEM 10 76 | 77 | /** Hash element used in the accept/ignore table. */ 78 | #define RTPMEM_TYPE_CLASS_ACCEPTIGNOREHASHELEMENT 11 79 | 80 | /** Buffer to store a PortInfo instance, used by the UDP over IPv4 and IPv6 transmitters. */ 81 | #define RTPMEM_TYPE_CLASS_ACCEPTIGNOREPORTINFO 12 82 | 83 | /** Buffer to store a HashElement instance for the destination hash table. */ 84 | #define RTPMEM_TYPE_CLASS_DESTINATIONLISTHASHELEMENT 13 85 | 86 | /** Buffer to store a HashElement instance for the multicast hash table. */ 87 | #define RTPMEM_TYPE_CLASS_MULTICASTHASHELEMENT 14 88 | 89 | /** Buffer to store an instance of RTCPAPPPacket. */ 90 | #define RTPMEM_TYPE_CLASS_RTCPAPPPACKET 15 91 | 92 | /** Buffer to store an instance of RTCPBYEPacket. */ 93 | #define RTPMEM_TYPE_CLASS_RTCPBYEPACKET 16 94 | 95 | /** Buffer to store an instance of RTCPCompoundPacketBuilder. */ 96 | #define RTPMEM_TYPE_CLASS_RTCPCOMPOUNDPACKETBUILDER 17 97 | 98 | /** Buffer to store an RTCPReceiverReport instance. */ 99 | #define RTPMEM_TYPE_CLASS_RTCPRECEIVERREPORT 18 100 | 101 | /** Buffer to store an instance of RTCPRRPacket. */ 102 | #define RTPMEM_TYPE_CLASS_RTCPRRPACKET 19 103 | 104 | /** Buffer to store an instance of RTCPSDESPacket. */ 105 | #define RTPMEM_TYPE_CLASS_RTCPSDESPACKET 20 106 | 107 | /** Buffer to store an instance of RTCPSRPacket. */ 108 | #define RTPMEM_TYPE_CLASS_RTCPSRPACKET 21 109 | 110 | /** Buffer to store an instance of RTCPUnknownPacket. */ 111 | #define RTPMEM_TYPE_CLASS_RTCPUNKNOWNPACKET 22 112 | 113 | /** Buffer to store an instance of an RTPAddress derived class. */ 114 | #define RTPMEM_TYPE_CLASS_RTPADDRESS 23 115 | 116 | /** Buffer to store an instance of RTPInternalSourceData. */ 117 | #define RTPMEM_TYPE_CLASS_RTPINTERNALSOURCEDATA 24 118 | 119 | /** Buffer to store an RTPPacket instance. */ 120 | #define RTPMEM_TYPE_CLASS_RTPPACKET 25 121 | 122 | /** Buffer to store an RTPPollThread instance. */ 123 | #define RTPMEM_TYPE_CLASS_RTPPOLLTHREAD 26 124 | 125 | /** Buffer to store an RTPRawPacket instance. */ 126 | #define RTPMEM_TYPE_CLASS_RTPRAWPACKET 27 127 | 128 | /** Buffer to store an RTPTransmissionInfo derived class. */ 129 | #define RTPMEM_TYPE_CLASS_RTPTRANSMISSIONINFO 28 130 | 131 | /** Buffer to store an RTPTransmitter derived class. */ 132 | #define RTPMEM_TYPE_CLASS_RTPTRANSMITTER 29 133 | 134 | /** Buffer to store an SDESPrivateItem instance. */ 135 | #define RTPMEM_TYPE_CLASS_SDESPRIVATEITEM 30 136 | 137 | /** Buffer to store an SDESSource instance. */ 138 | #define RTPMEM_TYPE_CLASS_SDESSOURCE 31 139 | 140 | /** Buffer to store a HashElement instance for the source table. */ 141 | #define RTPMEM_TYPE_CLASS_SOURCETABLEHASHELEMENT 32 142 | 143 | /** Buffer that's used when encrypting a packet. */ 144 | #define RTPMEM_TYPE_BUFFER_SRTPDATA 33 145 | 146 | namespace jrtplib 147 | { 148 | 149 | /** A memory manager. */ 150 | class JRTPLIB_IMPORTEXPORT RTPMemoryManager 151 | { 152 | public: 153 | RTPMemoryManager() { } 154 | virtual ~RTPMemoryManager() { } 155 | 156 | /** Called to allocate \c numbytes of memory. 157 | * Called to allocate \c numbytes of memory. The \c memtype parameter 158 | * indicates what the purpose of the memory block is. Relevant values 159 | * can be found in rtpmemorymanager.h . Note that the types starting with 160 | * \c RTPMEM_TYPE_CLASS indicate fixed size buffers and that types starting 161 | * with \c RTPMEM_TYPE_BUFFER indicate variable size buffers. 162 | */ 163 | virtual void *AllocateBuffer(size_t numbytes, int memtype) = 0; 164 | 165 | /** Frees the previously allocated memory block \c buffer */ 166 | virtual void FreeBuffer(void *buffer) = 0; 167 | }; 168 | 169 | } // end namespace 170 | 171 | #ifdef RTP_SUPPORT_MEMORYMANAGEMENT 172 | 173 | #include 174 | 175 | inline void *operator new(size_t numbytes, jrtplib::RTPMemoryManager *mgr, int memtype) 176 | { 177 | if (mgr == 0) 178 | return operator new(numbytes); 179 | return mgr->AllocateBuffer(numbytes,memtype); 180 | } 181 | 182 | inline void operator delete(void *buffer, jrtplib::RTPMemoryManager *mgr, int memtype) 183 | { 184 | JRTPLIB_UNUSED(memtype); 185 | if (mgr == 0) 186 | operator delete(buffer); 187 | else 188 | mgr->FreeBuffer(buffer); 189 | } 190 | 191 | #ifdef RTP_HAVE_ARRAYALLOC 192 | inline void *operator new[](size_t numbytes, jrtplib::RTPMemoryManager *mgr, int memtype) 193 | { 194 | if (mgr == 0) 195 | return operator new[](numbytes); 196 | return mgr->AllocateBuffer(numbytes,memtype); 197 | } 198 | 199 | inline void operator delete[](void *buffer, jrtplib::RTPMemoryManager *mgr, int memtype) 200 | { 201 | JRTPLIB_UNUSED(memtype); 202 | if (mgr == 0) 203 | operator delete[](buffer); 204 | else 205 | mgr->FreeBuffer(buffer); 206 | } 207 | #endif // RTP_HAVE_ARRAYALLOC 208 | 209 | namespace jrtplib 210 | { 211 | 212 | inline void RTPDeleteByteArray(uint8_t *buf, RTPMemoryManager *mgr) 213 | { 214 | if (mgr == 0) 215 | delete [] buf; 216 | else 217 | mgr->FreeBuffer(buf); 218 | } 219 | 220 | template 221 | inline void RTPDelete(ClassName *obj, RTPMemoryManager *mgr) 222 | { 223 | if (mgr == 0) 224 | delete obj; 225 | else 226 | { 227 | obj->~ClassName(); 228 | mgr->FreeBuffer(obj); 229 | } 230 | } 231 | 232 | } // end namespace 233 | 234 | #define RTPNew(a,b) new(a,b) 235 | 236 | #else 237 | 238 | #define RTPNew(a,b) new 239 | #define RTPDelete(a,b) delete a 240 | #define RTPDeleteByteArray(a,b) delete [] a; 241 | 242 | #endif // RTP_SUPPORT_MEMORYMANAGEMENT 243 | 244 | #endif // RTPMEMORYMANAGER_H 245 | 246 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpmemoryobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpmemoryobject.h 35 | */ 36 | 37 | #ifndef RTPMEMORYOBJECT_H 38 | 39 | #define RTPMEMORYOBJECT_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpmemorymanager.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | class JRTPLIB_IMPORTEXPORT RTPMemoryObject 48 | { 49 | protected: 50 | #ifdef RTP_SUPPORT_MEMORYMANAGEMENT 51 | RTPMemoryObject(RTPMemoryManager *memmgr) : mgr(memmgr) { } 52 | #else 53 | RTPMemoryObject(RTPMemoryManager *memmgr) { JRTPLIB_UNUSED(memmgr); } 54 | #endif // RTP_SUPPORT_MEMORYMANAGEMENT 55 | virtual ~RTPMemoryObject() { } 56 | 57 | #ifdef RTP_SUPPORT_MEMORYMANAGEMENT 58 | RTPMemoryManager *GetMemoryManager() const { return mgr; } 59 | void SetMemoryManager(RTPMemoryManager *m) { mgr = m; } 60 | #else 61 | RTPMemoryManager *GetMemoryManager() const { return 0; } 62 | void SetMemoryManager(RTPMemoryManager *m) { JRTPLIB_UNUSED(m); } 63 | #endif // RTP_SUPPORT_MEMORYMANAGEMENT 64 | 65 | #ifdef RTP_SUPPORT_MEMORYMANAGEMENT 66 | private: 67 | RTPMemoryManager *mgr; 68 | #endif // RTP_SUPPORT_MEMORYMANAGEMENT 69 | }; 70 | 71 | } // end namespace 72 | 73 | #endif // RTPMEMORYOBJECT_H 74 | 75 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtppacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtppacket.h 35 | */ 36 | 37 | #ifndef RTPPACKET_H 38 | 39 | #define RTPPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | #include "rtptimeutilities.h" 44 | #include "rtpmemoryobject.h" 45 | 46 | namespace jrtplib 47 | { 48 | 49 | class RTPRawPacket; 50 | 51 | /** Represents an RTP Packet. 52 | * The RTPPacket class can be used to parse a RTPRawPacket instance if it represents RTP data. 53 | * The class can also be used to create a new RTP packet according to the parameters specified by 54 | * the user. 55 | */ 56 | class JRTPLIB_IMPORTEXPORT RTPPacket : public RTPMemoryObject 57 | { 58 | public: 59 | /** Creates an RTPPacket instance based upon the data in \c rawpack, optionally installing a memory manager. 60 | * Creates an RTPPacket instance based upon the data in \c rawpack, optionally installing a memory manager. 61 | * If successful, the data is moved from the raw packet to the RTPPacket instance. 62 | */ 63 | RTPPacket(RTPRawPacket &rawpack,RTPMemoryManager *mgr = 0); 64 | 65 | /** Creates a new buffer for an RTP packet and fills in the fields according to the specified parameters. 66 | * Creates a new buffer for an RTP packet and fills in the fields according to the specified parameters. 67 | * If \c maxpacksize is not equal to zero, an error is generated if the total packet size would exceed 68 | * \c maxpacksize. The arguments of the constructor are self-explanatory. Note that the size of a header 69 | * extension is specified in a number of 32-bit words. A memory manager can be installed. 70 | */ 71 | RTPPacket(uint8_t payloadtype,const void *payloaddata,size_t payloadlen,uint16_t seqnr, 72 | uint32_t timestamp,uint32_t ssrc,bool gotmarker,uint8_t numcsrcs,const uint32_t *csrcs, 73 | bool gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,const void *extensiondata, 74 | size_t maxpacksize, RTPMemoryManager *mgr = 0); 75 | 76 | /** This constructor is similar to the other constructor, but here data is stored in an external buffer 77 | * \c buffer with size \c buffersize. */ 78 | RTPPacket(uint8_t payloadtype,const void *payloaddata,size_t payloadlen,uint16_t seqnr, 79 | uint32_t timestamp,uint32_t ssrc,bool gotmarker,uint8_t numcsrcs,const uint32_t *csrcs, 80 | bool gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,const void *extensiondata, 81 | void *buffer,size_t buffersize,RTPMemoryManager *mgr = 0); 82 | 83 | virtual ~RTPPacket() { if (packet && !externalbuffer) RTPDeleteByteArray(packet,GetMemoryManager()); } 84 | 85 | /** If an error occurred in one of the constructors, this function returns the error code. */ 86 | int GetCreationError() const { return error; } 87 | 88 | /** Returns \c true if the RTP packet has a header extension and \c false otherwise. */ 89 | bool HasExtension() const { return hasextension; } 90 | 91 | /** Returns \c true if the marker bit was set and \c false otherwise. */ 92 | bool HasMarker() const { return hasmarker; } 93 | 94 | /** Returns the number of CSRCs contained in this packet. */ 95 | int GetCSRCCount() const { return numcsrcs; } 96 | 97 | /** Returns a specific CSRC identifier. 98 | * Returns a specific CSRC identifier. The parameter \c num can go from 0 to GetCSRCCount()-1. 99 | */ 100 | uint32_t GetCSRC(int num) const; 101 | 102 | /** Returns the payload type of the packet. */ 103 | uint8_t GetPayloadType() const { return payloadtype; } 104 | 105 | /** Returns the extended sequence number of the packet. 106 | * Returns the extended sequence number of the packet. When the packet is just received, 107 | * only the low $16$ bits will be set. The high 16 bits can be filled in later. 108 | */ 109 | uint32_t GetExtendedSequenceNumber() const { return extseqnr; } 110 | 111 | /** Returns the sequence number of this packet. */ 112 | uint16_t GetSequenceNumber() const { return (uint16_t)(extseqnr&0x0000FFFF); } 113 | 114 | /** Sets the extended sequence number of this packet to \c seq. */ 115 | void SetExtendedSequenceNumber(uint32_t seq) { extseqnr = seq; } 116 | 117 | /** Returns the timestamp of this packet. */ 118 | uint32_t GetTimestamp() const { return timestamp; } 119 | 120 | /** Returns the SSRC identifier stored in this packet. */ 121 | uint32_t GetSSRC() const { return ssrc; } 122 | 123 | /** Returns a pointer to the data of the entire packet. */ 124 | uint8_t *GetPacketData() const { return packet; } 125 | 126 | /** Returns a pointer to the actual payload data. */ 127 | uint8_t *GetPayloadData() const { return payload; } 128 | 129 | /** Returns the length of the entire packet. */ 130 | size_t GetPacketLength() const { return packetlength; } 131 | 132 | /** Returns the payload length. */ 133 | size_t GetPayloadLength() const { return payloadlength; } 134 | 135 | /** If a header extension is present, this function returns the extension identifier. */ 136 | uint16_t GetExtensionID() const { return extid; } 137 | 138 | /** Returns the length of the header extension data. */ 139 | uint8_t *GetExtensionData() const { return extension; } 140 | 141 | /** Returns the length of the header extension data. */ 142 | size_t GetExtensionLength() const { return extensionlength; } 143 | #ifdef RTPDEBUG 144 | void Dump(); 145 | #endif // RTPDEBUG 146 | 147 | /** Returns the time at which this packet was received. 148 | * When an RTPPacket instance is created from an RTPRawPacket instance, the raw packet's 149 | * reception time is stored in the RTPPacket instance. This function then retrieves that 150 | * time. 151 | */ 152 | RTPTime GetReceiveTime() const { return receivetime; } 153 | private: 154 | void Clear(); 155 | int ParseRawPacket(RTPRawPacket &rawpack); 156 | int BuildPacket(uint8_t payloadtype,const void *payloaddata,size_t payloadlen,uint16_t seqnr, 157 | uint32_t timestamp,uint32_t ssrc,bool gotmarker,uint8_t numcsrcs,const uint32_t *csrcs, 158 | bool gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,const void *extensiondata, 159 | void *buffer,size_t maxsize); 160 | 161 | int error; 162 | 163 | bool hasextension,hasmarker; 164 | int numcsrcs; 165 | 166 | uint8_t payloadtype; 167 | uint32_t extseqnr,timestamp,ssrc; 168 | uint8_t *packet,*payload; 169 | size_t packetlength,payloadlength; 170 | 171 | uint16_t extid; 172 | uint8_t *extension; 173 | size_t extensionlength; 174 | 175 | bool externalbuffer; 176 | 177 | RTPTime receivetime; 178 | }; 179 | 180 | } // end namespace 181 | 182 | #endif // RTPPACKET_H 183 | 184 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtppollthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtppollthread.h 35 | */ 36 | 37 | #ifndef RTPPOLLTHREAD_H 38 | 39 | #define RTPPOLLTHREAD_H 40 | 41 | #include "rtpconfig.h" 42 | 43 | #ifdef RTP_SUPPORT_THREAD 44 | 45 | #include "rtptransmitter.h" 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | namespace jrtplib 52 | { 53 | 54 | class RTPSession; 55 | class RTCPScheduler; 56 | 57 | class JRTPLIB_IMPORTEXPORT RTPPollThread : private jthread::JThread 58 | { 59 | public: 60 | RTPPollThread(RTPSession &session,RTCPScheduler &rtcpsched); 61 | ~RTPPollThread(); 62 | int Start(RTPTransmitter *trans); 63 | void Stop(); 64 | private: 65 | void *Thread(); 66 | 67 | bool stop; 68 | jthread::JMutex stopmutex; 69 | RTPTransmitter *transmitter; 70 | 71 | RTPSession &rtpsession; 72 | RTCPScheduler &rtcpsched; 73 | }; 74 | 75 | } // end namespace 76 | 77 | #endif // RTP_SUPPORT_THREAD 78 | 79 | #endif // RTPPOLLTHREAD_H 80 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtprandom.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtprandom.h 35 | */ 36 | 37 | #ifndef RTPRANDOM_H 38 | 39 | #define RTPRANDOM_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | #include 44 | 45 | #define RTPRANDOM_2POWMIN63 1.08420217248550443400745280086994171142578125e-19 46 | 47 | namespace jrtplib 48 | { 49 | 50 | /** Interface for generating random numbers. */ 51 | class JRTPLIB_IMPORTEXPORT RTPRandom 52 | { 53 | public: 54 | RTPRandom() { } 55 | virtual ~RTPRandom() { } 56 | 57 | /** Returns a random eight bit value. */ 58 | virtual uint8_t GetRandom8() = 0; 59 | 60 | /** Returns a random sixteen bit value. */ 61 | virtual uint16_t GetRandom16() = 0; 62 | 63 | /** Returns a random thirty-two bit value. */ 64 | virtual uint32_t GetRandom32() = 0; 65 | 66 | /** Returns a random number between $0.0$ and $1.0$. */ 67 | virtual double GetRandomDouble() = 0; 68 | 69 | /** Can be used by subclasses to generate a seed for a random number generator. */ 70 | uint32_t PickSeed(); 71 | 72 | /** Allocate a default random number generator based on your platform. */ 73 | static RTPRandom *CreateDefaultRandomNumberGenerator(); 74 | }; 75 | 76 | } // end namespace 77 | 78 | #endif // RTPRANDOM_H 79 | 80 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtprandomrand48.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtprandomrand48.h 35 | */ 36 | 37 | #ifndef RTPRANDOMRAND48_H 38 | 39 | #define RTPRANDOMRAND48_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtprandom.h" 43 | #ifdef RTP_SUPPORT_THREAD 44 | #include 45 | #endif // RTP_SUPPORT_THREAD 46 | #include 47 | 48 | namespace jrtplib 49 | { 50 | 51 | /** A random number generator using the algorithm of the rand48 set of functions. */ 52 | class JRTPLIB_IMPORTEXPORT RTPRandomRand48 : public RTPRandom 53 | { 54 | public: 55 | RTPRandomRand48(); 56 | RTPRandomRand48(uint32_t seed); 57 | ~RTPRandomRand48(); 58 | 59 | uint8_t GetRandom8(); 60 | uint16_t GetRandom16(); 61 | uint32_t GetRandom32(); 62 | double GetRandomDouble(); 63 | private: 64 | void SetSeed(uint32_t seed); 65 | 66 | #ifdef RTP_SUPPORT_THREAD 67 | jthread::JMutex mutex; 68 | #endif // RTP_SUPPORT_THREAD 69 | uint64_t state; 70 | }; 71 | 72 | } // end namespace 73 | 74 | #endif // RTPRANDOMRAND48_H 75 | 76 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtprandomrands.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtprandomrands.h 35 | */ 36 | 37 | #ifndef RTPRANDOMRANDS_H 38 | 39 | #define RTPRANDOMRANDS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtprandom.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | /** A random number generator which tries to use the \c rand_s function on the 48 | * Win32 platform. 49 | */ 50 | class JRTPLIB_IMPORTEXPORT RTPRandomRandS : public RTPRandom 51 | { 52 | public: 53 | RTPRandomRandS(); 54 | ~RTPRandomRandS(); 55 | 56 | /** Initialize the random number generator. */ 57 | int Init(); 58 | 59 | uint8_t GetRandom8(); 60 | uint16_t GetRandom16(); 61 | uint32_t GetRandom32(); 62 | double GetRandomDouble(); 63 | private: 64 | bool initialized; 65 | }; 66 | 67 | } // end namespace 68 | 69 | #endif // RTPRANDOMRANDS_H 70 | 71 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtprandomurandom.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtprandomurandom.h 35 | */ 36 | 37 | #ifndef RTPRANDOMURANDOM_H 38 | 39 | #define RTPRANDOMURANDOM_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtprandom.h" 43 | #include 44 | 45 | namespace jrtplib 46 | { 47 | 48 | /** A random number generator which uses bytes delivered by the /dev/urandom device. */ 49 | class JRTPLIB_IMPORTEXPORT RTPRandomURandom : public RTPRandom 50 | { 51 | public: 52 | RTPRandomURandom(); 53 | ~RTPRandomURandom(); 54 | 55 | /** Initialize the random number generator. */ 56 | int Init(); 57 | 58 | uint8_t GetRandom8(); 59 | uint16_t GetRandom16(); 60 | uint32_t GetRandom32(); 61 | double GetRandomDouble(); 62 | private: 63 | FILE *device; 64 | }; 65 | 66 | } // end namespace 67 | 68 | #endif // RTPRANDOMURANDOM_H 69 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtprawpacket.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtprawpacket.h 35 | */ 36 | 37 | #ifndef RTPRAWPACKET_H 38 | 39 | #define RTPRAWPACKET_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptimeutilities.h" 43 | #include "rtpaddress.h" 44 | #include "rtptypes.h" 45 | #include "rtpmemoryobject.h" 46 | 47 | namespace jrtplib 48 | { 49 | 50 | /** This class is used by the transmission component to store the incoming RTP and RTCP data in. */ 51 | class JRTPLIB_IMPORTEXPORT RTPRawPacket : public RTPMemoryObject 52 | { 53 | public: 54 | /** Creates an instance which stores data from \c data with length \c datalen. 55 | * Creates an instance which stores data from \c data with length \c datalen. Only the pointer 56 | * to the data is stored, no actual copy is made! The address from which this packet originated 57 | * is set to \c address and the time at which the packet was received is set to \c recvtime. 58 | * The flag which indicates whether this data is RTP or RTCP data is set to \c rtp. A memory 59 | * manager can be installed as well. 60 | */ 61 | RTPRawPacket(uint8_t *data,size_t datalen,RTPAddress *address,RTPTime &recvtime,bool rtp,RTPMemoryManager *mgr = 0); 62 | ~RTPRawPacket(); 63 | 64 | /** Returns the pointer to the data which is contained in this packet. */ 65 | uint8_t *GetData() { return packetdata; } 66 | 67 | /** Returns the length of the packet described by this instance. */ 68 | size_t GetDataLength() const { return packetdatalength; } 69 | 70 | /** Returns the time at which this packet was received. */ 71 | RTPTime GetReceiveTime() const { return receivetime; } 72 | 73 | /** Returns the address stored in this packet. */ 74 | const RTPAddress *GetSenderAddress() const { return senderaddress; } 75 | 76 | /** Returns \c true if this data is RTP data, \c false if it is RTCP data. */ 77 | bool IsRTP() const { return isrtp; } 78 | 79 | /** Sets the pointer to the data stored in this packet to zero. 80 | * Sets the pointer to the data stored in this packet to zero. This will prevent 81 | * a \c delete call for the actual data when the destructor of RTPRawPacket is called. 82 | * This function is used by the RTPPacket and RTCPCompoundPacket classes to obtain 83 | * the packet data (without having to copy it) and to make sure the data isn't deleted 84 | * when the destructor of RTPRawPacket is called. 85 | */ 86 | void ZeroData() { packetdata = 0; packetdatalength = 0; } 87 | 88 | /** Allocates a number of bytes for RTP or RTCP data using the memory manager that 89 | * was used for this raw packet instance, can be useful if the RTPRawPacket::SetData 90 | * function will be used. */ 91 | uint8_t *AllocateBytes(bool isrtp, int recvlen) const; 92 | 93 | /** Deallocates the previously stored data and replaces it with the data that's 94 | * specified, can be useful when e.g. decrypting data in RTPSession::OnChangeIncomingData */ 95 | void SetData(uint8_t *data, size_t datalen); 96 | 97 | /** Deallocates the currently stored RTPAddress instance and replaces it 98 | * with the one that's specified (you probably don't need this function). */ 99 | void SetSenderAddress(RTPAddress *address); 100 | private: 101 | void DeleteData(); 102 | 103 | uint8_t *packetdata; 104 | size_t packetdatalength; 105 | RTPTime receivetime; 106 | RTPAddress *senderaddress; 107 | bool isrtp; 108 | }; 109 | 110 | inline RTPRawPacket::RTPRawPacket(uint8_t *data,size_t datalen,RTPAddress *address,RTPTime &recvtime,bool rtp,RTPMemoryManager *mgr):RTPMemoryObject(mgr),receivetime(recvtime) 111 | { 112 | packetdata = data; 113 | packetdatalength = datalen; 114 | senderaddress = address; 115 | isrtp = rtp; 116 | } 117 | 118 | inline RTPRawPacket::~RTPRawPacket() 119 | { 120 | DeleteData(); 121 | } 122 | 123 | inline void RTPRawPacket::DeleteData() 124 | { 125 | if (packetdata) 126 | RTPDeleteByteArray(packetdata,GetMemoryManager()); 127 | if (senderaddress) 128 | RTPDelete(senderaddress,GetMemoryManager()); 129 | 130 | packetdata = 0; 131 | senderaddress = 0; 132 | } 133 | 134 | inline uint8_t *RTPRawPacket::AllocateBytes(bool isrtp, int recvlen) const 135 | { 136 | JRTPLIB_UNUSED(isrtp); // possibly unused 137 | return RTPNew(GetMemoryManager(),(isrtp)?RTPMEM_TYPE_BUFFER_RECEIVEDRTPPACKET:RTPMEM_TYPE_BUFFER_RECEIVEDRTCPPACKET) uint8_t[recvlen]; 138 | } 139 | 140 | inline void RTPRawPacket::SetData(uint8_t *data, size_t datalen) 141 | { 142 | if (packetdata) 143 | RTPDeleteByteArray(packetdata,GetMemoryManager()); 144 | 145 | packetdata = data; 146 | packetdatalength = datalen; 147 | } 148 | 149 | inline void RTPRawPacket::SetSenderAddress(RTPAddress *address) 150 | { 151 | if (senderaddress) 152 | RTPDelete(senderaddress, GetMemoryManager()); 153 | 154 | senderaddress = address; 155 | } 156 | 157 | } // end namespace 158 | 159 | #endif // RTPRAWPACKET_H 160 | 161 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpsecuresession.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpsecuresession.h 35 | */ 36 | 37 | #ifndef RTPSECURESESSION_H 38 | 39 | #define RTPSECURESESSION_H 40 | 41 | #include "rtpconfig.h" 42 | 43 | #ifdef RTP_SUPPORT_SRTP 44 | 45 | #include "rtpsession.h" 46 | 47 | #ifdef RTP_SUPPORT_THREAD 48 | #include 49 | #endif // RTP_SUPPORT_THREAD 50 | 51 | struct srtp_ctx_t; 52 | 53 | namespace jrtplib 54 | { 55 | 56 | class RTPCrypt; 57 | 58 | // SRTP library needs to be initialized already! 59 | 60 | /** RTPSession derived class that serves as a base class for an SRTP implementation. 61 | * 62 | * This is an RTPSession derived class that serves as a base class for an SRTP implementation. 63 | * The class sets the RTPSession::SetChangeIncomingData and RTPSession::SetChangeOutgoingData 64 | * flags, and implements RTPSession::OnChangeIncomingData, RTPSession::OnChangeRTPOrRTCPData 65 | * and RTPSession::OnSentRTPOrRTCPData so that encryption and decryption is applied to packets. 66 | * The encryption and decryption will be done using [libsrtp](https://github.com/cisco/libsrtp), 67 | * which must be available at compile time. 68 | * 69 | * Your derived class should call RTPSecureSession::InitializeSRTPContext to initialize a context 70 | * struct of `libsrtp`. When this succeeds, the context can be obtained and used with the 71 | * RTPSecureSession::LockSRTPContext function, which also locks a mutex if thread support was 72 | * available. After you're done using the context yourself (to set encryption parameters for 73 | * SSRCs), you **must** release it again using RTPSecureSession::UnlockSRTPContext. 74 | * 75 | * See `example7.cpp` for an example of how to use this class. 76 | */ 77 | class JRTPLIB_IMPORTEXPORT RTPSecureSession : public RTPSession 78 | { 79 | public: 80 | /** Constructs an RTPSecureSession instance, see RTPSession::RTPSession 81 | * for more information about the parameters. */ 82 | RTPSecureSession(RTPRandom *rnd = 0, RTPMemoryManager *mgr = 0); 83 | ~RTPSecureSession(); 84 | protected: 85 | /** Initializes the SRTP context, in case of an error it may be useful to inspect 86 | * RTPSecureSession::GetLastLibSRTPError. */ 87 | int InitializeSRTPContext(); 88 | 89 | /** This function locks a mutex and returns the `libsrtp` context that was 90 | * created in RTPSecureSession::InitializeSRTPContext, so that you can further 91 | * use it to specify encryption parameters for various sources; note that you 92 | * **must** release the context again after use with the 93 | * RTPSecureSession::UnlockSRTPContext function. */ 94 | srtp_ctx_t *LockSRTPContext(); 95 | 96 | /** Releases the lock on the SRTP context that was obtained in 97 | * RTPSecureSession::LockSRTPContext. */ 98 | int UnlockSRTPContext(); 99 | 100 | /** Returns (and clears) the last error that was encountered when using a 101 | * `libsrtp` based function. */ 102 | int GetLastLibSRTPError(); 103 | 104 | void SetLastLibSRTPError(int err); 105 | 106 | /** In case the reimplementation of OnChangeIncomingData (which may take place 107 | * in a background thread) encounters an error, this member function will be 108 | * called; implement it in a derived class to receive notification of this. */ 109 | virtual void OnErrorChangeIncomingData(int errcode, int libsrtperrorcode); 110 | 111 | int OnChangeRTPOrRTCPData(const void *origdata, size_t origlen, bool isrtp, void **senddata, size_t *sendlen); 112 | bool OnChangeIncomingData(RTPRawPacket *rawpack); 113 | void OnSentRTPOrRTCPData(void *senddata, size_t sendlen, bool isrtp); 114 | private: 115 | int encryptData(uint8_t *pData, int &dataLength, bool rtp); 116 | int decryptRawPacket(RTPRawPacket *rawpack, int *srtpError); 117 | 118 | srtp_ctx_t *m_pSRTPContext; 119 | int m_lastSRTPError; 120 | #ifdef RTP_SUPPORT_THREAD 121 | jthread::JMutex m_srtpLock; 122 | #endif // RTP_SUPPORT_THREAD 123 | }; 124 | 125 | inline void RTPSecureSession::OnErrorChangeIncomingData(int, int) { } 126 | 127 | } // end namespace 128 | 129 | #endif // RTP_SUPPORT_SRTP 130 | 131 | #endif // RTPSECURESESSION_H 132 | 133 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpselect.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpselect.h 35 | */ 36 | 37 | #ifndef RTPSELECT_H 38 | 39 | #define RTPSELECT_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | #include "rtperrors.h" 44 | #include "rtptimeutilities.h" 45 | #include "rtpsocketutil.h" 46 | 47 | #if defined(RTP_HAVE_WSAPOLL) || defined(RTP_HAVE_POLL) 48 | 49 | #ifndef RTP_HAVE_WSAPOLL 50 | #include 51 | #endif // !RTP_HAVE_WSAPOLL 52 | 53 | #include 54 | #include 55 | 56 | namespace jrtplib 57 | { 58 | 59 | inline int RTPSelect(const SocketType *sockets, int8_t *readflags, size_t numsocks, RTPTime timeout) 60 | { 61 | using namespace std; 62 | 63 | vector fds(numsocks); 64 | 65 | for (size_t i = 0 ; i < numsocks ; i++) 66 | { 67 | fds[i].fd = sockets[i]; 68 | fds[i].events = POLLIN; 69 | fds[i].revents = 0; 70 | readflags[i] = 0; 71 | } 72 | 73 | int timeoutmsec = -1; 74 | if (timeout.GetDouble() >= 0) 75 | { 76 | double dtimeoutmsec = timeout.GetDouble()*1000.0; 77 | if (dtimeoutmsec > (numeric_limits::max)()) // parentheses to prevent windows 'max' macro expansion 78 | dtimeoutmsec = (numeric_limits::max)(); 79 | 80 | timeoutmsec = (int)dtimeoutmsec; 81 | } 82 | 83 | #ifdef RTP_HAVE_WSAPOLL 84 | int status = WSAPoll(&(fds[0]), (ULONG)numsocks, timeoutmsec); 85 | #else 86 | int status = poll(&(fds[0]), numsocks, timeoutmsec); 87 | #endif // RTP_HAVE_WSAPOLL 88 | if (status < 0) 89 | return ERR_RTP_SELECT_ERRORINPOLL; 90 | 91 | if (status > 0) 92 | { 93 | for (size_t i = 0 ; i < numsocks ; i++) 94 | { 95 | if (fds[i].revents) 96 | readflags[i] = 1; 97 | } 98 | } 99 | return status; 100 | } 101 | 102 | } // end namespace 103 | 104 | #else 105 | 106 | #ifndef RTP_SOCKETTYPE_WINSOCK 107 | #include 108 | #include 109 | #include 110 | #endif // !RTP_SOCKETTYPE_WINSOCK 111 | 112 | namespace jrtplib 113 | { 114 | 115 | /** Wrapper function around 'select', 'poll' or 'WSAPoll', depending on the 116 | * availability on your platform. 117 | * 118 | * Wrapper function around 'select', 'poll' or 'WSAPoll', depending on the 119 | * availability on your platform. The function will check the specified 120 | * `sockets` for incoming data and sets the flags in `readflags` if so. 121 | * A maximum time `timeout` will be waited for data to arrive, which is 122 | * indefinitely if set to a negative value. The function returns the number 123 | * of sockets that have data incoming. 124 | */ 125 | inline int RTPSelect(const SocketType *sockets, int8_t *readflags, size_t numsocks, RTPTime timeout) 126 | { 127 | struct timeval tv; 128 | struct timeval *pTv = 0; 129 | 130 | if (timeout.GetDouble() >= 0) 131 | { 132 | tv.tv_sec = (long)timeout.GetSeconds(); 133 | tv.tv_usec = timeout.GetMicroSeconds(); 134 | pTv = &tv; 135 | } 136 | 137 | fd_set fdset; 138 | FD_ZERO(&fdset); 139 | for (size_t i = 0 ; i < numsocks ; i++) 140 | { 141 | #ifndef RTP_SOCKETTYPE_WINSOCK 142 | const int setsize = FD_SETSIZE; 143 | // On windows it seems that comparing the socket value to FD_SETSIZE does 144 | // not make sense 145 | if (sockets[i] >= setsize) 146 | return ERR_RTP_SELECT_SOCKETDESCRIPTORTOOLARGE; 147 | #endif // RTP_SOCKETTYPE_WINSOCK 148 | FD_SET(sockets[i], &fdset); 149 | readflags[i] = 0; 150 | } 151 | 152 | int status = select(FD_SETSIZE, &fdset, 0, 0, pTv); 153 | if (status < 0) 154 | return ERR_RTP_SELECT_ERRORINSELECT; 155 | 156 | if (status > 0) // some descriptors were set, check them 157 | { 158 | for (size_t i = 0 ; i < numsocks ; i++) 159 | { 160 | if (FD_ISSET(sockets[i], &fdset)) 161 | readflags[i] = 1; 162 | } 163 | } 164 | return status; 165 | } 166 | 167 | } // end namespace 168 | 169 | #endif // RTP_HAVE_POLL || RTP_HAVE_WSAPOLL 170 | 171 | #endif // RTPSELECT_H 172 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpsessionsources.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpsessionsources.h 35 | */ 36 | 37 | #ifndef RTPSESSIONSOURCES_H 38 | 39 | #define RTPSESSIONSOURCES_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpsources.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | class RTPSession; 48 | 49 | class JRTPLIB_IMPORTEXPORT RTPSessionSources : public RTPSources 50 | { 51 | public: 52 | RTPSessionSources(RTPSession &sess,RTPMemoryManager *mgr) : RTPSources(RTPSources::ProbationStore,mgr),rtpsession(sess) 53 | { owncollision = false; } 54 | ~RTPSessionSources() { } 55 | void ClearOwnCollisionFlag() { owncollision = false; } 56 | bool DetectedOwnCollision() const { return owncollision; } 57 | private: 58 | void OnRTPPacket(RTPPacket *pack,const RTPTime &receivetime, 59 | const RTPAddress *senderaddress); 60 | void OnRTCPCompoundPacket(RTCPCompoundPacket *pack,const RTPTime &receivetime, 61 | const RTPAddress *senderaddress); 62 | void OnSSRCCollision(RTPSourceData *srcdat,const RTPAddress *senderaddress,bool isrtp); 63 | void OnCNAMECollision(RTPSourceData *srcdat,const RTPAddress *senderaddress, 64 | const uint8_t *cname,size_t cnamelength); 65 | void OnNewSource(RTPSourceData *srcdat); 66 | void OnRemoveSource(RTPSourceData *srcdat); 67 | void OnTimeout(RTPSourceData *srcdat); 68 | void OnBYETimeout(RTPSourceData *srcdat); 69 | void OnBYEPacket(RTPSourceData *srcdat); 70 | void OnAPPPacket(RTCPAPPPacket *apppacket,const RTPTime &receivetime, 71 | const RTPAddress *senderaddress); 72 | void OnUnknownPacketType(RTCPPacket *rtcppack,const RTPTime &receivetime, 73 | const RTPAddress *senderaddress); 74 | void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime, 75 | const RTPAddress *senderaddress); 76 | void OnNoteTimeout(RTPSourceData *srcdat); 77 | void OnValidatedRTPPacket(RTPSourceData *srcdat, RTPPacket *rtppack, bool isonprobation, bool *ispackethandled); 78 | void OnRTCPSenderReport(RTPSourceData *srcdat); 79 | void OnRTCPReceiverReport(RTPSourceData *srcdat); 80 | void OnRTCPSDESItem(RTPSourceData *srcdat, RTCPSDESPacket::ItemType t, 81 | const void *itemdata, size_t itemlength); 82 | #ifdef RTP_SUPPORT_SDESPRIV 83 | void OnRTCPSDESPrivateItem(RTPSourceData *srcdat, const void *prefixdata, size_t prefixlen, 84 | const void *valuedata, size_t valuelen); 85 | #endif // RTP_SUPPORT_SDESPRIV 86 | 87 | RTPSession &rtpsession; 88 | bool owncollision; 89 | }; 90 | 91 | } // end namespace 92 | 93 | #endif // RTPSESSIONSOURCES_H 94 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpsocketutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpsocketutil.h 35 | */ 36 | 37 | #ifndef RTPSOCKETUTIL_H 38 | 39 | #define RTPSOCKETUTIL_H 40 | 41 | #include "rtpconfig.h" 42 | #ifdef RTP_SOCKETTYPE_WINSOCK 43 | #include "rtptypes.h" 44 | #endif // RTP_SOCKETTYPE_WINSOCK 45 | 46 | namespace jrtplib 47 | { 48 | 49 | #ifndef RTP_SOCKETTYPE_WINSOCK 50 | 51 | typedef int SocketType; 52 | 53 | #else 54 | 55 | typedef SOCKET SocketType; 56 | 57 | #endif // RTP_SOCKETTYPE_WINSOCK 58 | 59 | } // end namespace 60 | 61 | #endif // RTPSOCKETUTIL_H 62 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtpstructs.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtpstructs.h 35 | */ 36 | 37 | #ifndef RTPSTRUCTS_H 38 | 39 | #define RTPSTRUCTS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptypes.h" 43 | 44 | namespace jrtplib 45 | { 46 | 47 | struct RTPHeader 48 | { 49 | #ifdef RTP_BIG_ENDIAN 50 | uint8_t version:2; 51 | uint8_t padding:1; 52 | uint8_t extension:1; 53 | uint8_t csrccount:4; 54 | 55 | uint8_t marker:1; 56 | uint8_t payloadtype:7; 57 | #else // little endian 58 | uint8_t csrccount:4; 59 | uint8_t extension:1; 60 | uint8_t padding:1; 61 | uint8_t version:2; 62 | 63 | uint8_t payloadtype:7; 64 | uint8_t marker:1; 65 | #endif // RTP_BIG_ENDIAN 66 | 67 | uint16_t sequencenumber; 68 | uint32_t timestamp; 69 | uint32_t ssrc; 70 | }; 71 | 72 | struct RTPExtensionHeader 73 | { 74 | uint16_t extid; 75 | uint16_t length; 76 | }; 77 | 78 | struct RTPSourceIdentifier 79 | { 80 | uint32_t ssrc; 81 | }; 82 | 83 | struct RTCPCommonHeader 84 | { 85 | #ifdef RTP_BIG_ENDIAN 86 | uint8_t version:2; 87 | uint8_t padding:1; 88 | uint8_t count:5; 89 | #else // little endian 90 | uint8_t count:5; 91 | uint8_t padding:1; 92 | uint8_t version:2; 93 | #endif // RTP_BIG_ENDIAN 94 | 95 | uint8_t packettype; 96 | uint16_t length; 97 | }; 98 | 99 | struct RTCPSenderReport 100 | { 101 | uint32_t ntptime_msw; 102 | uint32_t ntptime_lsw; 103 | uint32_t rtptimestamp; 104 | uint32_t packetcount; 105 | uint32_t octetcount; 106 | }; 107 | 108 | struct RTCPReceiverReport 109 | { 110 | uint32_t ssrc; // Identifies about which SSRC's data this report is... 111 | uint8_t fractionlost; 112 | uint8_t packetslost[3]; 113 | uint32_t exthighseqnr; 114 | uint32_t jitter; 115 | uint32_t lsr; 116 | uint32_t dlsr; 117 | }; 118 | 119 | struct RTCPSDESHeader 120 | { 121 | uint8_t sdesid; 122 | uint8_t length; 123 | }; 124 | 125 | } // end namespace 126 | 127 | #endif // RTPSTRUCTS 128 | 129 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtptcpaddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtptcpaddress.h 35 | */ 36 | 37 | #ifndef RTPTCPADDRESS_H 38 | 39 | #define RTPTCPADDRESS_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtpaddress.h" 43 | #include "rtptypes.h" 44 | #include "rtpsocketutil.h" 45 | 46 | namespace jrtplib 47 | { 48 | 49 | class RTPMemoryManager; 50 | 51 | /** Represents a TCP 'address' and port. 52 | * This class is used by the TCP transmission component, to specify which sockets 53 | * should be used to send/receive data, and to know on which socket incoming data 54 | * was received. 55 | */ 56 | class JRTPLIB_IMPORTEXPORT RTPTCPAddress : public RTPAddress 57 | { 58 | public: 59 | /** Creates an instance with which you can use a specific socket 60 | * in the TCP transmitter (must be connected). */ 61 | RTPTCPAddress(SocketType sock):RTPAddress(TCPAddress) 62 | { 63 | m_socket = sock; 64 | } 65 | 66 | ~RTPTCPAddress() { } 67 | 68 | /** Returns the socket that was specified in the constructor. */ 69 | SocketType GetSocket() const { return m_socket; } 70 | 71 | RTPAddress *CreateCopy(RTPMemoryManager *mgr) const; 72 | 73 | // Note that these functions are only used for received packets 74 | bool IsSameAddress(const RTPAddress *addr) const; 75 | bool IsFromSameHost(const RTPAddress *addr) const; 76 | #ifdef RTPDEBUG 77 | std::string GetAddressString() const; 78 | #endif // RTPDEBUG 79 | private: 80 | SocketType m_socket; 81 | }; 82 | 83 | } // end namespace 84 | 85 | #endif // RTPTCPADDRESS_H 86 | 87 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtptcptransmitter.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | /** 34 | * \file rtptcptransmitter.h 35 | */ 36 | 37 | #ifndef RTPTCPTRANSMITTER_H 38 | 39 | #define RTPTCPTRANSMITTER_H 40 | 41 | #include "rtpconfig.h" 42 | #include "rtptransmitter.h" 43 | #include "rtpsocketutil.h" 44 | #include "rtpabortdescriptors.h" 45 | #include 46 | #include 47 | #include 48 | 49 | #ifdef RTP_SUPPORT_THREAD 50 | #include 51 | #endif // RTP_SUPPORT_THREAD 52 | 53 | namespace jrtplib 54 | { 55 | 56 | /** Parameters for the TCP transmitter. */ 57 | class JRTPLIB_IMPORTEXPORT RTPTCPTransmissionParams : public RTPTransmissionParams 58 | { 59 | public: 60 | RTPTCPTransmissionParams(); 61 | 62 | /** If non null, the specified abort descriptors will be used to cancel 63 | * the function that's waiting for packets to arrive; set to null (the default) 64 | * to let the transmitter create its own instance. */ 65 | void SetCreatedAbortDescriptors(RTPAbortDescriptors *desc) { m_pAbortDesc = desc; } 66 | 67 | /** If non-null, this RTPAbortDescriptors instance will be used internally, 68 | * which can be useful when creating your own poll thread for multiple 69 | * sessions. */ 70 | RTPAbortDescriptors *GetCreatedAbortDescriptors() const { return m_pAbortDesc; } 71 | private: 72 | RTPAbortDescriptors *m_pAbortDesc; 73 | }; 74 | 75 | inline RTPTCPTransmissionParams::RTPTCPTransmissionParams() : RTPTransmissionParams(RTPTransmitter::TCPProto) 76 | { 77 | m_pAbortDesc = 0; 78 | } 79 | 80 | /** Additional information about the TCP transmitter. */ 81 | class JRTPLIB_IMPORTEXPORT RTPTCPTransmissionInfo : public RTPTransmissionInfo 82 | { 83 | public: 84 | RTPTCPTransmissionInfo() : RTPTransmissionInfo(RTPTransmitter::TCPProto) { } 85 | ~RTPTCPTransmissionInfo() { } 86 | }; 87 | 88 | // TODO: this is for IPv4, and will only be valid if one rtp packet is in one tcp frame 89 | #define RTPTCPTRANS_HEADERSIZE (20+20+2) // 20 IP, 20 TCP, 2 for framing (RFC 4571) 90 | 91 | /** A TCP transmission component. 92 | * 93 | * This class inherits the RTPTransmitter interface and implements a transmission component 94 | * which uses TCP to send and receive RTP and RTCP data. The component's parameters 95 | * are described by the class RTPTCPTransmissionParams. The functions which have an RTPAddress 96 | * argument require an argument of RTPTCPAddress. The RTPTransmitter::GetTransmissionInfo member function 97 | * returns an instance of type RTPTCPTransmissionInfo. 98 | * 99 | * After this transmission component was created, no data will actually be sent or received 100 | * yet. You can specify over which TCP connections (which must be established first) data 101 | * should be transmitted by using the RTPTransmitter::AddDestination member function. This 102 | * takes an argument of type RTPTCPAddress, with which relevant the socket descriptor can 103 | * be passed to the transmitter. 104 | * 105 | * These sockets will also be used to check for incoming RTP or RTCP data. The RTPTCPAddress 106 | * instance that's associated with a received packet, will contain the socket descriptor 107 | * on which the data was received. This descriptor can be obtained using RTPTCPAddress::GetSocket. 108 | * 109 | * To get notified of an error when sending over or receiving from a socket, override the 110 | * RTPTCPTransmitter::OnSendError and RTPTCPTransmitter::OnReceiveError member functions. 111 | */ 112 | class JRTPLIB_IMPORTEXPORT RTPTCPTransmitter : public RTPTransmitter 113 | { 114 | public: 115 | RTPTCPTransmitter(RTPMemoryManager *mgr); 116 | ~RTPTCPTransmitter(); 117 | 118 | int Init(bool treadsafe); 119 | int Create(size_t maxpacksize,const RTPTransmissionParams *transparams); 120 | void Destroy(); 121 | RTPTransmissionInfo *GetTransmissionInfo(); 122 | void DeleteTransmissionInfo(RTPTransmissionInfo *inf); 123 | 124 | int GetLocalHostName(uint8_t *buffer,size_t *bufferlength); 125 | bool ComesFromThisTransmitter(const RTPAddress *addr); 126 | size_t GetHeaderOverhead() { return RTPTCPTRANS_HEADERSIZE; } 127 | 128 | int Poll(); 129 | int WaitForIncomingData(const RTPTime &delay,bool *dataavailable = 0); 130 | int AbortWait(); 131 | 132 | int SendRTPData(const void *data,size_t len); 133 | int SendRTCPData(const void *data,size_t len); 134 | 135 | int AddDestination(const RTPAddress &addr); 136 | int DeleteDestination(const RTPAddress &addr); 137 | void ClearDestinations(); 138 | 139 | bool SupportsMulticasting(); 140 | int JoinMulticastGroup(const RTPAddress &addr); 141 | int LeaveMulticastGroup(const RTPAddress &addr); 142 | void LeaveAllMulticastGroups(); 143 | 144 | int SetReceiveMode(RTPTransmitter::ReceiveMode m); 145 | int AddToIgnoreList(const RTPAddress &addr); 146 | int DeleteFromIgnoreList(const RTPAddress &addr); 147 | void ClearIgnoreList(); 148 | int AddToAcceptList(const RTPAddress &addr); 149 | int DeleteFromAcceptList(const RTPAddress &addr); 150 | void ClearAcceptList(); 151 | int SetMaximumPacketSize(size_t s); 152 | 153 | bool NewDataAvailable(); 154 | RTPRawPacket *GetNextPacket(); 155 | #ifdef RTPDEBUG 156 | void Dump(); 157 | #endif // RTPDEBUG 158 | protected: 159 | /** By overriding this function you can be notified of an error when sending over a socket. */ 160 | virtual void OnSendError(SocketType sock); 161 | /** By overriding this function you can be notified of an error when receiving from a socket. */ 162 | virtual void OnReceiveError(SocketType sock); 163 | private: 164 | class SocketData 165 | { 166 | public: 167 | SocketData(); 168 | ~SocketData(); 169 | void Reset(); 170 | 171 | uint8_t m_lengthBuffer[2]; 172 | int m_lengthBufferOffset; 173 | int m_dataLength; 174 | int m_dataBufferOffset; 175 | uint8_t *m_pDataBuffer; 176 | 177 | uint8_t *ExtractDataBuffer() { uint8_t *pTmp = m_pDataBuffer; m_pDataBuffer = 0; return pTmp; } 178 | int ProcessAvailableBytes(SocketType sock, int availLen, bool &complete, RTPMemoryManager *pMgr); 179 | }; 180 | 181 | int SendRTPRTCPData(const void *data,size_t len); 182 | void FlushPackets(); 183 | int PollSocket(SocketType sock, SocketData &sdata); 184 | void ClearDestSockets(); 185 | int ValidateSocket(SocketType s); 186 | 187 | bool m_init; 188 | bool m_created; 189 | bool m_waitingForData; 190 | 191 | std::map m_destSockets; 192 | std::vector m_tmpSocks; 193 | std::vector m_tmpFlags; 194 | std::vector m_localHostname; 195 | size_t m_maxPackSize; 196 | 197 | std::list m_rawpacketlist; 198 | 199 | RTPAbortDescriptors m_abortDesc; 200 | RTPAbortDescriptors *m_pAbortDesc; // in case an external one was specified 201 | 202 | #ifdef RTP_SUPPORT_THREAD 203 | jthread::JMutex m_mainMutex, m_waitMutex; 204 | bool m_threadsafe; 205 | #endif // RTP_SUPPORT_THREAD 206 | }; 207 | 208 | inline void RTPTCPTransmitter::OnSendError(SocketType) { } 209 | inline void RTPTCPTransmitter::OnReceiveError(SocketType) { } 210 | 211 | } // end namespace 212 | 213 | #endif // RTPTCPTRANSMITTER_H 214 | 215 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtptypes.h: -------------------------------------------------------------------------------- 1 | #include "rtpconfig.h" 2 | 3 | 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jrtplib3/rtptypes_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of JRTPLIB 4 | Copyright (c) 1999-2017 Jori Liesenborgs 5 | 6 | Contact: jori.liesenborgs@gmail.com 7 | 8 | This library was developed at the Expertise Centre for Digital Media 9 | (http://www.edm.uhasselt.be), a research center of the Hasselt University 10 | (http://www.uhasselt.be). The library is based upon work done for 11 | my thesis at the School for Knowledge Technology (Belgium/The Netherlands). 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the "Software"), 15 | to deal in the Software without restriction, including without limitation 16 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | and/or sell copies of the Software, and to permit persons to whom the 18 | Software is furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included 21 | in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29 | IN THE SOFTWARE. 30 | 31 | */ 32 | 33 | #ifndef RTPTYPES_WIN_H 34 | 35 | #define RTPTYPES_WIN_H 36 | 37 | #ifndef INTTYPES_DEFINED 38 | 39 | #define INTTYPES_DEFINED 40 | 41 | typedef char int8_t; 42 | typedef unsigned char uint8_t; 43 | typedef short int16_t; 44 | typedef unsigned short uint16_t; 45 | typedef int int32_t; 46 | typedef unsigned int uint32_t; 47 | typedef __int64 int64_t; 48 | typedef unsigned __int64 uint64_t; 49 | 50 | #endif // INTTYPES_DEFINED 51 | 52 | #endif // RTPTYPES_WIN_H 53 | 54 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jthread/jmutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of the JThread package, which contains some object- 4 | oriented thread wrappers for different thread implementations. 5 | 6 | Copyright (c) 2000-2017 Jori Liesenborgs (jori.liesenborgs@gmail.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | */ 27 | 28 | #ifndef JTHREAD_JMUTEX_H 29 | 30 | #define JTHREAD_JMUTEX_H 31 | 32 | #include "jthreadconfig.h" 33 | #ifdef JTHREAD_CONFIG_WIN32THREADS 34 | #ifndef _WIN32_WCE 35 | #include 36 | #endif // _WIN32_WCE 37 | #include 38 | #include 39 | #else // using pthread 40 | #include 41 | #endif // JTHREAD_CONFIG_WIN32THREADS 42 | 43 | #define ERR_JMUTEX_ALREADYINIT -1 44 | #define ERR_JMUTEX_NOTINIT -2 45 | #define ERR_JMUTEX_CANTCREATEMUTEX -3 46 | 47 | namespace jthread 48 | { 49 | 50 | class JTHREAD_IMPORTEXPORT JMutex 51 | { 52 | public: 53 | JMutex(); 54 | ~JMutex(); 55 | int Init(); 56 | int Lock(); 57 | int Unlock(); 58 | bool IsInitialized() { return initialized; } 59 | private: 60 | #ifdef JTHREAD_CONFIG_WIN32THREADS 61 | #ifdef JTHREAD_CONFIG_JMUTEXCRITICALSECTION 62 | CRITICAL_SECTION mutex; 63 | #else // Use standard mutex 64 | HANDLE mutex; 65 | #endif // JTHREAD_CONFIG_JMUTEXCRITICALSECTION 66 | #else // pthread mutex 67 | pthread_mutex_t mutex; 68 | #endif // JTHREAD_CONFIG_WIN32THREADS 69 | bool initialized; 70 | }; 71 | 72 | } // end namespace 73 | 74 | #endif // JTHREAD_JMUTEX_H 75 | 76 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jthread/jmutexautolock.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of the JThread package, which contains some object- 4 | oriented thread wrappers for different thread implementations. 5 | 6 | Copyright (c) 2000-2017 Jori Liesenborgs (jori.liesenborgs@gmail.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | */ 27 | 28 | #ifndef JTHREAD_JMUTEXAUTOLOCK_H 29 | 30 | #define JTHREAD_JMUTEXAUTOLOCK_H 31 | 32 | #include "jthreadconfig.h" 33 | #include "jmutex.h" 34 | 35 | namespace jthread 36 | { 37 | 38 | class JTHREAD_IMPORTEXPORT JMutexAutoLock 39 | { 40 | public: 41 | JMutexAutoLock(JMutex &m) : mutex(m) { mutex.Lock(); } 42 | ~JMutexAutoLock() { mutex.Unlock(); } 43 | private: 44 | JMutex &mutex; 45 | }; 46 | 47 | } // end namespace 48 | 49 | #endif // JTHREAD_JMUTEXAUTOLOCK_H 50 | 51 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jthread/jthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of the JThread package, which contains some object- 4 | oriented thread wrappers for different thread implementations. 5 | 6 | Copyright (c) 2000-2017 Jori Liesenborgs (jori.liesenborgs@gmail.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | */ 27 | 28 | #ifndef JTHREAD_JTHREAD_H 29 | 30 | #define JTHREAD_JTHREAD_H 31 | 32 | #include "jthreadconfig.h" 33 | #include "jmutex.h" 34 | 35 | #define ERR_JTHREAD_CANTINITMUTEX -1 36 | #define ERR_JTHREAD_CANTSTARTTHREAD -2 37 | #define ERR_JTHREAD_THREADFUNCNOTSET -3 38 | #define ERR_JTHREAD_NOTRUNNING -4 39 | #define ERR_JTHREAD_ALREADYRUNNING -5 40 | 41 | namespace jthread 42 | { 43 | 44 | class JTHREAD_IMPORTEXPORT JThread 45 | { 46 | public: 47 | JThread(); 48 | virtual ~JThread(); 49 | int Start(); 50 | int Kill(); 51 | virtual void *Thread() = 0; 52 | bool IsRunning(); 53 | void *GetReturnValue(); 54 | bool IsSameThread(); 55 | protected: 56 | void ThreadStarted(); 57 | private: 58 | 59 | #ifdef JTHREAD_CONFIG_WIN32THREADS 60 | #ifdef _WIN32_WCE 61 | DWORD threadid; 62 | static DWORD WINAPI TheThread(void *param); 63 | #else 64 | static UINT __stdcall TheThread(void *param); 65 | UINT threadid; 66 | #endif // _WIN32_WCE 67 | HANDLE threadhandle; 68 | #else // pthread type threads 69 | static void *TheThread(void *param); 70 | 71 | pthread_t threadid; 72 | #endif // JTHREAD_CONFIG_WIN32THREADS 73 | void *retval; 74 | bool running; 75 | 76 | JMutex runningmutex; 77 | JMutex continuemutex,continuemutex2; 78 | bool mutexinit; 79 | }; 80 | 81 | } // end namespace 82 | 83 | #endif // JTHREAD_JTHREAD_H 84 | 85 | -------------------------------------------------------------------------------- /RtspClient/lib/include/jthread/jthreadconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is a part of the JThread package, which contains some object- 4 | oriented thread wrappers for different thread implementations. 5 | 6 | Copyright (c) 2000-2017 Jori Liesenborgs (jori.liesenborgs@gmail.com) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | 26 | */ 27 | 28 | #ifndef JTHREADCONFIG_H 29 | 30 | #define JTHREADCONFIG_H 31 | 32 | #define JTHREAD_IMPORT 33 | #define JTHREAD_EXPORT 34 | #ifdef JTHREAD_COMPILING 35 | #define JTHREAD_IMPORTEXPORT JTHREAD_EXPORT 36 | #else 37 | #define JTHREAD_IMPORTEXPORT JTHREAD_IMPORT 38 | #endif // JTHREAD_COMPILING 39 | 40 | // Using pthread based threads 41 | 42 | 43 | 44 | #endif // JTHREADCONFIG_H 45 | 46 | -------------------------------------------------------------------------------- /RtspClient/lib/libjrtp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjrtp.a -------------------------------------------------------------------------------- /RtspClient/lib/libjrtp.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjrtp.so -------------------------------------------------------------------------------- /RtspClient/lib/libjrtp.so.3.11.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjrtp.so.3.11.1 -------------------------------------------------------------------------------- /RtspClient/lib/libjthread.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjthread.a -------------------------------------------------------------------------------- /RtspClient/lib/libjthread.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjthread.so -------------------------------------------------------------------------------- /RtspClient/lib/libjthread.so.1.3.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/lib/libjthread.so.1.3.3 -------------------------------------------------------------------------------- /RtspClient/src/MediaSession.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/MediaSession.cpp -------------------------------------------------------------------------------- /RtspClient/src/RtpPacketType.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/RtpPacketType.cpp -------------------------------------------------------------------------------- /RtspClient/src/RtspClient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/RtspClient.cpp -------------------------------------------------------------------------------- /RtspClient/src/TcpSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/TcpSocket.cpp -------------------------------------------------------------------------------- /RtspClient/src/base64/Base64.cpp: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // "liveMedia" 17 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 18 | // Base64 encoding and decoding 19 | // implementation 20 | 21 | #include "Base64.hh" 22 | #include 23 | #include 24 | 25 | static char base64DecodeTable[256]; 26 | 27 | static void initBase64DecodeTable() { 28 | int i; 29 | for (i = 0; i < 256; ++i) base64DecodeTable[i] = (char)0x80; 30 | // default value: invalid 31 | 32 | for (i = 'A'; i <= 'Z'; ++i) base64DecodeTable[i] = 0 + (i - 'A'); 33 | for (i = 'a'; i <= 'z'; ++i) base64DecodeTable[i] = 26 + (i - 'a'); 34 | for (i = '0'; i <= '9'; ++i) base64DecodeTable[i] = 52 + (i - '0'); 35 | base64DecodeTable[(unsigned char)'+'] = 62; 36 | base64DecodeTable[(unsigned char)'/'] = 63; 37 | base64DecodeTable[(unsigned char)'='] = 0; 38 | } 39 | 40 | unsigned char* base64Decode(char const* in, unsigned& resultSize, 41 | Boolean trimTrailingZeros) { 42 | if (in == NULL) return NULL; // sanity check 43 | return base64Decode(in, strlen(in), resultSize, trimTrailingZeros); 44 | } 45 | 46 | unsigned char* base64Decode(char const* in, unsigned inSize, 47 | unsigned& resultSize, 48 | Boolean trimTrailingZeros) { 49 | static Boolean haveInitializedBase64DecodeTable = False; 50 | if (!haveInitializedBase64DecodeTable) { 51 | initBase64DecodeTable(); 52 | haveInitializedBase64DecodeTable = True; 53 | } 54 | 55 | unsigned char* out = (unsigned char*)strDupSize(in); // ensures we have enough space 56 | int k = 0; 57 | int paddingCount = 0; 58 | int const jMax = inSize - 3; 59 | // in case "inSize" is not a multiple of 4 (although it should be) 60 | for (int j = 0; j < jMax; j += 4) { 61 | char inTmp[4], outTmp[4]; 62 | for (int i = 0; i < 4; ++i) { 63 | inTmp[i] = in[i+j]; 64 | if (inTmp[i] == '=') ++paddingCount; 65 | outTmp[i] = base64DecodeTable[(unsigned char)inTmp[i]]; 66 | if ((outTmp[i]&0x80) != 0) outTmp[i] = 0; // this happens only if there was an invalid character; pretend that it was 'A' 67 | } 68 | 69 | out[k++] = (outTmp[0]<<2) | (outTmp[1]>>4); 70 | out[k++] = (outTmp[1]<<4) | (outTmp[2]>>2); 71 | out[k++] = (outTmp[2]<<6) | outTmp[3]; 72 | } 73 | 74 | if (trimTrailingZeros) { 75 | while (paddingCount > 0 && k > 0 && out[k-1] == '\0') { --k; --paddingCount; } 76 | } 77 | resultSize = k; 78 | unsigned char* result = new unsigned char[resultSize]; 79 | memmove(result, out, resultSize); 80 | delete[] out; 81 | 82 | return result; 83 | } 84 | 85 | static const char base64Char[] = 86 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 87 | 88 | char* base64Encode(char const* origSigned, unsigned origLength) { 89 | unsigned char const* orig = (unsigned char const*)origSigned; // in case any input bytes have the MSB set 90 | if (orig == NULL) return NULL; 91 | 92 | unsigned const numOrig24BitValues = origLength/3; 93 | Boolean havePadding = origLength > numOrig24BitValues*3; 94 | Boolean havePadding2 = origLength == numOrig24BitValues*3 + 2; 95 | unsigned const numResultBytes = 4*(numOrig24BitValues + havePadding); 96 | char* result = new char[numResultBytes+1]; // allow for trailing '\0' 97 | 98 | // Map each full group of 3 input bytes into 4 output base-64 characters: 99 | unsigned i; 100 | for (i = 0; i < numOrig24BitValues; ++i) { 101 | result[4*i+0] = base64Char[(orig[3*i]>>2)&0x3F]; 102 | result[4*i+1] = base64Char[(((orig[3*i]&0x3)<<4) | (orig[3*i+1]>>4))&0x3F]; 103 | result[4*i+2] = base64Char[((orig[3*i+1]<<2) | (orig[3*i+2]>>6))&0x3F]; 104 | result[4*i+3] = base64Char[orig[3*i+2]&0x3F]; 105 | } 106 | 107 | // Now, take padding into account. (Note: i == numOrig24BitValues) 108 | if (havePadding) { 109 | result[4*i+0] = base64Char[(orig[3*i]>>2)&0x3F]; 110 | if (havePadding2) { 111 | result[4*i+1] = base64Char[(((orig[3*i]&0x3)<<4) | (orig[3*i+1]>>4))&0x3F]; 112 | result[4*i+2] = base64Char[(orig[3*i+1]<<2)&0x3F]; 113 | } else { 114 | result[4*i+1] = base64Char[((orig[3*i]&0x3)<<4)&0x3F]; 115 | result[4*i+2] = '='; 116 | } 117 | result[4*i+3] = '='; 118 | } 119 | 120 | result[numResultBytes] = '\0'; 121 | return result; 122 | } 123 | -------------------------------------------------------------------------------- /RtspClient/src/base64/include/Base64.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // "liveMedia" 17 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 18 | // Base64 encoding and decoding 19 | // C++ header 20 | 21 | #ifndef _BASE64_HH 22 | #define _BASE64_HH 23 | 24 | #ifndef _BOOLEAN_HH 25 | #include "Boolean.hh" 26 | #endif 27 | 28 | unsigned char* base64Decode(char const* in, unsigned& resultSize, 29 | Boolean trimTrailingZeros = True); 30 | // returns a newly allocated array - of size "resultSize" - that 31 | // the caller is responsible for delete[]ing. 32 | 33 | unsigned char* base64Decode(char const* in, unsigned inSize, 34 | unsigned& resultSize, 35 | Boolean trimTrailingZeros = True); 36 | // As above, but includes the size of the input string (i.e., the number of bytes to decode) as a parameter. 37 | // This saves an extra call to "strlen()" if we already know the length of the input string. 38 | 39 | char* base64Encode(char const* orig, unsigned origLength); 40 | // returns a 0-terminated string that 41 | // the caller is responsible for delete[]ing. 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /RtspClient/src/base64/include/Boolean.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | #ifndef _BOOLEAN_HH 17 | #define _BOOLEAN_HH 18 | 19 | #if defined(__BORLANDC__) || (!defined(USE_LIVE555_BOOLEAN) && defined(_MSC_VER) && _MSC_VER >= 1400) 20 | // Use the "bool" type defined by the Borland compiler, and MSVC++ 8.0, Visual Studio 2005 and higher 21 | typedef bool Boolean; 22 | #define False false 23 | #define True true 24 | #else 25 | typedef unsigned char Boolean; 26 | #ifndef __MSHTML_LIBRARY_DEFINED__ 27 | #ifndef False 28 | const Boolean False = 0; 29 | #endif 30 | #ifndef True 31 | const Boolean True = 1; 32 | #endif 33 | 34 | #endif 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /RtspClient/src/base64/include/strDup.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | 17 | #ifndef _STRDUP_HH 18 | #define _STRDUP_HH 19 | 20 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 21 | // A C++ equivalent to the standard C routine "strdup()". 22 | // This generates a char* that can be deleted using "delete[]" 23 | // Header 24 | 25 | #include 26 | 27 | char* strDup(char const* str); 28 | // Note: strDup(NULL) returns NULL 29 | 30 | char* strDupSize(char const* str); 31 | // Like "strDup()", except that it *doesn't* copy the original. 32 | // (Instead, it just allocates a string of the same size as the original.) 33 | 34 | char* strDupSize(char const* str, size_t& resultBufSize); 35 | // An alternative form of "strDupSize()" that also returns the size of the allocated buffer. 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /RtspClient/src/base64/strDup.cpp: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 17 | // A C++ equivalent to the standard C routine "strdup()". 18 | // This generates a char* that can be deleted using "delete[]" 19 | // Implementation 20 | 21 | #include "strDup.hh" 22 | 23 | char* strDup(char const* str) { 24 | if (str == NULL) return NULL; 25 | size_t len = strlen(str) + 1; 26 | char* copy = new char[len]; 27 | 28 | if (copy != NULL) { 29 | memcpy(copy, str, len); 30 | } 31 | return copy; 32 | } 33 | 34 | char* strDupSize(char const* str) { 35 | size_t dummy; 36 | 37 | return strDupSize(str, dummy); 38 | } 39 | 40 | char* strDupSize(char const* str, size_t& resultBufSize) { 41 | if (str == NULL) { 42 | resultBufSize = 0; 43 | return NULL; 44 | } 45 | 46 | resultBufSize = strlen(str) + 1; 47 | char* copy = new char[resultBufSize]; 48 | 49 | return copy; 50 | } 51 | -------------------------------------------------------------------------------- /RtspClient/src/include/Definition.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2018 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : Definition.h 5 | * Description : Definition operation center 6 | * Created : 2017.09.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef DEFINITION_H 13 | #define DEFINITION_H 14 | 15 | #define TRUE 0 16 | #define FALSE -1 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | #endif //DEFINITION_H -------------------------------------------------------------------------------- /RtspClient/src/include/MediaSession.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/include/MediaSession.h -------------------------------------------------------------------------------- /RtspClient/src/include/RtpPacketType.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/include/RtpPacketType.h -------------------------------------------------------------------------------- /RtspClient/src/include/RtspClient.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspClient/src/include/RtspClient.h -------------------------------------------------------------------------------- /RtspClient/src/include/TcpSocket.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2018 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : TcpSocket.h 5 | * Description : TcpSocket operation center 6 | * Created : 2017.09.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef TCP_SOCKET_H 13 | #define TCP_SOCKET_H 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | using std::map; 21 | using std::string; 22 | 23 | /***************************************************************************** 24 | -Class : TcpSocket 25 | -Description : 26 | * Modify Date Version Author Modification 27 | * ----------------------------------------------- 28 | * 2017/09/21 V1.0.0 Yu Weifeng Created 29 | ******************************************************************************/ 30 | class TcpSocket 31 | { 32 | public: 33 | TcpSocket(); 34 | ~TcpSocket(); 35 | int Create(string i_URL); 36 | int Send(string *i_pMsg); 37 | int Recv(string *o_pMsg); 38 | void Close(); 39 | 40 | private: 41 | int GetIpAndPort(string i_URL,string *o_Ip,unsigned short *o_wPort); 42 | int m_iSocketFd; 43 | }; 44 | 45 | 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /RtspServer/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/Makefile -------------------------------------------------------------------------------- /RtspServer/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/ReadMe.txt -------------------------------------------------------------------------------- /RtspServer/copy.bat: -------------------------------------------------------------------------------- 1 | ::获取当前目录 当前目录拷贝到z pause 2 | set pa=%cd% 3 | echo %pa% 4 | xcopy %pa% Y:\test\RtspServer /Y/K/S 5 | ::pause -------------------------------------------------------------------------------- /RtspServer/examples/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/examples/Main.cpp -------------------------------------------------------------------------------- /RtspServer/sintel.h264: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/sintel.h264 -------------------------------------------------------------------------------- /RtspServer/src/RtpPacket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/RtpPacket.cpp -------------------------------------------------------------------------------- /RtspServer/src/RtpSession.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/RtpSession.cpp -------------------------------------------------------------------------------- /RtspServer/src/RtspServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/RtspServer.cpp -------------------------------------------------------------------------------- /RtspServer/src/TcpSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/TcpSocket.cpp -------------------------------------------------------------------------------- /RtspServer/src/Tools.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/Tools.cpp -------------------------------------------------------------------------------- /RtspServer/src/UdpSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/UdpSocket.cpp -------------------------------------------------------------------------------- /RtspServer/src/base64/Base64.cpp: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // "liveMedia" 17 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 18 | // Base64 encoding and decoding 19 | // implementation 20 | 21 | #include "Base64.hh" 22 | #include 23 | #include 24 | 25 | static char base64DecodeTable[256]; 26 | 27 | static void initBase64DecodeTable() { 28 | int i; 29 | for (i = 0; i < 256; ++i) base64DecodeTable[i] = (char)0x80; 30 | // default value: invalid 31 | 32 | for (i = 'A'; i <= 'Z'; ++i) base64DecodeTable[i] = 0 + (i - 'A'); 33 | for (i = 'a'; i <= 'z'; ++i) base64DecodeTable[i] = 26 + (i - 'a'); 34 | for (i = '0'; i <= '9'; ++i) base64DecodeTable[i] = 52 + (i - '0'); 35 | base64DecodeTable[(unsigned char)'+'] = 62; 36 | base64DecodeTable[(unsigned char)'/'] = 63; 37 | base64DecodeTable[(unsigned char)'='] = 0; 38 | } 39 | 40 | unsigned char* base64Decode(char const* in, unsigned& resultSize, 41 | Boolean trimTrailingZeros) { 42 | if (in == NULL) return NULL; // sanity check 43 | return base64Decode(in, strlen(in), resultSize, trimTrailingZeros); 44 | } 45 | 46 | unsigned char* base64Decode(char const* in, unsigned inSize, 47 | unsigned& resultSize, 48 | Boolean trimTrailingZeros) { 49 | static Boolean haveInitializedBase64DecodeTable = False; 50 | if (!haveInitializedBase64DecodeTable) { 51 | initBase64DecodeTable(); 52 | haveInitializedBase64DecodeTable = True; 53 | } 54 | 55 | unsigned char* out = (unsigned char*)strDupSize(in); // ensures we have enough space 56 | int k = 0; 57 | int paddingCount = 0; 58 | int const jMax = inSize - 3; 59 | // in case "inSize" is not a multiple of 4 (although it should be) 60 | for (int j = 0; j < jMax; j += 4) { 61 | char inTmp[4], outTmp[4]; 62 | for (int i = 0; i < 4; ++i) { 63 | inTmp[i] = in[i+j]; 64 | if (inTmp[i] == '=') ++paddingCount; 65 | outTmp[i] = base64DecodeTable[(unsigned char)inTmp[i]]; 66 | if ((outTmp[i]&0x80) != 0) outTmp[i] = 0; // this happens only if there was an invalid character; pretend that it was 'A' 67 | } 68 | 69 | out[k++] = (outTmp[0]<<2) | (outTmp[1]>>4); 70 | out[k++] = (outTmp[1]<<4) | (outTmp[2]>>2); 71 | out[k++] = (outTmp[2]<<6) | outTmp[3]; 72 | } 73 | 74 | if (trimTrailingZeros) { 75 | while (paddingCount > 0 && k > 0 && out[k-1] == '\0') { --k; --paddingCount; } 76 | } 77 | resultSize = k; 78 | unsigned char* result = new unsigned char[resultSize]; 79 | memmove(result, out, resultSize); 80 | delete[] out; 81 | 82 | return result; 83 | } 84 | 85 | static const char base64Char[] = 86 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 87 | 88 | char* base64Encode(char const* origSigned, unsigned origLength) { 89 | unsigned char const* orig = (unsigned char const*)origSigned; // in case any input bytes have the MSB set 90 | if (orig == NULL) return NULL; 91 | 92 | unsigned const numOrig24BitValues = origLength/3; 93 | Boolean havePadding = origLength > numOrig24BitValues*3; 94 | Boolean havePadding2 = origLength == numOrig24BitValues*3 + 2; 95 | unsigned const numResultBytes = 4*(numOrig24BitValues + havePadding); 96 | char* result = new char[numResultBytes+1]; // allow for trailing '\0' 97 | 98 | // Map each full group of 3 input bytes into 4 output base-64 characters: 99 | unsigned i; 100 | for (i = 0; i < numOrig24BitValues; ++i) { 101 | result[4*i+0] = base64Char[(orig[3*i]>>2)&0x3F]; 102 | result[4*i+1] = base64Char[(((orig[3*i]&0x3)<<4) | (orig[3*i+1]>>4))&0x3F]; 103 | result[4*i+2] = base64Char[((orig[3*i+1]<<2) | (orig[3*i+2]>>6))&0x3F]; 104 | result[4*i+3] = base64Char[orig[3*i+2]&0x3F]; 105 | } 106 | 107 | // Now, take padding into account. (Note: i == numOrig24BitValues) 108 | if (havePadding) { 109 | result[4*i+0] = base64Char[(orig[3*i]>>2)&0x3F]; 110 | if (havePadding2) { 111 | result[4*i+1] = base64Char[(((orig[3*i]&0x3)<<4) | (orig[3*i+1]>>4))&0x3F]; 112 | result[4*i+2] = base64Char[(orig[3*i+1]<<2)&0x3F]; 113 | } else { 114 | result[4*i+1] = base64Char[((orig[3*i]&0x3)<<4)&0x3F]; 115 | result[4*i+2] = '='; 116 | } 117 | result[4*i+3] = '='; 118 | } 119 | 120 | result[numResultBytes] = '\0'; 121 | return result; 122 | } 123 | -------------------------------------------------------------------------------- /RtspServer/src/base64/include/Base64.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // "liveMedia" 17 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 18 | // Base64 encoding and decoding 19 | // C++ header 20 | 21 | #ifndef _BASE64_HH 22 | #define _BASE64_HH 23 | 24 | #ifndef _BOOLEAN_HH 25 | #include "Boolean.hh" 26 | #endif 27 | 28 | unsigned char* base64Decode(char const* in, unsigned& resultSize, 29 | Boolean trimTrailingZeros = True); 30 | // returns a newly allocated array - of size "resultSize" - that 31 | // the caller is responsible for delete[]ing. 32 | 33 | unsigned char* base64Decode(char const* in, unsigned inSize, 34 | unsigned& resultSize, 35 | Boolean trimTrailingZeros = True); 36 | // As above, but includes the size of the input string (i.e., the number of bytes to decode) as a parameter. 37 | // This saves an extra call to "strlen()" if we already know the length of the input string. 38 | 39 | char* base64Encode(char const* orig, unsigned origLength); 40 | // returns a 0-terminated string that 41 | // the caller is responsible for delete[]ing. 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /RtspServer/src/base64/include/Boolean.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | #ifndef _BOOLEAN_HH 17 | #define _BOOLEAN_HH 18 | 19 | #if defined(__BORLANDC__) || (!defined(USE_LIVE555_BOOLEAN) && defined(_MSC_VER) && _MSC_VER >= 1400) 20 | // Use the "bool" type defined by the Borland compiler, and MSVC++ 8.0, Visual Studio 2005 and higher 21 | typedef bool Boolean; 22 | #define False false 23 | #define True true 24 | #else 25 | typedef unsigned char Boolean; 26 | #ifndef __MSHTML_LIBRARY_DEFINED__ 27 | #ifndef False 28 | const Boolean False = 0; 29 | #endif 30 | #ifndef True 31 | const Boolean True = 1; 32 | #endif 33 | 34 | #endif 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /RtspServer/src/base64/include/strDup.hh: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | 17 | #ifndef _STRDUP_HH 18 | #define _STRDUP_HH 19 | 20 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 21 | // A C++ equivalent to the standard C routine "strdup()". 22 | // This generates a char* that can be deleted using "delete[]" 23 | // Header 24 | 25 | #include 26 | 27 | char* strDup(char const* str); 28 | // Note: strDup(NULL) returns NULL 29 | 30 | char* strDupSize(char const* str); 31 | // Like "strDup()", except that it *doesn't* copy the original. 32 | // (Instead, it just allocates a string of the same size as the original.) 33 | 34 | char* strDupSize(char const* str, size_t& resultBufSize); 35 | // An alternative form of "strDupSize()" that also returns the size of the allocated buffer. 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /RtspServer/src/base64/strDup.cpp: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 2.1 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // Copyright (c) 1996-2015 Live Networks, Inc. All rights reserved. 17 | // A C++ equivalent to the standard C routine "strdup()". 18 | // This generates a char* that can be deleted using "delete[]" 19 | // Implementation 20 | 21 | #include "strDup.hh" 22 | 23 | char* strDup(char const* str) { 24 | if (str == NULL) return NULL; 25 | size_t len = strlen(str) + 1; 26 | char* copy = new char[len]; 27 | 28 | if (copy != NULL) { 29 | memcpy(copy, str, len); 30 | } 31 | return copy; 32 | } 33 | 34 | char* strDupSize(char const* str) { 35 | size_t dummy; 36 | 37 | return strDupSize(str, dummy); 38 | } 39 | 40 | char* strDupSize(char const* str, size_t& resultBufSize) { 41 | if (str == NULL) { 42 | resultBufSize = 0; 43 | return NULL; 44 | } 45 | 46 | resultBufSize = strlen(str) + 1; 47 | char* copy = new char[resultBufSize]; 48 | 49 | return copy; 50 | } 51 | -------------------------------------------------------------------------------- /RtspServer/src/include/Definition.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2020 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : Definition.h 5 | * Description : Definition operation center 6 | * Created : 2017.11.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef DEFINITION_H 13 | #define DEFINITION_H 14 | 15 | #define TRUE 0 16 | #define FALSE -1 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | #endif //DEFINITION_H -------------------------------------------------------------------------------- /RtspServer/src/include/RtpPacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/include/RtpPacket.h -------------------------------------------------------------------------------- /RtspServer/src/include/RtpSession.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2018 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : RtpSession.h 5 | * Description : RtpSession operation center 6 | * Created : 2017.09.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef RTP_SESSION_H 13 | #define RTP_SESSION_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include "UdpSocket.h" 19 | #include "TcpSocket.h" 20 | #include "RtpPacket.h" 21 | 22 | using std::string; 23 | 24 | 25 | 26 | 27 | 28 | /***************************************************************************** 29 | -Class : RtpSession 30 | -Description : 31 | * Modify Date Version Author Modification 32 | * ----------------------------------------------- 33 | * 2017/09/21 V1.0.0 Yu Weifeng Created 34 | ******************************************************************************/ 35 | class RtpSession 36 | { 37 | public: 38 | RtpSession(int i_wPayloadType,unsigned int i_dwSampleRate); 39 | ~RtpSession(); 40 | int Init(bool i_blIsTcp,string i_strLocalIP,string i_strIP,unsigned short i_wRtpPort,unsigned short i_wRtcpPort); 41 | int SendRtpData(char * i_acSendBuf,int i_iSendLen); 42 | int GetRtpSocket(); 43 | int GetRtcpSocket(); 44 | int GetRtpPacketParam(T_RtpPacketParam *o_RtpPacketParam); 45 | int SetRtpPacketParam(T_RtpPacketParam *i_ptRtpPacketParam); 46 | unsigned int GetSSRC(void); 47 | void Close(); 48 | private: 49 | UdpClient *m_pRtpClientOverUDP; 50 | UdpClient *m_pRtcpClientOverUDP; 51 | TcpClient *m_pRtpClientOverTCP; 52 | TcpClient *m_pRtcpClientOverTCP; 53 | T_RtpPacketParam m_tRtpPacketParam; 54 | }; 55 | 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /RtspServer/src/include/RtspServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/include/RtspServer.h -------------------------------------------------------------------------------- /RtspServer/src/include/TcpSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/include/TcpSocket.h -------------------------------------------------------------------------------- /RtspServer/src/include/Tools.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/include/Tools.h -------------------------------------------------------------------------------- /RtspServer/src/include/UdpSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/include/UdpSocket.h -------------------------------------------------------------------------------- /RtspServer/src/media/MediaHandle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/media/MediaHandle.cpp -------------------------------------------------------------------------------- /RtspServer/src/media/RawAudioHandle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/media/RawAudioHandle.cpp -------------------------------------------------------------------------------- /RtspServer/src/media/RawAudioHandle.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2018 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : RawAudioHandle.h 5 | * Description : RawAudioHandle operation center 6 | * Created : 2017.09.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef RAW_AUDIO_HANDLE_H 13 | #define RAW_AUDIO_HANDLE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include "MediaHandle.h" 19 | 20 | using std::string; 21 | 22 | 23 | #define AUDIO_ENC_FORMAT_G711_NAME ".G711" 24 | #define AUDIO_ENC_FORMAT_AAC_NAME ".AAC" 25 | 26 | 27 | 28 | 29 | /***************************************************************************** 30 | -Class : G711Handle 31 | -Description : 32 | * Modify Date Version Author Modification 33 | * ----------------------------------------------- 34 | * 2017/09/21 V1.0.0 Yu Weifeng Created 35 | ******************************************************************************/ 36 | class G711Handle : public MediaHandle 37 | { 38 | public: 39 | G711Handle(); 40 | ~G711Handle(); 41 | virtual int Init(char *i_strPath); 42 | virtual int GetNextFrame(T_MediaFrameParam *m_ptMediaFrameParam); 43 | virtual int GetMediaInfo(T_MediaInfo *o_ptMediaInfo); 44 | 45 | static char *m_strAudioFormatName; 46 | static int m_iAudioFixLen; 47 | private: 48 | //FILE * m_pAudioFile; 49 | }; 50 | 51 | 52 | 53 | 54 | /***************************************************************************** 55 | -Class : G711Handle 56 | -Description : 57 | * Modify Date Version Author Modification 58 | * ----------------------------------------------- 59 | * 2017/09/21 V1.0.0 Yu Weifeng Created 60 | ******************************************************************************/ 61 | class AACHandle : public MediaHandle 62 | { 63 | public: 64 | AACHandle(); 65 | ~AACHandle(); 66 | virtual int Init(char *i_strPath); 67 | virtual int GetNextFrame(T_MediaFrameParam *m_ptMediaFrameParam); 68 | virtual int GetMediaInfo(T_MediaInfo *o_ptMediaInfo); 69 | 70 | static char *m_strAudioFormatName; 71 | private: 72 | //FILE * m_pAudioFile; 73 | }; 74 | 75 | 76 | 77 | 78 | 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /RtspServer/src/media/RawVideoHandle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/media/RawVideoHandle.cpp -------------------------------------------------------------------------------- /RtspServer/src/media/RawVideoHandle.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2017-2018 Hanson Yu All rights reserved. 3 | ------------------------------------------------------------------------------ 4 | * File Module : VideoHandle.h 5 | * Description : VideoHandle operation center 6 | * Created : 2017.09.21. 7 | * Author : Yu Weifeng 8 | * Function List : 9 | * Last Modified : 10 | * History : 11 | ******************************************************************************/ 12 | #ifndef RAW_VIDEO_HANDLE_H 13 | #define RAW_VIDEO_HANDLE_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include "MediaHandle.h" 19 | 20 | using std::string; 21 | 22 | 23 | #define VIDEO_ENC_FORMAT_H264_NAME ".h264" 24 | #define VIDEO_ENC_FORMAT_H265_NAME ".h265" 25 | 26 | 27 | /***************************************************************************** 28 | -Class : H264Handle 29 | -Description : 30 | * Modify Date Version Author Modification 31 | * ----------------------------------------------- 32 | * 2017/09/21 V1.0.0 Yu Weifeng Created 33 | ******************************************************************************/ 34 | class H264Handle : public MediaHandle 35 | { 36 | public: 37 | H264Handle(); 38 | ~H264Handle(); 39 | virtual int Init(char *i_strPath); 40 | virtual int GetNextFrame(T_MediaFrameParam *m_ptMediaFrameParam); 41 | virtual int GetVideoEncParam(T_VideoEncodeParam *o_ptVideoEncodeParam); 42 | virtual int GetMediaInfo(T_MediaInfo *o_ptMediaInfo); 43 | 44 | static char *m_strVideoFormatName; 45 | private: 46 | int RemoveH264EmulationBytes(unsigned char *o_pbNaluBuf,int i_iMaxNaluBufLen,unsigned char *i_pbNaluBuf,int i_iNaluLen); 47 | T_VideoEncodeParam m_tVideoEncodeParam; 48 | }; 49 | 50 | 51 | 52 | /***************************************************************************** 53 | -Class : H264Handle 54 | -Description : 55 | * Modify Date Version Author Modification 56 | * ----------------------------------------------- 57 | * 2017/09/21 V1.0.0 Yu Weifeng Created 58 | ******************************************************************************/ 59 | class H265Handle : public MediaHandle 60 | { 61 | public: 62 | H265Handle(); 63 | ~H265Handle(); 64 | virtual int Init(char *i_strPath); 65 | virtual int GetNextFrame(T_MediaFrameParam *m_ptMediaFrameParam); 66 | virtual int GetVideoEncParam(T_VideoEncodeParam *o_ptVideoEncodeParam); 67 | virtual int GetMediaInfo(T_MediaInfo *o_ptMediaInfo); 68 | 69 | static char *m_strVideoFormatName; 70 | private: 71 | T_VideoEncodeParam m_tVideoEncodeParam; 72 | }; 73 | 74 | 75 | 76 | /***************************************************************************** 77 | -Class : VP9Handle 78 | -Description : 79 | * Modify Date Version Author Modification 80 | * ----------------------------------------------- 81 | * 2017/09/21 V1.0.0 Yu Weifeng Created 82 | ******************************************************************************/ 83 | class VP9Handle : public MediaHandle 84 | { 85 | public: 86 | VP9Handle(); 87 | ~VP9Handle(); 88 | //int Init(char *i_strPath); 89 | 90 | 91 | //static char *m_strVideoFormatName; 92 | private: 93 | T_VideoEncodeParam m_tVideoEncodeParam; 94 | }; 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /RtspServer/src/media/include/MediaHandle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengweiyu/RTSP/5c31a31d57f80a191da74cfc4c1aed69fdb4f294/RtspServer/src/media/include/MediaHandle.h --------------------------------------------------------------------------------