<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>jrtplib: src/rtppacket.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="jrtplib.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_e5298977290e638844c8018a73ab0caf.html">src</a> </div> </div> <div class="contents"> <h1>rtppacket.h</h1><a href="rtppacket_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> This file is a part of JRTPLIB</span> <a name="l00004"></a>00004 <span class="comment"> Copyright (c) 1999-2007 Jori Liesenborgs</span> <a name="l00005"></a>00005 <span class="comment"></span> <a name="l00006"></a>00006 <span class="comment"> Contact: jori.liesenborgs@gmail.com</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> This library was developed at the "Expertisecentrum Digitale Media"</span> <a name="l00009"></a>00009 <span class="comment"> (http://www.edm.uhasselt.be), a research center of the Hasselt University</span> <a name="l00010"></a>00010 <span class="comment"> (http://www.uhasselt.be). The library is based upon work done for </span> <a name="l00011"></a>00011 <span class="comment"> my thesis at the School for Knowledge Technology (Belgium/The Netherlands).</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> Permission is hereby granted, free of charge, to any person obtaining a</span> <a name="l00014"></a>00014 <span class="comment"> copy of this software and associated documentation files (the "Software"),</span> <a name="l00015"></a>00015 <span class="comment"> to deal in the Software without restriction, including without limitation</span> <a name="l00016"></a>00016 <span class="comment"> the rights to use, copy, modify, merge, publish, distribute, sublicense,</span> <a name="l00017"></a>00017 <span class="comment"> and/or sell copies of the Software, and to permit persons to whom the</span> <a name="l00018"></a>00018 <span class="comment"> Software is furnished to do so, subject to the following conditions:</span> <a name="l00019"></a>00019 <span class="comment"></span> <a name="l00020"></a>00020 <span class="comment"> The above copyright notice and this permission notice shall be included</span> <a name="l00021"></a>00021 <span class="comment"> in all copies or substantial portions of the Software.</span> <a name="l00022"></a>00022 <span class="comment"></span> <a name="l00023"></a>00023 <span class="comment"> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</span> <a name="l00024"></a>00024 <span class="comment"> OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span> <a name="l00025"></a>00025 <span class="comment"> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span> <a name="l00026"></a>00026 <span class="comment"> THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span> <a name="l00027"></a>00027 <span class="comment"> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span> <a name="l00028"></a>00028 <span class="comment"> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS</span> <a name="l00029"></a>00029 <span class="comment"> IN THE SOFTWARE.</span> <a name="l00030"></a>00030 <span class="comment"></span> <a name="l00031"></a>00031 <span class="comment">*/</span> <a name="l00032"></a>00032 <a name="l00037"></a>00037 <span class="preprocessor">#ifndef RTPPACKET_H</span> <a name="l00038"></a>00038 <span class="preprocessor"></span> <a name="l00039"></a>00039 <span class="preprocessor">#define RTPPACKET_H</span> <a name="l00040"></a>00040 <span class="preprocessor"></span> <a name="l00041"></a>00041 <span class="preprocessor">#include "rtpconfig.h"</span> <a name="l00042"></a>00042 <span class="preprocessor">#include "rtptypes.h"</span> <a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="rtptimeutilities_8h.html">rtptimeutilities.h</a>"</span> <a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="rtpmemoryobject_8h.html">rtpmemoryobject.h</a>"</span> <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">class </span><a class="code" href="classRTPRawPacket.html" title="This class is used by the transmission component to store the incoming RTP and RTCP...">RTPRawPacket</a>; <a name="l00047"></a>00047 <a name="l00053"></a><a class="code" href="classRTPPacket.html">00053</a> <span class="keyword">class </span><a class="code" href="classRTPPacket.html" title="Represents an RTP Packet.">RTPPacket</a> : <span class="keyword">public</span> RTPMemoryObject <a name="l00054"></a>00054 { <a name="l00055"></a>00055 <span class="keyword">public</span>: <a name="l00060"></a>00060 <a class="code" href="classRTPPacket.html#79759362371c15162f36570efa0f4a58" title="Creates an RTPPacket instance based upon the data in rawpack, optionally installing...">RTPPacket</a>(<a class="code" href="classRTPRawPacket.html" title="This class is used by the transmission component to store the incoming RTP and RTCP...">RTPRawPacket</a> &rawpack,<a class="code" href="classRTPMemoryManager.html" title="A memory manager.">RTPMemoryManager</a> *mgr = 0); <a name="l00061"></a>00061 <a name="l00068"></a>00068 <a class="code" href="classRTPPacket.html#79759362371c15162f36570efa0f4a58" title="Creates an RTPPacket instance based upon the data in rawpack, optionally installing...">RTPPacket</a>(uint8_t payloadtype,<span class="keyword">const</span> <span class="keywordtype">void</span> *payloaddata,<span class="keywordtype">size_t</span> payloadlen,uint16_t seqnr, <a name="l00069"></a>00069 uint32_t timestamp,uint32_t ssrc,<span class="keywordtype">bool</span> gotmarker,uint8_t numcsrcs,<span class="keyword">const</span> uint32_t *csrcs, <a name="l00070"></a>00070 <span class="keywordtype">bool</span> gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,<span class="keyword">const</span> <span class="keywordtype">void</span> *extensiondata, <a name="l00071"></a>00071 <span class="keywordtype">size_t</span> maxpacksize, <a class="code" href="classRTPMemoryManager.html" title="A memory manager.">RTPMemoryManager</a> *mgr = 0); <a name="l00072"></a>00072 <a name="l00075"></a>00075 <a class="code" href="classRTPPacket.html#79759362371c15162f36570efa0f4a58" title="Creates an RTPPacket instance based upon the data in rawpack, optionally installing...">RTPPacket</a>(uint8_t payloadtype,<span class="keyword">const</span> <span class="keywordtype">void</span> *payloaddata,<span class="keywordtype">size_t</span> payloadlen,uint16_t seqnr, <a name="l00076"></a>00076 uint32_t timestamp,uint32_t ssrc,<span class="keywordtype">bool</span> gotmarker,uint8_t numcsrcs,<span class="keyword">const</span> uint32_t *csrcs, <a name="l00077"></a>00077 <span class="keywordtype">bool</span> gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,<span class="keyword">const</span> <span class="keywordtype">void</span> *extensiondata, <a name="l00078"></a>00078 <span class="keywordtype">void</span> *buffer,<span class="keywordtype">size_t</span> buffersize,<a class="code" href="classRTPMemoryManager.html" title="A memory manager.">RTPMemoryManager</a> *mgr = 0); <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keyword">virtual</span> ~<a class="code" href="classRTPPacket.html" title="Represents an RTP Packet.">RTPPacket</a>() { <span class="keywordflow">if</span> (packet && !externalbuffer) RTPDeleteByteArray(packet,GetMemoryManager()); } <a name="l00081"></a>00081 <a name="l00083"></a><a class="code" href="classRTPPacket.html#59e541667649b2050c4428a12ac0b9d4">00083</a> <span class="keywordtype">int</span> <a class="code" href="classRTPPacket.html#59e541667649b2050c4428a12ac0b9d4" title="If an error occurred in one of the constructors, this function returns the error...">GetCreationError</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> error; } <a name="l00084"></a>00084 <a name="l00086"></a><a class="code" href="classRTPPacket.html#bdd43bd2efa6fae6279d0b8ccd375214">00086</a> <span class="keywordtype">bool</span> <a class="code" href="classRTPPacket.html#bdd43bd2efa6fae6279d0b8ccd375214" title="Returns true if the RTP packet has a header extension and false otherwise.">HasExtension</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> hasextension; } <a name="l00087"></a>00087 <a name="l00089"></a><a class="code" href="classRTPPacket.html#bdf85f21bbab74bec398902bff9e7d4b">00089</a> <span class="keywordtype">bool</span> <a class="code" href="classRTPPacket.html#bdf85f21bbab74bec398902bff9e7d4b" title="Returns true if the marker bit was set and false otherwise.">HasMarker</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> hasmarker; } <a name="l00090"></a>00090 <a name="l00092"></a><a class="code" href="classRTPPacket.html#f3719c75e9cf5cca89e3cfe6d4ca2180">00092</a> <span class="keywordtype">int</span> <a class="code" href="classRTPPacket.html#f3719c75e9cf5cca89e3cfe6d4ca2180" title="Returns the number of CSRCs contained in this packet.">GetCSRCCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> numcsrcs; } <a name="l00093"></a>00093 <a name="l00097"></a>00097 uint32_t <a class="code" href="classRTPPacket.html#18135bc439a52c337bd22a3bf05961ab" title="Returns a specific CSRC identifier.">GetCSRC</a>(<span class="keywordtype">int</span> num) <span class="keyword">const</span>; <a name="l00098"></a>00098 <a name="l00100"></a><a class="code" href="classRTPPacket.html#35bdf9419d3c9c3706a395f06040ad00">00100</a> uint8_t <a class="code" href="classRTPPacket.html#35bdf9419d3c9c3706a395f06040ad00" title="Returns the payload type of the packet.">GetPayloadType</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> payloadtype; } <a name="l00101"></a>00101 <a name="l00106"></a><a class="code" href="classRTPPacket.html#8d687e10420f7afccb147ea6a637b2bd">00106</a> uint32_t <a class="code" href="classRTPPacket.html#8d687e10420f7afccb147ea6a637b2bd" title="Returns the extended sequence number of the packet.">GetExtendedSequenceNumber</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> extseqnr; } <a name="l00107"></a>00107 <a name="l00109"></a><a class="code" href="classRTPPacket.html#0208504b4248c628652337f653f52717">00109</a> uint16_t <a class="code" href="classRTPPacket.html#0208504b4248c628652337f653f52717" title="Returns the sequence number of this packet.">GetSequenceNumber</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (uint16_t)(extseqnr&0x0000FFFF); } <a name="l00110"></a>00110 <a name="l00112"></a><a class="code" href="classRTPPacket.html#35813fff234b23a76a74cc7fb1b95480">00112</a> <span class="keywordtype">void</span> <a class="code" href="classRTPPacket.html#35813fff234b23a76a74cc7fb1b95480" title="Sets the extended sequence number of this packet to seq.">SetExtendedSequenceNumber</a>(uint32_t seq) { extseqnr = seq; } <a name="l00113"></a>00113 <a name="l00115"></a><a class="code" href="classRTPPacket.html#527b5b6f30ea8acd974be8c448bb1568">00115</a> uint32_t <a class="code" href="classRTPPacket.html#527b5b6f30ea8acd974be8c448bb1568" title="Returns the timestamp of this packet.">GetTimestamp</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> timestamp; } <a name="l00116"></a>00116 <a name="l00118"></a><a class="code" href="classRTPPacket.html#8bfb5c302310485fed36bfab0b0ac6d8">00118</a> uint32_t <a class="code" href="classRTPPacket.html#8bfb5c302310485fed36bfab0b0ac6d8" title="Returns the SSRC identifier stored in this packet.">GetSSRC</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ssrc; } <a name="l00119"></a>00119 <a name="l00121"></a><a class="code" href="classRTPPacket.html#9b0260e99d33c6dca70bc84843237f78">00121</a> uint8_t *<a class="code" href="classRTPPacket.html#9b0260e99d33c6dca70bc84843237f78" title="Returns a pointer to the data of the entire packet.">GetPacketData</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> packet; } <a name="l00122"></a>00122 <a name="l00124"></a><a class="code" href="classRTPPacket.html#0c2a6fe213eb3c604b10bda4c6784ae7">00124</a> uint8_t *<a class="code" href="classRTPPacket.html#0c2a6fe213eb3c604b10bda4c6784ae7" title="Returns a pointer to the actual payload data.">GetPayloadData</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> payload; } <a name="l00125"></a>00125 <a name="l00127"></a><a class="code" href="classRTPPacket.html#b5f6afc0b37f1cf24e9afe5c9fc4d3fc">00127</a> <span class="keywordtype">size_t</span> <a class="code" href="classRTPPacket.html#b5f6afc0b37f1cf24e9afe5c9fc4d3fc" title="Returns the length of the entire packet.">GetPacketLength</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> packetlength; } <a name="l00128"></a>00128 <a name="l00130"></a><a class="code" href="classRTPPacket.html#b49ef125ac5a7d6171699b2b4c473a7f">00130</a> <span class="keywordtype">size_t</span> <a class="code" href="classRTPPacket.html#b49ef125ac5a7d6171699b2b4c473a7f" title="Returns the payload length.">GetPayloadLength</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> payloadlength; } <a name="l00131"></a>00131 <a name="l00133"></a><a class="code" href="classRTPPacket.html#b639dfac83f0aa153a51937db34c52c1">00133</a> uint16_t <a class="code" href="classRTPPacket.html#b639dfac83f0aa153a51937db34c52c1" title="If a header extension is present, this function returns the extension identifier...">GetExtensionID</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> extid; } <a name="l00134"></a>00134 <a name="l00136"></a><a class="code" href="classRTPPacket.html#d9d6a4fb42b963551e5aac0f3e74b482">00136</a> uint8_t *<a class="code" href="classRTPPacket.html#d9d6a4fb42b963551e5aac0f3e74b482" title="Returns the length of the header extension data.">GetExtensionData</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> extension; } <a name="l00137"></a>00137 <a name="l00139"></a><a class="code" href="classRTPPacket.html#a55466f5874dce652951c142c809c54d">00139</a> <span class="keywordtype">size_t</span> <a class="code" href="classRTPPacket.html#a55466f5874dce652951c142c809c54d" title="Returns the length of the header extension data.">GetExtensionLength</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> extensionlength; } <a name="l00140"></a>00140 <span class="preprocessor">#ifdef RTPDEBUG</span> <a name="l00141"></a>00141 <span class="preprocessor"></span> <span class="keywordtype">void</span> Dump(); <a name="l00142"></a>00142 <span class="preprocessor">#endif // RTPDEBUG</span> <a name="l00143"></a>00143 <span class="preprocessor"></span> <a name="l00149"></a><a class="code" href="classRTPPacket.html#3cd278959cc46a1c236b9c7739830fa5">00149</a> <a class="code" href="classRTPTime.html" title="This class is used to specify wallclock time, delay intervals etc.">RTPTime</a> <a class="code" href="classRTPPacket.html#3cd278959cc46a1c236b9c7739830fa5" title="Returns the time at which this packet was received.">GetReceiveTime</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> receivetime; } <a name="l00150"></a>00150 <span class="keyword">private</span>: <a name="l00151"></a>00151 <span class="keywordtype">void</span> Clear(); <a name="l00152"></a>00152 <span class="keywordtype">int</span> ParseRawPacket(<a class="code" href="classRTPRawPacket.html" title="This class is used by the transmission component to store the incoming RTP and RTCP...">RTPRawPacket</a> &rawpack); <a name="l00153"></a>00153 <span class="keywordtype">int</span> BuildPacket(uint8_t payloadtype,<span class="keyword">const</span> <span class="keywordtype">void</span> *payloaddata,<span class="keywordtype">size_t</span> payloadlen,uint16_t seqnr, <a name="l00154"></a>00154 uint32_t timestamp,uint32_t ssrc,<span class="keywordtype">bool</span> gotmarker,uint8_t numcsrcs,<span class="keyword">const</span> uint32_t *csrcs, <a name="l00155"></a>00155 <span class="keywordtype">bool</span> gotextension,uint16_t extensionid,uint16_t extensionlen_numwords,<span class="keyword">const</span> <span class="keywordtype">void</span> *extensiondata, <a name="l00156"></a>00156 <span class="keywordtype">void</span> *buffer,<span class="keywordtype">size_t</span> maxsize); <a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="keywordtype">int</span> error; <a name="l00159"></a>00159 <a name="l00160"></a>00160 <span class="keywordtype">bool</span> hasextension,hasmarker; <a name="l00161"></a>00161 <span class="keywordtype">int</span> numcsrcs; <a name="l00162"></a>00162 <a name="l00163"></a>00163 uint8_t payloadtype; <a name="l00164"></a>00164 uint32_t extseqnr,timestamp,ssrc; <a name="l00165"></a>00165 uint8_t *packet,*payload; <a name="l00166"></a>00166 <span class="keywordtype">size_t</span> packetlength,payloadlength; <a name="l00167"></a>00167 <a name="l00168"></a>00168 uint16_t extid; <a name="l00169"></a>00169 uint8_t *extension; <a name="l00170"></a>00170 <span class="keywordtype">size_t</span> extensionlength; <a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="keywordtype">bool</span> externalbuffer; <a name="l00173"></a>00173 <a name="l00174"></a>00174 <a class="code" href="classRTPTime.html" title="This class is used to specify wallclock time, delay intervals etc.">RTPTime</a> receivetime; <a name="l00175"></a>00175 }; <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="preprocessor">#endif // RTPPACKET_H</span> <a name="l00178"></a>00178 <span class="preprocessor"></span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 09:42:07 2009 for jrtplib by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>