Starting with version 220.127.116.1176, our video SDK supports SRT streaming.
What is SRT?
Secure Reliable Transport (SRT) is an open source software protocol and technology stack designed for live video streaming over the public internet. If you want to learn more about its history, read our interview with the architect and evangelist of SRT.
SRT provides connection and control, reliable transmission similar to TCP, however, it does so at the application layer, using UDP protocol as an underlying transport layer. It supports packet recovery while maintaining low latency (default: 120 ms). SRT also supports encryption using AES.
There are two modes in the case of SRT streaming
- caller - requester side
- listener - listener side
These modes specify the network connection type - who is sending the request for connection and who is waiting for a request, it doesn't relative to the encoding or decoding processes, so your encoder could act as a listener and your decoder could be the requester.
Pay attention listener should be run before the caller and wait for a caller connection.
In most cases, the decision about how is going to be a requester and who is going to be the listener should be based on your network NAT firewall rules i.e caller in most cases doesn't need any additional rules, meanwhile, with listener mode, you should be sure that you have a specific port forward rule.
In our next examples, we are going to use the encoder (Writer Sample) as caller and the decoder (Network Playback Sample) as a listener.
You can use SRT with Medialooks SDKs in the same way as commonly known UDP/DVB protocols. On the streamer side
- Run Sample Writer x86 / Sample File Writer x86
- Choose the SRT as the video protocol
- Set desirable encoder (MPEG-2 in the current sample)
- Set URL value by the following pattern
There is a lot of settings available for the SRT (e.g., latency, passphrase) - you should set them directly in the target URL, and not in _bsProps parameter of the WriterNameSet (or WriterSet) method, for example:
On the receiver side:
- Run the Network Playback Sample
- URL should be the following srt://ip_address:port?mode=listener
MWriter/MFWriter object instances able to provide encoder statistics via "encoder::muxer::stat"
m_objMFWriter.PropsGet("encoder::muxer::stat", out strValue)
MFReader object instances could provide the SRT decoder statistics via splitter::current::stat
m_objMFreader.PropsGet("splitter::current::stat", out strValue)
For MFileClass object instances could provide the SRT decoder statistics via file::splitter::current::stat
m_objMFileClass.PropsGet("file::splitter::current::stat", out strValue)
In both cases for encoder and decoder statistics,
Video SDK will return default SRT stats, you can find statistics description on HaivisionGitHub https://github.com/Haivision/srt/blob/master/docs/API/statistics.md#summary-table
mode - should be equal to rendezvous
local_IP - required parameter- it's the local IP address for the current workstation
dest_external_IP - destination public IP
source_external_IP - source public IP