00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #ifndef RTCPPACKETBUILDER_H
00038
00039 #define RTCPPACKETBUILDER_H
00040
00041 #include "rtpconfig.h"
00042 #include "rtptypes.h"
00043 #include "rtperrors.h"
00044 #include "rtcpsdesinfo.h"
00045 #include "rtptimeutilities.h"
00046 #include "rtpmemoryobject.h"
00047
00048 class RTPSources;
00049 class RTPPacketBuilder;
00050 class RTCPScheduler;
00051 class RTCPCompoundPacket;
00052 class RTCPCompoundPacketBuilder;
00053
00060 class RTCPPacketBuilder : public RTPMemoryObject
00061 {
00062 public:
00068 RTCPPacketBuilder(RTPSources &sources,RTPPacketBuilder &rtppackbuilder, RTPMemoryManager *mgr = 0);
00069 ~RTCPPacketBuilder();
00070
00077 int Init(size_t maxpacksize,double timestampunit,const void *cname,size_t cnamelen);
00078
00080 void Destroy();
00081
00087 int SetTimestampUnit(double tsunit) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; if (tsunit < 0) return ERR_RTP_RTCPPACKETBUILDER_ILLEGALTIMESTAMPUNIT; timestampunit = tsunit; return 0; }
00088
00090 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; }
00091
00098 int SetPreTransmissionDelay(const RTPTime &delay) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; transmissiondelay = delay; return 0; }
00099
00101 int BuildNextPacket(RTCPCompoundPacket **pack);
00102
00108 int BuildBYEPacket(RTCPCompoundPacket **pack,const void *reason,size_t reasonlength,bool useSRifpossible = true);
00109
00116 void SetNameInterval(int count) { if (!init) return; interval_name = count; }
00117
00124 void SetEMailInterval(int count) { if (!init) return; interval_email = count; }
00125
00132 void SetLocationInterval(int count) { if (!init) return; interval_location = count; }
00133
00140 void SetPhoneInterval(int count) { if (!init) return; interval_phone = count; }
00141
00148 void SetToolInterval(int count) { if (!init) return; interval_tool = count; }
00149
00156 void SetNoteInterval(int count) { if (!init) return; interval_note = count; }
00157
00159 int SetLocalName(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetName((const uint8_t *)s,len); }
00160
00162 int SetLocalEMail(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetEMail((const uint8_t *)s,len); }
00163
00165 int SetLocalLocation(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetLocation((const uint8_t *)s,len); }
00166
00168 int SetLocalPhone(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetPhone((const uint8_t *)s,len); }
00169
00171 int SetLocalTool(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetTool((const uint8_t *)s,len); }
00172
00174 int SetLocalNote(const void *s,size_t len) { if (!init) return ERR_RTP_RTCPPACKETBUILDER_NOTINIT; return ownsdesinfo.SetNote((const uint8_t *)s,len); }
00175
00177 uint8_t *GetLocalCNAME(size_t *len) const { if (!init) return 0; return ownsdesinfo.GetCNAME(len); }
00178 private:
00179 void ClearAllSourceFlags();
00180 int FillInReportBlocks(RTCPCompoundPacketBuilder *pack,const RTPTime &curtime,int maxcount,bool *full,int *added,int *skipped,bool *atendoflist);
00181 int FillInSDES(RTCPCompoundPacketBuilder *pack,bool *full,bool *processedall,int *added);
00182 void ClearAllSDESFlags();
00183
00184 RTPSources &sources;
00185 RTPPacketBuilder &rtppacketbuilder;
00186
00187 bool init;
00188 size_t maxpacketsize;
00189 double timestampunit;
00190 bool firstpacket;
00191 RTPTime prevbuildtime,transmissiondelay;
00192
00193 class RTCPSDESInfoInternal : public RTCPSDESInfo
00194 {
00195 public:
00196 RTCPSDESInfoInternal(RTPMemoryManager *mgr) : RTCPSDESInfo(mgr) { ClearFlags(); }
00197 void ClearFlags() { pname = false; pemail = false; plocation = false; pphone = false; ptool = false; pnote = false; }
00198 bool ProcessedName() const { return pname; }
00199 bool ProcessedEMail() const { return pemail; }
00200 bool ProcessedLocation() const { return plocation; }
00201 bool ProcessedPhone() const { return pphone; }
00202 bool ProcessedTool() const { return ptool; }
00203 bool ProcessedNote() const { return pnote; }
00204 void SetProcessedName(bool v) { pname = v; }
00205 void SetProcessedEMail(bool v) { pemail = v; }
00206 void SetProcessedLocation(bool v) { plocation = v; }
00207 void SetProcessedPhone(bool v) { pphone = v; }
00208 void SetProcessedTool(bool v) { ptool = v; }
00209 void SetProcessedNote(bool v) { pnote = v; }
00210 private:
00211 bool pname,pemail,plocation,pphone,ptool,pnote;
00212 };
00213
00214 RTCPSDESInfoInternal ownsdesinfo;
00215 int interval_name,interval_email,interval_location;
00216 int interval_phone,interval_tool,interval_note;
00217 bool doname,doemail,doloc,dophone,dotool,donote;
00218 bool processingsdes;
00219
00220 int sdesbuildcount;
00221 };
00222
00223 #endif // RTCPPACKETBUILDER_H
00224