37 #ifndef RTCPCOMPOUNDPACKETBUILDER_H 39 #define RTCPCOMPOUNDPACKETBUILDER_H 41 #include "rtpconfig.h" 51 class RTPMemoryManager;
70 int InitBuild(
size_t maxpacketsize);
76 int InitBuild(
void *externalbuffer,
size_t buffersize);
83 int StartSenderReport(uint32_t senderssrc,
const RTPNTPTime &ntptimestamp,uint32_t rtptimestamp,
84 uint32_t packetcount,uint32_t octetcount);
91 int StartReceiverReport(uint32_t senderssrc);
97 int AddReportBlock(uint32_t ssrc,uint8_t fractionlost,int32_t packetslost,uint32_t exthighestseq,
98 uint32_t jitter,uint32_t lsr,uint32_t dlsr);
101 int AddSDESSource(uint32_t ssrc);
108 #ifdef RTP_SUPPORT_SDESPRIV 110 int AddSDESPrivateItem(
const void *prefixdata,uint8_t prefixlength,
const void *valuedata,
111 uint8_t valuelength);
112 #endif // RTP_SUPPORT_SDESPRIV 119 int AddBYEPacket(uint32_t *ssrcs,uint8_t numssrcs,
const void *reasondata,uint8_t reasonlength);
125 int AddAPPPacket(uint8_t subtype,uint32_t ssrc,
const uint8_t name[4],
const void *appdata,
size_t appdatalen);
133 #ifdef RTP_SUPPORT_RTCPUNKNOWN 137 int AddUnknownPacket(uint8_t payload_type, uint8_t subtype, uint32_t ssrc,
const void *data,
size_t len);
138 #endif // RTP_SUPPORT_RTCPUNKNOWN 143 Buffer():packetdata(0),packetlength(0) { }
144 Buffer(uint8_t *data,
size_t len):packetdata(data),packetlength(len) { }
150 class Report :
public RTPMemoryObject
155 headerdata = (uint8_t *)headerdata32;
159 ~Report() { Clear(); }
163 std::list<Buffer>::const_iterator it;
164 for (it = reportblocks.begin() ; it != reportblocks.end() ; it++)
166 if ((*it).packetdata)
167 RTPDeleteByteArray((*it).packetdata,GetMemoryManager());
169 reportblocks.clear();
177 n = reportblocks.size();
180 if (headerlength == 0)
182 x =
sizeof(RTCPCommonHeader)+headerlength;
186 x = n*
sizeof(RTCPReceiverReport);
191 x += d*(
sizeof(RTCPCommonHeader)+
sizeof(uint32_t));
193 x +=
sizeof(RTCPSenderReport);
198 size_t NeededBytesWithExtraReportBlock()
201 n = reportblocks.size() + 1;
202 x = n*
sizeof(RTCPReceiverReport);
207 x += d*(
sizeof(RTCPCommonHeader)+
sizeof(uint32_t));
209 x +=
sizeof(RTCPSenderReport);
216 uint32_t headerdata32[(
sizeof(uint32_t)+
sizeof(RTCPSenderReport))/
sizeof(uint32_t)];
218 std::list<Buffer> reportblocks;
221 class SDESSource :
public RTPMemoryObject
224 SDESSource(uint32_t s,
RTPMemoryManager *mgr) : RTPMemoryObject(mgr),ssrc(s),totalitemsize(0) { }
227 std::list<Buffer>::const_iterator it;
228 for (it = items.begin() ; it != items.end() ; it++)
230 if ((*it).packetdata)
231 RTPDeleteByteArray((*it).packetdata,GetMemoryManager());
239 x = totalitemsize + 1;
240 r = x%
sizeof(uint32_t);
242 x += (
sizeof(uint32_t)-r);
243 x +=
sizeof(uint32_t);
247 size_t NeededBytesWithExtraItem(uint8_t itemdatalength)
250 x = totalitemsize +
sizeof(RTCPSDESHeader) + (
size_t)itemdatalength + 1;
251 r = x%
sizeof(uint32_t);
253 x += (
sizeof(uint32_t)-r);
254 x +=
sizeof(uint32_t);
258 void AddItem(uint8_t *buf,
size_t len)
261 totalitemsize += len;
266 std::list<Buffer> items;
268 size_t totalitemsize;
271 class SDES :
public RTPMemoryObject
274 SDES(
RTPMemoryManager *mgr) : RTPMemoryObject(mgr) { sdesit = sdessources.end(); }
279 std::list<SDESSource *>::const_iterator it;
281 for (it = sdessources.begin() ; it != sdessources.end() ; it++)
282 RTPDelete(*it,GetMemoryManager());
286 int AddSSRC(uint32_t ssrc)
290 return ERR_RTP_OUTOFMEM;
291 sdessources.push_back(s);
292 sdesit = sdessources.end();
297 int AddItem(uint8_t *buf,
size_t len)
299 if (sdessources.empty())
300 return ERR_RTP_RTCPCOMPPACKBUILDER_NOCURRENTSOURCE;
301 (*sdesit)->AddItem(buf,len);
307 std::list<SDESSource *>::const_iterator it;
311 if (sdessources.empty())
314 for (it = sdessources.begin() ; it != sdessources.end() ; it++)
315 x += (*it)->NeededBytes();
316 n = sdessources.size();
321 x += d*
sizeof(RTCPCommonHeader);
325 size_t NeededBytesWithExtraItem(uint8_t itemdatalength)
327 std::list<SDESSource *>::const_iterator it;
331 if (sdessources.empty())
334 for (it = sdessources.begin() ; it != sdesit ; it++)
335 x += (*it)->NeededBytes();
336 x += (*sdesit)->NeededBytesWithExtraItem(itemdatalength);
337 n = sdessources.size();
342 x += d*
sizeof(RTCPCommonHeader);
346 size_t NeededBytesWithExtraSource()
348 std::list<SDESSource *>::const_iterator it;
352 if (sdessources.empty())
355 for (it = sdessources.begin() ; it != sdessources.end() ; it++)
356 x += (*it)->NeededBytes();
359 x +=
sizeof(uint32_t)*2;
361 n = sdessources.size() + 1;
366 x += d*
sizeof(RTCPCommonHeader);
370 std::list<SDESSource *> sdessources;
372 std::list<SDESSource *>::const_iterator sdesit;
375 size_t maximumpacketsize;
383 std::list<Buffer> byepackets;
386 std::list<Buffer> apppackets;
389 #ifdef RTP_SUPPORT_RTCPUNKNOWN 390 std::list<Buffer> unknownpackets;
392 #endif // RTP_SUPPORT_RTCPUNKNOWN 394 void ClearBuildBuffers();
399 #endif // RTCPCOMPOUNDPACKETBUILDER_H
Represents an RTCP compound packet.
Definition: rtcpcompoundpacket.h:53
This is a simple wrapper for the most significant word (MSW) and least significant word (LSW) of an N...
Definition: rtptimeutilities.h:65
ItemType
Identifies the type of an SDES item.
Definition: rtcpsdespacket.h:59
#define RTPMEM_TYPE_CLASS_SDESSOURCE
Buffer to store an SDESSource instance.
Definition: rtpmemorymanager.h:138
Definition: rtpfaketransmitter.h:64
A memory manager.
Definition: rtpmemorymanager.h:150
This class can be used to construct an RTCP compound packet.
Definition: rtcpcompoundpacketbuilder.h:59