.NET Server Demo
The Server Demo shows how to use the StreamingServer in user applications, how to use stand-alone single protocol servers, and demonstrates how to implement receiving and transmitting data without visualization.
The demo contains projects for Windows, Linux, and macOS, already configured with platform-specific extensions for convenience.
Requirements
On Windows the Server Demo requires administrator privileges because it uses Microsoft HTTP.sys server which can only be started by an administrator.
Setup
There are several important initialization steps in Program.Main that should be copied when integrating VASTreaming into your project.
Log Initialization
VAST.Common.Log.LogFileName = System.IO.Path.Combine(logFolderName, logFileName);
VAST.Common.Log.LogLevel = VAST.Common.Log.Level.Debug;
License Key
For binary licenses (annual subscription or lifetime license), set the license key:
// enter the license
VAST.Common.License.Key = "YOUR_LICENSE_KEY";
Source code licenses do not need this line.
Sample Selection
Choose which sample to run by uncommenting the desired line:
// TODO: choose which server you want to run
MultiProtoServer sample = new MultiProtoServer();
//SimpleRtmpServer sample = new SimpleRtmpServer();
//SimpleRtspServer sample = new SimpleRtspServer();
//SendSample1 sample = new SendSample1();
//SendSample2 sample = new SendSample2();
//ReceiveSample sample = new ReceiveSample("rtp://127.0.0.1:10000");
//SimpleWebRtcServer sample = new SimpleWebRtcServer();
//FileReaderSample sample = new FileReaderSample(@"C:\path\to\file.mp4");
//FileWriterSample1 sample = new FileWriterSample1("rtsp://127.0.0.1/test", @"C:\path\to\file.mp4");
//FileWriterSample2 sample = new FileWriterSample2(@"C:\path\to\file.mp4");
//IsoFragmentWriterSample sample = new IsoFragmentWriterSample("rtsp://127.0.0.1/test");
The MultiProtoServer is uncommented by default.
Available Samples
| Sample | Description |
|---|---|
| Multi-Protocol Server | Multi-protocol streaming server with all VASTreaming server components |
| Simple RTSP Server | Stand-alone RTSP server |
| Simple RTMP Server | Stand-alone RTMP server |
| Simple WebRTC Server | Stand-alone WebRTC signaling server |
| Receive Sample | Receive and decode streams from remote sources |
| Send Sample 1 | Send pre-encoded audio to a remote server |
| Send Sample 2 | Send pre-encoded audio and video to a remote server |
| MP4 Reader Sample | Read and decode media files |
| MP4 Writer Sample 1 | Record streams to files (simple approach) |
| MP4 Writer Sample 2 | Record streams to files (manual control) |
| MP4 Fragment Writer Sample | Generate MP4 fragments for streaming |
MultiProtoServer
MultiProtoServer demonstrates the multi-protocol streaming server with all server components provided by VASTreaming libraries. For detailed documentation, see Multi-Protocol Server.
SimpleRtspServer
SimpleRtspServer shows how to use RTSP server in stand-alone mode without the multi-protocol server. The sample demonstrates manual media flow handling between connected peers. For detailed documentation, see Simple RTSP Server.
For automatic media flow handling, use StreamingServer instead.
SimpleRtmpServer
SimpleRtmpServer shows how to use RTMP server in stand-alone mode. Like SimpleRtspServer, it demonstrates manual media flow handling. For detailed documentation, see Simple RTMP Server.
For automatic media flow handling, use StreamingServer instead.
SimpleWebRtcServer
SimpleWebRtcServer shows how to use the stand-alone WebRTC signaling server. This server is intended for creating and controlling rooms with 2 or more users. Media data is exchanged directly among connected peers. For detailed documentation, see Simple WebRTC Server.
ReceiveSample
ReceiveSample demonstrates how to use IMediaSource directly to receive data from a remote peer and optionally decode it for further processing. For detailed documentation, see Receive Sample.
The sample shows how to:
- Create decoders for video (to BGRA) and audio (to PCM S16)
- Handle stream detection via
NewStreamevent - Process decoded samples via
NewSampleevent - Start the source after receiving
Openedstate
SendSample1
SendSample1 demonstrates how to use IMediaSink directly to send pre-encoded audio data to a remote server. For detailed documentation, see Send Sample 1.
SendSample2
SendSample2 extends SendSample1 by demonstrating how to send both audio and video streams simultaneously using pre-encoded H.264 video and AAC audio. For detailed documentation, see Send Sample 2.
FileReaderSample
FileReaderSample demonstrates reading and decoding media files. For detailed documentation, see MP4 Reader Sample.
- ISO/MP4 file reading with IsoSource
- Playback speed control
- Seek operations
- Video decoding to BGRA
- Audio decoding to PCM S16
FileWriterSample1
FileWriterSample1 demonstrates the simple approach to recording streams to files using MediaSession. For detailed documentation, see MP4 Writer Sample 1.
FileWriterSample2
FileWriterSample2 demonstrates recording with manual control over the writing process. For detailed documentation, see MP4 Writer Sample 2.
- VirtualNetworkSource for custom media pushing
- Manual H.264/AAC buffer management
- Frame-by-frame writing with timestamp control
IsoFragmentWriterSample
IsoFragmentWriterSample demonstrates MP4 fragmentation for streaming scenarios (HLS/DASH). For detailed documentation, see MP4 Fragment Writer Sample.
- Initialization segment generation
- Media fragment creation at keyframes
- In-memory fragment handling with VersatileBufferStream
Access URLs
When running MultiProtoServer or standalone servers with default settings, streams are accessible at:
| Protocol | URL Format |
|---|---|
| RTMP | rtmp://127.0.0.1/live/<publishing-path> |
| RTSP | rtsp://127.0.0.1/<publishing-path> |
| SRT | srt://127.0.0.1:21330?streamid=<publishing-path> |
| HLS | http://127.0.0.1:8888/hls/<publishing-path> |
| MPEG-DASH | http://127.0.0.1:8888/dash/<publishing-path> |
| MJPEG | http://127.0.0.1:8888/mjpeg/<publishing-path> (disabled by default) |
| TS over HTTP | http://127.0.0.1:8888/ts/<publishing-path> (disabled by default) |
See Also
Samples
- Multi-Protocol Server - Multi-protocol streaming server
- Simple RTSP Server - Stand-alone RTSP server
- Simple RTMP Server - Stand-alone RTMP server
- Simple WebRTC Server - Stand-alone WebRTC signaling server
- Receive Sample - Receive and decode streams
- Send Sample 1 - Send pre-encoded audio
- Send Sample 2 - Send pre-encoded audio and video
- MP4 Reader Sample - Read and decode media files
- MP4 Writer Sample 1 - Record streams (simple)
- MP4 Writer Sample 2 - Record streams (manual control)
- MP4 Fragment Writer Sample - Generate MP4 fragments
Related Documentation
- Sample Applications - Overview of all demo projects
- VAST.Network Library - StreamingServer documentation