Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 598246a3099b0106d22dd5249478d3b7 > files > 257

ccrtp-devel-1.7.1-2.fc12.i686.rpm

<!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&nbsp;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 &lt;fedemp@altern.org&gt;</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 &lt;cstdlib&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="rtp_8h.html" title="Generic and audio/video profile specific RTP interface of ccRTP.">ccrtp/rtp.h</a>&gt;</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&amp; 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 &lt;&lt; <span class="stringliteral">"My SSRC identifier is: "</span> 
                     &lt;&lt; hex &lt;&lt; (int)getLocalSSRC() &lt;&lt; endl;

                <a name="a2"></a><a class="code" href="group__sources.html#g206420a8423d0c261e9bfc5a388a9534" title="Get the RTPApplication object for the &amp;quot;default&amp;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 &lt;&lt; <span class="stringliteral">"Could not connect"</span> &lt;&lt; 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 &lt; 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 &lt;&lt; <span class="stringliteral">"rtpsend..."</span> &lt;&lt; endl;

        <span class="keywordflow">if</span> (argc != 6) { 
                cerr &lt;&lt; <span class="stringliteral">"Syntax: "</span> &lt;&lt; <span class="stringliteral">"data host port timestamp count"</span> &lt;&lt; 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 &lt;&lt; <span class="stringliteral">"I have sent "</span> &lt;&lt; argv[5] 
             &lt;&lt; <span class="stringliteral">" RTP packets containing \""</span> &lt;&lt; argv[1]
             &lt;&lt; <span class="stringliteral">"\", with timestamp "</span> &lt;&lt; argv[4]
             &lt;&lt; <span class="stringliteral">" to "</span> &lt;&lt; argv[2] &lt;&lt; <span class="stringliteral">":"</span> &lt;&lt; argv[3]
             &lt;&lt; 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&nbsp;
<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>