├── README.md
├── ios-jrtplib.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── hadesmo.xcuserdatad
│ └── xcschemes
│ ├── ios-jrtplib.xcscheme
│ └── xcschememanagement.plist
└── ios-jrtplib
├── extratransmitters
├── rtpfaketransmitter.cpp
└── rtpfaketransmitter.h
├── jmutex.cpp
├── jmutex.h
├── rtcpapppacket.cpp
├── rtcpapppacket.h
├── rtcpbyepacket.cpp
├── rtcpbyepacket.h
├── rtcpcompoundpacket.cpp
├── rtcpcompoundpacket.h
├── rtcpcompoundpacketbuilder.cpp
├── rtcpcompoundpacketbuilder.h
├── rtcppacket.cpp
├── rtcppacket.h
├── rtcppacketbuilder.cpp
├── rtcppacketbuilder.h
├── rtcprrpacket.cpp
├── rtcprrpacket.h
├── rtcpscheduler.cpp
├── rtcpscheduler.h
├── rtcpsdesinfo.cpp
├── rtcpsdesinfo.h
├── rtcpsdespacket.cpp
├── rtcpsdespacket.h
├── rtcpsrpacket.cpp
├── rtcpsrpacket.h
├── rtcpunknownpacket.h
├── rtpaddress.h
├── rtpbyteaddress.cpp
├── rtpbyteaddress.h
├── rtpcollisionlist.cpp
├── rtpcollisionlist.h
├── rtpconfig.h
├── rtpconfig.h.in
├── rtpdebug.cpp
├── rtpdebug.h
├── rtpdefines.h
├── rtperrors.cpp
├── rtperrors.h
├── rtpexternaltransmitter.cpp
├── rtpexternaltransmitter.h
├── rtphashtable.h
├── rtpinternalsourcedata.cpp
├── rtpinternalsourcedata.h
├── rtpipv4address.cpp
├── rtpipv4address.h
├── rtpipv4destination.h
├── rtpipv6address.cpp
├── rtpipv6address.h
├── rtpipv6destination.h
├── rtpkeyhashtable.h
├── rtplibraryversion.cpp
├── rtplibraryversion.h
├── rtpmemorymanager.h
├── rtpmemoryobject.h
├── rtppacket.cpp
├── rtppacket.h
├── rtppacketbuilder.cpp
├── rtppacketbuilder.h
├── rtppollthread.cpp
├── rtppollthread.h
├── rtprandom.cpp
├── rtprandom.h
├── rtprandomrand48.cpp
├── rtprandomrand48.h
├── rtprandomrands.cpp
├── rtprandomrands.h
├── rtprandomurandom.cpp
├── rtprandomurandom.h
├── rtprawpacket.h
├── rtpsession.cpp
├── rtpsession.h
├── rtpsessionparams.cpp
├── rtpsessionparams.h
├── rtpsessionsources.cpp
├── rtpsessionsources.h
├── rtpsourcedata.cpp
├── rtpsourcedata.h
├── rtpsources.cpp
├── rtpsources.h
├── rtpstructs.h
├── rtptimeutilities.cpp
├── rtptimeutilities.h
├── rtptransmitter.h
├── rtptypes.h
├── rtptypes.h.in
├── rtptypes_win.h
├── rtpudpv4transmitter.cpp
├── rtpudpv4transmitter.h
├── rtpudpv6transmitter.cpp
└── rtpudpv6transmitter.h
/README.md:
--------------------------------------------------------------------------------
1 | # ios-jrtplib
2 |
--------------------------------------------------------------------------------
/ios-jrtplib.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios-jrtplib.xcodeproj/xcuserdata/hadesmo.xcuserdatad/xcschemes/ios-jrtplib.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/ios-jrtplib.xcodeproj/xcuserdata/hadesmo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ios-jrtplib.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B3F9E6611BFC088E0052EA85
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ios-jrtplib/jmutex.cpp:
--------------------------------------------------------------------------------
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-2011 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 | #include "jmutex.h"
29 |
30 | namespace jthread
31 | {
32 |
33 | JMutex::JMutex()
34 | {
35 | initialized = false;
36 | }
37 |
38 | JMutex::~JMutex()
39 | {
40 | if (initialized)
41 | pthread_mutex_destroy(&mutex);
42 | }
43 |
44 | int JMutex::Init()
45 | {
46 | if (initialized)
47 | return ERR_JMUTEX_ALREADYINIT;
48 |
49 | pthread_mutex_init(&mutex,NULL);
50 | initialized = true;
51 | return 0;
52 | }
53 |
54 | int JMutex::Lock()
55 | {
56 | if (!initialized)
57 | return ERR_JMUTEX_NOTINIT;
58 |
59 | pthread_mutex_lock(&mutex);
60 | return 0;
61 | }
62 |
63 | int JMutex::Unlock()
64 | {
65 | if (!initialized)
66 | return ERR_JMUTEX_NOTINIT;
67 |
68 | pthread_mutex_unlock(&mutex);
69 | return 0;
70 | }
71 |
72 | } // end namespace
73 |
74 |
--------------------------------------------------------------------------------
/ios-jrtplib/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-2011 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 | #ifdef JTHREAD_CONFIG_WIN32THREADS
33 | #ifndef _WIN32_WCE
34 | #include
35 | #endif // _WIN32_WCE
36 | #include
37 | #include
38 | #else // using pthread
39 | #include
40 | #endif // JTHREAD_CONFIG_WIN32THREADS
41 |
42 | #define ERR_JMUTEX_ALREADYINIT -1
43 | #define ERR_JMUTEX_NOTINIT -2
44 | #define ERR_JMUTEX_CANTCREATEMUTEX -3
45 |
46 | namespace jthread
47 | {
48 |
49 | class JMutex
50 | {
51 | public:
52 | JMutex();
53 | ~JMutex();
54 | int Init();
55 | int Lock();
56 | int Unlock();
57 | bool IsInitialized() { return initialized; }
58 | private:
59 | #ifdef JTHREAD_CONFIG_WIN32THREADS
60 | #ifdef JTHREAD_CONFIG_JMUTEXCRITICALSECTION
61 | CRITICAL_SECTION mutex;
62 | #else // Use standard mutex
63 | HANDLE mutex;
64 | #endif // JTHREAD_CONFIG_JMUTEXCRITICALSECTION
65 | #else // pthread mutex
66 | pthread_mutex_t mutex;
67 | #endif // JTHREAD_CONFIG_WIN32THREADS
68 | bool initialized;
69 | };
70 |
71 | } // end namespace
72 |
73 | #endif // JTHREAD_JMUTEX_H
74 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpapppacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpapppacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #include
37 | #include
38 | #endif // RTPDEBUG
39 |
40 | #include "rtpdebug.h"
41 |
42 | namespace jrtplib
43 | {
44 |
45 | RTCPAPPPacket::RTCPAPPPacket(uint8_t *data,size_t datalength)
46 | : RTCPPacket(APP,data,datalength)
47 | {
48 | knownformat = false;
49 |
50 | RTCPCommonHeader *hdr;
51 | size_t len = datalength;
52 |
53 | hdr = (RTCPCommonHeader *)data;
54 | if (hdr->padding)
55 | {
56 | uint8_t padcount = data[datalength-1];
57 | if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
58 | return;
59 | if (((size_t)padcount) >= len)
60 | return;
61 | len -= (size_t)padcount;
62 | }
63 |
64 | if (len < (sizeof(RTCPCommonHeader)+sizeof(uint32_t)*2))
65 | return;
66 | len -= (sizeof(RTCPCommonHeader)+sizeof(uint32_t)*2);
67 | appdatalen = len;
68 | knownformat = true;
69 | }
70 |
71 | #ifdef RTPDEBUG
72 | void RTCPAPPPacket::Dump()
73 | {
74 | RTCPPacket::Dump();
75 | if (!IsKnownFormat())
76 | {
77 | std::cout << " Unknown format!" << std::endl;
78 | }
79 | else
80 | {
81 | std::cout << " SSRC: " << GetSSRC() << std::endl;
82 |
83 | char str[5];
84 | memcpy(str,GetName(),4);
85 | str[4] = 0;
86 | std::cout << " Name: " << std::string(str).c_str() << std::endl;
87 | std::cout << " Length: " << GetAPPDataLength() << std::endl;
88 | }
89 | }
90 | #endif // RTPDEBUG
91 |
92 | } // end namespace
93 |
94 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpapppacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
45 | #include
46 | #endif // WIN32
47 |
48 | namespace jrtplib
49 | {
50 |
51 | class RTCPCompoundPacket;
52 |
53 | /** Describes an RTCP APP packet. */
54 | class 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpbyepacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpbyepacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #include
37 | #endif // RTPDEBUG
38 |
39 | #include "rtpdebug.h"
40 |
41 | namespace jrtplib
42 | {
43 |
44 | RTCPBYEPacket::RTCPBYEPacket(uint8_t *data,size_t datalength)
45 | : RTCPPacket(BYE,data,datalength)
46 | {
47 | knownformat = false;
48 | reasonoffset = 0;
49 |
50 | RTCPCommonHeader *hdr;
51 | size_t len = datalength;
52 |
53 | hdr = (RTCPCommonHeader *)data;
54 | if (hdr->padding)
55 | {
56 | uint8_t padcount = data[datalength-1];
57 | if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
58 | return;
59 | if (((size_t)padcount) >= len)
60 | return;
61 | len -= (size_t)padcount;
62 | }
63 |
64 | size_t ssrclen = ((size_t)(hdr->count))*sizeof(uint32_t) + sizeof(RTCPCommonHeader);
65 | if (ssrclen > len)
66 | return;
67 | if (ssrclen < len) // there's probably a reason for leaving
68 | {
69 | uint8_t *reasonlength = (data+ssrclen);
70 | size_t reaslen = (size_t)(*reasonlength);
71 | if (reaslen > (len-ssrclen-1))
72 | return;
73 | reasonoffset = ssrclen;
74 | }
75 | knownformat = true;
76 | }
77 |
78 | #ifdef RTPDEBUG
79 | void RTCPBYEPacket::Dump()
80 | {
81 | RTCPPacket::Dump();
82 | if (!IsKnownFormat())
83 | {
84 | std::cout << " Unknown format" << std::endl;
85 | return;
86 | }
87 |
88 | int num = GetSSRCCount();
89 | int i;
90 |
91 | for (i = 0 ; i < num ; i++)
92 | std::cout << " SSRC: " << GetSSRC(i) << std::endl;
93 | if (HasReasonForLeaving())
94 | {
95 | char str[1024];
96 | memcpy(str,GetReasonData(),GetReasonLength());
97 | str[GetReasonLength()] = 0;
98 | std::cout << " Reason: " << str << std::endl;
99 | }
100 | }
101 | #endif // RTPDEBUG
102 |
103 | } // end namespace
104 |
105 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpbyepacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined (_WIN32_WCE))
45 | #include
46 | #endif // WIN32
47 |
48 | namespace jrtplib
49 | {
50 |
51 | class RTCPCompoundPacket;
52 |
53 | /** Describes an RTCP BYE packet. */
54 | class 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpcompoundpacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpcompoundpacket.h"
34 | #include "rtprawpacket.h"
35 | #include "rtperrors.h"
36 | #include "rtpstructs.h"
37 | #include "rtpdefines.h"
38 | #include "rtcpsrpacket.h"
39 | #include "rtcprrpacket.h"
40 | #include "rtcpsdespacket.h"
41 | #include "rtcpbyepacket.h"
42 | #include "rtcpapppacket.h"
43 | #include "rtcpunknownpacket.h"
44 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
45 | #include
46 | #endif // WIN32
47 |
48 | #include "rtpdebug.h"
49 |
50 | namespace jrtplib
51 | {
52 |
53 | RTCPCompoundPacket::RTCPCompoundPacket(RTPRawPacket &rawpack, RTPMemoryManager *mgr) : RTPMemoryObject(mgr)
54 | {
55 | compoundpacket = 0;
56 | compoundpacketlength = 0;
57 | error = 0;
58 |
59 | if (rawpack.IsRTP())
60 | {
61 | error = ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
62 | return;
63 | }
64 |
65 | uint8_t *data = rawpack.GetData();
66 | size_t datalen = rawpack.GetDataLength();
67 |
68 | error = ParseData(data,datalen);
69 | if (error < 0)
70 | return;
71 |
72 | compoundpacket = rawpack.GetData();
73 | compoundpacketlength = rawpack.GetDataLength();
74 | deletepacket = true;
75 |
76 | rawpack.ZeroData();
77 |
78 | rtcppackit = rtcppacklist.begin();
79 | }
80 |
81 | RTCPCompoundPacket::RTCPCompoundPacket(uint8_t *packet, size_t packetlen, bool deletedata, RTPMemoryManager *mgr) : RTPMemoryObject(mgr)
82 | {
83 | compoundpacket = 0;
84 | compoundpacketlength = 0;
85 |
86 | error = ParseData(packet,packetlen);
87 | if (error < 0)
88 | return;
89 |
90 | compoundpacket = packet;
91 | compoundpacketlength = packetlen;
92 | deletepacket = deletedata;
93 |
94 | rtcppackit = rtcppacklist.begin();
95 | }
96 |
97 | RTCPCompoundPacket::RTCPCompoundPacket(RTPMemoryManager *mgr) : RTPMemoryObject(mgr)
98 | {
99 | compoundpacket = 0;
100 | compoundpacketlength = 0;
101 | error = 0;
102 | deletepacket = true;
103 | }
104 |
105 | int RTCPCompoundPacket::ParseData(uint8_t *data, size_t datalen)
106 | {
107 | bool first;
108 |
109 | if (datalen < sizeof(RTCPCommonHeader))
110 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
111 |
112 | first = true;
113 |
114 | do
115 | {
116 | RTCPCommonHeader *rtcphdr;
117 | size_t length;
118 |
119 | rtcphdr = (RTCPCommonHeader *)data;
120 | if (rtcphdr->version != RTP_VERSION) // check version
121 | {
122 | ClearPacketList();
123 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
124 | }
125 | if (first)
126 | {
127 | // Check if first packet is SR or RR
128 |
129 | first = false;
130 | if ( ! (rtcphdr->packettype == RTP_RTCPTYPE_SR || rtcphdr->packettype == RTP_RTCPTYPE_RR))
131 | {
132 | ClearPacketList();
133 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
134 | }
135 | }
136 |
137 | length = (size_t)ntohs(rtcphdr->length);
138 | length++;
139 | length *= sizeof(uint32_t);
140 |
141 | if (length > datalen) // invalid length field
142 | {
143 | ClearPacketList();
144 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
145 | }
146 |
147 | if (rtcphdr->padding)
148 | {
149 | // check if it's the last packet
150 | if (length != datalen)
151 | {
152 | ClearPacketList();
153 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
154 | }
155 | }
156 |
157 | RTCPPacket *p;
158 |
159 | switch (rtcphdr->packettype)
160 | {
161 | case RTP_RTCPTYPE_SR:
162 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPSRPACKET) RTCPSRPacket(data,length);
163 | break;
164 | case RTP_RTCPTYPE_RR:
165 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPRRPACKET) RTCPRRPacket(data,length);
166 | break;
167 | case RTP_RTCPTYPE_SDES:
168 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPSDESPACKET) RTCPSDESPacket(data,length);
169 | break;
170 | case RTP_RTCPTYPE_BYE:
171 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPBYEPACKET) RTCPBYEPacket(data,length);
172 | break;
173 | case RTP_RTCPTYPE_APP:
174 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPAPPPACKET) RTCPAPPPacket(data,length);
175 | break;
176 | default:
177 | p = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTCPUNKNOWNPACKET) RTCPUnknownPacket(data,length);
178 | }
179 |
180 | if (p == 0)
181 | {
182 | ClearPacketList();
183 | return ERR_RTP_OUTOFMEM;
184 | }
185 |
186 | rtcppacklist.push_back(p);
187 |
188 | datalen -= length;
189 | data += length;
190 | } while (datalen >= (size_t)sizeof(RTCPCommonHeader));
191 |
192 | if (datalen != 0) // some remaining bytes
193 | {
194 | ClearPacketList();
195 | return ERR_RTP_RTCPCOMPOUND_INVALIDPACKET;
196 | }
197 | return 0;
198 | }
199 |
200 | RTCPCompoundPacket::~RTCPCompoundPacket()
201 | {
202 | ClearPacketList();
203 | if (compoundpacket && deletepacket)
204 | RTPDeleteByteArray(compoundpacket,GetMemoryManager());
205 | }
206 |
207 | void RTCPCompoundPacket::ClearPacketList()
208 | {
209 | std::list::const_iterator it;
210 |
211 | for (it = rtcppacklist.begin() ; it != rtcppacklist.end() ; it++)
212 | RTPDelete(*it,GetMemoryManager());
213 | rtcppacklist.clear();
214 | rtcppackit = rtcppacklist.begin();
215 | }
216 |
217 | #ifdef RTPDEBUG
218 | void RTCPCompoundPacket::Dump()
219 | {
220 | std::list::const_iterator it;
221 | for (it = rtcppacklist.begin() ; it != rtcppacklist.end() ; it++)
222 | {
223 | RTCPPacket *p = *it;
224 |
225 | p->Dump();
226 | }
227 | }
228 | #endif // RTPDEBUG
229 |
230 | } // end namespace
231 |
232 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpcompoundpacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcppacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcppacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #endif // RTPDEBUG
37 |
38 | #include "rtpdebug.h"
39 |
40 | #ifdef RTPDEBUG
41 |
42 | namespace jrtplib
43 | {
44 |
45 | void RTCPPacket::Dump()
46 | {
47 | switch(packettype)
48 | {
49 | case SR:
50 | std::cout << "RTCP Sender Report ";
51 | break;
52 | case RR:
53 | std::cout << "RTCP Receiver Report ";
54 | break;
55 | case SDES:
56 | std::cout << "RTCP Source Description ";
57 | break;
58 | case APP:
59 | std::cout << "RTCP APP Packet ";
60 | break;
61 | case BYE:
62 | std::cout << "RTCP Bye Packet ";
63 | break;
64 | case Unknown:
65 | std::cout << "Unknown RTCP Packet ";
66 | break;
67 | default:
68 | std::cout << "ERROR: Invalid packet type!" << std::endl;
69 | }
70 | std::cout << "Length: " << datalen;
71 | std::cout << std::endl;
72 | }
73 |
74 | } // end namespace
75 |
76 | #endif // RTPDEBUG
77 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcppacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcprrpacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcprrpacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #endif // RTPDEBUG
37 |
38 | #include "rtpdebug.h"
39 |
40 | namespace jrtplib
41 | {
42 |
43 | RTCPRRPacket::RTCPRRPacket(uint8_t *data,size_t datalength)
44 | : RTCPPacket(RR,data,datalength)
45 | {
46 | knownformat = false;
47 |
48 | RTCPCommonHeader *hdr;
49 | size_t len = datalength;
50 | size_t expectedlength;
51 |
52 | hdr = (RTCPCommonHeader *)data;
53 | if (hdr->padding)
54 | {
55 | uint8_t padcount = data[datalength-1];
56 | if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
57 | return;
58 | if (((size_t)padcount) >= len)
59 | return;
60 | len -= (size_t)padcount;
61 | }
62 |
63 | expectedlength = sizeof(RTCPCommonHeader)+sizeof(uint32_t);
64 | expectedlength += sizeof(RTCPReceiverReport)*((int)hdr->count);
65 |
66 | if (expectedlength != len)
67 | return;
68 |
69 | knownformat = true;
70 | }
71 |
72 | #ifdef RTPDEBUG
73 | void RTCPRRPacket::Dump()
74 | {
75 | RTCPPacket::Dump();
76 | if (!IsKnownFormat())
77 | std::cout << " Unknown format" << std::endl;
78 | else
79 | {
80 | int num = GetReceptionReportCount();
81 | int i;
82 |
83 | std::cout << " SSRC of sender: " << GetSenderSSRC() << std::endl;
84 | for (i = 0 ; i < num ; i++)
85 | {
86 | std::cout << " Report block " << i << std::endl;
87 | std::cout << " SSRC: " << GetSSRC(i) << std::endl;
88 | std::cout << " Fraction lost: " << (uint32_t)GetFractionLost(i) << std::endl;
89 | std::cout << " Packets lost: " << GetLostPacketCount(i) << std::endl;
90 | std::cout << " Seq. nr.: " << GetExtendedHighestSequenceNumber(i) << std::endl;
91 | std::cout << " Jitter: " << GetJitter(i) << std::endl;
92 | std::cout << " LSR: " << GetLSR(i) << std::endl;
93 | std::cout << " DLSR: " << GetDLSR(i) << std::endl;
94 | }
95 | }
96 | }
97 | #endif // RTPDEBUG
98 |
99 | } // end namespace
100 |
101 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcprrpacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
45 | #include
46 | #endif // WIN32
47 |
48 | namespace jrtplib
49 | {
50 |
51 | class RTCPCompoundPacket;
52 |
53 | /** Describes an RTCP receiver report packet. */
54 | class 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpscheduler.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpsdesinfo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpsdesinfo.h"
34 |
35 | #include "rtpdebug.h"
36 |
37 | namespace jrtplib
38 | {
39 |
40 | void RTCPSDESInfo::Clear()
41 | {
42 | #ifdef RTP_SUPPORT_SDESPRIV
43 | std::list::const_iterator it;
44 |
45 | for (it = privitems.begin() ; it != privitems.end() ; ++it)
46 | RTPDelete(*it,GetMemoryManager());
47 | privitems.clear();
48 | #endif // RTP_SUPPORT_SDESPRIV
49 | }
50 |
51 | #ifdef RTP_SUPPORT_SDESPRIV
52 | int RTCPSDESInfo::SetPrivateValue(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen)
53 | {
54 | std::list::const_iterator it;
55 | bool found;
56 |
57 | found = false;
58 | it = privitems.begin();
59 | while (!found && it != privitems.end())
60 | {
61 | uint8_t *p;
62 | size_t l;
63 |
64 | p = (*it)->GetPrefix(&l);
65 | if (l == prefixlen)
66 | {
67 | if (l <= 0)
68 | found = true;
69 | else if (memcmp(prefix,p,l) == 0)
70 | found = true;
71 | else
72 | ++it;
73 | }
74 | else
75 | ++it;
76 | }
77 |
78 | SDESPrivateItem *item;
79 |
80 | if (found) // replace the value for this entry
81 | item = *it;
82 | else // no entry for this prefix found... add it
83 | {
84 | if (privitems.size() >= RTP_MAXPRIVITEMS) // too many items present, just ignore it
85 | return ERR_RTP_SDES_MAXPRIVITEMS;
86 |
87 | int status;
88 |
89 | item = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_SDESPRIVATEITEM) SDESPrivateItem(GetMemoryManager());
90 | if (item == 0)
91 | return ERR_RTP_OUTOFMEM;
92 | if ((status = item->SetPrefix(prefix,prefixlen)) < 0)
93 | {
94 | RTPDelete(item,GetMemoryManager());
95 | return status;
96 | }
97 | privitems.push_front(item);
98 | }
99 | return item->SetInfo(value,valuelen);
100 | }
101 |
102 | int RTCPSDESInfo::DeletePrivatePrefix(const uint8_t *prefix,size_t prefixlen)
103 | {
104 | std::list::iterator it;
105 | bool found;
106 |
107 | found = false;
108 | it = privitems.begin();
109 | while (!found && it != privitems.end())
110 | {
111 | uint8_t *p;
112 | size_t l;
113 |
114 | p = (*it)->GetPrefix(&l);
115 | if (l == prefixlen)
116 | {
117 | if (l <= 0)
118 | found = true;
119 | else if (memcmp(prefix,p,l) == 0)
120 | found = true;
121 | else
122 | ++it;
123 | }
124 | else
125 | ++it;
126 | }
127 | if (!found)
128 | return ERR_RTP_SDES_PREFIXNOTFOUND;
129 |
130 | RTPDelete(*it,GetMemoryManager());
131 | privitems.erase(it);
132 | return 0;
133 | }
134 |
135 | void RTCPSDESInfo::GotoFirstPrivateValue()
136 | {
137 | curitem = privitems.begin();
138 | }
139 |
140 | bool RTCPSDESInfo::GetNextPrivateValue(uint8_t **prefix,size_t *prefixlen,uint8_t **value,size_t *valuelen)
141 | {
142 | if (curitem == privitems.end())
143 | return false;
144 | *prefix = (*curitem)->GetPrefix(prefixlen);
145 | *value = (*curitem)->GetInfo(valuelen);
146 | ++curitem;
147 | return true;
148 | }
149 |
150 | bool RTCPSDESInfo::GetPrivateValue(const uint8_t *prefix,size_t prefixlen,uint8_t **value,size_t *valuelen) const
151 | {
152 | std::list::const_iterator it;
153 | bool found;
154 |
155 | found = false;
156 | it = privitems.begin();
157 | while (!found && it != privitems.end())
158 | {
159 | uint8_t *p;
160 | size_t l;
161 |
162 | p = (*it)->GetPrefix(&l);
163 | if (l == prefixlen)
164 | {
165 | if (l <= 0)
166 | found = true;
167 | else if (memcmp(prefix,p,l) == 0)
168 | found = true;
169 | else
170 | ++it;
171 | }
172 | else
173 | ++it;
174 | }
175 | if (found)
176 | *value = (*it)->GetInfo(valuelen);
177 | return found;
178 | }
179 | #endif // RTP_SUPPORT_SDESPRIV
180 |
181 | } // end namespace
182 |
183 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpsdespacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpsdespacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #include
37 | #endif // RTPDEBUG
38 |
39 | #include "rtpdebug.h"
40 |
41 | namespace jrtplib
42 | {
43 |
44 | RTCPSDESPacket::RTCPSDESPacket(uint8_t *data,size_t datalength)
45 | : RTCPPacket(SDES,data,datalength)
46 | {
47 | knownformat = false;
48 | currentchunk = 0;
49 | itemoffset = 0;
50 | curchunknum = 0;
51 |
52 | RTCPCommonHeader *hdr = (RTCPCommonHeader *)data;
53 | size_t len = datalength;
54 |
55 | if (hdr->padding)
56 | {
57 | uint8_t padcount = data[datalength-1];
58 | if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
59 | return;
60 | if (((size_t)padcount) >= len)
61 | return;
62 | len -= (size_t)padcount;
63 | }
64 |
65 | if (hdr->count == 0)
66 | {
67 | if (len != sizeof(RTCPCommonHeader))
68 | return;
69 | }
70 | else
71 | {
72 | int ssrccount = (int)(hdr->count);
73 | uint8_t *chunk;
74 | int chunkoffset;
75 |
76 | if (len < sizeof(RTCPCommonHeader))
77 | return;
78 |
79 | len -= sizeof(RTCPCommonHeader);
80 | chunk = data+sizeof(RTCPCommonHeader);
81 |
82 | while ((ssrccount > 0) && (len > 0))
83 | {
84 | chunkoffset = 0;
85 |
86 | if (len < (sizeof(uint32_t)*2)) // chunk must contain at least a SSRC identifier
87 | return; // and a (possibly empty) item
88 |
89 | len -= sizeof(uint32_t);
90 | chunkoffset = sizeof(uint32_t);
91 |
92 | bool done = false;
93 | while (!done)
94 | {
95 | if (len < 1) // at least a zero byte (end of item list) should be there
96 | return;
97 |
98 | RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *)(chunk+chunkoffset);
99 | if (sdeshdr->sdesid == 0) // end of item list
100 | {
101 | len--;
102 | chunkoffset++;
103 |
104 | size_t r = (chunkoffset&0x03);
105 | if (r != 0)
106 | {
107 | size_t addoffset = 4-r;
108 |
109 | if (addoffset > len)
110 | return;
111 | len -= addoffset;
112 | chunkoffset += addoffset;
113 | }
114 | done = true;
115 | }
116 | else
117 | {
118 | if (len < sizeof(RTCPSDESHeader))
119 | return;
120 |
121 | len -= sizeof(RTCPSDESHeader);
122 | chunkoffset += sizeof(RTCPSDESHeader);
123 |
124 | size_t itemlen = (size_t)(sdeshdr->length);
125 | if (itemlen > len)
126 | return;
127 |
128 | len -= itemlen;
129 | chunkoffset += itemlen;
130 | }
131 | }
132 |
133 | ssrccount--;
134 | chunk += chunkoffset;
135 | }
136 |
137 | // check for remaining bytes
138 | if (len > 0)
139 | return;
140 | if (ssrccount > 0)
141 | return;
142 | }
143 |
144 | knownformat = true;
145 | }
146 |
147 | #ifdef RTPDEBUG
148 | void RTCPSDESPacket::Dump()
149 | {
150 | RTCPPacket::Dump();
151 | if (!IsKnownFormat())
152 | {
153 | std::cout << " Unknown format" << std::endl;
154 | return;
155 | }
156 | if (!GotoFirstChunk())
157 | {
158 | std::cout << " No chunks present" << std::endl;
159 | return;
160 | }
161 |
162 | do
163 | {
164 | std::cout << " SDES Chunk for SSRC: " << GetChunkSSRC() << std::endl;
165 | if (!GotoFirstItem())
166 | std::cout << " No items found" << std::endl;
167 | else
168 | {
169 | do
170 | {
171 | std::cout << " ";
172 | switch (GetItemType())
173 | {
174 | case None:
175 | std::cout << "None ";
176 | break;
177 | case CNAME:
178 | std::cout << "CNAME ";
179 | break;
180 | case NAME:
181 | std::cout << "NAME ";
182 | break;
183 | case EMAIL:
184 | std::cout << "EMAIL ";
185 | break;
186 | case PHONE:
187 | std::cout << "PHONE ";
188 | break;
189 | case LOC:
190 | std::cout << "LOC ";
191 | break;
192 | case TOOL:
193 | std::cout << "TOOL ";
194 | break;
195 | case NOTE:
196 | std::cout << "NOTE ";
197 | break;
198 | case PRIV:
199 | std::cout << "PRIV ";
200 | break;
201 | case Unknown:
202 | default:
203 | std::cout << "Unknown ";
204 | }
205 |
206 | std::cout << "Length: " << GetItemLength() << std::endl;
207 |
208 | if (GetItemType() != PRIV)
209 | {
210 | char str[1024];
211 | memcpy(str,GetItemData(),GetItemLength());
212 | str[GetItemLength()] = 0;
213 | std::cout << " Value: " << str << std::endl;
214 | }
215 | #ifdef RTP_SUPPORT_SDESPRIV
216 | else // PRIV item
217 | {
218 | char str[1024];
219 | memcpy(str,GetPRIVPrefixData(),GetPRIVPrefixLength());
220 | str[GetPRIVPrefixLength()] = 0;
221 | std::cout << " Prefix: " << str << std::endl;
222 | std::cout << " Length: " << GetPRIVPrefixLength() << std::endl;
223 | memcpy(str,GetPRIVValueData(),GetPRIVValueLength());
224 | str[GetPRIVValueLength()] = 0;
225 | std::cout << " Value: " << str << std::endl;
226 | std::cout << " Length: " << GetPRIVValueLength() << std::endl;
227 | }
228 | #endif // RTP_SUPPORT_SDESPRIV
229 | } while (GotoNextItem());
230 | }
231 | } while (GotoNextChunk());
232 | }
233 | #endif // RTPDEBUG
234 |
235 | } // end namespace
236 |
237 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpsrpacket.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtcpsrpacket.h"
34 | #ifdef RTPDEBUG
35 | #include
36 | #endif // RTPDEBUG
37 |
38 | #include "rtpdebug.h"
39 |
40 | namespace jrtplib
41 | {
42 |
43 | RTCPSRPacket::RTCPSRPacket(uint8_t *data,size_t datalength)
44 | : RTCPPacket(SR,data,datalength)
45 | {
46 | knownformat = false;
47 |
48 | RTCPCommonHeader *hdr;
49 | size_t len = datalength;
50 | size_t expectedlength;
51 |
52 | hdr = (RTCPCommonHeader *)data;
53 | if (hdr->padding)
54 | {
55 | uint8_t padcount = data[datalength-1];
56 | if ((padcount & 0x03) != 0) // not a multiple of four! (see rfc 3550 p 37)
57 | return;
58 | if (((size_t)padcount) >= len)
59 | return;
60 | len -= (size_t)padcount;
61 | }
62 |
63 | expectedlength = sizeof(RTCPCommonHeader)+sizeof(uint32_t)+sizeof(RTCPSenderReport);
64 | expectedlength += sizeof(RTCPReceiverReport)*((int)hdr->count);
65 |
66 | if (expectedlength != len)
67 | return;
68 |
69 | knownformat = true;
70 | }
71 |
72 | #ifdef RTPDEBUG
73 | void RTCPSRPacket::Dump()
74 | {
75 | RTCPPacket::Dump();
76 | if (!IsKnownFormat())
77 | std::cout << " Unknown format" << std::endl;
78 | else
79 | {
80 | int num = GetReceptionReportCount();
81 | int i;
82 | RTPNTPTime t = GetNTPTimestamp();
83 |
84 | std::cout << " SSRC of sender: " << GetSenderSSRC() << std::endl;
85 | std::cout << " Sender info:" << std::endl;
86 | std::cout << " NTP timestamp: " << t.GetMSW() << ":" << t.GetLSW() << std::endl;
87 | std::cout << " RTP timestamp: " << GetRTPTimestamp() << std::endl;
88 | std::cout << " Packet count: " << GetSenderPacketCount() << std::endl;
89 | std::cout << " Octet count: " << GetSenderOctetCount() << std::endl;
90 | for (i = 0 ; i < num ; i++)
91 | {
92 | std::cout << " Report block " << i << std::endl;
93 | std::cout << " SSRC: " << GetSSRC(i) << std::endl;
94 | std::cout << " Fraction lost: " << (uint32_t)GetFractionLost(i) << std::endl;
95 | std::cout << " Packets lost: " << GetLostPacketCount(i) << std::endl;
96 | std::cout << " Seq. nr.: " << GetExtendedHighestSequenceNumber(i) << std::endl;
97 | std::cout << " Jitter: " << GetJitter(i) << std::endl;
98 | std::cout << " LSR: " << GetLSR(i) << std::endl;
99 | std::cout << " DLSR: " << GetDLSR(i) << std::endl;
100 | }
101 | }
102 | }
103 | #endif // RTPDEBUG
104 |
105 | } // end namespace
106 |
107 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtcpunknownpacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpaddress.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 | };
61 |
62 | /** Returns the type of address the actual implementation represents. */
63 | AddressType GetAddressType() const { return addresstype; }
64 |
65 | /** Creates a copy of the RTPAddress instance.
66 | * Creates a copy of the RTPAddress instance. If \c mgr is not NULL, the
67 | * corresponding memory manager will be used to allocate the memory for the address
68 | * copy.
69 | */
70 | virtual RTPAddress *CreateCopy(RTPMemoryManager *mgr) const = 0;
71 |
72 | /** Checks if the address \c addr is the same address as the one this instance represents.
73 | * Checks if the address \c addr is the same address as the one this instance represents.
74 | * Implementations must be able to handle a NULL argument.
75 | */
76 | virtual bool IsSameAddress(const RTPAddress *addr) const = 0;
77 |
78 | /** Checks if the address \c addr represents the same host as this instance.
79 | * Checks if the address \c addr represents the same host as this instance. Implementations
80 | * must be able to handle a NULL argument.
81 | */
82 | virtual bool IsFromSameHost(const RTPAddress *addr) const = 0;
83 |
84 | #ifdef RTPDEBUG
85 | virtual std::string GetAddressString() const = 0;
86 | #endif // RTPDEBUG
87 |
88 | virtual ~RTPAddress() { }
89 | protected:
90 | // only allow subclasses to be created
91 | RTPAddress(const AddressType t) : addresstype(t) { }
92 | private:
93 | const AddressType addresstype;
94 | };
95 |
96 | } // end namespace
97 |
98 | #endif // RTPADDRESS_H
99 |
100 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpbyteaddress.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpbyteaddress.h"
34 | #include "rtpmemorymanager.h"
35 | #ifdef RTPDEBUG
36 | #include "rtpdefines.h"
37 | #include
38 | #endif // RTPDEBUG
39 |
40 | namespace jrtplib
41 | {
42 |
43 | bool RTPByteAddress::IsSameAddress(const RTPAddress *addr) const
44 | {
45 | if (addr == 0)
46 | return false;
47 | if (addr->GetAddressType() != ByteAddress)
48 | return false;
49 |
50 | const RTPByteAddress *addr2 = (const RTPByteAddress *)addr;
51 |
52 | if (addr2->addresslength != addresslength)
53 | return false;
54 | if (addresslength == 0 || (memcmp(hostaddress, addr2->hostaddress, addresslength) == 0))
55 | {
56 | if (port == addr2->port)
57 | return true;
58 | }
59 | return false;
60 | }
61 |
62 | bool RTPByteAddress::IsFromSameHost(const RTPAddress *addr) const
63 | {
64 | if (addr == 0)
65 | return false;
66 | if (addr->GetAddressType() != ByteAddress)
67 | return false;
68 |
69 | const RTPByteAddress *addr2 = (const RTPByteAddress *)addr;
70 |
71 | if (addr2->addresslength != addresslength)
72 | return false;
73 | if (addresslength == 0 || (memcmp(hostaddress, addr2->hostaddress, addresslength) == 0))
74 | return true;
75 | return false;
76 | }
77 |
78 | RTPAddress *RTPByteAddress::CreateCopy(RTPMemoryManager *mgr) const
79 | {
80 | RTPByteAddress *a = RTPNew(mgr, RTPMEM_TYPE_CLASS_RTPADDRESS) RTPByteAddress(hostaddress, addresslength, port);
81 | return a;
82 | }
83 |
84 | #ifdef RTPDEBUG
85 | std::string RTPByteAddress::GetAddressString() const
86 | {
87 | char str[16];
88 | std::string s;
89 |
90 | for (int i = 0 ; i < addresslength ; i++)
91 | {
92 | RTP_SNPRINTF(str, 16, "%02X", (int)hostaddress[i]);
93 | s += std::string(str);
94 | }
95 | s += std::string(":");
96 |
97 | RTP_SNPRINTF(str, 16, "%d",(int)port);
98 | s += std::string(str);
99 |
100 | return s;
101 | }
102 |
103 | #endif // RTPDEBUG
104 |
105 | } // end namespace
106 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpbyteaddress.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpcollisionlist.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpcollisionlist.h"
34 | #include "rtperrors.h"
35 | #include "rtpmemorymanager.h"
36 | #ifdef RTPDEBUG
37 | #include
38 | #endif // RTPDEBUG
39 |
40 | #include "rtpdebug.h"
41 |
42 | namespace jrtplib
43 | {
44 |
45 | RTPCollisionList::RTPCollisionList(RTPMemoryManager *mgr) : RTPMemoryObject(mgr)
46 | {
47 | #if (defined(WIN32) || defined(_WIN32_WCE))
48 | timeinit.Dummy();
49 | #endif // WIN32 || _WIN32_WCE
50 | }
51 |
52 | void RTPCollisionList::Clear()
53 | {
54 | std::list::iterator it;
55 |
56 | for (it = addresslist.begin() ; it != addresslist.end() ; it++)
57 | RTPDelete((*it).addr,GetMemoryManager());
58 | addresslist.clear();
59 | }
60 |
61 | int RTPCollisionList::UpdateAddress(const RTPAddress *addr,const RTPTime &receivetime,bool *created)
62 | {
63 | if (addr == 0)
64 | return ERR_RTP_COLLISIONLIST_BADADDRESS;
65 |
66 | std::list::iterator it;
67 |
68 | for (it = addresslist.begin() ; it != addresslist.end() ; it++)
69 | {
70 | if (((*it).addr)->IsSameAddress(addr))
71 | {
72 | (*it).recvtime = receivetime;
73 | *created = false;
74 | return 0;
75 | }
76 | }
77 |
78 | RTPAddress *newaddr = addr->CreateCopy(GetMemoryManager());
79 | if (newaddr == 0)
80 | return ERR_RTP_OUTOFMEM;
81 |
82 | addresslist.push_back(AddressAndTime(newaddr,receivetime));
83 | *created = true;
84 | return 0;
85 | }
86 |
87 | bool RTPCollisionList::HasAddress(const RTPAddress *addr) const
88 | {
89 | std::list::const_iterator it;
90 |
91 | for (it = addresslist.begin() ; it != addresslist.end() ; it++)
92 | {
93 | if (((*it).addr)->IsSameAddress(addr))
94 | return true;
95 | }
96 |
97 | return false;
98 | }
99 |
100 | void RTPCollisionList::Timeout(const RTPTime ¤ttime,const RTPTime &timeoutdelay)
101 | {
102 | std::list::iterator it;
103 | RTPTime checktime = currenttime;
104 | checktime -= timeoutdelay;
105 |
106 | it = addresslist.begin();
107 | while(it != addresslist.end())
108 | {
109 | if ((*it).recvtime < checktime) // timeout
110 | {
111 | RTPDelete((*it).addr,GetMemoryManager());
112 | it = addresslist.erase(it);
113 | }
114 | else
115 | it++;
116 | }
117 | }
118 |
119 | #ifdef RTPDEBUG
120 | void RTPCollisionList::Dump()
121 | {
122 | std::list::const_iterator it;
123 |
124 | for (it = addresslist.begin() ; it != addresslist.end() ; it++)
125 | std::cout << "Address: " << ((*it).addr)->GetAddressString() << "\tTime: " << (*it).recvtime.GetSeconds() << std::endl;
126 | }
127 | #endif // RTPDEBUG
128 |
129 | } // end namespace
130 |
131 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpcollisionlist.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpconfig.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | // Don't have
38 |
39 | // Don't have
40 |
41 | // Little endian system
42 |
43 | // socklen_t is 'int'
44 |
45 | // No sa_len member in struct sockaddr
46 |
47 | #define RTP_SUPPORT_IPV4MULTICAST
48 |
49 | // No support for JThread was enabled
50 |
51 | #define RTP_SUPPORT_SDESPRIV
52 |
53 | #define RTP_SUPPORT_PROBATION
54 |
55 | // Not using getlogin_r
56 |
57 | #define RTP_SUPPORT_IPV6
58 |
59 | #define RTP_SUPPORT_IPV6MULTICAST
60 |
61 | // No ifaddrs support
62 |
63 | #define RTP_SUPPORT_SENDAPP
64 |
65 | #define RTP_SUPPORT_MEMORYMANAGEMENT
66 |
67 | // No support for sending unknown RTCP packets
68 |
69 | #endif // RTPCONFIG_UNIX_H
70 |
71 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpconfig.h.in:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | ${RTP_HAVE_SYS_FILIO}
38 |
39 | ${RTP_HAVE_SYS_SOCKIO}
40 |
41 | ${RTP_ENDIAN}
42 |
43 | ${RTP_SOCKLENTYPE_UINT}
44 |
45 | ${RTP_HAVE_SOCKADDR_LEN}
46 |
47 | ${RTP_SUPPORT_IPV4MULTICAST}
48 |
49 | ${RTP_SUPPORT_THREAD}
50 |
51 | ${RTP_SUPPORT_SDESPRIV}
52 |
53 | ${RTP_SUPPORT_PROBATION}
54 |
55 | ${RTP_SUPPORT_GETLOGINR}
56 |
57 | ${RTP_SUPPORT_IPV6}
58 |
59 | ${RTP_SUPPORT_IPV6MULTICAST}
60 |
61 | ${RTP_SUPPORT_IFADDRS}
62 |
63 | ${RTP_SUPPORT_SENDAPP}
64 |
65 | ${RTP_SUPPORT_MEMORYMANAGEMENT}
66 |
67 | ${RTP_SUPPORT_RTCPUNKNOWN}
68 |
69 | #endif // RTPCONFIG_UNIX_H
70 |
71 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpdebug.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpconfig.h"
34 |
35 | #ifdef RTPDEBUG
36 |
37 | #include "rtptypes.h"
38 | #include
39 | #include
40 | #include
41 |
42 | struct MemoryInfo
43 | {
44 | void *ptr;
45 | size_t size;
46 | int lineno;
47 | char *filename;
48 |
49 | MemoryInfo *next;
50 | };
51 |
52 | class MemoryTracker
53 | {
54 | public:
55 | MemoryTracker() { firstblock = NULL; }
56 | ~MemoryTracker()
57 | {
58 | MemoryInfo *tmp;
59 | int count = 0;
60 |
61 | printf("Checking for memory leaks...\n");fflush(stdout);
62 | while(firstblock)
63 | {
64 | count++;
65 | printf("Unfreed block %p of %d bytes (file '%s', line %d)\n",firstblock->ptr,(int)firstblock->size,firstblock->filename,firstblock->lineno);;
66 |
67 | tmp = firstblock->next;
68 |
69 | free(firstblock->ptr);
70 | if (firstblock->filename)
71 | free(firstblock->filename);
72 | free(firstblock);
73 | firstblock = tmp;
74 | }
75 | if (count == 0)
76 | printf("No memory leaks found\n");
77 | else
78 | printf("%d leaks found\n",count);
79 | }
80 |
81 | MemoryInfo *firstblock;
82 | };
83 |
84 | static MemoryTracker memtrack;
85 |
86 | void *donew(size_t s,char filename[],int line)
87 | {
88 | void *p;
89 | MemoryInfo *meminf;
90 |
91 | p = malloc(s);
92 | meminf = (MemoryInfo *)malloc(sizeof(MemoryInfo));
93 |
94 | meminf->ptr = p;
95 | meminf->size = s;
96 | meminf->lineno = line;
97 | meminf->filename = (char *)malloc(strlen(filename)+1);
98 | strcpy(meminf->filename,filename);
99 | meminf->next = memtrack.firstblock;
100 |
101 | memtrack.firstblock = meminf;
102 |
103 | return p;
104 | }
105 |
106 | void dodelete(void *p)
107 | {
108 | MemoryInfo *tmp,*tmpprev;
109 | bool found;
110 |
111 | tmpprev = NULL;
112 | tmp = memtrack.firstblock;
113 | found = false;
114 | while (tmp != NULL && !found)
115 | {
116 | if (tmp->ptr == p)
117 | found = true;
118 | else
119 | {
120 | tmpprev = tmp;
121 | tmp = tmp->next;
122 | }
123 | }
124 | if (!found)
125 | {
126 | printf("Couldn't free block %p!\n",p);
127 | fflush(stdout);
128 | }
129 | else
130 | {
131 | MemoryInfo *n;
132 |
133 | fflush(stdout);
134 | n = tmp->next;
135 | free(tmp->ptr);
136 | if (tmp->filename)
137 | free(tmp->filename);
138 | free(tmp);
139 |
140 | if (tmpprev)
141 | tmpprev->next = n;
142 | else
143 | memtrack.firstblock = n;
144 | }
145 | }
146 |
147 | void *operator new(size_t s)
148 | {
149 | return donew(s,"UNKNOWN FILE",0);
150 | }
151 |
152 | void *operator new[](size_t s)
153 | {
154 | return donew(s,"UNKNOWN FILE",0);
155 | }
156 |
157 | void *operator new(size_t s,char filename[],int line)
158 | {
159 | return donew(s,filename,line);
160 | }
161 |
162 | void *operator new[](size_t s,char filename[],int line)
163 | {
164 | return donew(s,filename,line);
165 | }
166 |
167 | void operator delete(void *p)
168 | {
169 | dodelete(p);
170 | }
171 |
172 | void operator delete[](void *p)
173 | {
174 | dodelete(p);
175 | }
176 |
177 | #endif // RTPDEBUG
178 |
179 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpdebug.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
44 | void *operator new[](size_t s,char filename[],int line);
45 | #define new new (__FILE__,__LINE__)
46 | #else
47 | #define new new (__FILE__,__LINE__)
48 | #endif // WIN32
49 | #endif // RTPDEBUG
50 |
51 | #endif // RTPDEBUG_H
52 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpdefines.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if (defined(WIN32) || defined(_WIN32_WCE))
76 | #if (!defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >= 1400 )
77 | #define RTP_SNPRINTF _snprintf_s
78 | #else
79 | #define RTP_SNPRINTF _snprintf
80 | #endif
81 | #else
82 | #define RTP_SNPRINTF snprintf
83 | #endif // WIN32 || _WIN32_WCE
84 |
85 | #endif // RTPDEFINES_H
86 |
87 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpinternalsourcedata.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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);
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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv4address.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpipv4address.h"
34 | #include "rtpmemorymanager.h"
35 | #ifdef RTPDEBUG
36 | #include "rtpdefines.h"
37 | #include
38 | #endif // RTPDEBUG
39 |
40 | #include "rtpdebug.h"
41 |
42 | namespace jrtplib
43 | {
44 |
45 | bool RTPIPv4Address::IsSameAddress(const RTPAddress *addr) const
46 | {
47 | if (addr == 0)
48 | return false;
49 | if (addr->GetAddressType() != IPv4Address)
50 | return false;
51 |
52 | const RTPIPv4Address *addr2 = (const RTPIPv4Address *)addr;
53 | if (addr2->GetIP() == ip && addr2->GetPort() == port)
54 | return true;
55 | return false;
56 | }
57 |
58 | bool RTPIPv4Address::IsFromSameHost(const RTPAddress *addr) const
59 | {
60 | if (addr == 0)
61 | return false;
62 | if (addr->GetAddressType() != IPv4Address)
63 | return false;
64 |
65 | const RTPIPv4Address *addr2 = (const RTPIPv4Address *)addr;
66 | if (addr2->GetIP() == ip)
67 | return true;
68 | return false;
69 | }
70 |
71 | RTPAddress *RTPIPv4Address::CreateCopy(RTPMemoryManager *mgr) const
72 | {
73 | RTPIPv4Address *a = RTPNew(mgr,RTPMEM_TYPE_CLASS_RTPADDRESS) RTPIPv4Address(ip,port);
74 | return a;
75 | }
76 |
77 | #ifdef RTPDEBUG
78 | std::string RTPIPv4Address::GetAddressString() const
79 | {
80 | char str[24];
81 |
82 | RTP_SNPRINTF(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),
83 | (int)(ip&0xFF),(int)port);
84 | return std::string(str);
85 | }
86 | #endif // RTPDEBUG
87 |
88 | } // end namespace
89 |
90 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv4address.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 RTPIPv4Address : public RTPAddress
57 | {
58 | public:
59 | /** Creates an instance with IP address \c ip and port number \c port (both are interpreted in host byte order). */
60 | RTPIPv4Address(uint32_t ip = 0, uint16_t port = 0):RTPAddress(IPv4Address) { RTPIPv4Address::ip = ip; RTPIPv4Address::port = port; }
61 |
62 | /** Creates an instance with IP address \c ip and port number \c port (\c port is interpreted in host byte order). */
63 | RTPIPv4Address(const uint8_t ip[4],uint16_t port = 0):RTPAddress(IPv4Address) { 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); RTPIPv4Address::port = port; }
64 | ~RTPIPv4Address() { }
65 |
66 | /** Sets the IP address for this instance to \c ip which is assumed to be in host byte order. */
67 | void SetIP(uint32_t ip) { RTPIPv4Address::ip = ip; }
68 |
69 | /** Sets the IP address of this instance to \c ip. */
70 | 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); }
71 |
72 | /** Sets the port number for this instance to \c port which is interpreted in host byte order. */
73 | void SetPort(uint16_t port) { RTPIPv4Address::port = port; }
74 |
75 | /** Returns the IP address contained in this instance in host byte order. */
76 | uint32_t GetIP() const { return ip; }
77 |
78 | /** Returns the port number of this instance in host byte order. */
79 | uint16_t GetPort() const { return port; }
80 |
81 | RTPAddress *CreateCopy(RTPMemoryManager *mgr) const;
82 | bool IsSameAddress(const RTPAddress *addr) const;
83 | bool IsFromSameHost(const RTPAddress *addr) const;
84 | #ifdef RTPDEBUG
85 | std::string GetAddressString() const;
86 | #endif // RTPDEBUG
87 | private:
88 | uint32_t ip;
89 | uint16_t port;
90 | };
91 |
92 | } // end namespace
93 |
94 | #endif // RTPIPV4ADDRESS_H
95 |
96 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv4destination.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
43 | #include
44 | #include
45 | #include
46 | #endif // WIN32
47 | #ifdef RTPDEBUG
48 | #include "rtpdefines.h"
49 | #include
50 | #include
51 | #endif // RTPDEBUG
52 | #include
53 |
54 | namespace jrtplib
55 | {
56 |
57 | class RTPIPv4Destination
58 | {
59 | public:
60 | RTPIPv4Destination(uint32_t ip,uint16_t rtpportbase)
61 | {
62 | memset(&rtpaddr,0,sizeof(struct sockaddr_in));
63 | memset(&rtcpaddr,0,sizeof(struct sockaddr_in));
64 |
65 | rtpaddr.sin_family = AF_INET;
66 | rtpaddr.sin_port = htons(rtpportbase);
67 | rtpaddr.sin_addr.s_addr = htonl(ip);
68 |
69 | rtcpaddr.sin_family = AF_INET;
70 | rtcpaddr.sin_port = htons(rtpportbase+1);
71 | rtcpaddr.sin_addr.s_addr = htonl(ip);
72 |
73 | RTPIPv4Destination::ip = ip;
74 | }
75 |
76 | bool operator==(const RTPIPv4Destination &src) const
77 | {
78 | if (rtpaddr.sin_addr.s_addr == src.rtpaddr.sin_addr.s_addr && rtpaddr.sin_port == src.rtpaddr.sin_port)
79 | return true;
80 | return false;
81 | }
82 | uint32_t GetIP() const { return ip; }
83 | // nbo = network byte order
84 | uint32_t GetIP_NBO() const { return rtpaddr.sin_addr.s_addr; }
85 | uint16_t GetRTPPort_NBO() const { return rtpaddr.sin_port; }
86 | uint16_t GetRTCPPort_NBO() const { return rtcpaddr.sin_port; }
87 | const struct sockaddr_in *GetRTPSockAddr() const { return &rtpaddr; }
88 | const struct sockaddr_in *GetRTCPSockAddr() const { return &rtcpaddr; }
89 | #ifdef RTPDEBUG
90 | std::string GetDestinationString() const;
91 | #endif // RTPDEBUG
92 | private:
93 | uint32_t ip;
94 | struct sockaddr_in rtpaddr;
95 | struct sockaddr_in rtcpaddr;
96 | };
97 |
98 | #ifdef RTPDEBUG
99 | inline std::string RTPIPv4Destination::GetDestinationString() const
100 | {
101 | char str[24];
102 | uint32_t ip = GetIP();
103 | uint16_t portbase = ntohs(GetRTPPort_NBO());
104 |
105 | RTP_SNPRINTF(str,24,"%d.%d.%d.%d:%d",(int)((ip>>24)&0xFF),(int)((ip>>16)&0xFF),(int)((ip>>8)&0xFF),(int)(ip&0xFF),(int)(portbase));
106 | return std::string(str);
107 | }
108 | #endif // RTPDEBUG
109 |
110 | } // end namespace
111 |
112 | #endif // RTPIPV4DESTINATION_H
113 |
114 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv6address.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpipv6address.h"
34 | #include "rtpmemorymanager.h"
35 |
36 | #ifdef RTP_SUPPORT_IPV6
37 |
38 | #ifdef RTPDEBUG
39 | #include "rtpdefines.h"
40 | #include
41 | #endif // RTPDEBUG
42 |
43 | #include "rtpdebug.h"
44 |
45 | namespace jrtplib
46 | {
47 |
48 | RTPAddress *RTPIPv6Address::CreateCopy(RTPMemoryManager *mgr) const
49 | {
50 | RTPIPv6Address *newaddr = RTPNew(mgr,RTPMEM_TYPE_CLASS_RTPADDRESS) RTPIPv6Address(ip,port);
51 | return newaddr;
52 | }
53 |
54 | bool RTPIPv6Address::IsSameAddress(const RTPAddress *addr) const
55 | {
56 | if (addr == 0)
57 | return false;
58 | if (addr->GetAddressType() != RTPAddress::IPv6Address)
59 | return false;
60 |
61 | const RTPIPv6Address *addr2 = (const RTPIPv6Address *)addr;
62 | const uint8_t *ip2 = addr2->ip.s6_addr;
63 |
64 | if (port != addr2->port)
65 | return false;
66 |
67 | for (int i = 0 ; i < 16 ; i++)
68 | {
69 | if (ip.s6_addr[i] != ip2[i])
70 | return false;
71 | }
72 | return true;
73 | }
74 |
75 | bool RTPIPv6Address::IsFromSameHost(const RTPAddress *addr) const
76 | {
77 | if (addr == 0)
78 | return false;
79 | if (addr->GetAddressType() != RTPAddress::IPv6Address)
80 | return false;
81 |
82 | const RTPIPv6Address *addr2 = (const RTPIPv6Address *)addr;
83 | const uint8_t *ip2 = addr2->ip.s6_addr;
84 | for (int i = 0 ; i < 16 ; i++)
85 | {
86 | if (ip.s6_addr[i] != ip2[i])
87 | return false;
88 | }
89 | return true;
90 | }
91 |
92 | #ifdef RTPDEBUG
93 | std::string RTPIPv6Address::GetAddressString() const
94 | {
95 | char str[48];
96 | uint16_t ip16[8];
97 | int i,j;
98 |
99 | for (i = 0,j = 0 ; j < 8 ; j++,i += 2)
100 | {
101 | ip16[j] = (((uint16_t)ip.s6_addr[i])<<8);
102 | ip16[j] |= ((uint16_t)ip.s6_addr[i+1]);
103 | }
104 |
105 | RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)port);
106 | return std::string(str);
107 | }
108 | #endif // RTPDEBUG
109 |
110 | } // end namespace
111 |
112 | #endif // RTP_SUPPORT_IPV6
113 |
114 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv6address.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if ! (defined(WIN32) || defined(_WIN32_WCE))
48 | #include
49 | #endif // WIN32
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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpipv6destination.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #ifndef WIN32
48 | #include
49 | #include
50 | #include
51 | #endif // WIN32
52 | #ifdef RTPDEBUG
53 | #include "rtpdefines.h"
54 | #include
55 | #include
56 | #endif // RTPDEBUG
57 |
58 | namespace jrtplib
59 | {
60 |
61 | class RTPIPv6Destination
62 | {
63 | public:
64 | RTPIPv6Destination(in6_addr ip,uint16_t portbase)
65 | {
66 | memset(&rtpaddr,0,sizeof(struct sockaddr_in6));
67 | memset(&rtcpaddr,0,sizeof(struct sockaddr_in6));
68 | rtpaddr.sin6_family = AF_INET6;
69 | rtpaddr.sin6_port = htons(portbase);
70 | rtpaddr.sin6_addr = ip;
71 | rtcpaddr.sin6_family = AF_INET6;
72 | rtcpaddr.sin6_port = htons(portbase+1);
73 | rtcpaddr.sin6_addr = ip;
74 | }
75 | in6_addr GetIP() const { return rtpaddr.sin6_addr; }
76 | bool operator==(const RTPIPv6Destination &src) const
77 | {
78 | if (rtpaddr.sin6_port == src.rtpaddr.sin6_port && (memcmp(&(src.rtpaddr.sin6_addr),&(rtpaddr.sin6_addr),sizeof(in6_addr)) == 0))
79 | return true;
80 | return false;
81 | }
82 | const struct sockaddr_in6 *GetRTPSockAddr() const { return &rtpaddr; }
83 | const struct sockaddr_in6 *GetRTCPSockAddr() const { return &rtcpaddr; }
84 | #ifdef RTPDEBUG
85 | std::string GetDestinationString() const;
86 | #endif // RTPDEBUG
87 | private:
88 | struct sockaddr_in6 rtpaddr;
89 | struct sockaddr_in6 rtcpaddr;
90 | };
91 |
92 | #ifdef RTPDEBUG
93 | inline std::string RTPIPv6Destination::GetDestinationString() const
94 | {
95 | uint16_t ip16[8];
96 | char str[48];
97 | uint16_t portbase = ntohs(rtpaddr.sin6_port);
98 | int i,j;
99 | for (i = 0,j = 0 ; j < 8 ; j++,i += 2)
100 | {
101 | ip16[j] = (((uint16_t)rtpaddr.sin6_addr.s6_addr[i])<<8);
102 | ip16[j] |= ((uint16_t)rtpaddr.sin6_addr.s6_addr[i+1]);
103 | }
104 | RTP_SNPRINTF(str,48,"%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X/%d",(int)ip16[0],(int)ip16[1],(int)ip16[2],(int)ip16[3],(int)ip16[4],(int)ip16[5],(int)ip16[6],(int)ip16[7],(int)portbase);
105 | return std::string(str);
106 | }
107 | #endif // RTPDEBUG
108 |
109 | } // end namespace
110 |
111 | #endif // RTP_SUPPORT_IPV6
112 |
113 | #endif // RTPIPV6DESTINATION_H
114 |
115 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtplibraryversion.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtplibraryversion.h"
34 | #include "rtpdefines.h"
35 | #include
36 |
37 | namespace jrtplib
38 | {
39 |
40 | RTPLibraryVersion RTPLibraryVersion::GetVersion()
41 | {
42 | return RTPLibraryVersion(3,9,0);
43 | }
44 |
45 | std::string RTPLibraryVersion::GetVersionString() const
46 | {
47 | char str[16];
48 |
49 | RTP_SNPRINTF(str,16,"%d.%d.%d",majornr,minornr,debugnr);
50 |
51 | return std::string(str);
52 | }
53 |
54 | } // end namespace
55 |
56 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtplibraryversion.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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
42 | #include
43 |
44 | namespace jrtplib
45 | {
46 |
47 | /**
48 | * Used to provide information about the version of the library.
49 | */
50 | class RTPLibraryVersion
51 | {
52 | public:
53 | /** Returns an instance of RTPLibraryVersion describing the version of the library. */
54 | static RTPLibraryVersion GetVersion();
55 | private:
56 | RTPLibraryVersion(int major,int minor,int debug) { majornr = major; minornr = minor; debugnr = debug; }
57 | public:
58 | /** Returns the major version number. */
59 | int GetMajorNumber() const { return majornr; }
60 |
61 | /** Returns the minor version number. */
62 | int GetMinorNumber() const { return minornr; }
63 |
64 | /** Returns the debug version number. */
65 | int GetDebugNumber() const { return debugnr; }
66 |
67 | /** Returns a string describing the library version. */
68 | std::string GetVersionString() const;
69 | private:
70 | int debugnr,minornr,majornr;
71 | };
72 |
73 | } // end namespace
74 |
75 | #endif // RTPLIBRARYVERSION_H
76 |
77 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpmemoryobject.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 RTPMemoryObject
48 | {
49 | protected:
50 | #ifdef RTP_SUPPORT_MEMORYMANAGEMENT
51 | RTPMemoryObject(RTPMemoryManager *memmgr) : mgr(memmgr) { }
52 | #else
53 | RTPMemoryObject(RTPMemoryManager *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) { }
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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtppacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtppacketbuilder.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtppacketbuilder.h"
34 | #include "rtperrors.h"
35 | #include "rtppacket.h"
36 | #include "rtpsources.h"
37 | #include
38 | #include
39 | #ifdef RTPDEBUG
40 | #include
41 | #endif // RTPDEBUG
42 |
43 | #include "rtpdebug.h"
44 |
45 | namespace jrtplib
46 | {
47 |
48 | RTPPacketBuilder::RTPPacketBuilder(RTPRandom &r,RTPMemoryManager *mgr) : RTPMemoryObject(mgr),rtprnd(r),lastwallclocktime(0,0)
49 | {
50 | init = false;
51 | #if (defined(WIN32) || defined(_WIN32_WCE))
52 | timeinit.Dummy();
53 | #endif // WIN32 || _WIN32_WCE
54 |
55 | //std::cout << (void *)(&rtprnd) << std::endl;
56 | }
57 |
58 | RTPPacketBuilder::~RTPPacketBuilder()
59 | {
60 | Destroy();
61 | }
62 |
63 | int RTPPacketBuilder::Init(size_t max)
64 | {
65 | if (init)
66 | return ERR_RTP_PACKBUILD_ALREADYINIT;
67 | if (max <= 0)
68 | return ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE;
69 |
70 | maxpacksize = max;
71 | buffer = RTPNew(GetMemoryManager(),RTPMEM_TYPE_BUFFER_RTPPACKETBUILDERBUFFER) uint8_t [max];
72 | if (buffer == 0)
73 | return ERR_RTP_OUTOFMEM;
74 | packetlength = 0;
75 |
76 | CreateNewSSRC();
77 |
78 | deftsset = false;
79 | defptset = false;
80 | defmarkset = false;
81 |
82 | numcsrcs = 0;
83 |
84 | init = true;
85 | return 0;
86 | }
87 |
88 | void RTPPacketBuilder::Destroy()
89 | {
90 | if (!init)
91 | return;
92 | RTPDeleteByteArray(buffer,GetMemoryManager());
93 | init = false;
94 | }
95 |
96 | int RTPPacketBuilder::SetMaximumPacketSize(size_t max)
97 | {
98 | uint8_t *newbuf;
99 |
100 | if (max <= 0)
101 | return ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE;
102 | newbuf = RTPNew(GetMemoryManager(),RTPMEM_TYPE_BUFFER_RTPPACKETBUILDERBUFFER) uint8_t[max];
103 | if (newbuf == 0)
104 | return ERR_RTP_OUTOFMEM;
105 |
106 | RTPDeleteByteArray(buffer,GetMemoryManager());
107 | buffer = newbuf;
108 | maxpacksize = max;
109 | return 0;
110 | }
111 |
112 | int RTPPacketBuilder::AddCSRC(uint32_t csrc)
113 | {
114 | if (!init)
115 | return ERR_RTP_PACKBUILD_NOTINIT;
116 | if (numcsrcs >= RTP_MAXCSRCS)
117 | return ERR_RTP_PACKBUILD_CSRCLISTFULL;
118 |
119 | int i;
120 |
121 | for (i = 0 ; i < numcsrcs ; i++)
122 | {
123 | if (csrcs[i] == csrc)
124 | return ERR_RTP_PACKBUILD_CSRCALREADYINLIST;
125 | }
126 | csrcs[numcsrcs] = csrc;
127 | numcsrcs++;
128 | return 0;
129 | }
130 |
131 | int RTPPacketBuilder::DeleteCSRC(uint32_t csrc)
132 | {
133 | if (!init)
134 | return ERR_RTP_PACKBUILD_NOTINIT;
135 |
136 | int i = 0;
137 | bool found = false;
138 |
139 | while (!found && i < numcsrcs)
140 | {
141 | if (csrcs[i] == csrc)
142 | found = true;
143 | else
144 | i++;
145 | }
146 |
147 | if (!found)
148 | return ERR_RTP_PACKBUILD_CSRCNOTINLIST;
149 |
150 | // move the last csrc in the place of the deleted one
151 | numcsrcs--;
152 | if (numcsrcs > 0 && numcsrcs != i)
153 | csrcs[i] = csrcs[numcsrcs];
154 | return 0;
155 | }
156 |
157 | void RTPPacketBuilder::ClearCSRCList()
158 | {
159 | if (!init)
160 | return;
161 | numcsrcs = 0;
162 | }
163 |
164 | uint32_t RTPPacketBuilder::CreateNewSSRC()
165 | {
166 | ssrc = rtprnd.GetRandom32();
167 | timestamp = rtprnd.GetRandom32();
168 | seqnr = rtprnd.GetRandom16();
169 |
170 | // p 38: the count SHOULD be reset if the sender changes its SSRC identifier
171 | numpayloadbytes = 0;
172 | numpackets = 0;
173 | return ssrc;
174 | }
175 |
176 | uint32_t RTPPacketBuilder::CreateNewSSRC(RTPSources &sources)
177 | {
178 | bool found;
179 |
180 | do
181 | {
182 | ssrc = rtprnd.GetRandom32();
183 | found = sources.GotEntry(ssrc);
184 | } while (found);
185 |
186 | timestamp = rtprnd.GetRandom32();
187 | seqnr = rtprnd.GetRandom16();
188 |
189 | // p 38: the count SHOULD be reset if the sender changes its SSRC identifier
190 | numpayloadbytes = 0;
191 | numpackets = 0;
192 | return ssrc;
193 | }
194 |
195 | int RTPPacketBuilder::BuildPacket(const void *data,size_t len)
196 | {
197 | if (!init)
198 | return ERR_RTP_PACKBUILD_NOTINIT;
199 | if (!defptset)
200 | return ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET;
201 | if (!defmarkset)
202 | return ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET;
203 | if (!deftsset)
204 | return ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET;
205 | return PrivateBuildPacket(data,len,defaultpayloadtype,defaultmark,defaulttimestampinc,false);
206 | }
207 |
208 | int RTPPacketBuilder::BuildPacket(const void *data,size_t len,
209 | uint8_t pt,bool mark,uint32_t timestampinc)
210 | {
211 | if (!init)
212 | return ERR_RTP_PACKBUILD_NOTINIT;
213 | return PrivateBuildPacket(data,len,pt,mark,timestampinc,false);
214 | }
215 |
216 | int RTPPacketBuilder::BuildPacketEx(const void *data,size_t len,
217 | uint16_t hdrextID,const void *hdrextdata,size_t numhdrextwords)
218 | {
219 | if (!init)
220 | return ERR_RTP_PACKBUILD_NOTINIT;
221 | if (!defptset)
222 | return ERR_RTP_PACKBUILD_DEFAULTPAYLOADTYPENOTSET;
223 | if (!defmarkset)
224 | return ERR_RTP_PACKBUILD_DEFAULTMARKNOTSET;
225 | if (!deftsset)
226 | return ERR_RTP_PACKBUILD_DEFAULTTSINCNOTSET;
227 | return PrivateBuildPacket(data,len,defaultpayloadtype,defaultmark,defaulttimestampinc,true,hdrextID,hdrextdata,numhdrextwords);
228 | }
229 |
230 | int RTPPacketBuilder::BuildPacketEx(const void *data,size_t len,
231 | uint8_t pt,bool mark,uint32_t timestampinc,
232 | uint16_t hdrextID,const void *hdrextdata,size_t numhdrextwords)
233 | {
234 | if (!init)
235 | return ERR_RTP_PACKBUILD_NOTINIT;
236 | return PrivateBuildPacket(data,len,pt,mark,timestampinc,true,hdrextID,hdrextdata,numhdrextwords);
237 |
238 | }
239 |
240 | int RTPPacketBuilder::PrivateBuildPacket(const void *data,size_t len,
241 | uint8_t pt,bool mark,uint32_t timestampinc,bool gotextension,
242 | uint16_t hdrextID,const void *hdrextdata,size_t numhdrextwords)
243 | {
244 | RTPPacket p(pt,data,len,seqnr,timestamp,ssrc,mark,numcsrcs,csrcs,gotextension,hdrextID,
245 | (uint16_t)numhdrextwords,hdrextdata,buffer,maxpacksize,GetMemoryManager());
246 | int status = p.GetCreationError();
247 |
248 | if (status < 0)
249 | return status;
250 | packetlength = p.GetPacketLength();
251 |
252 | if (numpackets == 0) // first packet
253 | {
254 | lastwallclocktime = RTPTime::CurrentTime();
255 | lastrtptimestamp = timestamp;
256 | prevrtptimestamp = timestamp;
257 | }
258 | else if (timestamp != prevrtptimestamp)
259 | {
260 | lastwallclocktime = RTPTime::CurrentTime();
261 | lastrtptimestamp = timestamp;
262 | prevrtptimestamp = timestamp;
263 | }
264 |
265 | numpayloadbytes += (uint32_t)p.GetPayloadLength();
266 | numpackets++;
267 | timestamp += timestampinc;
268 | seqnr++;
269 |
270 | return 0;
271 | }
272 |
273 | } // end namespace
274 |
275 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtppollthread.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtppollthread.h"
34 |
35 | #ifdef RTP_SUPPORT_THREAD
36 |
37 | #include "rtpsession.h"
38 | #include "rtcpscheduler.h"
39 | #include "rtperrors.h"
40 | #include "rtprawpacket.h"
41 | #include
42 |
43 | #ifndef _WIN32_WCE
44 | #include
45 | #endif // _WIN32_WCE
46 |
47 | #include "rtpdebug.h"
48 |
49 | namespace jrtplib
50 | {
51 |
52 | RTPPollThread::RTPPollThread(RTPSession &session,RTCPScheduler &sched):rtpsession(session),rtcpsched(sched)
53 | {
54 | stop = false;
55 | transmitter = 0;
56 | #if (defined(WIN32) || defined(_WIN32_WCE))
57 | timeinit.Dummy();
58 | #endif // WIN32 || _WIN32_WCE
59 | }
60 |
61 | RTPPollThread::~RTPPollThread()
62 | {
63 | Stop();
64 | }
65 |
66 | int RTPPollThread::Start(RTPTransmitter *trans)
67 | {
68 | if (JThread::IsRunning())
69 | return ERR_RTP_POLLTHREAD_ALREADYRUNNING;
70 |
71 | transmitter = trans;
72 | if (!stopmutex.IsInitialized())
73 | {
74 | if (stopmutex.Init() < 0)
75 | return ERR_RTP_POLLTHREAD_CANTINITMUTEX;
76 | }
77 | stop = false;
78 | if (JThread::Start() < 0)
79 | return ERR_RTP_POLLTHREAD_CANTSTARTTHREAD;
80 | return 0;
81 | }
82 |
83 | void RTPPollThread::Stop()
84 | {
85 | if (!IsRunning())
86 | return;
87 |
88 | stopmutex.Lock();
89 | stop = true;
90 | stopmutex.Unlock();
91 |
92 | if (transmitter)
93 | transmitter->AbortWait();
94 |
95 | RTPTime thetime = RTPTime::CurrentTime();
96 | bool done = false;
97 |
98 | while (JThread::IsRunning() && !done)
99 | {
100 | // wait max 5 sec
101 | RTPTime curtime = RTPTime::CurrentTime();
102 | if ((curtime.GetDouble()-thetime.GetDouble()) > 5.0)
103 | done = true;
104 | RTPTime::Wait(RTPTime(0,10000));
105 | }
106 |
107 | if (JThread::IsRunning())
108 | {
109 | #ifndef _WIN32_WCE
110 | std::cerr << "RTPPollThread: Warning! Having to kill thread!" << std::endl;
111 | #endif // _WIN32_WCE
112 | JThread::Kill();
113 | }
114 | stop = false;
115 | transmitter = 0;
116 | }
117 |
118 | void *RTPPollThread::Thread()
119 | {
120 | JThread::ThreadStarted();
121 |
122 | bool stopthread;
123 |
124 | stopmutex.Lock();
125 | stopthread = stop;
126 | stopmutex.Unlock();
127 |
128 | rtpsession.OnPollThreadStart(stopthread);
129 |
130 | while (!stopthread)
131 | {
132 | int status;
133 |
134 | rtpsession.schedmutex.Lock();
135 | rtpsession.sourcesmutex.Lock();
136 |
137 | RTPTime rtcpdelay = rtcpsched.GetTransmissionDelay();
138 |
139 | rtpsession.sourcesmutex.Unlock();
140 | rtpsession.schedmutex.Unlock();
141 |
142 | if ((status = transmitter->WaitForIncomingData(rtcpdelay)) < 0)
143 | {
144 | stopthread = true;
145 | rtpsession.OnPollThreadError(status);
146 | }
147 | else
148 | {
149 | if ((status = transmitter->Poll()) < 0)
150 | {
151 | stopthread = true;
152 | rtpsession.OnPollThreadError(status);
153 | }
154 | else
155 | {
156 | if ((status = rtpsession.ProcessPolledData()) < 0)
157 | {
158 | stopthread = true;
159 | rtpsession.OnPollThreadError(status);
160 | }
161 | else
162 | {
163 | rtpsession.OnPollThreadStep();
164 | stopmutex.Lock();
165 | stopthread = stop;
166 | stopmutex.Unlock();
167 | }
168 | }
169 | }
170 | }
171 |
172 | rtpsession.OnPollThreadStop();
173 |
174 | return 0;
175 | }
176 |
177 | } // end namespace
178 |
179 | #endif // RTP_SUPPORT_THREAD
180 |
181 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtppollthread.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandom.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if defined(WIN32) && !defined(_WIN32_WCE)
34 | #define _CRT_RAND_S
35 | #endif // WIN32 || _WIN32_WCE
36 |
37 | #include "rtprandom.h"
38 | #include
39 | #ifndef WIN32
40 | #include
41 | #else
42 | #ifndef _WIN32_WCE
43 | #include
44 | #else
45 | #include
46 | #include
47 | #endif // _WIN32_WINCE
48 | #include
49 | #endif // WIN32
50 |
51 | #include "rtpdebug.h"
52 |
53 | namespace jrtplib
54 | {
55 |
56 | uint32_t RTPRandom::PickSeed()
57 | {
58 | uint32_t x;
59 | #if defined(WIN32) || defined(_WIN32_WINCE)
60 | #ifndef _WIN32_WCE
61 | x = (uint32_t)_getpid();
62 | x += (uint32_t)time(0);
63 | x += (uint32_t)clock();
64 | #else
65 | x = (uint32_t)GetCurrentProcessId();
66 |
67 | FILETIME ft;
68 | SYSTEMTIME st;
69 |
70 | GetSystemTime(&st);
71 | SystemTimeToFileTime(&st,&ft);
72 |
73 | x += ft.dwLowDateTime;
74 | #endif // _WIN32_WCE
75 | x ^= (uint32_t)((uint8_t *)this - (uint8_t *)0);
76 | #else
77 | x = (uint32_t)getpid();
78 | x += (uint32_t)time(0);
79 | x += (uint32_t)clock();
80 | x ^= (uint32_t)((uint8_t *)this - (uint8_t *)0);
81 | #endif
82 | return x;
83 | }
84 |
85 | } // end namespace
86 |
87 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandom.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
73 | } // end namespace
74 |
75 | #endif // RTPRANDOM_H
76 |
77 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomrand48.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtprandomrand48.h"
34 |
35 | namespace jrtplib
36 | {
37 |
38 | RTPRandomRand48::RTPRandomRand48()
39 | {
40 | SetSeed(PickSeed());
41 | }
42 |
43 | RTPRandomRand48::RTPRandomRand48(uint32_t seed)
44 | {
45 | SetSeed(seed);
46 | }
47 |
48 | RTPRandomRand48::~RTPRandomRand48()
49 | {
50 | }
51 |
52 | void RTPRandomRand48::SetSeed(uint32_t seed)
53 | {
54 | #ifdef RTP_SUPPORT_THREAD
55 | mutex.Init(); // TODO: check error!
56 | #endif // RTP_SUPPORT_THREAD
57 |
58 | #if (defined(WIN32) || defined(_WIN32_WCE)) && defined(_MSC_VER) && _MSC_VER <= 1200
59 | state = ((uint64_t)seed) << 16 | 0x330Eui64;
60 | #else
61 | state = ((uint64_t)seed) << 16 | 0x330EULL;
62 | #endif
63 | }
64 |
65 | uint8_t RTPRandomRand48::GetRandom8()
66 | {
67 | uint32_t x = ((GetRandom32() >> 24)&0xff);
68 |
69 | return (uint8_t)x;
70 | }
71 |
72 | uint16_t RTPRandomRand48::GetRandom16()
73 | {
74 | uint32_t x = ((GetRandom32() >> 16)&0xffff);
75 |
76 | return (uint16_t)x;
77 | }
78 |
79 | uint32_t RTPRandomRand48::GetRandom32()
80 | {
81 | #ifdef RTP_SUPPORT_THREAD
82 | mutex.Lock();
83 | #endif // RTP_SUPPORT_THREAD
84 |
85 | #if (defined(WIN32) || defined(_WIN32_WCE)) && defined(_MSC_VER) && _MSC_VER <= 1200
86 | state = ((0x5DEECE66Dui64*state) + 0xBui64)&0x0000ffffffffffffui64;
87 |
88 | uint32_t x = (uint32_t)((state>>16)&0xffffffffui64);
89 | #else
90 | state = ((0x5DEECE66DULL*state) + 0xBULL)&0x0000ffffffffffffULL;
91 |
92 | uint32_t x = (uint32_t)((state>>16)&0xffffffffULL);
93 | #endif
94 |
95 | #ifdef RTP_SUPPORT_THREAD
96 | mutex.Unlock();
97 | #endif // RTP_SUPPORT_THREAD
98 | return x;
99 | }
100 |
101 | double RTPRandomRand48::GetRandomDouble()
102 | {
103 | #ifdef RTP_SUPPORT_THREAD
104 | mutex.Lock();
105 | #endif // RTP_SUPPORT_THREAD
106 |
107 | #if (defined(WIN32) || defined(_WIN32_WCE)) && defined(_MSC_VER) && _MSC_VER <= 1200
108 | state = ((0x5DEECE66Dui64*state) + 0xBui64)&0x0000ffffffffffffui64;
109 |
110 | int64_t x = (int64_t)state;
111 | #else
112 | state = ((0x5DEECE66DULL*state) + 0xBULL)&0x0000ffffffffffffULL;
113 |
114 | int64_t x = (int64_t)state;
115 | #endif
116 |
117 | #ifdef RTP_SUPPORT_THREAD
118 | mutex.Unlock();
119 | #endif // RTP_SUPPORT_THREAD
120 | double y = 3.552713678800500929355621337890625e-15 * (double)x;
121 | return y;
122 | }
123 |
124 | } // end namespace
125 |
126 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomrand48.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomrands.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if defined(WIN32) && !defined(_WIN32_WCE)
34 | #define _CRT_RAND_S
35 | #endif // WIN32 || _WIN32_WCE
36 |
37 | #include "rtprandomrands.h"
38 | #include "rtperrors.h"
39 |
40 | #if (defined(WIN32) && !defined(_WIN32_WCE)) && (defined(_MSC_VER) && _MSC_VER >= 1400 )
41 | #include
42 | #include
43 | // If compiling on VC 8 or later for full Windows, we'll attempt to use rand_s,
44 | // which generates better random numbers. However, its only supported on Windows XP,
45 | // Windows Server 2003, and later, so we'll do a run-time check to see if we can
46 | // use it (it won't work on Windows 2000 SP4 for example).
47 | #define RTP_SUPPORT_RANDS
48 | #endif
49 |
50 | #include "rtpdebug.h"
51 |
52 | namespace jrtplib
53 | {
54 |
55 | #ifndef RTP_SUPPORT_RANDS
56 |
57 | RTPRandomRandS::RTPRandomRandS()
58 | {
59 | initialized = false;
60 | }
61 |
62 | RTPRandomRandS::~RTPRandomRandS()
63 | {
64 | }
65 |
66 | int RTPRandomRandS::Init()
67 | {
68 | return ERR_RTP_RTPRANDOMRANDS_NOTSUPPORTED;
69 | }
70 |
71 | uint8_t RTPRandomRandS::GetRandom8()
72 | {
73 | return 0;
74 | }
75 |
76 | uint16_t RTPRandomRandS::GetRandom16()
77 | {
78 | return 0;
79 | }
80 |
81 | uint32_t RTPRandomRandS::GetRandom32()
82 | {
83 | return 0;
84 | }
85 |
86 | double RTPRandomRandS::GetRandomDouble()
87 | {
88 | return 0;
89 | }
90 |
91 | #else
92 |
93 | RTPRandomRandS::RTPRandomRandS()
94 | {
95 | initialized = false;
96 | }
97 |
98 | RTPRandomRandS::~RTPRandomRandS()
99 | {
100 | }
101 |
102 | int RTPRandomRandS::Init()
103 | {
104 | if (initialized) // doesn't matter then
105 | return 0;
106 |
107 | HMODULE hAdvApi32 = LoadLibrary(TEXT("ADVAPI32.DLL"));
108 | if(hAdvApi32 != NULL)
109 | {
110 | if(NULL != GetProcAddress( hAdvApi32, "SystemFunction036" )) // RtlGenRandom
111 | {
112 | initialized = true;
113 | }
114 | FreeLibrary(hAdvApi32);
115 | hAdvApi32 = NULL;
116 | }
117 |
118 | if (!initialized)
119 | return ERR_RTP_RTPRANDOMRANDS_NOTSUPPORTED;
120 | return 0;
121 | }
122 |
123 | // rand_s gives a number between 0 and UINT_MAX. We'll assume that UINT_MAX is at least 8 bits
124 |
125 | uint8_t RTPRandomRandS::GetRandom8()
126 | {
127 | if (!initialized)
128 | return 0;
129 |
130 | unsigned int r;
131 |
132 | rand_s(&r);
133 |
134 | return (uint8_t)(r&0xff);
135 | }
136 |
137 | uint16_t RTPRandomRandS::GetRandom16()
138 | {
139 | if (!initialized)
140 | return 0;
141 |
142 | unsigned int r;
143 | int shift = 0;
144 | uint16_t x = 0;
145 |
146 | for (int i = 0 ; i < 2 ; i++, shift += 8)
147 | {
148 | rand_s(&r);
149 |
150 | x ^= ((uint16_t)r << shift);
151 | }
152 |
153 | return x;
154 | }
155 |
156 | uint32_t RTPRandomRandS::GetRandom32()
157 | {
158 | if (!initialized)
159 | return 0;
160 |
161 | unsigned int r;
162 | int shift = 0;
163 | uint32_t x = 0;
164 |
165 | for (int i = 0 ; i < 4 ; i++, shift += 8)
166 | {
167 | rand_s(&r);
168 |
169 | x ^= ((uint32_t)r << shift);
170 | }
171 |
172 | return x;
173 | }
174 |
175 | double RTPRandomRandS::GetRandomDouble()
176 | {
177 | if (!initialized)
178 | return 0;
179 |
180 | unsigned int r;
181 | int shift = 0;
182 | uint64_t x = 0;
183 |
184 | for (int i = 0 ; i < 8 ; i++, shift += 8)
185 | {
186 | rand_s(&r);
187 |
188 | x ^= ((uint64_t)r << shift);
189 | }
190 |
191 | x &= 0x7fffffffffffffffULL;
192 |
193 | int64_t x2 = (int64_t)x;
194 | return RTPRANDOM_2POWMIN63*(double)x2;
195 | }
196 |
197 | #endif // RTP_SUPPORT_RANDS
198 |
199 | } // end namespace
200 |
201 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomrands.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomurandom.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtprandomurandom.h"
34 | #include "rtperrors.h"
35 |
36 | #include "rtpdebug.h"
37 |
38 | namespace jrtplib
39 | {
40 |
41 | RTPRandomURandom::RTPRandomURandom()
42 | {
43 | device = 0;
44 | }
45 |
46 | RTPRandomURandom::~RTPRandomURandom()
47 | {
48 | if (device)
49 | fclose(device);
50 | }
51 |
52 | int RTPRandomURandom::Init()
53 | {
54 | if (device)
55 | return ERR_RTP_RTPRANDOMURANDOM_ALREADYOPEN;
56 |
57 | device = fopen("/dev/urandom","rb");
58 | if (device == 0)
59 | return ERR_RTP_RTPRANDOMURANDOM_CANTOPEN;
60 |
61 | return 0;
62 | }
63 |
64 | uint8_t RTPRandomURandom::GetRandom8()
65 | {
66 | if (!device)
67 | return 0;
68 |
69 | uint8_t value;
70 |
71 | fread(&value, sizeof(uint8_t), 1, device);
72 |
73 | return value;
74 | }
75 |
76 | uint16_t RTPRandomURandom::GetRandom16()
77 | {
78 | if (!device)
79 | return 0;
80 |
81 | uint16_t value;
82 |
83 | fread(&value, sizeof(uint16_t), 1, device);
84 |
85 | return value;
86 | }
87 |
88 | uint32_t RTPRandomURandom::GetRandom32()
89 | {
90 | if (!device)
91 | return 0;
92 |
93 | uint32_t value;
94 |
95 | fread(&value, sizeof(uint32_t), 1, device);
96 |
97 | return value;
98 | }
99 |
100 | double RTPRandomURandom::GetRandomDouble()
101 | {
102 | if (!device)
103 | return 0;
104 |
105 | uint64_t value;
106 |
107 | fread(&value, sizeof(uint64_t), 1, device);
108 |
109 | #if (defined(WIN32) || defined(_WIN32_WCE)) && defined(_MSC_VER) && _MSC_VER <= 1200
110 | value &= 0x7fffffffffffffffui64;
111 | #else
112 | value &= 0x7fffffffffffffffULL;
113 | #endif
114 |
115 | int64_t value2 = (int64_t)value;
116 | double x = RTPRANDOM_2POWMIN63*(double)value2;
117 |
118 | return x;
119 |
120 | }
121 |
122 | } // end namespace
123 |
124 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprandomurandom.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtprawpacket.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 | private:
88 | uint8_t *packetdata;
89 | size_t packetdatalength;
90 | RTPTime receivetime;
91 | RTPAddress *senderaddress;
92 | bool isrtp;
93 | };
94 |
95 | inline RTPRawPacket::RTPRawPacket(uint8_t *data,size_t datalen,RTPAddress *address,RTPTime &recvtime,bool rtp,RTPMemoryManager *mgr):RTPMemoryObject(mgr),receivetime(recvtime)
96 | {
97 | packetdata = data;
98 | packetdatalength = datalen;
99 | senderaddress = address;
100 | isrtp = rtp;
101 | }
102 |
103 | inline RTPRawPacket::~RTPRawPacket()
104 | {
105 | if (packetdata)
106 | RTPDeleteByteArray(packetdata,GetMemoryManager());
107 | if (senderaddress)
108 | RTPDelete(senderaddress,GetMemoryManager());
109 | }
110 |
111 | } // end namespace
112 |
113 | #endif // RTPRAWPACKET_H
114 |
115 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpsessionparams.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpconfig.h"
34 | #include "rtpsessionparams.h"
35 | #include "rtpdefines.h"
36 | #include "rtperrors.h"
37 |
38 | #include "rtpdebug.h"
39 |
40 | namespace jrtplib
41 | {
42 |
43 | RTPSessionParams::RTPSessionParams() : mininterval(0,0)
44 | {
45 | #ifdef RTP_SUPPORT_THREAD
46 | usepollthread = true;
47 | #else
48 | usepollthread = false;
49 | #endif // RTP_SUPPORT_THREAD
50 | maxpacksize = RTP_DEFAULTPACKETSIZE;
51 | receivemode = RTPTransmitter::AcceptAll;
52 | acceptown = false;
53 | owntsunit = -1; // The user will have to set it to the correct value himself
54 | resolvehostname = false;
55 | #ifdef RTP_SUPPORT_PROBATION
56 | probationtype = RTPSources::ProbationStore;
57 | #endif // RTP_SUPPORT_PROBATION
58 |
59 | mininterval = RTPTime(RTCP_DEFAULTMININTERVAL);
60 | sessionbandwidth = RTP_DEFAULTSESSIONBANDWIDTH;
61 | controlfrac = RTCP_DEFAULTBANDWIDTHFRACTION;
62 | senderfrac = RTCP_DEFAULTSENDERFRACTION;
63 | usehalfatstartup = RTCP_DEFAULTHALFATSTARTUP;
64 | immediatebye = RTCP_DEFAULTIMMEDIATEBYE;
65 | SR_BYE = RTCP_DEFAULTSRBYE;
66 |
67 | sendermultiplier = RTP_SENDERTIMEOUTMULTIPLIER;
68 | generaltimeoutmultiplier = RTP_MEMBERTIMEOUTMULTIPLIER;
69 | byetimeoutmultiplier = RTP_BYETIMEOUTMULTIPLIER;
70 | collisionmultiplier = RTP_COLLISIONTIMEOUTMULTIPLIER;
71 | notemultiplier = RTP_NOTETTIMEOUTMULTIPLIER;
72 |
73 | usepredefinedssrc = false;
74 | predefinedssrc = 0;
75 | }
76 |
77 | int RTPSessionParams::SetUsePollThread(bool usethread)
78 | {
79 | #ifndef RTP_SUPPORT_THREAD
80 | return ERR_RTP_NOTHREADSUPPORT;
81 | #else
82 | usepollthread = usethread;
83 | return 0;
84 | #endif // RTP_SUPPORT_THREAD
85 | }
86 |
87 | } // end namespace
88 |
89 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpsessionsources.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #include "rtpsessionsources.h"
34 | #include "rtpsession.h"
35 | #include "rtpsourcedata.h"
36 |
37 | #include "rtpdebug.h"
38 |
39 | namespace jrtplib
40 | {
41 |
42 | void RTPSessionSources::OnRTPPacket(RTPPacket *pack,const RTPTime &receivetime,const RTPAddress *senderaddress)
43 | {
44 | rtpsession.OnRTPPacket(pack,receivetime,senderaddress);
45 | }
46 |
47 | void RTPSessionSources::OnRTCPCompoundPacket(RTCPCompoundPacket *pack,const RTPTime &receivetime,const RTPAddress *senderaddress)
48 | {
49 | if (senderaddress != 0) // don't analyse own RTCP packets again (they're already analysed on their way out)
50 | rtpsession.rtcpsched.AnalyseIncoming(*pack);
51 | rtpsession.OnRTCPCompoundPacket(pack,receivetime,senderaddress);
52 | }
53 |
54 | void RTPSessionSources::OnSSRCCollision(RTPSourceData *srcdat,const RTPAddress *senderaddress,bool isrtp)
55 | {
56 | if (srcdat->IsOwnSSRC())
57 | owncollision = true;
58 | rtpsession.OnSSRCCollision(srcdat,senderaddress,isrtp);
59 | }
60 |
61 | void RTPSessionSources::OnCNAMECollision(RTPSourceData *srcdat,const RTPAddress *senderaddress,const uint8_t *cname,size_t cnamelength)
62 | {
63 | rtpsession.OnCNAMECollision(srcdat,senderaddress,cname,cnamelength);
64 | }
65 |
66 | void RTPSessionSources::OnNewSource(RTPSourceData *srcdat)
67 | {
68 | rtpsession.OnNewSource(srcdat);
69 | }
70 |
71 | void RTPSessionSources::OnRemoveSource(RTPSourceData *srcdat)
72 | {
73 | rtpsession.OnRemoveSource(srcdat);
74 | }
75 |
76 | void RTPSessionSources::OnTimeout(RTPSourceData *srcdat)
77 | {
78 | rtpsession.rtcpsched.ActiveMemberDecrease();
79 | rtpsession.OnTimeout(srcdat);
80 | }
81 |
82 | void RTPSessionSources::OnBYETimeout(RTPSourceData *srcdat)
83 | {
84 | rtpsession.OnBYETimeout(srcdat);
85 | }
86 |
87 | void RTPSessionSources::OnBYEPacket(RTPSourceData *srcdat)
88 | {
89 | rtpsession.rtcpsched.ActiveMemberDecrease();
90 | rtpsession.OnBYEPacket(srcdat);
91 | }
92 |
93 | void RTPSessionSources::OnAPPPacket(RTCPAPPPacket *apppacket,const RTPTime &receivetime,const RTPAddress *senderaddress)
94 | {
95 | rtpsession.OnAPPPacket(apppacket,receivetime,senderaddress);
96 | }
97 |
98 | void RTPSessionSources::OnUnknownPacketType(RTCPPacket *rtcppack,const RTPTime &receivetime, const RTPAddress *senderaddress)
99 | {
100 | rtpsession.OnUnknownPacketType(rtcppack,receivetime,senderaddress);
101 | }
102 |
103 | void RTPSessionSources::OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime,const RTPAddress *senderaddress)
104 | {
105 | rtpsession.OnUnknownPacketFormat(rtcppack,receivetime,senderaddress);
106 | }
107 |
108 | void RTPSessionSources::OnNoteTimeout(RTPSourceData *srcdat)
109 | {
110 | rtpsession.OnNoteTimeout(srcdat);
111 | }
112 |
113 | } // end namespace
114 |
115 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpsessionsources.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 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 |
78 | RTPSession &rtpsession;
79 | bool owncollision;
80 | };
81 |
82 | } // end namespace
83 |
84 | #endif // RTPSESSIONSOURCES_H
85 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtpstructs.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtptimeutilities.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 | #if (defined(WIN32) || defined(_WIN32_WCE))
34 |
35 | #include "rtptimeutilities.h"
36 | #ifdef RTPDEBUG
37 | #include
38 | #endif // RTPDEBUG
39 |
40 | namespace jrtplib
41 | {
42 |
43 | RTPTimeInitializer::RTPTimeInitializer()
44 | {
45 | #ifdef RTPDEBUG
46 | std::cout << "RTPTimeInitializer: Initializing RTPTime::CurrentTime()" << std::endl;
47 | #endif // RTPDEBUG
48 | RTPTime curtime = RTPTime::CurrentTime();
49 | dummy = -1;
50 | }
51 |
52 | RTPTimeInitializer timeinit;
53 |
54 | } // end namespace
55 |
56 | #endif // WIN32 || _WIN32_WCE
57 |
58 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtptypes.h:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtptypes.h.in:
--------------------------------------------------------------------------------
1 | ${RTP_WINSOCK_HEADERS}
2 | ${RTP_INTTYPE_HEADERS}
3 |
--------------------------------------------------------------------------------
/ios-jrtplib/rtptypes_win.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | This file is a part of JRTPLIB
4 | Copyright (c) 1999-2011 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 |
--------------------------------------------------------------------------------