RTP Audio System
2.0.0
|
00001 // ########################################################################## 00002 // #### #### 00003 // #### RTP Audio Server Project #### 00004 // #### ============================ #### 00005 // #### #### 00006 // #### RTP Packet #### 00007 // #### #### 00008 // #### Copyright (C) 1999-2012 by Thomas Dreibholz #### 00009 // #### #### 00010 // #### Contact: #### 00011 // #### EMail: dreibh@iem.uni-due.de #### 00012 // #### WWW: https://www.nntb.no/~dreibh/rtpaudio #### 00013 // #### #### 00014 // #### ---------------------------------------------------------------- #### 00015 // #### #### 00016 // #### This program is free software: you can redistribute it and/or #### 00017 // #### modify it under the terms of the GNU General Public License as #### 00018 // #### published by the Free Software Foundation, either version 3 of #### 00019 // #### the License, or (at your option) any later version. #### 00020 // #### #### 00021 // #### This program is distributed in the hope that it will be useful, #### 00022 // #### but WITHOUT ANY WARRANTY; without even the implied warranty of #### 00023 // #### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #### 00024 // #### GNU General Public License for more details. #### 00025 // #### #### 00026 // #### You should have received a copy of the GNU General Public #### 00027 // #### License along with this program. If not, see #### 00028 // #### <http://www.gnu.org/licenses/>. #### 00029 // #### #### 00030 // ########################################################################## 00031 // $Id: rtppacket.h 1314 2011-12-23 11:07:45Z dreibh $ 00032 00033 00034 #ifndef RTPPACKET_H 00035 #define RTPPACKET_H 00036 00037 00038 #include "tdsystem.h" 00039 #include "tdsocket.h" 00040 00041 00042 namespace RTPConstants { 00043 00044 00049 const cardinal RTPMaxPayloadLimit = 8192; 00050 00056 const cardinal RTPDefaultMaxPayload = 1376; 00057 00061 const cardinal RTPDefaultHeaderSize = 12; 00062 00066 const card8 RTPVersion = 2; 00067 00071 const double RTPMicroSecondsPerTimeStamp = 1000.0 / 16.0; 00072 00073 00074 #ifdef USE_TRANSPORTINFO 00075 00081 const cardinal RTPMaxQualityLayers = 4; 00082 00083 #else 00084 00090 const cardinal RTPMaxQualityLayers = 16; 00091 00092 #endif 00093 00094 00095 } 00096 00097 00108 struct RTPPacket 00109 { 00110 // ====== Constructor ==================================================== 00111 public: 00115 RTPPacket(); 00116 00117 00118 // ====== Get methods ==================================================== 00124 inline card8 getVersion() const; 00125 00131 inline card8 getPadding() const; 00132 00138 inline card8 getExtension() const; 00139 00145 inline card8 getCSRCCount() const; 00146 00152 inline bool getMarker() const; 00153 00159 inline card8 getPayloadType() const; 00160 00166 inline card16 getSequenceNumber() const; 00167 00173 inline card32 getTimeStamp() const; 00174 00180 inline card32 getSSRC() const; 00181 00188 inline card32 getCSRC(cardinal index) const; 00189 00190 00196 inline cardinal calculateHeaderSize() const; 00197 00203 inline char* getPayloadData() const; 00204 00210 inline cardinal getMaxPayloadSize() const; 00211 00212 00213 // ====== Set methods ==================================================== 00219 inline void setVersion(const card8 version); 00220 00226 inline void setPadding(const card8 padding); 00227 00233 inline void setExtension(const card8 extension); 00234 00240 inline void setCSRCCount(const card8 count); 00241 00247 inline void setMarker(const bool marker); 00248 00254 inline void setPayloadType(const card8 payloadType); 00255 00261 inline void setSequenceNumber(const card16 sequenceNumber); 00262 00268 inline void setTimeStamp(const card32 timeStamp); 00269 00275 inline void setSSRC(const card32 ssrc); 00276 00283 inline void setCSRC(const cardinal index, const card32 csrc); 00284 00285 00289 friend std::ostream& operator<<(std::ostream& os, const RTPPacket& packet); 00290 00291 00292 // ====== Private data =================================================== 00293 private: 00294 #if BYTE_ORDER == BIG_ENDIAN 00295 card8 V:2; // Version 00296 card8 P:1; // Padding 00297 card8 X:1; // Extension 00298 card8 CC:4; // CSRC Count 00299 card8 M:1; // Marker 00300 card8 PT:7; // Payload Type 00301 #elif BYTE_ORDER == LITTLE_ENDIAN 00302 card8 CC:4; // CSRC Count 00303 card8 X:1; // Extension 00304 card8 P:1; // Padding 00305 card8 V:2; // Version 00306 card8 PT:7; // Payload Type 00307 card8 M:1; // Marker 00308 #else 00309 #error "Unknown BYTE_ORDER setting!" 00310 #endif 00311 card16 SequenceNumber; // Sequence number 00312 card32 TimeStamp; // TimeStamp 00313 card32 SSRC; // Synchronization Source (SSRC) identifier 00314 card32 CSRC[16]; // Contributing Source (CSRC) identifiers 00315 char Data[RTPConstants::RTPMaxPayloadLimit]; // Payload data 00316 } __attribute__((packed)); 00317 00318 00319 #include "rtppacket.icc" 00320 00321 00322 #endif