jrtplib  3.6.0
rtcppacketbuilder.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 RTCPPACKETBUILDER_H
38 
39 #define RTCPPACKETBUILDER_H
40 
41 #include "rtpconfig.h"
42 #include "rtptypes.h"
43 #include "rtperrors.h"
44 #include "rtcpsdesinfo.h"
45 #include "rtptimeutilities.h"
46 #include "rtpmemoryobject.h"
47 
48 class RTPSources;
49 class RTPPacketBuilder;
50 class RTCPScheduler;
51 class RTCPCompoundPacket;
53 
60 class RTCPPacketBuilder : public RTPMemoryObject
61 {
62 public:
68  RTCPPacketBuilder(RTPSources &sources,RTPPacketBuilder &rtppackbuilder, RTPMemoryManager *mgr = 0);
70 
77  int Init(size_t maxpacksize,double timestampunit,const void *cname,size_t cnamelen);
78 
80  void Destroy();
81 
87  int SetTimestampUnit(double tsunit) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; if (tsunit < 0) return ERR_RTP_RTCPPACKETBUILDER_ILLEGALTIMESTAMPUNIT; timestampunit = tsunit; return 0; }
88 
90  int SetMaximumPacketSize(size_t maxpacksize) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; if (maxpacksize < RTP_MINPACKETSIZE) return ERR_RTP_RTCPPACKETBUILDER_ILLEGALMAXPACKSIZE; maxpacketsize = maxpacksize; return 0; }
91 
98  int SetPreTransmissionDelay(const RTPTime &delay) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; transmissiondelay = delay; return 0; }
99 
102 
108  int BuildBYEPacket(RTCPCompoundPacket **pack,const void *reason,size_t reasonlength,bool useSRifpossible = true);
109 
116  void SetNameInterval(int count) { if (!init) return; interval_name = count; }
117 
124  void SetEMailInterval(int count) { if (!init) return; interval_email = count; }
125 
132  void SetLocationInterval(int count) { if (!init) return; interval_location = count; }
133 
140  void SetPhoneInterval(int count) { if (!init) return; interval_phone = count; }
141 
148  void SetToolInterval(int count) { if (!init) return; interval_tool = count; }
149 
156  void SetNoteInterval(int count) { if (!init) return; interval_note = count; }
157 
159  int SetLocalName(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetName((const uint8_t *)s,len); }
160 
162  int SetLocalEMail(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetEMail((const uint8_t *)s,len); }
163 
165  int SetLocalLocation(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetLocation((const uint8_t *)s,len); }
166 
168  int SetLocalPhone(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetPhone((const uint8_t *)s,len); }
169 
171  int SetLocalTool(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetTool((const uint8_t *)s,len); }
172 
174  int SetLocalNote(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetNote((const uint8_t *)s,len); }
175 
177  uint8_t *GetLocalCNAME(size_t *len) const { if (!init) return 0; return ownsdesinfo.GetCNAME(len); }
178 private:
179  void ClearAllSourceFlags();
180  int FillInReportBlocks(RTCPCompoundPacketBuilder *pack,const RTPTime &curtime,int maxcount,bool *full,int *added,int *skipped,bool *atendoflist);
181  int FillInSDES(RTCPCompoundPacketBuilder *pack,bool *full,bool *processedall,int *added);
182  void ClearAllSDESFlags();
183 
184  RTPSources &sources;
185  RTPPacketBuilder &rtppacketbuilder;
186 
187  bool init;
188  size_t maxpacketsize;
189  double timestampunit;
190  bool firstpacket;
191  RTPTime prevbuildtime,transmissiondelay;
192 
193  class RTCPSDESInfoInternal : public RTCPSDESInfo
194  {
195  public:
196  RTCPSDESInfoInternal(RTPMemoryManager *mgr) : RTCPSDESInfo(mgr) { ClearFlags(); }
197  void ClearFlags() { pname = false; pemail = false; plocation = false; pphone = false; ptool = false; pnote = false; }
198  bool ProcessedName() const { return pname; }
199  bool ProcessedEMail() const { return pemail; }
200  bool ProcessedLocation() const { return plocation; }
201  bool ProcessedPhone() const { return pphone; }
202  bool ProcessedTool() const { return ptool; }
203  bool ProcessedNote() const { return pnote; }
204  void SetProcessedName(bool v) { pname = v; }
205  void SetProcessedEMail(bool v) { pemail = v; }
206  void SetProcessedLocation(bool v) { plocation = v; }
207  void SetProcessedPhone(bool v) { pphone = v; }
208  void SetProcessedTool(bool v) { ptool = v; }
209  void SetProcessedNote(bool v) { pnote = v; }
210  private:
211  bool pname,pemail,plocation,pphone,ptool,pnote;
212  };
213 
214  RTCPSDESInfoInternal ownsdesinfo;
215  int interval_name,interval_email,interval_location;
216  int interval_phone,interval_tool,interval_note;
217  bool doname,doemail,doloc,dophone,dotool,donote;
218  bool processingsdes;
219 
220  int sdesbuildcount;
221 };
222 
223 #endif // RTCPPACKETBUILDER_H
224 
int BuildBYEPacket(RTCPCompoundPacket **pack, const void *reason, size_t reasonlength, bool useSRifpossible=true)
Builds a BYE packet with reason for leaving specified by reason and length reasonlength.
The class RTCPSDESInfo is a container for RTCP SDES information.
Definition: rtcpsdesinfo.h:50
A memory manager.
Definition: rtpmemorymanager.h:144
void SetEMailInterval(int count)
Sets the RTCP interval for the SDES e-mail item.
Definition: rtcppacketbuilder.h:124
int SetLocalTool(const void *s, size_t len)
Sets the SDES tool item for the local participant to the value s with length len. ...
Definition: rtcppacketbuilder.h:171
void SetLocationInterval(int count)
Sets the RTCP interval for the SDES location item.
Definition: rtcppacketbuilder.h:132
Represents a table in which information about the participating sources is kept.
Definition: rtpsources.h:71
RTCPPacketBuilder(RTPSources &sources, RTPPacketBuilder &rtppackbuilder, RTPMemoryManager *mgr=0)
Creates an RTCPPacketBuilder instance.
uint8_t * GetLocalCNAME(size_t *len) const
Returns the own CNAME item with length len.
Definition: rtcppacketbuilder.h:177
This class is used to specify wallclock time, delay intervals etc.
Definition: rtptimeutilities.h:77
int SetLocalLocation(const void *s, size_t len)
Sets the SDES location item for the local participant to the value s with length len.
Definition: rtcppacketbuilder.h:165
int SetTimestampUnit(double tsunit)
Sets the timestamp unit to be used to tsunit.
Definition: rtcppacketbuilder.h:87
Represents an RTCP compound packet.
Definition: rtcpcompoundpacket.h:50
This class can be used to construct an RTCP compound packet.
Definition: rtcpcompoundpacketbuilder.h:56
void SetPhoneInterval(int count)
Sets the RTCP interval for the SDES phone item.
Definition: rtcppacketbuilder.h:140
This class can be used to build RTCP compound packets, on a higher level than the RTCPCompoundPacketB...
Definition: rtcppacketbuilder.h:60
void SetToolInterval(int count)
Sets the RTCP interval for the SDES tool item.
Definition: rtcppacketbuilder.h:148
int SetLocalName(const void *s, size_t len)
Sets the SDES name item for the local participant to the value s with length len. ...
Definition: rtcppacketbuilder.h:159
void SetNameInterval(int count)
Sets the RTCP interval for the SDES name item.
Definition: rtcppacketbuilder.h:116
int SetLocalEMail(const void *s, size_t len)
Sets the SDES e-mail item for the local participant to the value s with length len.
Definition: rtcppacketbuilder.h:162
int BuildNextPacket(RTCPCompoundPacket **pack)
Builds the next RTCP compound packet which should be sent and stores it in pack.
int Init(size_t maxpacksize, double timestampunit, const void *cname, size_t cnamelen)
Initializes the builder.
void SetNoteInterval(int count)
Sets the RTCP interval for the SDES note item.
Definition: rtcppacketbuilder.h:156
This class can be used to build RTP packets and is a bit more high-level than the RTPPacket class: it...
Definition: rtppacketbuilder.h:54
int SetLocalNote(const void *s, size_t len)
Sets the SDES note item for the local participant to the value s with length len. ...
Definition: rtcppacketbuilder.h:174
This class determines when RTCP compound packets should be sent.
Definition: rtcpscheduler.h:98
void Destroy()
Cleans up the builder.
int SetLocalPhone(const void *s, size_t len)
Sets the SDES phone item for the local participant to the value s with length len.
Definition: rtcppacketbuilder.h:168
int SetPreTransmissionDelay(const RTPTime &delay)
This function allows you to inform RTCP packet builder about the delay between sampling the first sam...
Definition: rtcppacketbuilder.h:98
int SetMaximumPacketSize(size_t maxpacksize)
Sets the maximum size allowed size of an RTCP compound packet to maxpacksize.
Definition: rtcppacketbuilder.h:90