JRTPLIB  3.11.1
rtpinternalsourcedata.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of JRTPLIB
4  Copyright (c) 1999-2017 Jori Liesenborgs
5 
6  Contact: jori.liesenborgs@gmail.com
7 
8  This library was developed at the Expertise Centre for Digital Media
9  (http://www.edm.uhasselt.be), a research center of the Hasselt University
10  (http://www.uhasselt.be). The library is based upon work done for
11  my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
12 
13  Permission is hereby granted, free of charge, to any person obtaining a
14  copy of this software and associated documentation files (the "Software"),
15  to deal in the Software without restriction, including without limitation
16  the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  and/or sell copies of the Software, and to permit persons to whom the
18  Software is furnished to do so, subject to the following conditions:
19 
20  The above copyright notice and this permission notice shall be included
21  in all copies or substantial portions of the Software.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29  IN THE SOFTWARE.
30 
31 */
32 
37 #ifndef RTPINTERNALSOURCEDATA_H
38 
39 #define RTPINTERNALSOURCEDATA_H
40 
41 #include "rtpconfig.h"
42 #include "rtpsourcedata.h"
43 #include "rtpaddress.h"
44 #include "rtptimeutilities.h"
45 #include "rtpsources.h"
46 
47 namespace jrtplib
48 {
49 
50 class JRTPLIB_IMPORTEXPORT RTPInternalSourceData : public RTPSourceData
51 {
52 public:
53  RTPInternalSourceData(uint32_t ssrc, RTPSources::ProbationType probtype, RTPMemoryManager *mgr = 0);
54  ~RTPInternalSourceData();
55 
56  int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,bool *stored, RTPSources *sources);
57  void ProcessSenderInfo(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t packetcount,
58  uint32_t octetcount,const RTPTime &receivetime) { SRprevinf = SRinf; SRinf.Set(ntptime,rtptime,packetcount,octetcount,receivetime); stats.SetLastMessageTime(receivetime); }
59  void ProcessReportBlock(uint8_t fractionlost,int32_t lostpackets,uint32_t exthighseqnr,
60  uint32_t jitter,uint32_t lsr,uint32_t dlsr,
61  const RTPTime &receivetime) { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); }
62  void UpdateMessageTime(const RTPTime &receivetime) { stats.SetLastMessageTime(receivetime); }
63  int ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis);
64 #ifdef RTP_SUPPORT_SDESPRIV
65  int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime);
66 #endif // RTP_SUPPORT_SDESPRIV
67  int ProcessBYEPacket(const uint8_t *reason,size_t reasonlen,const RTPTime &receivetime);
68 
69  int SetRTPDataAddress(const RTPAddress *a);
70  int SetRTCPDataAddress(const RTPAddress *a);
71 
72  void ClearSenderFlag() { issender = false; }
73  void SentRTPPacket() { if (!ownssrc) return; RTPTime t = RTPTime::CurrentTime(); issender = true; stats.SetLastRTPPacketTime(t); stats.SetLastMessageTime(t); }
74  void SetOwnSSRC() { ownssrc = true; validated = true; }
75  void SetCSRC() { validated = true; iscsrc = true; }
76  void ClearNote() { SDESinf.SetNote(0,0); }
77 
78 #ifdef RTP_SUPPORT_PROBATION
79 private:
80  RTPSources::ProbationType probationtype;
81 #endif // RTP_SUPPORT_PROBATION
82 };
83 
84 inline int RTPInternalSourceData::SetRTPDataAddress(const RTPAddress *a)
85 {
86  if (a == 0)
87  {
88  if (rtpaddr)
89  {
90  RTPDelete(rtpaddr,GetMemoryManager());
91  rtpaddr = 0;
92  }
93  }
94  else
95  {
96  RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
97  if (newaddr == 0)
98  return ERR_RTP_OUTOFMEM;
99 
100  if (rtpaddr && a != rtpaddr)
101  RTPDelete(rtpaddr,GetMemoryManager());
102  rtpaddr = newaddr;
103  }
104  isrtpaddrset = true;
105  return 0;
106 }
107 
108 inline int RTPInternalSourceData::SetRTCPDataAddress(const RTPAddress *a)
109 {
110  if (a == 0)
111  {
112  if (rtcpaddr)
113  {
114  RTPDelete(rtcpaddr,GetMemoryManager());
115  rtcpaddr = 0;
116  }
117  }
118  else
119  {
120  RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
121  if (newaddr == 0)
122  return ERR_RTP_OUTOFMEM;
123 
124  if (rtcpaddr && a != rtcpaddr)
125  RTPDelete(rtcpaddr,GetMemoryManager());
126  rtcpaddr = newaddr;
127  }
128  isrtcpaddrset = true;
129  return 0;
130 }
131 
132 } // end namespace
133 
134 #endif // RTPINTERNALSOURCEDATA_H
135 
ProbationType
Type of probation to use for new sources.
Definition: rtpsources.h:78
Definition: rtpfaketransmitter.h:64
static RTPTime CurrentTime()
Returns an RTPTime instance representing the current wallclock time.
Definition: rtptimeutilities.h:298