Skip to content

v2.0.79: Add SRT (Secure Reliable Transport) support for TS streaming (#1388)

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Apr 15:41
9a270d9
### Add SRT (Secure Reliable Transport) support for TS streaming

This PR integrates the SRT library as an alternative transport between SAT>IP client and server, providing reliable, low-latency delivery over lossy networks.

#### Key Changes & Improvements:

**1. Refactored Connection Model:**
* **Server (Listener):** The server now hosts an SRT listener on the RTSP port (UDP). It uses a "pre-accept" callback to queue incoming connections.
* **Client (Caller):** The client initiates the SRT connection. It generates a random `srt_streamid` used to correlate the SRT transport with the RTSP session.
* **Correlation:** The `srt_streamid` is passed via the RTSP `Transport` header (`RTP/AVP/SRT;srt_streamid=...`) and during the SRT handshake (`SRTO_STREAMID`).

**2. Threadless Client Architecture:**
* Eliminated the dedicated SRT receiver thread and pipe in `satipc.cpp`.
* The SRT socket is now integrated directly into the main `poll()` loop by using its underlying UDP file descriptor, improving efficiency and reducing resource overhead.

**3. Performance & Stability:**
* **Latency:** Increased default SRT latency to **1000ms** to ensure better performance across WAN and high-loss environments.
* **Optimized Chunking:** Data is chunked into **1316 bytes** (7x188 TS packets) to fit perfectly within standard MTU/UDP limits.
* **Socket Reuse:** Implemented a pending connection pool on the server to allow fast reuse of connected SRT sockets during channel changes.

**4. Server-side (stream.cpp & srt.cpp):**
* New `STREAM_RTSP_SRT` type.
* Dedicated `srt.cpp` for listener lifecycle and connection matching.
* `flush_stream()` handles raw TS delivery over SRT without RTP headers.

**5. Client-side (satipc.cpp):**
* Support for `^` prefix on `-s` to trigger SRT (e.g., `-s ^dvbc:host:port`).
* Integrated SRT socket handling into the unified `socketworks` event loop.

**6. Build System:**
* Conditional compilation via `SRT` (CMake) and `DISABLE_SRT` (Code) flags.
* Improved auto-detection of `libsrt`.
* Added SRT support to the automated test suite.