<divclass="textblock"><p><aclass="anchor"id="md_html_INDEX"></a> uvgRTP is an <em>Real-Time Transport Protocol (RTP)</em> library written in C++ with a focus on simple to use and high-efficiency media delivery over the Internet. It features an intuitive and easy-to-use <em>Application Programming Interface (API)</em>, built-in support for transporting <em>Versatile Video Coding (VVC)</em>, <em>High Efficiency Video Coding (HEVC)</em>, <em>Advanced Video Coding (AVC)</em> encoded video and Opus encoded audio. uvgRTP also supports <em>End-to-End Encrypted (E2EE)</em> media delivery using the combination of <em>Secure RTP (SRTP)</em> and ZRTP. According to <ahref="https://researchportal.tuni.fi/en/publications/open-source-rtp-library-for-high-speed-4k-hevc-video-streaming">our measurements</a> uvgRTP is able to reach a goodput of 600 MB/s (4K at 700fps) for HEVC stream when measured in LAN. The CPU usage is relative to the goodput value, and therefore smaller streams have a very small CPU usage.</p>
<p>uvgRTP is licensed under the permissive BSD 2-Clause License. This cross-platform library can be run on both Linux and Windows operating systems. Mac OS is also supported, but the support relies on community contributions. For SRTP/ZRTP support, uvgRTP uses <ahref="https://www.cryptopp.com/">Crypto++ library</a>.</p>
<p>Currently supported specifications:</p><ul>
<li><ahref="https://tools.ietf.org/html/rfc3550">RFC 3550: RTP: A Transport Protocol for Real-Time Applications</a></li>
<p>You can either include files individually from the include-folder or use <aclass="el"href="lib_8hh_source.html">lib.hh</a> to include all necessary files with one line:</p>
<p>When using uvgRTP, you must always first create the <aclass="el"href="classuvgrtp_1_1context.html"title="Provides CNAME isolation and can be used to create uvgrtp::session objects.">uvgrtp::context</a> object:</p>
<p>Next, you will use the <aclass="el"href="classuvgrtp_1_1context.html"title="Provides CNAME isolation and can be used to create uvgrtp::session objects.">uvgrtp::context</a> object to create <aclass="el"href="classuvgrtp_1_1session.html"title="Provides ZRTP synchronization and can be used to create uvgrtp::media_stream objects.">uvgrtp::session</a> objects. The <aclass="el"href="classuvgrtp_1_1session.html"title="Provides ZRTP synchronization and can be used to create uvgrtp::media_stream objects.">uvgrtp::session</a> object contains all media streams you are sending/receiving to/from single IP address. Broadcast addresses should also work. There are two options for creating this: 1) specify one address, role of which can be determined with RCE_SEND_ONLY or RCE_RECEIVE_ONLY flag later:</p>
</div><!-- fragment --><h2><aclass="anchor"id="autotoc_md5"></a>
Step 3: Create media_stream</h2>
<p>To send/receive actual media, a <aclass="el"href="classuvgrtp_1_1media__stream.html"title="The media_stream is an entity which represents one RTP stream.">uvgrtp::media_stream</a> object has to be created. The first parameter is the local port from which the sending happens and the second port is the port where the data is sent to (note that these are in the reverse order compared to creating the session). The third parameter specifies the RTP payload format which will be used for the outgoing and incoming data. The last parameter holds the flags that can be used to modify the behavior of created <aclass="el"href="classuvgrtp_1_1media__stream.html"title="The media_stream is an entity which represents one RTP stream.">uvgrtp::media_stream</a>. The flags can be combined using bitwise OR-operation(|). These flags start with prefix <code>RCE_</code> and the explanations can be found in docs folder of repository. RTCP can be enabled with <code>RCE_RTCP</code>-flag.</p>
</div><!-- fragment --><p>One port version of this also exists, to be used with RCE_SEND_ONLY and RCE_RECEIVE_ONLY flags: </p><divclass="fragment"><divclass="line">uvgrtp::media_stream *strm = sess->create_stream(8888, RTP_FORMAT_GENERIC, RCE_RECEIVE_ONLY);</div>
</div><!-- fragment --><h2><aclass="anchor"id="autotoc_md6"></a>
Step 3.1: Encryption (optional)</h2>
<p>The encryption can be enabled by specifying <code>RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP</code> or <code>RCE_SRTP | RCE_SRTP_KMNGMNT_USER</code> in the flags parameter of create_stream. The <code>RCE_SRTP_KMNGMNT_USER</code> requires calling <code>add_srtp_ctx(key, salt)</code> for the created <aclass="el"href="classuvgrtp_1_1media__stream.html"title="The media_stream is an entity which represents one RTP stream.">uvgrtp::media_stream</a>.</p>
<p>Some of the <aclass="el"href="classuvgrtp_1_1media__stream.html"title="The media_stream is an entity which represents one RTP stream.">uvgrtp::media_stream</a> functionality can be configured after the stream has been created: </p><divclass="fragment"><divclass="line">strm->configure_ctx(RCC_MTU_SIZE, 2312);</div>
</div><!-- fragment --><p>The flags start with prefix <code>RCC_</code> and the rest of the flags can be found in the docs folder. Also, see the configuration example for more details.</p>
<p>Sending can be done by simple calling push_frame()-function on created <aclass="el"href="classuvgrtp_1_1media__stream.html"title="The media_stream is an entity which represents one RTP stream.">uvgrtp::media_stream</a>:</p>
</div><!-- fragment --><p> See the sending example for more details. uvgRTP does not take ownership of the memory unless the data is provided with std::unique_ptr.</p>
<p>There are two alternatives to receiving data. Using pull_frame()-function: </p><divclass="fragment"><divclass="line">auto frame = strm->pull_frame();</div>
</div><!-- fragment --><p>or function callback based approach (I would recommend this to minimize latency):</p>
</div><!-- fragment --><p>If you use classes, you can give a pointer to your class in the first parameter and call it in your callback function (an std::function API does not exist yet). In both versions of receiving, the user will be responsible for releasing the memory with the following function: </p><divclass="fragment"><divclass="line">uvgrtp::frame::dealloc_frame(frame);</div>