jrtplib  3.6.0
rtpinternalsourcedata.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of JRTPLIB
4  Copyright (c) 1999-2006 Jori Liesenborgs
5 
6  Contact: jori.liesenborgs@gmail.com
7 
8  This library was developed at the "Expertisecentrum Digitale 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 class RTPInternalSourceData : public RTPSourceData
48 {
49 public:
50  RTPInternalSourceData(uint32_t ssrc, RTPSources::ProbationType probtype, RTPMemoryManager *mgr = 0);
51  ~RTPInternalSourceData();
52 
53  int ProcessRTPPacket(RTPPacket *rtppack,const RTPTime &receivetime,bool *stored);
54  void ProcessSenderInfo(const RTPNTPTime &ntptime,uint32_t rtptime,uint32_t packetcount,
55  uint32_t octetcount,const RTPTime &receivetime) { SRprevinf = SRinf; SRinf.Set(ntptime,rtptime,packetcount,octetcount,receivetime); stats.SetLastMessageTime(receivetime); }
56  void ProcessReportBlock(uint8_t fractionlost,int32_t lostpackets,uint32_t exthighseqnr,
57  uint32_t jitter,uint32_t lsr,uint32_t dlsr,
58  const RTPTime &receivetime) { RRprevinf = RRinf; RRinf.Set(fractionlost,lostpackets,exthighseqnr,jitter,lsr,dlsr,receivetime); stats.SetLastMessageTime(receivetime); }
59  void UpdateMessageTime(const RTPTime &receivetime) { stats.SetLastMessageTime(receivetime); }
60  int ProcessSDESItem(uint8_t sdesid,const uint8_t *data,size_t itemlen,const RTPTime &receivetime,bool *cnamecollis);
61 #ifdef RTP_SUPPORT_SDESPRIV
62  int ProcessPrivateSDESItem(const uint8_t *prefix,size_t prefixlen,const uint8_t *value,size_t valuelen,const RTPTime &receivetime);
63 #endif // RTP_SUPPORT_SDESPRIV
64  int ProcessBYEPacket(const uint8_t *reason,size_t reasonlen,const RTPTime &receivetime);
65 
66  int SetRTPDataAddress(const RTPAddress *a);
67  int SetRTCPDataAddress(const RTPAddress *a);
68 
69  void ClearSenderFlag() { issender = false; }
70  void SentRTPPacket() { if (!ownssrc) return; RTPTime t = RTPTime::CurrentTime(); issender = true; stats.SetLastRTPPacketTime(t); stats.SetLastMessageTime(t); }
71  void SetOwnSSRC() { ownssrc = true; validated = true; }
72  void SetCSRC() { validated = true; iscsrc = true; }
73  void ClearNote() { SDESinf.SetNote(0,0); }
74 
75 #ifdef RTP_SUPPORT_PROBATION
76 private:
77  RTPSources::ProbationType probationtype;
78 #endif // RTP_SUPPORT_PROBATION
79 };
80 
81 inline int RTPInternalSourceData::SetRTPDataAddress(const RTPAddress *a)
82 {
83  if (a == 0)
84  {
85  if (rtpaddr)
86  {
87  RTPDelete(rtpaddr,GetMemoryManager());
88  rtpaddr = 0;
89  }
90  }
91  else
92  {
93  RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
94  if (newaddr == 0)
95  return ERR_RTP_OUTOFMEM;
96 
97  if (rtpaddr && a != rtpaddr)
98  RTPDelete(rtpaddr,GetMemoryManager());
99  rtpaddr = newaddr;
100  }
101  isrtpaddrset = true;
102  return 0;
103 }
104 
105 inline int RTPInternalSourceData::SetRTCPDataAddress(const RTPAddress *a)
106 {
107  if (a == 0)
108  {
109  if (rtcpaddr)
110  {
111  RTPDelete(rtcpaddr,GetMemoryManager());
112  rtcpaddr = 0;
113  }
114  }
115  else
116  {
117  RTPAddress *newaddr = a->CreateCopy(GetMemoryManager());
118  if (newaddr == 0)
119  return ERR_RTP_OUTOFMEM;
120 
121  if (rtcpaddr && a != rtcpaddr)
122  RTPDelete(rtcpaddr,GetMemoryManager());
123  rtcpaddr = newaddr;
124  }
125  isrtcpaddrset = true;
126  return 0;
127 }
128 
129 #endif // RTPINTERNALSOURCEDATA_H
130 
int SetNote(const uint8_t *s, size_t l)
Sets the SDES note item to s with length l.
Definition: rtcpsdesinfo.h:79
Represents an RTP Packet.
Definition: rtppacket.h:53
A memory manager.
Definition: rtpmemorymanager.h:144
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:77
virtual RTPAddress * CreateCopy(RTPMemoryManager *mgr) const =0
Creates a copy of the RTPAddress instance.
ProbationType
Type of probation to use for new sources.
Definition: rtpsources.h:75
This class is an abstract class which is used to specify destinations, multicast groups etc...
Definition: rtpaddress.h:47
static RTPTime CurrentTime()
Returns an RTPTime instance representing the current wallclock time.
Definition: rtptimeutilities.h:205
This is a simple wrapper for the most significant word (MSW) and least significant word (LSW) of an N...
Definition: rtptimeutilities.h:58
Describes an entry in the RTPSources source table.
Definition: rtpsourcedata.h:164