<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ccRTP: rtp.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.4 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <a class="qindex" href="examples.html">Examples</a></div> <div class="nav"> <a class="el" href="dir_000000.html">src</a> » <a class="el" href="dir_000001.html">ccrtp</a></div> <h1>rtp.h</h1><a href="rtp_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 1999-2005 Open Source Telecom Corporation.</span> <a name="l00002"></a>00002 <span class="comment">// </span> <a name="l00003"></a>00003 <span class="comment">// This program is free software; you can redistribute it and/or modify</span> <a name="l00004"></a>00004 <span class="comment">// it under the terms of the GNU General Public License as published by</span> <a name="l00005"></a>00005 <span class="comment">// the Free Software Foundation; either version 2 of the License, or</span> <a name="l00006"></a>00006 <span class="comment">// (at your option) any later version.</span> <a name="l00007"></a>00007 <span class="comment">// </span> <a name="l00008"></a>00008 <span class="comment">// This program is distributed in the hope that it will be useful,</span> <a name="l00009"></a>00009 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00010"></a>00010 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00011"></a>00011 <span class="comment">// GNU General Public License for more details.</span> <a name="l00012"></a>00012 <span class="comment">// </span> <a name="l00013"></a>00013 <span class="comment">// You should have received a copy of the GNU General Public License</span> <a name="l00014"></a>00014 <span class="comment">// along with this program; if not, write to the Free Software </span> <a name="l00015"></a>00015 <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span> <a name="l00016"></a>00016 <span class="comment">// </span> <a name="l00017"></a>00017 <span class="comment">// As a special exception, you may use this file as part of a free software</span> <a name="l00018"></a>00018 <span class="comment">// library without restriction. Specifically, if other files instantiate</span> <a name="l00019"></a>00019 <span class="comment">// templates or use macros or inline functions from this file, or you compile</span> <a name="l00020"></a>00020 <span class="comment">// this file and link it with other files to produce an executable, this</span> <a name="l00021"></a>00021 <span class="comment">// file does not by itself cause the resulting executable to be covered by</span> <a name="l00022"></a>00022 <span class="comment">// the GNU General Public License. This exception does not however </span> <a name="l00023"></a>00023 <span class="comment">// invalidate any other reasons why the executable file might be covered by</span> <a name="l00024"></a>00024 <span class="comment">// the GNU General Public License. </span> <a name="l00025"></a>00025 <span class="comment">//</span> <a name="l00026"></a>00026 <span class="comment">// This exception applies only to the code released under the name GNU</span> <a name="l00027"></a>00027 <span class="comment">// ccRTP. If you copy code from other releases into a copy of GNU</span> <a name="l00028"></a>00028 <span class="comment">// ccRTP, as the General Public License permits, the exception does</span> <a name="l00029"></a>00029 <span class="comment">// not apply to the code that you add in this way. To avoid misleading</span> <a name="l00030"></a>00030 <span class="comment">// anyone as to the status of such modified files, you must delete</span> <a name="l00031"></a>00031 <span class="comment">// this exception notice from them.</span> <a name="l00032"></a>00032 <span class="comment">//</span> <a name="l00033"></a>00033 <span class="comment">// If you write modifications of your own for GNU ccRTP, it is your choice</span> <a name="l00034"></a>00034 <span class="comment">// whether to permit this exception to apply to your modifications.</span> <a name="l00035"></a>00035 <span class="comment">// If you do not wish that, delete this exception notice.</span> <a name="l00036"></a>00036 <span class="comment">//</span> <a name="l00037"></a>00037 <a name="l00049"></a>00049 <span class="preprocessor">#ifndef CCXX_RTP_RTP_H_</span> <a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#define CCXX_RTP_RTP_H_</span> <a name="l00051"></a>00051 <span class="preprocessor"></span> <a name="l00052"></a>00052 <span class="preprocessor">#include <<a class="code" href="cqueue_8h.html">ccrtp/cqueue.h</a>></span> <a name="l00053"></a>00053 <span class="preprocessor">#include <<a class="code" href="channel_8h.html">ccrtp/channel.h</a>></span> <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="preprocessor">#ifdef CCXX_NAMESPACES</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><span class="keyword">namespace </span>ost { <a name="l00057"></a>00057 <span class="preprocessor">#endif</span> <a name="l00058"></a>00058 <span class="preprocessor"></span> <a name="l00085"></a>00085 <span class="keyword">template</span> <<span class="keyword">class </span>RTPDataChannel = <a class="code" href="class_dual_r_t_p_channel.html">DualRTPUDPIPv4Channel</a>, <a name="l00086"></a>00086 <span class="keyword">class </span>RTCPChannel = <a class="code" href="class_dual_r_t_p_channel.html">DualRTPUDPIPv4Channel</a>, <a name="l00087"></a>00087 <span class="keyword">class </span>ServiceQueue = <a class="code" href="class_a_v_p_queue.html">AVPQueue</a>> <a name="l00088"></a><a class="code" href="class_t_r_t_p_session_base.html">00088</a> <span class="keyword">class </span>__EXPORT TRTPSessionBase : <span class="keyword">public</span> ServiceQueue <a name="l00089"></a>00089 { <a name="l00090"></a>00090 <span class="keyword">public</span>: <a name="l00100"></a><a class="code" href="class_t_r_t_p_session_base.html#a0">00100</a> TRTPSessionBase(<span class="keyword">const</span> InetHostAddress& ia, tpport_t dataPort, <a name="l00101"></a>00101 tpport_t controlPort, uint32 membersSize, <a name="l00102"></a>00102 <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app) : <a name="l00103"></a>00103 ServiceQueue(membersSize,app) <a name="l00104"></a>00104 { build(ia,dataPort,controlPort); } <a name="l00105"></a>00105 <a name="l00117"></a><a class="code" href="class_t_r_t_p_session_base.html#a1">00117</a> TRTPSessionBase(uint32 ssrc, <a name="l00118"></a>00118 <span class="keyword">const</span> InetHostAddress& ia, <a name="l00119"></a>00119 tpport_t dataPort, tpport_t controlPort, <a name="l00120"></a>00120 uint32 membersSize, <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app): <a name="l00121"></a>00121 ServiceQueue(ssrc,membersSize,app) <a name="l00122"></a>00122 { build(ia,dataPort,controlPort); } <a name="l00123"></a>00123 <a name="l00136"></a><a class="code" href="class_t_r_t_p_session_base.html#a2">00136</a> TRTPSessionBase(<span class="keyword">const</span> InetMcastAddress& ia, tpport_t dataPort, <a name="l00137"></a>00137 tpport_t controlPort, uint32 membersSize, <a name="l00138"></a>00138 <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app, uint32 iface) : <a name="l00139"></a>00139 ServiceQueue(membersSize,app) <a name="l00140"></a>00140 { build(ia,dataPort,controlPort,iface); } <a name="l00141"></a>00141 <a name="l00156"></a><a class="code" href="class_t_r_t_p_session_base.html#a3">00156</a> TRTPSessionBase(uint32 ssrc, <a name="l00157"></a>00157 <span class="keyword">const</span> InetMcastAddress& ia, tpport_t dataPort, <a name="l00158"></a>00158 tpport_t controlPort, uint32 membersSize, <a name="l00159"></a>00159 <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app, uint32 iface) : <a name="l00160"></a>00160 ServiceQueue(ssrc,membersSize,app) <a name="l00161"></a>00161 { build(ia,dataPort,controlPort,iface); } <a name="l00162"></a>00162 <a name="l00163"></a><a class="code" href="class_t_r_t_p_session_base.html#a4">00163</a> <span class="keyword">virtual</span> size_t dispatchBYE(<span class="keyword">const</span> std::string &str) <a name="l00164"></a>00164 { <a name="l00165"></a>00165 <span class="keywordflow">return</span> <a class="code" href="class_queue_r_t_c_p_manager.html#b19">QueueRTCPManager::dispatchBYE</a>(str); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="keyword">inline</span> <span class="keyword">virtual</span> <a name="l00169"></a><a class="code" href="class_t_r_t_p_session_base.html#a5">00169</a> ~TRTPSessionBase() <a name="l00170"></a>00170 { <a name="l00171"></a>00171 dispatchBYE(<span class="stringliteral">"RTP session being destroyed, GNU ccRTP stack finishing."</span>); <a name="l00172"></a>00172 endSocket(); <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a><a class="code" href="class_t_r_t_p_session_base.html#a6">00175</a> <span class="keyword">inline</span> RTPDataChannel *getDSO(<span class="keywordtype">void</span>) <a name="l00176"></a>00176 {<span class="keywordflow">return</span> dso;}; <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="keyword">protected</span>: <a name="l00182"></a>00182 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00183"></a><a class="code" href="class_t_r_t_p_session_base.html#b0">00183</a> isPendingData(<a class="code" href="base_8h.html#a2">microtimeout_t</a> timeout) <a name="l00184"></a>00184 { <span class="keywordflow">return</span> dso->isPendingRecv(timeout); } <a name="l00185"></a>00185 <a name="l00186"></a>00186 InetHostAddress <a name="l00187"></a><a class="code" href="class_t_r_t_p_session_base.html#b1">00187</a> getDataSender(tpport_t *port = NULL)<span class="keyword"> const</span> <a name="l00188"></a>00188 <span class="keyword"> </span>{ <span class="keywordflow">return</span> dso->getSender(port); } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keyword">inline</span> size_t <a name="l00191"></a><a class="code" href="class_t_r_t_p_session_base.html#b2">00191</a> getNextDataPacketSize()<span class="keyword"> const</span> <a name="l00192"></a>00192 <span class="keyword"> </span>{ <span class="keywordflow">return</span> dso->getNextPacketSize(); } <a name="l00193"></a>00193 <a name="l00203"></a>00203 <span class="keyword">inline</span> size_t <a name="l00204"></a><a class="code" href="class_t_r_t_p_session_base.html#b3">00204</a> recvData(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* buffer, size_t len, <a name="l00205"></a>00205 InetHostAddress& na, tpport_t& tp) <a name="l00206"></a>00206 { na = dso->getSender(tp); <span class="keywordflow">return</span> dso->recv(buffer, len); } <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a name="l00209"></a><a class="code" href="class_t_r_t_p_session_base.html#b4">00209</a> setDataPeer(<span class="keyword">const</span> InetAddress &host, tpport_t port) <a name="l00210"></a>00210 { dso->setPeer(host,port); } <a name="l00211"></a>00211 <a name="l00216"></a>00216 <span class="keyword">inline</span> size_t <a name="l00217"></a><a class="code" href="class_t_r_t_p_session_base.html#b5">00217</a> sendData(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> buffer, size_t len) <a name="l00218"></a>00218 { <span class="keywordflow">return</span> dso->send(buffer, len); } <a name="l00219"></a>00219 <a name="l00220"></a><a class="code" href="class_t_r_t_p_session_base.html#b6">00220</a> <span class="keyword">inline</span> SOCKET getDataRecvSocket()<span class="keyword"> const</span> <a name="l00221"></a>00221 <span class="keyword"> </span>{ <span class="keywordflow">return</span> dso->getRecvSocket(); } <a name="l00222"></a>00222 <a name="l00227"></a>00227 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a name="l00228"></a><a class="code" href="class_t_r_t_p_session_base.html#b7">00228</a> isPendingControl(<a class="code" href="base_8h.html#a2">microtimeout_t</a> timeout) <a name="l00229"></a>00229 { <span class="keywordflow">return</span> cso->isPendingRecv(timeout); } <a name="l00230"></a>00230 <a name="l00231"></a>00231 InetHostAddress <a name="l00232"></a><a class="code" href="class_t_r_t_p_session_base.html#b8">00232</a> getControlSender(tpport_t *port = NULL)<span class="keyword"> const</span> <a name="l00233"></a>00233 <span class="keyword"> </span>{ <span class="keywordflow">return</span> cso->getSender(port); } <a name="l00234"></a>00234 <a name="l00244"></a>00244 <span class="keyword">inline</span> size_t <a name="l00245"></a><a class="code" href="class_t_r_t_p_session_base.html#b9">00245</a> recvControl(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buffer, size_t len, <a name="l00246"></a>00246 InetHostAddress& na, tpport_t& tp) <a name="l00247"></a>00247 { na = cso->getSender(tp); <span class="keywordflow">return</span> cso->recv(buffer,len); } <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a name="l00250"></a><a class="code" href="class_t_r_t_p_session_base.html#b10">00250</a> setControlPeer(<span class="keyword">const</span> InetAddress &host, tpport_t port) <a name="l00251"></a>00251 { cso->setPeer(host,port); } <a name="l00252"></a>00252 <a name="l00258"></a>00258 <span class="keyword">inline</span> size_t <a name="l00259"></a><a class="code" href="class_t_r_t_p_session_base.html#b11">00259</a> sendControl(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* <span class="keyword">const</span> buffer, size_t len) <a name="l00260"></a>00260 { <span class="keywordflow">return</span> cso->send(buffer,len); } <a name="l00261"></a>00261 <a name="l00262"></a><a class="code" href="class_t_r_t_p_session_base.html#b12">00262</a> <span class="keyword">inline</span> SOCKET getControlRecvSocket()<span class="keyword"> const</span> <a name="l00263"></a>00263 <span class="keyword"> </span>{ <span class="keywordflow">return</span> cso->getRecvSocket(); } <a name="l00264"></a>00264 <a name="l00265"></a>00265 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a name="l00266"></a><a class="code" href="class_t_r_t_p_session_base.html#b13">00266</a> endSocket() <a name="l00267"></a>00267 { <a name="l00268"></a>00268 dso->endSocket(); <a name="l00269"></a>00269 cso->endSocket(); <a name="l00270"></a>00270 <span class="keywordflow">if</span> (dso) <span class="keyword">delete</span> dso; <a name="l00271"></a>00271 dso = NULL; <a name="l00272"></a>00272 <span class="keywordflow">if</span> (cso) <span class="keyword">delete</span> cso; <a name="l00273"></a>00273 cso = NULL; <a name="l00274"></a>00274 } <a name="l00275"></a>00275 <a name="l00276"></a>00276 <span class="keyword">private</span>: <a name="l00277"></a>00277 <span class="keywordtype">void</span> <a name="l00278"></a>00278 build(<span class="keyword">const</span> InetHostAddress& ia, tpport_t dataPort, <a name="l00279"></a>00279 tpport_t controlPort) <a name="l00280"></a>00280 { <a name="l00281"></a>00281 <span class="keywordflow">if</span> ( 0 == controlPort ) { <a name="l00282"></a>00282 dataBasePort = even_port(dataPort); <a name="l00283"></a>00283 controlBasePort = dataBasePort + 1; <a name="l00284"></a>00284 } <span class="keywordflow">else</span> { <a name="l00285"></a>00285 dataBasePort = dataPort; <a name="l00286"></a>00286 controlBasePort = controlPort; <a name="l00287"></a>00287 } <a name="l00288"></a>00288 dso = <span class="keyword">new</span> RTPDataChannel(ia,dataBasePort); <a name="l00289"></a>00289 cso = <span class="keyword">new</span> RTCPChannel(ia,controlBasePort); <a name="l00290"></a>00290 } <a name="l00291"></a>00291 <a name="l00292"></a>00292 <span class="keywordtype">void</span> <a name="l00293"></a>00293 build(<span class="keyword">const</span> InetMcastAddress& ia, tpport_t dataPort, <a name="l00294"></a>00294 tpport_t controlPort, uint32 iface) <a name="l00295"></a>00295 { <a name="l00296"></a>00296 <span class="keywordflow">if</span> ( 0 == controlPort ) { <a name="l00297"></a>00297 dataBasePort = even_port(dataPort); <a name="l00298"></a>00298 controlBasePort = dataBasePort + 1; <a name="l00299"></a>00299 } <span class="keywordflow">else</span> { <a name="l00300"></a>00300 dataBasePort = dataPort; <a name="l00301"></a>00301 controlBasePort = controlPort; <a name="l00302"></a>00302 } <a name="l00303"></a>00303 dso = <span class="keyword">new</span> RTPDataChannel(InetHostAddress(<span class="stringliteral">"0.0.0.0"</span>),dataBasePort); <a name="l00304"></a>00304 cso = <span class="keyword">new</span> RTCPChannel(InetHostAddress(<span class="stringliteral">"0.0.0.0"</span>),controlBasePort); <a name="l00305"></a>00305 joinGroup(ia,iface); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <a name="l00314"></a>00314 <span class="keyword">inline</span> Socket::Error <a name="l00315"></a>00315 joinGroup(<span class="keyword">const</span> InetMcastAddress& ia, uint32 iface) <a name="l00316"></a>00316 { <a name="l00317"></a>00317 Socket::Error error = dso->setMulticast(<span class="keyword">true</span>); <a name="l00318"></a>00318 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00319"></a>00319 error = dso->join(ia,iface); <a name="l00320"></a>00320 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00321"></a>00321 error = cso->setMulticast(<span class="keyword">true</span>); <a name="l00322"></a>00322 <span class="keywordflow">if</span> ( error ) { <a name="l00323"></a>00323 dso->drop(ia); <a name="l00324"></a>00324 <span class="keywordflow">return</span> error; <a name="l00325"></a>00325 } <a name="l00326"></a>00326 error = cso->join(ia,iface); <a name="l00327"></a>00327 <span class="keywordflow">if</span> ( error ) { <a name="l00328"></a>00328 dso->drop(ia); <a name="l00329"></a>00329 <span class="keywordflow">return</span> error; <a name="l00330"></a>00330 } <a name="l00331"></a>00331 <span class="keywordflow">return</span> Socket::errSuccess; <a name="l00332"></a>00332 } <a name="l00333"></a>00333 <a name="l00340"></a>00340 <span class="keyword">inline</span> Socket::Error <a name="l00341"></a>00341 leaveGroup(<span class="keyword">const</span> InetMcastAddress& ia) <a name="l00342"></a>00342 { <a name="l00343"></a>00343 Socket::Error error = dso->setMulticast(<span class="keyword">false</span>); <a name="l00344"></a>00344 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00345"></a>00345 error = dso->leaveGroup(ia); <a name="l00346"></a>00346 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00347"></a>00347 error = cso->setMulticast(<span class="keyword">false</span>); <a name="l00348"></a>00348 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00349"></a>00349 <span class="keywordflow">return</span> cso->leaveGroup(ia); <a name="l00350"></a>00350 } <a name="l00351"></a>00351 <a name="l00358"></a>00358 <span class="keyword">inline</span> Socket::Error <a name="l00359"></a>00359 setMcastTTL(uint8 ttl) <a name="l00360"></a>00360 { <a name="l00361"></a>00361 Socket::Error error = dso->setMulticast(<span class="keyword">true</span>); <a name="l00362"></a>00362 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00363"></a>00363 error = dso->setTimeToLive(ttl); <a name="l00364"></a>00364 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00365"></a>00365 error = cso->setMulticast(<span class="keyword">true</span>); <a name="l00366"></a>00366 <span class="keywordflow">if</span> ( error ) <span class="keywordflow">return</span> error; <a name="l00367"></a>00367 <span class="keywordflow">return</span> cso->setTimeToLive(ttl); <a name="l00368"></a>00368 } <a name="l00369"></a>00369 <a name="l00377"></a>00377 <span class="keyword">inline</span> tpport_t <a name="l00378"></a>00378 odd_port(tpport_t port) <a name="l00379"></a>00379 { <span class="keywordflow">return</span> (port & 0x01)? (port) : (port - 1); } <a name="l00380"></a>00380 <a name="l00388"></a>00388 <span class="keyword">inline</span> tpport_t <a name="l00389"></a>00389 even_port(tpport_t port) <a name="l00390"></a>00390 { <span class="keywordflow">return</span> (port & 0x01)? (port - 1) : (port); } <a name="l00391"></a>00391 <a name="l00392"></a>00392 tpport_t dataBasePort; <a name="l00393"></a>00393 tpport_t controlBasePort; <a name="l00394"></a>00394 <a name="l00395"></a>00395 <span class="keyword">protected</span>: <a name="l00396"></a><a class="code" href="class_t_r_t_p_session_base.html#p0">00396</a> RTPDataChannel* dso; <a name="l00397"></a><a class="code" href="class_t_r_t_p_session_base.html#p1">00397</a> RTCPChannel* cso; <a name="l00398"></a><a class="code" href="class_t_r_t_p_session_base.html#n0">00398</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_p_session_base_handler.html">RTPSessionBaseHandler</a>; <a name="l00399"></a>00399 }; <a name="l00400"></a>00400 <a name="l00411"></a>00411 <span class="keyword">template</span> <a name="l00412"></a>00412 <<span class="keyword">class </span>RTPDataChannel = <a class="code" href="class_dual_r_t_p_channel.html">DualRTPUDPIPv4Channel</a>, <a name="l00413"></a>00413 <span class="keyword">class </span>RTCPChannel = <a class="code" href="class_dual_r_t_p_channel.html">DualRTPUDPIPv4Channel</a>, <a name="l00414"></a>00414 <span class="keyword">class </span>ServiceQueue = <a class="code" href="class_a_v_p_queue.html">AVPQueue</a>> <a name="l00415"></a><a class="code" href="class_single_thread_r_t_p_session.html">00415</a> <span class="keyword">class </span>__EXPORT SingleThreadRTPSession : <a name="l00416"></a>00416 <span class="keyword">protected</span> Thread, <a name="l00417"></a>00417 <span class="keyword">public</span> TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue> <a name="l00418"></a>00418 { <a name="l00419"></a>00419 <span class="keyword">public</span>: <a name="l00420"></a><a class="code" href="class_single_thread_r_t_p_session.html#a0">00420</a> SingleThreadRTPSession(<span class="keyword">const</span> InetHostAddress& ia, <a name="l00421"></a>00421 tpport_t dataPort = <a class="code" href="base_8h.html#a4">DefaultRTPDataPort</a>, <a name="l00422"></a>00422 tpport_t controlPort = 0, <a name="l00423"></a>00423 <span class="keywordtype">int</span> pri = 0, <a name="l00424"></a>00424 uint32 memberssize = <a name="l00425"></a>00425 <a class="code" href="class_membership_bookkeeping.html#t0">MembershipBookkeeping::defaultMembersHashSize</a>, <a name="l00426"></a>00426 <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app = <a class="code" href="group__sources.html#ga0">defaultApplication</a>() <a name="l00427"></a>00427 #<span class="keywordflow">if</span> defined(_MSC_VER) && _MSC_VER >= 1300 <a name="l00428"></a>00428 ); <a name="l00429"></a>00429 <span class="preprocessor">#else</span> <a name="l00430"></a>00430 <span class="preprocessor"></span> ): <a name="l00431"></a>00431 Thread(pri), <a name="l00432"></a>00432 <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue></a> <a name="l00433"></a>00433 (ia,dataPort,controlPort,memberssize,app) <a name="l00434"></a>00434 { } <a name="l00435"></a>00435 <span class="preprocessor">#endif</span> <a name="l00436"></a>00436 <span class="preprocessor"></span> <a name="l00437"></a><a class="code" href="class_single_thread_r_t_p_session.html#a1">00437</a> SingleThreadRTPSession(<span class="keyword">const</span> InetMcastAddress& ia, <a name="l00438"></a>00438 tpport_t dataPort = <a class="code" href="base_8h.html#a4">DefaultRTPDataPort</a>, <a name="l00439"></a>00439 tpport_t controlPort = 0, <a name="l00440"></a>00440 <span class="keywordtype">int</span> pri = 0, <a name="l00441"></a>00441 uint32 memberssize = <a name="l00442"></a>00442 <a class="code" href="class_membership_bookkeeping.html#t0">MembershipBookkeeping::defaultMembersHashSize</a>, <a name="l00443"></a>00443 <a class="code" href="class_r_t_p_application.html">RTPApplication</a>& app = <a class="code" href="group__sources.html#ga0">defaultApplication</a>(), <a name="l00444"></a>00444 uint32 iface = 0) <a name="l00445"></a>00445 #<span class="keywordflow">if</span> defined(_MSC_VER) && _MSC_VER >= 1300 <a name="l00446"></a>00446 ; <a name="l00447"></a>00447 <span class="preprocessor">#else</span> <a name="l00448"></a>00448 <span class="preprocessor"></span> : <a name="l00449"></a>00449 Thread(pri), <a name="l00450"></a>00450 <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue></a> <a name="l00451"></a>00451 (ia,dataPort,controlPort,memberssize,app,iface) <a name="l00452"></a>00452 { } <a name="l00453"></a>00453 <span class="preprocessor">#endif</span> <a name="l00454"></a>00454 <span class="preprocessor"></span> <a name="l00455"></a><a class="code" href="class_single_thread_r_t_p_session.html#a2">00455</a> ~SingleThreadRTPSession() <a name="l00456"></a>00456 { terminate(); } <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="preprocessor">#if defined(_MSC_VER) && _MSC_VER >= 1300 </span> <a name="l00459"></a>00459 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> startRunning(); <a name="l00460"></a>00460 <span class="preprocessor">#else</span> <a name="l00461"></a>00461 <span class="preprocessor"></span> <a name="l00464"></a>00464 <span class="keywordtype">void</span> <a name="l00465"></a><a class="code" href="class_single_thread_r_t_p_session.html#a3">00465</a> startRunning() <a name="l00466"></a>00466 { enableStack(); Thread::start(); } <a name="l00467"></a>00467 <span class="preprocessor">#endif</span> <a name="l00468"></a>00468 <span class="preprocessor"></span> <a name="l00469"></a>00469 <a name="l00470"></a>00470 <span class="keyword">protected</span>: <a name="l00471"></a><a class="code" href="class_single_thread_r_t_p_session.html#b0">00471</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> enableStack(<span class="keywordtype">void</span>) <a name="l00472"></a>00472 {<a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::enableStack</a>();} <a name="l00473"></a>00473 <a name="l00474"></a><a class="code" href="class_single_thread_r_t_p_session.html#b1">00474</a> <span class="keyword">inline</span> <a class="code" href="base_8h.html#a2">microtimeout_t</a> getSchedulingTimeout(<span class="keywordtype">void</span>) <a name="l00475"></a>00475 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::getSchedulingTimeout</a>();} <a name="l00476"></a>00476 <a name="l00477"></a><a class="code" href="class_single_thread_r_t_p_session.html#b2">00477</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> controlReceptionService(<span class="keywordtype">void</span>) <a name="l00478"></a>00478 {<a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::controlReceptionService</a>();} <a name="l00479"></a>00479 <a name="l00480"></a><a class="code" href="class_single_thread_r_t_p_session.html#b3">00480</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> controlTransmissionService(<span class="keywordtype">void</span>) <a name="l00481"></a>00481 {<a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::controlTransmissionService</a>();} <a name="l00482"></a>00482 <a name="l00483"></a><a class="code" href="class_single_thread_r_t_p_session.html#b4">00483</a> <span class="keyword">inline</span> timeval getRTCPCheckInterval(<span class="keywordtype">void</span>) <a name="l00484"></a>00484 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::getRTCPCheckInterval</a>();}; <a name="l00485"></a>00485 <a name="l00486"></a><a class="code" href="class_single_thread_r_t_p_session.html#b5">00486</a> <span class="keyword">inline</span> size_t dispatchDataPacket(<span class="keywordtype">void</span>) <a name="l00487"></a>00487 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchDataPacket</a>();}; <a name="l00488"></a>00488 <a name="l00489"></a>00489 <span class="preprocessor">#if defined(_MSC_VER) && _MSC_VER >= 1300</span> <a name="l00490"></a>00490 <span class="preprocessor"></span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> run(<span class="keywordtype">void</span>); <a name="l00491"></a>00491 <a name="l00492"></a>00492 <span class="keyword">virtual</span> <span class="keywordtype">void</span> timerTick(<span class="keywordtype">void</span>); <a name="l00493"></a>00493 <a name="l00494"></a>00494 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isPendingData(<a class="code" href="base_8h.html#a2">microtimeout_t</a> timeout); <a name="l00495"></a>00495 <span class="preprocessor">#else</span> <a name="l00496"></a>00496 <span class="preprocessor"></span> <a name="l00497"></a><a class="code" href="class_single_thread_r_t_p_session.html#b6">00497</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> timerTick(<span class="keywordtype">void</span>) <a name="l00498"></a>00498 {<span class="keywordflow">return</span>;} <a name="l00499"></a>00499 <a name="l00500"></a><a class="code" href="class_single_thread_r_t_p_session.html#b7">00500</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isPendingData(<a class="code" href="base_8h.html#a2">microtimeout_t</a> timeout) <a name="l00501"></a>00501 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html#b0">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::isPendingData</a>(timeout);} <a name="l00502"></a>00502 <a name="l00507"></a><a class="code" href="class_single_thread_r_t_p_session.html#b8">00507</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> run(<span class="keywordtype">void</span>) <a name="l00508"></a>00508 { <a name="l00509"></a>00509 <a class="code" href="base_8h.html#a2">microtimeout_t</a> timeout = 0; <a name="l00510"></a>00510 <span class="keywordflow">while</span> ( ServiceQueue::isActive() ) { <a name="l00511"></a>00511 <span class="keywordflow">if</span> ( timeout < 1000 ){ <span class="comment">// !(timeout/1000)</span> <a name="l00512"></a>00512 timeout = getSchedulingTimeout(); <a name="l00513"></a>00513 } <a name="l00514"></a>00514 setCancel(cancelDeferred); <a name="l00515"></a>00515 controlReceptionService(); <a name="l00516"></a>00516 controlTransmissionService(); <a name="l00517"></a>00517 setCancel(cancelImmediate); <a name="l00518"></a>00518 <a class="code" href="base_8h.html#a2">microtimeout_t</a> maxWait = <a name="l00519"></a>00519 <a class="code" href="base_8h.html#a7">timeval2microtimeout</a>(getRTCPCheckInterval()); <a name="l00520"></a>00520 <span class="comment">// make sure the scheduling timeout is</span> <a name="l00521"></a>00521 <span class="comment">// <= the check interval for RTCP</span> <a name="l00522"></a>00522 <span class="comment">// packets</span> <a name="l00523"></a>00523 timeout = (timeout > maxWait)? maxWait : timeout; <a name="l00524"></a>00524 <span class="keywordflow">if</span> ( timeout < 1000 ) { <span class="comment">// !(timeout/1000)</span> <a name="l00525"></a>00525 setCancel(cancelDeferred); <a name="l00526"></a>00526 dispatchDataPacket(); <a name="l00527"></a>00527 setCancel(cancelImmediate); <a name="l00528"></a>00528 timerTick(); <a name="l00529"></a>00529 } <span class="keywordflow">else</span> { <a name="l00530"></a>00530 <span class="keywordflow">if</span> ( isPendingData(timeout/1000) ) { <a name="l00531"></a>00531 setCancel(cancelDeferred); <a name="l00532"></a>00532 takeInDataPacket(); <a name="l00533"></a>00533 setCancel(cancelImmediate); <a name="l00534"></a>00534 } <a name="l00535"></a>00535 timeout = 0; <a name="l00536"></a>00536 } <a name="l00537"></a>00537 } <a name="l00538"></a>00538 dispatchBYE(<span class="stringliteral">"GNU ccRTP stack finishing."</span>); <a name="l00539"></a>00539 sleep((timeout_t)~0); <a name="l00540"></a>00540 } <a name="l00541"></a>00541 <a name="l00542"></a>00542 <span class="preprocessor">#endif</span> <a name="l00543"></a>00543 <span class="preprocessor"></span> <a name="l00544"></a><a class="code" href="class_single_thread_r_t_p_session.html#b9">00544</a> <span class="keyword">inline</span> size_t takeInDataPacket(<span class="keywordtype">void</span>) <a name="l00545"></a>00545 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::takeInDataPacket</a>();} <a name="l00546"></a>00546 <a name="l00547"></a><a class="code" href="class_single_thread_r_t_p_session.html#b10">00547</a> <span class="keyword">inline</span> size_t dispatchBYE(<span class="keyword">const</span> std::string &str) <a name="l00548"></a>00548 {<span class="keywordflow">return</span> <a class="code" href="class_t_r_t_p_session_base.html#a4">TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchBYE</a>(str);} <a name="l00549"></a>00549 }; <a name="l00550"></a>00550 <a name="l00559"></a><a class="code" href="group__sessions.html#ga0">00559</a> <span class="keyword">typedef</span> <a class="code" href="class_single_thread_r_t_p_session.html">SingleThreadRTPSession<></a> <a class="code" href="class_single_thread_r_t_p_session.html">RTPSession</a>; <a name="l00560"></a>00560 <a name="l00566"></a><a class="code" href="group__sessions.html#ga1">00566</a> <span class="keyword">typedef</span> <a class="code" href="class_single_thread_r_t_p_session.html">RTPSession</a> <a class="code" href="class_single_thread_r_t_p_session.html">RTPSocket</a>; <a name="l00567"></a>00567 <a name="l00576"></a>00576 <span class="keyword">typedef</span> SingleThreadRTPSession<<a class="code" href="class_r_t_p_base_u_d_p_i_pv4_socket.html">SymmetricRTPChannel</a>, <a name="l00577"></a><a class="code" href="group__sessions.html#ga2">00577</a> <a class="code" href="class_r_t_p_base_u_d_p_i_pv4_socket.html">SymmetricRTPChannel</a>> <a class="code" href="class_single_thread_r_t_p_session.html">SymmetricRTPSession</a>; <a name="l00578"></a>00578 <span class="comment">// sessions</span> <a name="l00580"></a>00580 <a name="l00581"></a>00581 <span class="preprocessor">#ifdef CCXX_NAMESPACES</span> <a name="l00582"></a>00582 <span class="preprocessor"></span>} <a name="l00583"></a>00583 <span class="preprocessor">#endif</span> <a name="l00584"></a>00584 <span class="preprocessor"></span> <a name="l00585"></a>00585 <span class="preprocessor">#endif //CCXX_RTP_RTP_H_</span> <a name="l00586"></a>00586 <span class="preprocessor"></span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Dec 9 22:32:03 2005 for ccRTP by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4 </small></address> </body> </html>