Spangle.Net.Transport.SRT 0.2.0

dotnet add package Spangle.Net.Transport.SRT --version 0.2.0
                    
NuGet\Install-Package Spangle.Net.Transport.SRT -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Spangle.Net.Transport.SRT" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Spangle.Net.Transport.SRT" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Spangle.Net.Transport.SRT" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Spangle.Net.Transport.SRT --version 0.2.0
                    
#r "nuget: Spangle.Net.Transport.SRT, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Spangle.Net.Transport.SRT@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Spangle.Net.Transport.SRT&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Spangle.Net.Transport.SRT&version=0.2.0
                    
Install as a Cake Tool

Spangle.Net.Transport.SRT

An SRT (Secure Reliable Transport) listener and duplex-pipe transport for .NET, built on System.IO.Pipelines. Part of the Spangle streaming media server family.

The NuGet package is fully self-contained: the native libsrt (statically linked with mbedTLS) ships inside for win-x64, win-arm64, linux-x64, linux-arm64 and osx-arm64. No system packages, no vcpkg, nothing to install.

Features

  • Truly asynchronous accept — a dedicated thread drives srt_epoll and feeds a bounded channel; await AcceptSRTClientAsync() never blocks a thread pool thread
  • Backpressure-aware receive — when the consumer falls behind, the socket is masked out of the epoll set until the pipe drains; memory stays bounded per connection while libsrt buffers within its own receive window
  • Zero staging copiessrt_recvmsg writes directly into the pipe's buffer
  • IDuplexPipe surface — consume SRT streams with the same PipeReader code you would use for any other transport
  • Stream ids — the sender's streamid (the SRT counterpart of an RTMP stream key) surfaces as SRTClient.StreamId, ready for routing and publish authorization
  • Encryption — set SRTListenerOptions.Passphrase and only senders presenting the same passphrase can connect; payloads are AES-encrypted on the wire (mbedTLS backend, PBKDF2 key derivation)

Getting Started

dotnet add package Spangle.Net.Transport.SRT
using System.Net;
using Spangle.Net.Transport.SRT;

var listener = new SRTListener(IPEndPoint.Parse("0.0.0.0:9998"), new SRTListenerOptions
{
    Passphrase = "correct horse battery staple", // optional; 10-79 bytes
});
listener.Start();

while (true)
{
    SRTClient client = await listener.AcceptSRTClientAsync(ct);
    // e.g. "srt://host:9998?streamid=live/abc" => route to stream "live/abc"
    Console.WriteLine($"accepted: {client.StreamId}");
    _ = ConsumeAsync(client, ct);
}

static async Task ConsumeAsync(SRTClient client, CancellationToken ct)
{
    using (client)
    {
        while (true)
        {
            var result = await client.Pipe.Input.ReadAsync(ct);
            // e.g. feed result.Buffer (MPEG-TS packets) to a demuxer
            client.Pipe.Input.AdvanceTo(result.Buffer.End);
            if (result.IsCompleted) break;
        }
    }
}

Push a test stream with an SRT-capable ffmpeg:

ffmpeg -re -f lavfi -i testsrc2 -c:v libx264 -f mpegts srt://127.0.0.1:9998

Status

Pre-1.0: the API surface is small and still evolving. Listener/receive comes first; client-side connect is not exposed yet (open an issue if you need it - it will be prioritized immediately).

Native pieces

Component Version License
libsrt pinned tag (see release notes) MPL-2.0
Mbed TLS 3.6 LTS Apache-2.0

Both are statically linked, unmodified, into a single srt_interop library per RID and rebuilt from source by CI on native runners for every target. See THIRD-PARTY-NOTICES.txt for the details required by their licenses.

License

This library is under the MIT License. See LICENSE. The bundled native components remain under their own licenses as described above.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 70 7/10/2026
0.1.0 43 7/10/2026