<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>ccRTP: rtpsend.cpp</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.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="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div> <div class="contents"> <h1>rtpsend.cpp</h1><div class="fragment"><pre class="fragment"><span class="comment">// rtpsend</span> <span class="comment">// Send RTP packets using ccRTP.</span> <span class="comment">// Copyright (C) 2001,2002 Federico Montesino <fedemp@altern.org></span> <span class="comment">// </span> <span class="comment">// This program is free software; you can redistribute it and/or modify</span> <span class="comment">// it under the terms of the GNU General Public License as published by</span> <span class="comment">// the Free Software Foundation; either version 2 of the License, or</span> <span class="comment">// (at your option) any later version.</span> <span class="comment">// </span> <span class="comment">// This program is distributed in the hope that it will be useful,</span> <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <span class="comment">// GNU General Public License for more details.</span> <span class="comment">// </span> <span class="comment">// You should have received a copy of the GNU General Public License</span> <span class="comment">// along with this program; if not, write to the Free Software</span> <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span> <span class="preprocessor">#include <cstdlib></span> <span class="preprocessor">#include <<a class="code" href="rtp_8h.html" title="Generic and audio/video profile specific RTP interface of ccRTP.">ccrtp/rtp.h</a>></span> <span class="preprocessor">#ifdef CCXX_NAMESPACES</span> <span class="preprocessor"></span><span class="keyword">using namespace </span>ost; <span class="keyword">using namespace </span>std; <span class="preprocessor">#endif</span> <span class="preprocessor"></span> <span class="keyword">class </span>Sender: <span class="keyword">public</span> <a name="_a0"></a><a class="code" href="class_single_thread_r_t_p_session.html" title="This template class adds the threading aspect to the RTPSessionBase template in one...">RTPSession</a>, <span class="keyword">public</span> TimerPort { <span class="keyword">public</span>: Sender(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* data, <span class="keyword">const</span> InetHostAddress& ia, tpport_t port, uint32 tstamp, uint16 count): <a name="a1"></a><a class="code" href="group__sessions.html#g24e16f350c9ae0c1e2a3f5d6a6dad9f9" title="Uses two pairs of sockets for RTP data and RTCP transmission/reception.">RTPSession</a>(InetHostAddress(<span class="stringliteral">"0.0.0.0"</span>)), packetsPerSecond(10) { uint32 timestamp = tstamp? tstamp : 0; cout << <span class="stringliteral">"My SSRC identifier is: "</span> << hex << (int)getLocalSSRC() << endl; <a name="a2"></a><a class="code" href="group__sources.html#g206420a8423d0c261e9bfc5a388a9534" title="Get the RTPApplication object for the &quot;default&quot; application (the only one...">defaultApplication</a>().<a name="a3"></a><a class="code" href="class_r_t_p_application.html#8f508dc361e2127b6ce494af67ca41c6">setSDESItem</a>(<a name="a4"></a><a class="code" href="group__rtcppacket.html#ggf6d38e5ccbbcdf2a24ebbd4fc5b4eeac34f49dfe99b37116fd6459c6b20435f2" title="Application or tool.">SDESItemTypeTOOL</a>, <span class="stringliteral">"rtpsend demo app."</span>); setSchedulingTimeout(10000); setExpireTimeout(1000000); <span class="keywordflow">if</span> ( !addDestination(ia,port) ) { cerr << <span class="stringliteral">"Could not connect"</span> << endl; exit(); } setPayloadFormat(<a name="_a5"></a><a class="code" href="class_static_payload_format.html" title="Static payload format objects.">StaticPayloadFormat</a>(<a name="a6"></a><a class="code" href="group__payload.html#gg7644623ce29b8ca519d7e3f276b6ddc6095b083465fe4d6597ba586e0116022c" title="ITU-T G.711. mu-law audio 8 Khz (RFC 1890).">sptPCMU</a>)); <a name="a7"></a><a class="code" href="class_single_thread_r_t_p_session.html#e861fb5d15be69ea35da87ee41ad6b0b" title="Activate stack and start service thread.">startRunning</a>(); uint16 tstampInc = getCurrentRTPClockRate()/packetsPerSecond; uint32 period = 1000/packetsPerSecond; TimerPort::setTimer(period); <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < count ; i++ ) { putData(timestamp + i*tstampInc, data,strlen((<span class="keywordtype">char</span> *)data) + 1); Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } } <span class="keyword">private</span>: <span class="keyword">const</span> uint16 packetsPerSecond; }; <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) { cout << <span class="stringliteral">"rtpsend..."</span> << endl; <span class="keywordflow">if</span> (argc != 6) { cerr << <span class="stringliteral">"Syntax: "</span> << <span class="stringliteral">"data host port timestamp count"</span> << endl; exit(1); } Sender sender((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)argv[1], InetHostAddress(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5])); cout << <span class="stringliteral">"I have sent "</span> << argv[5] << <span class="stringliteral">" RTP packets containing \""</span> << argv[1] << <span class="stringliteral">"\", with timestamp "</span> << argv[4] << <span class="stringliteral">" to "</span> << argv[2] << <span class="stringliteral">":"</span> << argv[3] << endl; <span class="keywordflow">return</span> 0; } </pre></div> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jul 24 21:42:25 2009 for ccRTP 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>