Initialization
The MultiProtoServer constructor creates and configures a StreamingServer instance, enables the desired protocols, registers event handlers, and starts the server.
server = new VAST.Network.StreamingServer(20);
The constructor parameter specifies the maximum number of concurrent connections. Adjust this value based on expected load.
RTMP
Enabled via the VAST.RTMP library. The RTMP server accepts publishers and clients on the standard RTMP port (1935). The RtmpApplication property defines the application name used in RTMP URLs.
server.EnableRtmp = true;
server.RtmpServerParameters.RtmpEndPoints.Add(new IPEndPoint(IPAddress.Any, 1935));
server.RtmpServerParameters.RtmpApplication = "live";
To enable RTMPS (RTMP over TLS), uncomment the secure endpoint and assign a valid certificate thumbprint (see TLS Certificates):
server.RtmpServerParameters.RtmpsEndPoints.Add(new IPEndPoint(IPAddress.Any, 1936));
Clients connect via rtmp://server:1935/live/<name> or rtmps://server:1936/live/<name>.
RTSP
Enabled via the VAST.RTSP library. The RTSP server accepts publishers and clients on the standard RTSP port (554). The AllowedRtpTransports property controls which RTP transports are accepted (UDP, TCP interleaved, HTTP tunnel).
server.EnableRtsp = true;
server.RtspServerParameters.AllowedRtpTransports = VAST.RTP.RtpTransportType.Any;
server.RtspServerParameters.RtspEndPoints.Add(new IPEndPoint(IPAddress.Any, 554));
To enable RTSPS (RTSP over TLS), uncomment the secure endpoint:
server.RtspServerParameters.RtspsEndPoints.Add(new IPEndPoint(IPAddress.Any, 322));
Clients connect via rtsp://server/<name> or rtsps://server:322/<name>.
SRT
Enabled via the VAST.SRT library. SRT uses instance-based configuration where each SrtServerInstanceParameters defines a separate listener with its own settings.
Full Instance (Default)
A full instance handles an arbitrary number of publishing points and accepts both publishers and clients. The stream ID in the SRT URI determines which publishing point to connect to.
server.EnableSrt = true;
var srtInstance = new VAST.SRT.SrtServerInstanceParameters
{
AllowFileTransfers = true
};
server.SrtServerParameters.Instances.Add(srtInstance);
By default, the instance listens on IPAddress.Any and IPAddress.IPv6Any on port 21330. Clients connect via srt://server:21330?streamid=<name>.
Custom Endpoint
To listen on a specific port or interface:
var srtInstance = new VAST.SRT.SrtServerInstanceParameters();
srtInstance.EndPoints.Clear();
srtInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 9000));
server.SrtServerParameters.Instances.Add(srtInstance);
Encrypted Instance
Enable AES encryption by setting a passphrase (10-79 characters):
var srtInstance = new VAST.SRT.SrtServerInstanceParameters();
srtInstance.EndPoints.Clear();
srtInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 21331));
srtInstance.Passphrase = "mysecretpassphrase";
srtInstance.EncryptionKeyLength = 32; // 256-bit AES (default is 16 = 128-bit)
server.SrtServerParameters.Instances.Add(srtInstance);
Simple Instance
A simple instance handles a single pre-defined publishing path with a fixed flow direction. Use this for peers that do not support the SRT stream ID concept.
Receiving from a remote publisher:
var srtInstance = new VAST.SRT.SrtServerInstanceParameters
{
IsSimpleInstance = true,
PublishingPath = "camera1",
FlowDirection = VAST.Common.MediaFlowDirection.Input
};
srtInstance.EndPoints.Clear();
srtInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 10001));
server.SrtServerParameters.Instances.Add(srtInstance);
Serving to a remote client:
var srtInstance = new VAST.SRT.SrtServerInstanceParameters
{
IsSimpleInstance = true,
PublishingPath = "stream1",
FlowDirection = VAST.Common.MediaFlowDirection.Output
};
srtInstance.EndPoints.Clear();
srtInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 10002));
server.SrtServerParameters.Instances.Add(srtInstance);
Rendezvous Handshake
For peer-to-peer scenarios where both sides initiate connections simultaneously:
var srtInstance = new VAST.SRT.SrtServerInstanceParameters
{
IsSimpleInstance = true,
PublishingPath = "stream1",
FlowDirection = VAST.Common.MediaFlowDirection.Input,
HandshakeMode = VAST.SRT.SrtHandshakeMode.Rendezvous,
RemoteEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.200"), 21330)
};
server.SrtServerParameters.Instances.Add(srtInstance);
Latency Strategy
Control how the receiver handles packet delivery timing:
var srtInstance = new VAST.SRT.SrtServerInstanceParameters
{
LatencyStrategy = VAST.SRT.SrtLatencyStrategy.Minimal
};
server.SrtServerParameters.Instances.Add(srtInstance);
| Strategy | Description |
|---|---|
| Fixed | Maintains specified latency for smooth delivery (default) |
| Minimal | Delivers frames as soon as possible after last consecutive packet arrives |
| Zero | Minimal retransmission logic for lowest possible latency |
Multiple Instances
You can add multiple instances with different settings to the same server. For example, an unencrypted instance on port 21330 and an encrypted instance on port 21331:
server.EnableSrt = true;
var publicInstance = new VAST.SRT.SrtServerInstanceParameters();
publicInstance.EndPoints.Clear();
publicInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 21330));
var secureInstance = new VAST.SRT.SrtServerInstanceParameters();
secureInstance.EndPoints.Clear();
secureInstance.EndPoints.Add(new IPEndPoint(IPAddress.Any, 21331));
secureInstance.Passphrase = "mysecretpassphrase";
server.SrtServerParameters.Instances.Add(publicInstance);
server.SrtServerParameters.Instances.Add(secureInstance);
Warning
Each SRT instance must listen on its own unique port. Endpoint ports of different instances must not overlap, otherwise the server will fail to start.
HTTP Server
A shared HTTP server provides the transport for WebRTC, MPEG-DASH, HLS, TS over HTTP, MJPEG over HTTP, PCM over WebSocket, and the JSON API. It is enabled automatically when any of these protocols are active.
The HTTP server is based on System.Net.HttpListener (and essentially on HTTP.sys on Windows). For Kestrel-based hosting, see the ASP.NET Core Razor and ASP.NET Core Blazor demos.
server.EnableHttp = true;
server.HttpServerParameters = new VAST.HTTP.HttpServerParameters
{
HttpPorts = { 8888 },
};
To enable HTTPS, uncomment the secure port:
server.HttpServerParameters.HttpsPorts.Add(8889);
Note
On Windows the HTTP server uses Microsoft HTTP.sys and requires administrator privileges.
WebRTC
Enabled via the VAST.WebRTC library. The WebRTC server uses the shared HTTP server for signaling and exchanges media via ICE/DTLS/SRTP.
server.EnableWebRtc = true;
server.WebRtcServerParameters = new VAST.WebRTC.WebRtcServerParameters
{
WebRtcPath = "/rtc",
IceServers = "stun:stun.l.google.com:19302",
MediaTransport = VAST.WebRTC.WebRtcTransport.Auto,
VideoTranscoding = VAST.Common.MediaTranscodingMode.TranscodeIncompatible,
};
The VideoTranscoding property controls whether video is transcoded for browser compatibility (e.g., H.265 to H.264). TranscodeIncompatible transcodes only when the source codec is not supported by the browser.
TURN Server
For WebRTC connections behind NAT, the sample includes an optional TURN server using the VAST.ICE library. Replace publicIPv4 with your actual public IP address to activate it:
string publicIPv4 = "YOUR_PUBLIC_IPV4_ADDRESS";
server.WebRtcServerParameters.IceServers = $"turn:user:password@{publicIPv4}:3478";
var credentials = new Dictionary<string, string>();
credentials.Add("user", "password");
var turnPars = new VAST.ICE.TurnServerParameters
{
UserCredentials = credentials,
PublicIPv4Address = IPAddress.Parse(publicIPv4)
};
var turnServer = new VAST.ICE.TurnServer(turnPars);
turnServer.Start();
The TURN server supports IPv6 dual-stack and optional TLS endpoints.
MPEG-DASH
Enabled via the VAST.DASH library. The DASH server uses the shared HTTP server to deliver MPD manifests and fragmented MP4 segments.
server.EnableMpegDash = true;
server.DashServerParameters = new VAST.DASH.DashServerParameters
{
MpegDashPath = "/dash"
};
Clients access streams via http://server:8888/dash/<name>.
HLS
Enabled via the VAST.HLS library. The HLS server uses the shared HTTP server to deliver M3U8 playlists and media segments. Supports both traditional HLS and Low-Latency HLS.
server.EnableHls = true;
server.HlsServerParameters = new VAST.HLS.HlsServerParameters
{
HlsPath = "/hls",
EnableLowLatency = false
};
Set EnableLowLatency to true for LL-HLS with partial segments and sub-second latency.
Clients access streams via http://server:8888/hls/<name>.
TS over HTTP
Enabled via the VAST.TS library. Delivers a continuous MPEG-2 Transport Stream over HTTP. Disabled by default in the sample.
server.EnableTsHttp = false;
server.TsHttpServerParameters = new VAST.TS.TsHttpServerParameters
{
TsHttpPath = "/ts",
};
MJPEG over HTTP
Enabled via the VAST.Image library. Delivers a Motion JPEG stream over HTTP. Disabled by default in the sample.
server.EnableMjpeg = false;
server.MjpegServerParameters = new VAST.Image.JPEG.MjpegServerParameters
{
MjpegPath = "/mjpeg",
};
PCM over WebSocket
Enabled via the VAST.Audio library. Delivers raw PCM audio over WebSocket. Disabled by default in the sample.
server.EnableWsPcm = false;
server.WsPcmServerParameters = new VAST.Audio.WsPcmServerParameters
{
WsPcmPath = "/pcm",
};
JSON API
Enabled via the VAST.Network library. Provides a REST API for monitoring and controlling the server at runtime. See JSON API for details.
server.EnableJsonApi = true;
server.ApiServerParameters.Users.Add("admin", "admin");
TLS Certificates
To enable secure protocols (RTMPS, RTSPS, HTTPS, TURN over TLS), assign a certificate thumbprint:
server.CertificateThumbprint = "YOUR_CERTIFICATE_THUMBPRINT";
This thumbprint must correspond to a certificate installed in the local machine certificate store. All secure endpoints across all protocols share this certificate.
Note
For HTTP server on Windows specifying CertificateThumbprint alone is not sufficient. You must also configure URL reservations or SSL certificates using netsh:
// either create urlacl rule allowing HTTP access to the port
netsh http add urlacl url=http://*:<port>/ user=Everyone
// or associate the certificate to your application explicitly
netsh http add sslcert ipport=0.0.0.0:<https-port> certhash=<thumbprint> appid={<application-guid>}
Event Handlers and Start
After configuring all protocols, register event handlers and start the server:
server.PublishingPointRequested += Server_PublishingPointRequested;
server.Authorize += Server_Authorize;
server.PublisherConnected += Server_PublisherConnected;
server.ClientConnected += Server_ClientConnected;
server.FileTransferRequestedHandler = Server_FileTransferRequestedHandler;
server.Error += Server_Error;
server.PublishingPointDisposing += Server_PublishingPointDisposing;
server.Disconnected += Server_Disconnected;
server.Start();
For detailed event handler documentation, see Server Event Handlers.
Conditional Compilation
Each protocol section in the source code is wrapped in conditional compilation directives (#if VAST_FEATURE_RTMP, #if VAST_FEATURE_RTSP, etc.). If a protocol library is not referenced by the project, its code is excluded at compile time. This allows the same source file to be used across different license configurations without modification.
See Also
- Sample Applications — overview of all demo projects
- .NET Server Demo — parent page with setup instructions, license key configuration, and access URL reference
- Multi-Protocol Server — overview
- VAST.Network Library — StreamingServer API reference