uvgrtp-base/docs/html/index.html

171 lines
12 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>uvgRTP: uvgRTP</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">uvgRTP<span id="projectnumber">&#160;2.0.1</span>
</div>
<div id="projectbrief">An open-source library for RTP/SRTP media delivery</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">uvgRTP </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p ><a class="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 <a href="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 <a href="https://www.cryptopp.com/">Crypto++ library</a>.</p>
<p >Currently supported specifications:</p><ul>
<li><a href="https://tools.ietf.org/html/rfc3550">RFC 3550: RTP: A Transport Protocol for Real-Time Applications</a></li>
<li><a href="https://tools.ietf.org/html/rfc7798">RFC 7798: RTP Payload Format for High Efficiency Video Coding (HEVC)</a></li>
<li><a href="https://tools.ietf.org/html/rfc6184">RFC 6184: RTP Payload Format for H.264 Video</a></li>
<li><a href="https://tools.ietf.org/html/rfc7587">RFC 7587: RTP Payload Format for the Opus Speech and Audio Codec</a></li>
<li><a href="https://tools.ietf.org/html/rfc3711">RFC 3711: The Secure Real-time Transport Protocol (SRTP)</a></li>
<li><a href="https://tools.ietf.org/html/rfc6189">RFC 6189: ZRTP: Media Path Key Agreement for Unicast Secure RTP</a></li>
<li><a href="https://tools.ietf.org/html/draft-ietf-avtcore-rtp-vvc-08">Draft: RTP Payload Format for Versatile Video Coding (VVC)</a></li>
</ul>
<h1><a class="anchor" id="autotoc_md1"></a>
Notable features</h1>
<ul>
<li>AVC/HEVC/VVC video streaming, including packetization</li>
<li>Ready support for many formats which don't need packetization, including Opus</li>
<li>Delivery encryption with SRTP</li>
<li>Encryption key negotiation with ZRTP</li>
<li>UDP firewall hole punching</li>
<li>Simple to use API</li>
<li>Working examples</li>
<li>Permissive license</li>
</ul>
<h1><a class="anchor" id="autotoc_md2"></a>
Tutorial</h1>
<p >You can either include files individually from <a href="../include">include</a> folder or use <a class="el" href="lib_8hh_source.html">lib.hh</a> to include all necessary files with one line:</p>
<div class="fragment"><div class="line">#include &lt;uvgrtp/lib.hh&gt;</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md3"></a>
Create context</h2>
<p >When using uvgRTP, you must always first create the context object:</p>
<div class="fragment"><div class="line">uvgrtp::context ctx;</div>
</div><!-- fragment --> <h2><a class="anchor" id="autotoc_md4"></a>
Create session</h2>
<p >Next, you will use the context object to create session objects. Session object contains all the different media streams you are sending/receiving to/from single IP address. Broadcast addresses should also work. There are two options fort creating this, Specify only remote address (currently this also binds to ANY with each media_stream):</p>
<div class="fragment"><div class="line">uvgrtp::session *sess = ctx.create_session(&quot;10.10.10.2&quot;);</div>
</div><!-- fragment --><p> or specify both remote and local addresses:</p>
<div class="fragment"><div class="line">uvgrtp::session *sess = ctx.create_session(&quot;10.10.10.2&quot;, &quot;10.10.10.3&quot;);</div>
</div><!-- fragment --><p >Hopefully in the future also only binding to local address and only sending will be supported. This is discussed in issue #83 and PRs are welcome to this issue (be careful not to invalidate current API).</p>
<h2><a class="anchor" id="autotoc_md5"></a>
Create media_stream</h2>
<p >To send/receive actual media, a media_stream 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 uvgRTP in regards to this media_stream.</p>
<div class="fragment"><div class="line">uvgrtp::media_stream *strm = sess-&gt;create_stream(8888, 8888, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);</div>
</div><!-- fragment --><p >The encryption can be enabled here bug specifying <code>RCE_SRTP| RCE_SRTP_KMNGMNT_ZRTP</code> or <code>RCE_SRTP | RCE_SRTP_KMNGMNT_USER</code> in the last parameter. The <code>RCE_SRTP_KMNGMNT_USER</code> requires calling <code>add_srtp_ctx(key, salt)</code> for the created media_stream after creation. These flags start with prefix <code>RCE_</code> and the explanations can be found in <a href="../docs">docs folder</a>. Other useful flags include <code>RCE_RTCP</code> for enabling RTCP and <code>RCE_H26X_PREPEND_SC</code> for prepending start codes which are needed for decoding of an H26x stream.</p>
<h2><a class="anchor" id="autotoc_md6"></a>
Configure media_stream (optional)</h2>
<p >Some of the media_stream functionality can be configured after the stream has been created: </p><div class="fragment"><div class="line">strm-&gt;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 <a href="../docs">docs folder</a>. Also, see <a href="configuration.cc">configuration example</a> for more details.</p>
<h2><a class="anchor" id="autotoc_md7"></a>
Sending data</h2>
<p >Sending can be done by simple calling push_frame()-function on created media_stream:</p>
<div class="fragment"><div class="line">strm-&gt;push_frame((uint8_t *)message, msg_len, RTP_NO_FLAGS);</div>
</div><!-- fragment --><p> See <a href="sending.cc">sending example</a> for more details.</p>
<h2><a class="anchor" id="autotoc_md8"></a>
Receiving data</h2>
<p >There are two alternatives to receiving data. Using pull_frame()-function: </p><div class="fragment"><div class="line">auto frame = strm-&gt;pull_frame();</div>
</div><!-- fragment --><p >or function callback based approach (I would recommend this to minimize latency):</p>
<div class="fragment"><div class="line">strm-&gt;install_receive_hook(nullptr, rtp_receive_hook);</div>
</div><!-- fragment --><p >If you use classes, you can give a pointer to your class in the first parameter and call it in you callback function (an std::function API would be nice, but does not exist yet). In both versions, the user will be responsible for releasing the memory.</p>
<h2><a class="anchor" id="autotoc_md9"></a>
Cleanup</h2>
<p >Cleanup can be dune with following functions: </p><div class="fragment"><div class="line">sess-&gt;destroy_stream(strm);</div>
<div class="line">ctx.destroy_session(sess);</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md10"></a>
Simple example (non-working)</h2>
<div class="fragment"><div class="line">#include &lt;uvgrtp/lib.hh&gt;</div>
<div class="line"> </div>
<div class="line">/* g++ main.cc -luvgrtp -lpthread &amp;&amp; ./a.out */</div>
<div class="line"> </div>
<div class="line">int main(void)</div>
<div class="line">{</div>
<div class="line"> uvgrtp::context ctx;</div>
<div class="line"> uvgrtp::session *sess = ctx.create_session(&quot;127.0.0.1&quot;);</div>
<div class="line"> </div>
<div class="line"> uvgrtp::media_stream *strm = sess-&gt;create_stream(8888, 8888, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);</div>
<div class="line"> </div>
<div class="line"> strm-&gt;configure_ctx(RCC_MTU_SIZE, 2312);</div>
<div class="line"> </div>
<div class="line"> char *message = (char *)&quot;Hello, world!&quot;;</div>
<div class="line"> size_t msg_len = strlen(message) + 1;</div>
<div class="line"> </div>
<div class="line"> for (;;) {</div>
<div class="line"> strm-&gt;push_frame((uint8_t *)message, msg_len, RTP_NO_FLAGS);</div>
<div class="line"> auto frame = strm-&gt;pull_frame();</div>
<div class="line"> fprintf(stderr, &quot;Message: &#39;%s&#39;\n&quot;, frame-&gt;payload);</div>
<div class="line"> uvgrtp::frame::dealloc_frame(frame);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --> </div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>