OPAL  Version 3.18.8
rtp.h
Go to the documentation of this file.
1 /*
2  * rtp.h
3  *
4  * RTP protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions of this code were written with the assisance of funding from
25  * Vovida Networks, Inc. http://www.vovida.com.
26  *
27  * Contributor(s): ______________________________________.
28  */
29 
30 #ifndef OPAL_RTP_RTP_H
31 #define OPAL_RTP_RTP_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #include <opal_config.h>
38 
39 #include <ptclib/url.h>
40 
41 #include <set>
42 
43 
44 typedef uint32_t RTP_Timestamp;
45 typedef uint16_t RTP_SequenceNumber;
46 typedef uint32_t RTP_SyncSourceId;
47 typedef std::vector<RTP_SyncSourceId> RTP_SyncSourceArray;
48 class RTP_ReceiverReport;
49 class RTP_SenderReport;
50 
51 
53 // Real Time Protocol - IETF RFC1889 and RFC1890
54 
55 class RTP_SourceDescription : public PObject
56 {
57  PCLASSINFO(RTP_SourceDescription, PObject);
58  public:
60 #if PTRACING
61  void PrintOn(ostream &) const;
62 #endif
63 
65  POrdinalToString items;
66 };
67 
68 typedef PArray<RTP_SourceDescription> RTP_SourceDescriptionArray;
69 
70 
71 class RTP_TransportWideCongestionControl : public PObject
72 {
73  PCLASSINFO(RTP_TransportWideCongestionControl, PObject);
74  public:
76 
77  struct Info
78  {
79  Info(const PTimeInterval & ts = 0, unsigned id = 0, RTP_SyncSourceId ssrc = 0)
80  : m_timestamp(ts)
81  , m_sessionID(id)
82  , m_SSRC(ssrc)
83  { }
84 
85  PTimeInterval m_timestamp;
86  unsigned m_sessionID;
88  };
89  /* Note, map index is (effectively) a 17 bit transport wide sequence
90  number, even though the over the wire value is 16 bit, as wraparound
91  is compensated for to make sure the correct order in the map of the
92  packets is maintained. */
93  typedef std::map<unsigned, Info> PacketMap;
96 };
97 
98 
101 class RTP_ControlFrame : public PBYTEArray
102 {
103  PCLASSINFO(RTP_ControlFrame, PBYTEArray);
104 
105  public:
106  RTP_ControlFrame(PINDEX compoundSize = 2048);
107  RTP_ControlFrame(const BYTE * data, PINDEX size, bool dynamic = true);
108 
109 #if PTRACING
110  virtual void PrintOn(ostream &) const;
111 #endif
112 
113  bool IsValid() const;
114 
115  unsigned GetVersion() const { return (BYTE)theArray[m_compoundOffset]>>6; }
116 
117  unsigned GetCount() const { return (BYTE)theArray[m_compoundOffset]&0x1f; }
118  void SetCount(unsigned count);
119 
120  RTP_SyncSourceId GetSenderSyncSource() const { return *(PUInt32b *)(theArray + 4); } // Always first DWORD in the first payload
121 
123  e_FirstValidPayloadType = 192, // RFC5761
128  e_Goodbye = 203,
130  e_TransportLayerFeedBack = 205, // RFC4585
132  e_ExtendedReport = 207, // RFC3611
133  e_LastValidPayloadType = 223 // RFC5761
134  };
135 
136  PayloadTypes GetPayloadType() const { return (PayloadTypes)(BYTE)theArray[m_compoundOffset+1]; }
137  void SetPayloadType(PayloadTypes pt);
138 
139  PINDEX GetPayloadSize() const { return 4*(*(PUInt16b *)&theArray[m_compoundOffset+2]); }
140  bool SetPayloadSize(PINDEX sz);
141 
142  BYTE * GetPayloadPtr() const;
143 
144  bool ReadNextPacket();
145  bool StartNewPacket(PayloadTypes pt);
146  void EndPacket();
147 
148  PINDEX GetPacketSize() const { return m_packetSize; }
149  bool SetPacketSize(PINDEX size);
150 
151  bool ParseGoodbye(RTP_SyncSourceId & ssrc, RTP_SyncSourceArray & csrc, PString & msg);
152 
153 #pragma pack(1)
154  struct ReceiverReport {
155  PUInt32b ssrc; /* data source being reported */
156  BYTE fraction; /* fraction lost since last SR/RR */
157  BYTE lost[3]; /* cumulative number of packets lost (signed!) */
158  PUInt32b last_seq; /* extended last sequence number received */
159  PUInt32b jitter; /* interarrival jitter */
160  PUInt32b lsr; /* last SR packet from this source */
161  PUInt32b dlsr; /* delay since last SR packet */
162 
163  int GetLostPackets() const;
164  void SetLostPackets(int packets);
165  };
166 
167  bool ParseReceiverReport(
168  RTP_SyncSourceId & ssrc,
169  const ReceiverReport * & rr,
170  unsigned & count
171  );
173  RTP_SyncSourceId ssrc,
174  unsigned receivers
175  );
176 
177  struct SenderReport {
178  PUInt32b ssrc;
179  PUInt64b ntp_ts; /* NTP timestamp */
180  PUInt32b rtp_ts; /* RTP timestamp */
181  PUInt32b psent; /* packets sent */
182  PUInt32b osent; /* octets sent */
183  };
184 
185  bool ParseSenderReport(
186  RTP_SenderReport & txReport,
187  const ReceiverReport * & rr,
188  unsigned & count
189  );
191  RTP_SyncSourceId ssrc,
192  const PTime & ntp,
193  RTP_Timestamp ts,
194  unsigned packets,
195  uint64_t octets,
196  unsigned receivers
197  );
198 
199  struct ExtendedReport {
200  BYTE bt; /* block type */
201  BYTE type_specific; /* determined by the block definition */
202  PUInt16b length; /* length of the report block */
203  };
204 
206  PUInt64b ntp;
207  };
209  RTP_SyncSourceId ssrc,
210  const PTime & ntp
211  );
212 
214  struct Receiver {
215  PUInt32b ssrc;
216  PUInt32b lrr;
217  PUInt32b dlrr;
218  } m_receiver[1];
219  };
221  RTP_SyncSourceId ssrc,
222  unsigned receivers
223  );
224  static void AddDelayLastReceiverReport(
226  RTP_SyncSourceId ssrc,
227  const PTime & ntp,
228  const PTimeInterval & delay
229  );
230 
231 
232 #if OPAL_RTCP_XR
233  struct MetricsReport : ExtendedReport {
234  /* VoIP Metrics Report Block */
235  PUInt32b ssrc; /* data source being reported */
236  BYTE loss_rate; /* fraction of RTP data packets lost */
237  BYTE discard_rate; /* fraction of RTP data packets discarded */
238  BYTE burst_density; /* fraction of RTP data packets within burst periods */
239  BYTE gap_density; /* fraction of RTP data packets within inter-burst gaps */
240  PUInt16b burst_duration; /* the mean duration, in ms, of burst periods */
241  PUInt16b gap_duration; /* the mean duration, in ms, of gap periods */
242  PUInt16b round_trip_delay; /* the most recently calculated round trip time */
243  PUInt16b end_system_delay; /* the most recently estimates end system delay */
244  BYTE signal_level; /* voice signal level related to 0 dBm */
245  BYTE noise_level; /* ratio of the silent background level to 0 dBm */
246  BYTE rerl; /* residual echo return loss */
247  BYTE gmin; /* gap threshold */
248  BYTE r_factor; /* voice quality metric of the call */
249  BYTE ext_r_factor; /* external R factor */
250  BYTE mos_lq; /* MOS for listen quality */
251  BYTE mos_cq; /* MOS for conversational quality */
252  BYTE rx_config; /* receiver configuration byte */
253  BYTE reserved; /* reserved for future definition */
254  PUInt16b jb_nominal; /* current nominal jitter buffer delay, in ms */
255  PUInt16b jb_maximum; /* current maximum jitter buffer delay, in ms */
256  PUInt16b jb_absolute; /* current absolute maximum jitter buffer delay, in ms */
257  };
258 #endif
259 
260 
272  };
273 
275  PUInt32b src; /* first SSRC/CSRC */
276  struct Item {
277  BYTE type; /* type of SDES item (enum DescriptionTypes) */
278  BYTE length; /* length of SDES item (in octets) */
279  char data[1]; /* text, not zero-terminated */
280 
281  /* WARNING, SourceDescription may not be big enough to contain length and data, for
282  instance, when type == RTP_ControlFrame::e_END.
283  Be careful whan calling the following function of it may read to over to
284  memory allocated*/
285  unsigned int GetLengthTotal() const {return (unsigned int)(length + 2);}
286  const Item * GetNextItem() const { return (const Item *)((char *)this + length + 2); }
287  Item * GetNextItem() { return (Item *)((char *)this + length + 2); }
288  } item[1]; /* list of SDES items */
289  };
290 
292  RTP_SyncSourceId src
293  );
294 
296  unsigned type,
297  const PString & data
298  );
299 
301  RTP_SourceDescriptionArray & descriptions
302  );
304  RTP_SyncSourceId ssrc,
305  const PString & cname,
306  const PString & toolName,
307  bool endPacket = true
308  );
309 
310  // Add RFC2032 Intra Frame Request
311  void AddIFR(
312  RTP_SyncSourceId syncSourceIn
313  );
314 
315 
316  // RFC4585 Feedback Message Type (FMT)
317  struct FbHeader {
318  PUInt32b senderSSRC; /* data source of sender of message */
319  PUInt32b mediaSSRC; /* data source of media */
320  };
321 
322  unsigned GetFbType() const { return (BYTE)theArray[m_compoundOffset]&0x1f; }
323 
324  FbHeader * AddFeedback(PayloadTypes pt, unsigned type, PINDEX fciSize);
325  template <typename FB> void AddFeedback(PayloadTypes pt, unsigned type, FB * & data) { data = (FB *)AddFeedback(pt, type, sizeof(FB)); }
326 
327  // RFC4585 transport layer
330  e_TMMBR = 3,
332  e_TWCC = 15
333  };
334 
335  struct FbNACK : FbHeader {
336  struct Field
337  {
338  PUInt16b packetID;
339  PUInt16b bitmask;
340  } fld[1];
341  };
342  struct LostPacketMask : std::set<RTP_SequenceNumber>
343  {
344  friend ostream & operator<<(ostream & strm, const LostPacketMask & mask);
345  };
346  void AddNACK(
347  RTP_SyncSourceId syncSourceOut,
348  RTP_SyncSourceId syncSourceIn,
349  const LostPacketMask & lostPackets
350  );
351  bool ParseNACK(
352  RTP_SyncSourceId & senderSSRC,
353  RTP_SyncSourceId & targetSSRC,
354  LostPacketMask & lostPackets
355  );
356 
357  // Same for request (e_TMMBR) and notification (e_TMMBN)
358  struct FbTMMB : FbHeader {
359  PUInt32b requestSSRC;
360  PUInt32b bitRateAndOverhead; // Various bit fields
361  };
362  void AddTMMB(
363  RTP_SyncSourceId syncSourceOut,
364  RTP_SyncSourceId syncSourceIn,
365  unsigned maxBitRate,
366  unsigned overhead,
367  bool notify
368  );
369  bool ParseTMMB(
370  RTP_SyncSourceId & senderSSRC,
371  RTP_SyncSourceId & targetSSRC,
372  unsigned & maxBitRate,
373  unsigned & overhead
374  );
375 
376  struct FbTWCC : FbHeader {
377  PUInt16b baseSN;
378  PUInt16b statusCount;
379  uint8_t referenceTime[3];
380  uint8_t rtcpSN;
381  };
382  void AddTWCC(
383  RTP_SyncSourceId syncSourceOut,
385  );
386  bool ParseTWCC(
387  RTP_SyncSourceId & senderSSRC,
389  );
390 
400  };
401 
402  void AddPLI(
403  RTP_SyncSourceId syncSourceOut,
404  RTP_SyncSourceId syncSourceIn
405  );
406  bool ParsePLI(
407  RTP_SyncSourceId & senderSSRC,
408  RTP_SyncSourceId & targetSSRC
409  );
410 
411  struct FbFIR : FbHeader {
412  PUInt32b requestSSRC;
414  };
415  void AddFIR(
416  RTP_SyncSourceId syncSourceOut,
417  RTP_SyncSourceId syncSourceIn,
418  unsigned sequenceNumber
419  );
420  bool ParseFIR(
421  RTP_SyncSourceId & senderSSRC,
422  RTP_SyncSourceId & targetSSRC,
423  unsigned & sequenceNumber
424  );
425 
426  struct FbTSTO : FbHeader {
427  PUInt32b requestSSRC;
429  BYTE reserver[2];
430  BYTE tradeOff;
431  };
432  void AddTSTO(
433  RTP_SyncSourceId syncSourceOut,
434  RTP_SyncSourceId syncSourceIn,
435  unsigned tradeOff,
436  unsigned sequenceNumber
437  );
438  bool ParseTSTO(
439  RTP_SyncSourceId & senderSSRC,
440  RTP_SyncSourceId & targetSSRC,
441  unsigned & tradeOff,
442  unsigned & sequenceNumber
443  );
444 
445  struct FbREMB : FbHeader {
446  char id[4]; // 'R' 'E' 'M' 'B'
447  BYTE numSSRC;
448  BYTE bitRate[3];
449  PUInt32b feedbackSSRC[1];
450  };
451  void AddREMB(
452  RTP_SyncSourceId syncSourceOut,
453  RTP_SyncSourceId syncSourceIn,
454  unsigned maxBitRate
455  );
456  bool ParseREMB(
457  RTP_SyncSourceId & senderSSRC,
458  RTP_SyncSourceArray & targetSSRCs,
459  unsigned & maxBitRate
460  );
461 
462 #pragma pack()
463 
465  char m_type[5];
466  unsigned m_subType;
468  PBYTEArray m_data;
469 
470  ApplDefinedInfo(const char * type = NULL, unsigned subType = 0, RTP_SyncSourceId ssrc = 0, const BYTE * data = NULL, PINDEX size = 0);
471  };
472  void AddApplDefined(const ApplDefinedInfo & info);
473  bool ParseApplDefined(ApplDefinedInfo & info);
474 
475  protected:
476  PINDEX m_packetSize;
479 
480  private:
481  virtual PBoolean SetSize(PINDEX sz) { return PBYTEArray::SetSize(sz); }
482 };
483 
484 
485 class RTP_SenderReport : public PObject
486 {
487  PCLASSINFO(RTP_SenderReport, PObject);
488  public:
491 #if PTRACING
492  void PrintOn(ostream &) const;
493 #endif
494 
496  uint64_t ntpPassThrough;
499  unsigned packetsSent;
500  unsigned octetsSent;
501 };
502 
503 
504 class RTP_ReceiverReport : public PObject
505 {
506  PCLASSINFO(RTP_ReceiverReport, PObject);
507  public:
508  RTP_ReceiverReport(const RTP_ControlFrame::ReceiverReport & report, uint64_t ntpPassThru);
509 #if PTRACING
510  void PrintOn(ostream &) const;
511 #endif
512 
513  RTP_SyncSourceId sourceIdentifier; /* data source being reported */
514  unsigned fractionLost; /* fraction lost since last SR/RR */
515  unsigned totalLost; /* cumulative number of packets lost (signed!) */
516  unsigned lastSequenceNumber; /* extended last sequence number received */
517  unsigned jitter; /* interarrival jitter */
518  PTime lastTimestamp; /* last SR time from this source */
519  PTimeInterval delay; /* delay since last SR packet */
520 };
521 
522 
523 class RTP_DelayLastReceiverReport : public PObject
524 {
525  PCLASSINFO(RTP_DelayLastReceiverReport, PObject);
526  public:
528 #if PTRACING
529  void PrintOn(ostream &) const;
530 #endif
531 
533  PTime m_lastTimestamp; /* last RR packet from this source */
534  PTimeInterval m_delay; /* delay since last RR packet */
535 };
536 
537 
540 class RTP_DataFrame : public PBYTEArray
541 {
542  PCLASSINFO(RTP_DataFrame, PBYTEArray);
543 
544  public:
545  RTP_DataFrame(PINDEX payloadSize = 0, PINDEX bufferSize = 0);
546  RTP_DataFrame(const BYTE * data, PINDEX len, bool dynamic = true);
547  RTP_DataFrame(const PBYTEArray & data);
548 
549  enum {
552  // Max safe MTU size (576 bytes as per RFC879) minus IP, UDP an RTP headers
553  MaxMtuPayloadSize = (576-20-16-12)
554  };
555 
557  PCMU, // G.711 u-Law
558  FS1016, // Federal Standard 1016 CELP
559  G721, // ADPCM - Subsumed by G.726
561  GSM, // GSM 06.10
562  G7231, // G.723.1 at 6.3kbps or 5.3 kbps
563  DVI4_8k, // DVI4 at 8kHz sample rate
564  DVI4_16k, // DVI4 at 16kHz sample rate
565  LPC, // LPC-10 Linear Predictive CELP
566  PCMA, // G.711 A-Law
567  G722, // G.722
568  L16_Stereo, // 16 bit linear PCM
569  L16_Mono, // 16 bit linear PCM
570  G723, // G.723
571  CN, // Confort Noise
572  MPA, // MPEG1 or MPEG2 audio
573  G728, // G.728 16kbps CELP
574  DVI4_11k, // DVI4 at 11kHz sample rate
575  DVI4_22k, // DVI4 at 22kHz sample rate
576  G729, // G.729 8kbps
577  Cisco_CN, // Cisco systems comfort noise (unofficial)
578 
579  CelB = 25, // Sun Systems Cell-B video
580  JPEG, // Motion JPEG
581  H261 = 31, // H.261
582  MPV, // MPEG1 or MPEG2 video
583  MP2T, // MPEG2 transport system
584  H263, // H.263
585 
586  T38 = 38, // T.38 (internal)
587 
589 
592 
596  };
597 
598  unsigned GetVersion() const { return (theArray[0]>>6)&3; }
599 
600  bool GetExtension() const { return (theArray[0]&0x10) != 0; }
601  void SetExtension(bool ext);
602 
603  bool GetMarker() const { return (theArray[1]&0x80) != 0; }
604  void SetMarker(bool m);
605 
606  bool GetPadding() const { return (theArray[0]&0x20) != 0; }
607  void SetPadding(bool v) { if (v) theArray[0] |= 0x20; else theArray[0] &= 0xdf; }
608  BYTE * GetPaddingPtr() const { return (BYTE *)(theArray+m_headerSize+m_payloadSize); }
609 
610  PINDEX GetPaddingSize() const { return m_paddingSize > 0 ? m_paddingSize-1 : 0; }
611  bool SetPaddingSize(PINDEX sz);
612 
613  PayloadTypes GetPayloadType() const { return (PayloadTypes)(theArray[1]&0x7f); }
615 
616  RTP_SequenceNumber GetSequenceNumber() const { return *(PUInt16b *)&theArray[2]; }
617  void SetSequenceNumber(RTP_SequenceNumber n) { *(PUInt16b *)&theArray[2] = n; }
618 
619  RTP_Timestamp GetTimestamp() const { return *(PUInt32b *)&theArray[4]; }
620  void SetTimestamp(RTP_Timestamp t) { *(PUInt32b *)&theArray[4] = t; }
621 
622  RTP_SyncSourceId GetSyncSource() const { return *(PUInt32b *)&theArray[8]; }
623  void SetSyncSource(RTP_SyncSourceId s) { *(PUInt32b *)&theArray[8] = s; }
624 
625  PINDEX GetContribSrcCount() const { return theArray[0]&0xf; }
626  RTP_SyncSourceId GetContribSource(PINDEX idx) const;
627  void SetContribSource(PINDEX idx, RTP_SyncSourceId src);
628 
629  PINDEX GetHeaderSize() const { return m_headerSize; }
630 
631  void CopyHeader(const RTP_DataFrame & other);
632  void Copy(const RTP_DataFrame & other);
633 
640  BYTE * GetHeaderExtension(
641  unsigned & id,
642  PINDEX & length,
643  int idx = -1
644  ) const;
645 
651  };
652 
653  static const unsigned MaxHeaderExtensionId = 65535;
654  static const unsigned MaxHeaderExtensionIdOneByte = 14;
655  static const unsigned MaxHeaderExtensionIdTwoByte = 255;
656 
660  BYTE * GetHeaderExtension(
661  HeaderExtensionType type,
662  unsigned id,
663  PINDEX & length
664  ) const;
665 
673  bool SetHeaderExtension(
674  unsigned id,
675  PINDEX length,
676  const BYTE * data,
677  HeaderExtensionType type
678  );
679 
680  PINDEX GetExtensionSizeDWORDs() const; // get the number of 32 bit words in the extension (excluding the header).
681  bool SetExtensionSizeDWORDs(PINDEX sz); // set the number of 32 bit words in the extension (excluding the header)
682 
683  PINDEX GetPayloadSize() const { return m_payloadSize; }
684  bool SetPayloadSize(PINDEX sz);
685  bool SetPayload(const BYTE * data, PINDEX sz);
686  BYTE * GetPayloadPtr() const { return (BYTE *)(theArray+m_headerSize); }
687 
688  virtual PObject * Clone() const { return new RTP_DataFrame(*this); }
689 #if PTRACING
690  virtual void PrintOn(ostream & strm) const;
691 #endif
692 
693  // Note this sets the whole packet length, and calculates the various
694  // sub-section sizes: header payload and padding.
695  bool SetPacketSize(PINDEX sz);
696 
697  // Get the packet size including headers, padding etc.
698  PINDEX GetPacketSize() const;
699 
704  struct MetaData
705  {
706  MetaData();
707 
714  PTime m_receivedTime; //< Local wall clock time packet was physically read from socket
715  unsigned m_discontinuity; //< Number of packets lost since the last one
716  PString m_lipSyncId; //< Identifier for pairing audio and video packets.
717  };
718 
721  const MetaData & GetMetaData() const { return m_metaData; }
722 
725  void SetMetaData(const MetaData & metaData) { m_metaData = metaData; }
726 
729  PTime GetAbsoluteTime() const { return m_metaData.m_absoluteTime; }
730 
733  void SetAbsoluteTime() { m_metaData.m_absoluteTime.SetCurrentTime(); }
734  void SetAbsoluteTime(const PTime & t) { m_metaData.m_absoluteTime = t; }
735 
738  void SetTransmitTime(const PTime & when) { m_metaData.m_transmitTime = when; }
739  void SetTransmitTimeNTP(uint64_t ntp) { m_metaData.m_transmitTime.SetNTP(ntp); }
740 
743  void SetReceivedTime(const PTime & when) { m_metaData.m_receivedTime = when; }
744 
749  unsigned GetDiscontinuity() const { return m_metaData.m_discontinuity; }
750 
753  void SetDiscontinuity(unsigned lost) { m_metaData.m_discontinuity = lost; }
754 
758  const PString & GetLipSyncId() const { return m_metaData.m_lipSyncId; }
759 
763  void SetLipSyncId(const PString & id) { m_metaData.m_lipSyncId = id; }
764 
765  // backward compatibility
766  P_DEPRECATED const PString & GetBundleId() const { return m_metaData.m_lipSyncId; }
767  P_DEPRECATED void SetBundleId(const PString & id) { m_metaData.m_lipSyncId = id; }
768 
769  protected:
770  bool AdjustHeaderSize(PINDEX newSize);
771 
772  PINDEX m_headerSize;
776 
777 #if PTRACING
778  friend ostream & operator<<(ostream & o, PayloadTypes t);
779 #endif
780 
781  private:
782  virtual PBoolean SetSize(PINDEX sz) { return PBYTEArray::SetSize(sz); }
783 };
784 
785 PLIST(RTP_DataFrameList, RTP_DataFrame);
786 
787 
789 
792 class RTPHeaderExtensionInfo : public PObject
793 {
794  PCLASSINFO(RTPHeaderExtensionInfo, PObject);
795  public:
796  unsigned m_id;
797 
798  enum Direction {
799  Undefined = -1,
803  SendRecv
804  } m_direction;
805 
806  PURL m_uri;
807 
808  PString m_attributes;
809 
811  explicit RTPHeaderExtensionInfo(
812  const PURL & uri,
813  const PString & attributes = PString::Empty()
814  );
816  unsigned id,
817  const PURL & uri,
818  const PString & attributes = PString::Empty()
819  );
820 
821 #if PTRACING
822  virtual void PrintOn(ostream & strm) const;
823 #endif
824  virtual Comparison Compare(const PObject & other) const;
825 
826 #if OPAL_SDP
827  bool ParseSDP(const PString & param);
828  void OutputSDP(ostream & strm) const;
829 #endif
830 };
831 
832 class RTPHeaderExtensions : public std::set<RTPHeaderExtensionInfo>
833 {
834 public:
835  bool AddUniqueID(RTPHeaderExtensionInfo & info);
836  bool Contains(const RTPHeaderExtensionInfo & info) const;
837 };
838 
839 
840 #if PTRACING
841 class RTP_TRACE_SRC
842 {
843  public:
844  RTP_TRACE_SRC(RTP_SyncSourceId src)
845  : m_src(src)
846  {
847  }
848 
849  friend std::ostream & operator<<(std::ostream & strm, const RTP_TRACE_SRC & src)
850  {
851  return strm << src.m_src << " (0x" << std::hex << src.m_src << std::dec << ')';
852  }
853 
854  protected:
855  RTP_SyncSourceId m_src;
856 };
857 #endif // PTRACING
858 
859 #endif // OPAL_RTP_RTP_H
860 
PUInt32b ssrc
Definition: rtp.h:178
PUInt32b requestSSRC
Definition: rtp.h:427
Definition: rtp.h:566
Definition: rtp.h:269
void SetLostPackets(int packets)
RTP_SyncSourceId m_ssrc
Definition: rtp.h:532
void AddReceiverReferenceTimeReport(RTP_SyncSourceId ssrc, const PTime &ntp)
void AddFIR(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn, unsigned sequenceNumber)
Definition: rtp.h:792
void Copy(const RTP_DataFrame &other)
Definition: rtp.h:570
PUInt16b packetID
Definition: rtp.h:338
Definition: rtp.h:581
struct RTP_ControlFrame::FbNACK::Field fld[1]
Definition: rtp.h:265
Definition: rtp.h:358
BYTE fraction
Definition: rtp.h:156
BYTE bitRate[3]
Definition: rtp.h:448
unsigned totalLost
Definition: rtp.h:515
TransportLayerFbTypes
Definition: rtp.h:328
bool SetPaddingSize(PINDEX sz)
PString m_attributes
Definition: rtp.h:808
virtual PObject * Clone() const
Definition: rtp.h:688
bool SetPacketSize(PINDEX size)
BYTE type_specific
Definition: rtp.h:201
unsigned int GetLengthTotal() const
Definition: rtp.h:285
PUInt64b ntp_ts
Definition: rtp.h:179
bool SetPayloadSize(PINDEX sz)
void AddPLI(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn)
PINDEX GetPaddingSize() const
Definition: rtp.h:610
unsigned m_sessionID
Session ID we sent packet on, unused on rx RTCP.
Definition: rtp.h:86
unsigned GetVersion() const
Definition: rtp.h:598
bool AdjustHeaderSize(PINDEX newSize)
bool ParseReceiverReport(RTP_SyncSourceId &ssrc, const ReceiverReport *&rr, unsigned &count)
void AddApplDefined(const ApplDefinedInfo &info)
PUInt32b jitter
Definition: rtp.h:159
void AddNACK(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn, const LostPacketMask &lostPackets)
PTimeInterval delay
Definition: rtp.h:519
Definition: rtp.h:586
RTP_ReceiverReport(const RTP_ControlFrame::ReceiverReport &report, uint64_t ntpPassThru)
Definition: rtp.h:573
PayloadTypes GetPayloadType() const
Definition: rtp.h:613
Definition: rtp.h:550
void SetReceivedTime(const PTime &when)
Definition: rtp.h:743
unsigned m_subType
Definition: rtp.h:466
PUInt32b psent
Definition: rtp.h:181
Definition: rtp.h:263
Definition: rtp.h:580
void SetTimestamp(RTP_Timestamp t)
Definition: rtp.h:620
PUInt32b requestSSRC
Definition: rtp.h:359
Definition: rtp.h:376
Definition: rtp.h:55
Definition: rtp.h:332
MetaData m_metaData
Definition: rtp.h:775
RTP_SyncSourceId sourceIdentifier
Definition: rtp.h:513
POrdinalToString items
Definition: rtp.h:65
void SetContribSource(PINDEX idx, RTP_SyncSourceId src)
bool SetPacketSize(PINDEX sz)
Definition: rtp.h:336
PUInt32b ssrc
Definition: rtp.h:155
bool ParseTSTO(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceId &targetSSRC, unsigned &tradeOff, unsigned &sequenceNumber)
bool ParseApplDefined(ApplDefinedInfo &info)
PINDEX m_payloadSize
Definition: rtp.h:478
Definition: rtp.h:411
bool GetMarker() const
Definition: rtp.h:603
PArray< RTP_SourceDescription > RTP_SourceDescriptionArray
Definition: rtp.h:68
Definition: rtp.h:582
P_DEPRECATED void SetBundleId(const PString &id)
Definition: rtp.h:767
bool ParseSenderReport(RTP_SenderReport &txReport, const ReceiverReport *&rr, unsigned &count)
BYTE numSSRC
Definition: rtp.h:447
bool StartNewPacket(PayloadTypes pt)
RTP_ControlFrame(PINDEX compoundSize=2048)
Definition: rtp.h:330
RTP_SyncSourceId m_SSRC
SSRC we sent packet with, unused on rx RTCP.
Definition: rtp.h:87
bool SetPayloadSize(PINDEX sz)
PINDEX GetContribSrcCount() const
Definition: rtp.h:625
Definition: rtp.h:575
Definition: rtp.h:335
std::vector< RTP_SyncSourceId > RTP_SyncSourceArray
Definition: rtp.h:47
bool GetPadding() const
Definition: rtp.h:606
Definition: rtp.h:593
friend ostream & operator<<(ostream &strm, const LostPacketMask &mask)
static const unsigned MaxHeaderExtensionIdTwoByte
Definition: rtp.h:655
bool ParseFIR(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceId &targetSSRC, unsigned &sequenceNumber)
Definition: rtp.h:485
PTime m_lastTimestamp
Definition: rtp.h:533
PUInt16b length
Definition: rtp.h:202
Definition: rtp.h:565
Definition: rtp.h:571
unsigned GetVersion() const
Definition: rtp.h:115
RTP_DelayLastReceiverReport(const RTP_ControlFrame::DelayLastReceiverReport::Receiver &dlrr)
Definition: rtp.h:572
bool ParsePLI(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceId &targetSSRC)
void SetLipSyncId(const PString &id)
Definition: rtp.h:763
unsigned m_rtcpSequenceNumber
RTCP sequence number, note, lower 8 bits only are significant.
Definition: rtp.h:95
RTP_DataFrame(PINDEX payloadSize=0, PINDEX bufferSize=0)
PUInt32b mediaSSRC
Definition: rtp.h:319
Definition: rtp.h:574
void StartSourceDescription(RTP_SyncSourceId src)
Definition: rtp.h:569
void AddTWCC(RTP_SyncSourceId syncSourceOut, const RTP_TransportWideCongestionControl &info)
Definition: rtp.h:591
uint16_t RTP_SequenceNumber
Definition: rtp.h:45
RTP_SyncSourceId sourceIdentifier
Definition: rtp.h:64
PUInt32b rtp_ts
Definition: rtp.h:180
uint64_t ntpPassThrough
Definition: rtp.h:496
PINDEX GetExtensionSizeDWORDs() const
unsigned lastSequenceNumber
Definition: rtp.h:516
Definition: rtp.h:594
PayloadTypes
Definition: rtp.h:556
unsigned GetDiscontinuity() const
Definition: rtp.h:749
Definition: rtp.h:557
PINDEX m_compoundOffset
Definition: rtp.h:477
Definition: rtp.h:579
unsigned GetCount() const
Definition: rtp.h:117
RTP_SequenceNumber GetSequenceNumber() const
Definition: rtp.h:616
void SetSyncSource(RTP_SyncSourceId s)
Definition: rtp.h:623
bool SetHeaderExtension(unsigned id, PINDEX length, const BYTE *data, HeaderExtensionType type)
Definition: rtp.h:270
unsigned octetsSent
Definition: rtp.h:500
struct RTP_ControlFrame::SourceDescription::Item item[1]
bool ParseTWCC(RTP_SyncSourceId &senderSSRC, RTP_TransportWideCongestionControl &info)
PUInt32b lsr
Definition: rtp.h:160
void SetSequenceNumber(RTP_SequenceNumber n)
Definition: rtp.h:617
PUInt32b feedbackSSRC[1]
Definition: rtp.h:449
PayloadTypes
Definition: rtp.h:122
struct RTP_ControlFrame::DelayLastReceiverReport::Receiver m_receiver[1]
PUInt32b senderSSRC
Definition: rtp.h:318
unsigned jitter
Definition: rtp.h:517
Definition: rtp.h:577
BYTE bt
Definition: rtp.h:200
Definition: rtp.h:540
Definition: rtp.h:177
void SetAbsoluteTime(const PTime &t)
Definition: rtp.h:734
PINDEX GetPayloadSize() const
Definition: rtp.h:683
BYTE sequenceNumber
Definition: rtp.h:413
PTimeInterval m_delay
Definition: rtp.h:534
Definition: rtp.h:559
BYTE * GetHeaderExtension(unsigned &id, PINDEX &length, int idx=-1) const
Definition: rtp.h:558
Definition: rtp.h:648
PUInt32b dlsr
Definition: rtp.h:161
PUInt32b osent
Definition: rtp.h:182
bool ParseTMMB(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceId &targetSSRC, unsigned &maxBitRate, unsigned &overhead)
static const unsigned MaxHeaderExtensionIdOneByte
Definition: rtp.h:654
unsigned GetFbType() const
Definition: rtp.h:322
BYTE sequenceNumber
Definition: rtp.h:428
PUInt16b bitmask
Definition: rtp.h:339
ReceiverReport * AddReceiverReport(RTP_SyncSourceId ssrc, unsigned receivers)
BYTE * GetPayloadPtr() const
Definition: rtp.h:686
RTP_SyncSourceId GetContribSource(PINDEX idx) const
void SetTransmitTime(const PTime &when)
Definition: rtp.h:738
uint8_t referenceTime[3]
Definition: rtp.h:379
bool ParseGoodbye(RTP_SyncSourceId &ssrc, RTP_SyncSourceArray &csrc, PString &msg)
Definition: rtp.h:426
PUInt16b baseSN
Definition: rtp.h:377
Definition: rtp.h:504
Definition: rtp.h:576
void AddSourceDescription(RTP_SyncSourceId ssrc, const PString &cname, const PString &toolName, bool endPacket=true)
Definition: rtp.h:649
void AddTMMB(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn, unsigned maxBitRate, unsigned overhead, bool notify)
PUInt32b requestSSRC
Definition: rtp.h:412
PUInt32b bitRateAndOverhead
Definition: rtp.h:360
Definition: rtp.h:650
PINDEX GetPacketSize() const
Definition: rtp.h:148
Definition: rtp.h:567
RTP_SyncSourceId GetSenderSyncSource() const
Definition: rtp.h:120
PTime realTimestamp
Definition: rtp.h:497
PLIST(H323LogicalChannelList, H323Channel)
FbHeader * AddFeedback(PayloadTypes pt, unsigned type, PINDEX fciSize)
PTime m_receivedTime
Definition: rtp.h:714
bool ParseSourceDescriptions(RTP_SourceDescriptionArray &descriptions)
const PString & GetLipSyncId() const
Definition: rtp.h:758
RTP_SyncSourceId sourceIdentifier
Definition: rtp.h:495
PayloadTypes GetPayloadType() const
Definition: rtp.h:136
PINDEX GetHeaderSize() const
Definition: rtp.h:629
HeaderExtensionType
Extension header types.
Definition: rtp.h:647
BYTE reserver[2]
Definition: rtp.h:429
Definition: rtp.h:562
BYTE * GetPaddingPtr() const
Definition: rtp.h:608
ApplDefinedInfo(const char *type=NULL, unsigned subType=0, RTP_SyncSourceId ssrc=0, const BYTE *data=NULL, PINDEX size=0)
Definition: rtp.h:563
Definition: rtp.h:568
PINDEX GetPacketSize() const
DescriptionTypes
Definition: rtp.h:261
ostream & operator<<(ostream &strm, OpalSilenceDetector::Mode mode)
void AddIFR(RTP_SyncSourceId syncSourceIn)
char m_type[5]
Definition: rtp.h:465
bool SetPayload(const BYTE *data, PINDEX sz)
RTP_SourceDescription(RTP_SyncSourceId src)
Definition: rtp.h:59
void SetDiscontinuity(unsigned lost)
Definition: rtp.h:753
void SetExtension(bool ext)
void SetMetaData(const MetaData &metaData)
Definition: rtp.h:725
PBYTEArray m_data
Definition: rtp.h:468
PURL m_uri
Definition: rtp.h:806
bool ParseNACK(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceId &targetSSRC, LostPacketMask &lostPackets)
uint32_t RTP_Timestamp
Definition: rtp.h:44
void SetPayloadType(PayloadTypes pt)
BYTE * GetPayloadPtr() const
Definition: rtp.h:264
unsigned m_id
Definition: rtp.h:796
PString m_lipSyncId
Definition: rtp.h:716
void SetPadding(bool v)
Definition: rtp.h:607
Definition: rtp.h:583
unsigned packetsSent
Definition: rtp.h:499
Definition: rtp.h:560
unsigned m_discontinuity
Definition: rtp.h:715
Item * GetNextItem()
Definition: rtp.h:287
Definition: rtp.h:523
PUInt16b statusCount
Definition: rtp.h:378
void SetPayloadType(PayloadTypes t)
PacketMap m_packets
Info of each packet that was sent.
Definition: rtp.h:94
RTP_Timestamp GetTimestamp() const
Definition: rtp.h:619
void SetMarker(bool m)
bool SetExtensionSizeDWORDs(PINDEX sz)
Definition: rtp.h:317
Definition: rtp.h:128
P_DEPRECATED const PString & GetBundleId() const
Definition: rtp.h:766
void CopyHeader(const RTP_DataFrame &other)
void AddSourceDescriptionItem(unsigned type, const PString &data)
Definition: rtp.h:561
BYTE lost[3]
Definition: rtp.h:157
Definition: rtp.h:331
DelayLastReceiverReport::Receiver * AddDelayLastReceiverReport(RTP_SyncSourceId ssrc, unsigned receivers)
PTime m_transmitTime
Definition: rtp.h:711
const Item * GetNextItem() const
Definition: rtp.h:286
Definition: rtp.h:584
void SetAbsoluteTime()
Definition: rtp.h:733
Definition: rtp.h:129
bool ParseREMB(RTP_SyncSourceId &senderSSRC, RTP_SyncSourceArray &targetSSRCs, unsigned &maxBitRate)
Definition: rtp.h:267
unsigned fractionLost
Definition: rtp.h:514
PTime m_absoluteTime
Definition: rtp.h:708
Definition: rtp.h:101
RTP_Timestamp rtpTimestamp
Definition: rtp.h:498
bool IsValid() const
void SetCount(unsigned count)
PINDEX GetPayloadSize() const
Definition: rtp.h:139
uint8_t rtcpSN
Definition: rtp.h:380
PINDEX m_headerSize
Definition: rtp.h:772
RTP_SyncSourceId m_SSRC
Definition: rtp.h:467
uint32_t RTP_SyncSourceId
Definition: rtp.h:46
PTime lastTimestamp
Definition: rtp.h:518
const MetaData & GetMetaData() const
Definition: rtp.h:721
Definition: rtp.h:832
PINDEX m_packetSize
Definition: rtp.h:476
PINDEX m_paddingSize
Definition: rtp.h:774
Definition: rtp.h:551
PTimeInterval m_timestamp
Time relative to an arbitrary moment in time.
Definition: rtp.h:85
void SetTransmitTimeNTP(uint64_t ntp)
Definition: rtp.h:739
Direction
Definition: rtp.h:798
BYTE tradeOff
Definition: rtp.h:430
Definition: rtp.h:262
std::map< unsigned, Info > PacketMap
Definition: rtp.h:93
static const unsigned MaxHeaderExtensionId
Definition: rtp.h:653
PUInt32b src
Definition: rtp.h:275
Definition: rtp.h:704
ReceiverReport * AddSenderReport(RTP_SyncSourceId ssrc, const PTime &ntp, RTP_Timestamp ts, unsigned packets, uint64_t octets, unsigned receivers)
void AddREMB(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn, unsigned maxBitRate)
PUInt32b last_seq
Definition: rtp.h:158
Definition: rtp.h:266
PINDEX m_payloadSize
Definition: rtp.h:773
void AddTSTO(RTP_SyncSourceId syncSourceOut, RTP_SyncSourceId syncSourceIn, unsigned tradeOff, unsigned sequenceNumber)
void AddFeedback(PayloadTypes pt, unsigned type, FB *&data)
Definition: rtp.h:325
RTP_SyncSourceId GetSyncSource() const
Definition: rtp.h:622
Definition: rtp.h:268
PayloadSpecificFbTypes
Definition: rtp.h:391
PTime GetAbsoluteTime() const
Definition: rtp.h:729
Info(const PTimeInterval &ts=0, unsigned id=0, RTP_SyncSourceId ssrc=0)
Definition: rtp.h:79
Definition: rtp.h:445
Definition: rtp.h:564
bool GetExtension() const
Definition: rtp.h:600