uvgRTP 3.1.3
An open-source library for RTP/SRTP media delivery
|
uvgRTP is an Real-Time Transport Protocol (RTP) 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 Application Programming Interface (API), built-in support for transporting Versatile Video Coding (VVC), High Efficiency Video Coding (HEVC), Advanced Video Coding (AVC) encoded video and Opus encoded audio. uvgRTP also supports End-to-End Encrypted (E2EE) media delivery using the combination of Secure RTP (SRTP) and ZRTP. uvgRTP has been designed to minimize memory operations to reduce its CPU usage and latency.
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 the Crypto++ library.
Currently supported specifications:
You can either include files individually from the include-folder or use lib.hh to include all necessary files with one line:
When using uvgRTP, you must always first create the uvgrtp::context object:
Next, you will use the uvgrtp::context object to create uvgrtp::session objects. The uvgrtp::session 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:
or 2) specify both remote and local addresses:
To send/receive actual media, a uvgrtp::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 created uvgrtp::media_stream. The flags can be combined using bitwise OR-operation(|). These flags start with prefix RCE_
and the explanations can be found in docs folder of repository. RTCP can be enabled with RCE_RTCP
-flag.
One port version of this also exists, to be used with RCE_SEND_ONLY and RCE_RECEIVE_ONLY flags:
The encryption can be enabled by specifying RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP
or RCE_SRTP | RCE_SRTP_KMNGMNT_USER
in the flags parameter of create_stream. The RCE_SRTP_KMNGMNT_USER
requires calling add_srtp_ctx(key, salt)
for the created uvgrtp::media_stream.
Some of the uvgrtp::media_stream functionality can be configured after the stream has been created:
The flags start with prefix RCC_
and the rest of the flags can be found in the docs folder. Also, see the configuration example for more details.
Sending can be done by simple calling push_frame()-function on created uvgrtp::media_stream:
See the sending example for more details. uvgRTP does not take ownership of the memory unless the data is provided with std::unique_ptr.
There are two alternatives to receiving data. Using pull_frame()-function:
or function callback based approach (I would recommend this to minimize latency):
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:
Cleanup can be done with following functions: