SRT Protocol
The Secure Reliable Transport (SRT) is a transport protocol that enables secure, reliable streaming of data across unpredictable networks. This document describes the implementation of SRT within the Monibuca (m7s) streaming server, focusing on the protocol's architecture, connection handling, and media streaming capabilities.
Architecture Overview
The SRT implementation in Monibuca is structured as a plugin that enables both publishing (pushing) and playing (pulling) of media streams over SRT. The plugin automatically registers standard SRT support on port 6000 and can be configured to use custom ports.
Core Components
The SRT plugin is composed of the following primary components:
Component | Description |
---|---|
SRTPlugin | Main plugin structure with configuration and initialization logic |
SRTServer | Server implementation that handles incoming connections |
Receiver | Handles incoming media data from publishers |
Sender | Manages outgoing media data to subscribers |
The plugin is registered using Monibuca's plugin system and implements the necessary interfaces for pushing and pulling media streams.
SRT Protocol Flow
Connection Establishment
When a client connects to the SRT server, the following sequence occurs:
- TCP connection is established
- SRT handshake is performed
- Stream ID is processed to determine connection type (publish/subscribe)
- Media streaming begins
Stream ID Format
The SRT implementation uses a specific stream ID format to distinguish between publishing and subscribing connections:
- For publishing:
publish:/{streamPath}
- For subscribing:
subscribe:/{streamPath}
The stream path is extracted from the stream ID and used to create the appropriate publisher or subscriber in the Monibuca system.
Configuration and Initialization
The SRT plugin can be configured with these settings:
Setting | Default | Description |
---|---|---|
ListenAddr | :6000 | Address and port to listen on |
Passphrase | "" | Optional passphrase for encryption |
On initialization, the plugin registers its capabilities and address formats:
srt://{hostName}?streamid=publish:/{streamPath} (Port 6000)
srt://{hostName}:{port}?streamid=publish:/{streamPath} (Custom port)
srt://{hostName}?streamid=subscribe:/{streamPath} (Port 6000)
srt://{hostName}:{port}?streamid=subscribe:/{streamPath} (Custom port)
Connection Handling
Publisher Connection
When a publisher connects:
- The connection is authenticated using the configured passphrase
- A new publisher is created in the Monibuca system
- A receiver task is started to handle incoming media data
- The media data is processed and made available to other plugins
Subscriber Connection
When a subscriber connects:
- The connection is authenticated using the configured passphrase
- A new subscriber is created in the Monibuca system
- A sender task is started to handle outgoing media data
- The media data is sent to the client
Integration with Monibuca Core
The SRT plugin integrates with the Monibuca core system through several mechanisms:
- Plugin registration via
m7s.InstallPlugin
- Task system for connection handling
- Publisher/Subscriber interfaces for media handling
- Integration with the core streaming system
Security Features
The SRT implementation includes several security features:
- Optional passphrase-based encryption
- Stream ID validation
- Connection type verification (publish/subscribe)
Summary
The SRT protocol implementation in Monibuca provides a robust foundation for secure streaming media applications. It supports:
- Full SRT protocol with encryption capabilities
- Publishing and playing operations
- Custom port configuration
- Secure connections with passphrase protection
- Seamless integration with other Monibuca plugins
This implementation enables Monibuca to interact with a wide range of SRT clients, including media encoders, players, and other streaming servers.