uvgRTP 2.0.1
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. According to our measurements 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.
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 Crypto++ library.
Currently supported specifications:
You can either include files individually from include folder or use lib.hh to include all necessary files with one line:
When using uvgRTP, you must always first create the context object:
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):
or specify both remote and local addresses:
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).
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.
The encryption can be enabled here bug specifying RCE_SRTP| RCE_SRTP_KMNGMNT_ZRTP
or RCE_SRTP | RCE_SRTP_KMNGMNT_USER
in the last parameter. The RCE_SRTP_KMNGMNT_USER
requires calling add_srtp_ctx(key, salt)
for the created media_stream after creation. These flags start with prefix RCE_
and the explanations can be found in docs folder. Other useful flags include RCE_RTCP
for enabling RTCP and RCE_H26X_PREPEND_SC
for prepending start codes which are needed for decoding of an H26x stream.
Some of the 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 configuration example for more details.
Sending can be done by simple calling push_frame()-function on created media_stream:
See sending example for more details.
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 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.
Cleanup can be dune with following functions: