Table of Contents

VAST.Common.Ext.ASP

The VAST.Common.Ext.ASP assembly provides ASP.NET Core integration for VASTreaming applications, enabling you to host streaming servers (RTSP, SRT, HLS, WebRTC) within ASP.NET Core web applications using Kestrel or other ASP.NET Core hosting models.

Overview

Feature Description
HTTP Context Adapter Bridges ASP.NET Core HttpContext to VASTreaming interfaces
WebSocket Support Enables WebSocket-based streaming protocols
Request/Response Abstraction Unified HTTP handling for streaming servers
Kestrel Integration Run streaming servers alongside ASP.NET Core APIs

Purpose

This library serves as an integration layer between ASP.NET Core and VASTreaming's streaming infrastructure. It allows you to:

  • Host streaming servers within existing ASP.NET Core applications
  • Share ports between REST APIs and streaming endpoints
  • Leverage ASP.NET Core's middleware pipeline for streaming
  • Use Kestrel's high-performance HTTP handling for media delivery
Note

This library provides HTTP integration only. For media encoding, decoding, and capture functionality, you must also reference a platform-specific extension library (such as VAST.Common.Ext.ASP.Win32 on Windows or VAST.Common.Ext.ASP.Linux on Linux).

Requirements

  • ASP.NET Core: 6.0 or later
  • Platform: Any platform supported by ASP.NET Core
  • .NET: .NET 6.0 or later
  • Dependencies: VAST.Common

Architecture

┌─────────────────────────────────────────────────────────────┐
│                   ASP.NET Core Application                  │
├─────────────────────────────────────────────────────────────┤
│  Kestrel / IIS / Other Host                                 │
├─────────────────────────────────────────────────────────────┤
│  ASP.NET Core Middleware Pipeline                           │
├─────────────────────────────────────────────────────────────┤
│  VAST.Common.Ext.ASP (HTTP Context Adapter)                 │
├─────────────────────────────────────────────────────────────┤
│  VASTreaming Servers (HLS, DASH, WebRTC, etc.)              │
└─────────────────────────────────────────────────────────────┘

HTTP Context Integration

The library provides AspHttpRequestContext which adapts ASP.NET Core's HttpContext to VASTreaming's IHttpRequestContext interface.

Features

Feature Support
HTTP Methods GET, POST, PUT, DELETE, OPTIONS, etc.
Request Headers Full access via NameValueCollection
Response Headers Add custom headers
Request Body Stream-based access
Response Body Stream-based output
WebSocket Upgrade Native support
Redirects 301/302 redirects
Keep-Alive Connection persistence

Request Properties

The HTTP request adapter provides access to:

Response Properties

The HTTP response adapter provides:

WebSocket Support

The library fully supports WebSocket connections, enabling WebSocket-based streaming protocols.

WebSocket support must be enabled to utilize this function:

public class Program
{
    public static void Main(string[] args)
    {
        ...
        app.UseWebSockets(new WebSocketOptions());
        ...
    }
}

Usage with Streaming Servers

public class Program
{
    public static void Main(string[] args)
    {
        ...
		
        builder.WebHost.UseKestrel(options =>
        {
            // synchronous operations must be enabled because the HTTP based servers use them
            options.AllowSynchronousIO = true;
            ...
        });

        ...

        MultiProtoServer multiProtoServer = new();
        app.Run(async (context) =>
        {
            // dispatch unprocessed HTTP requests to the VASTreaming engine
            await multiProtoServer.HttpDispatcher.DispatchRequest(new VAST.HTTP.AspHttpRequestContext(context));
        });

        ...
    }
}

See the server demo for the details of MultiProtoServer class.

Limitations

The ASP extension provides HTTP integration only. The following features are not supported directly by this library:

Feature Status Solution
Video Encoding Not supported Use platform-specific library
Video Decoding Not supported Use platform-specific library
Audio Encoding Not supported Use platform-specific library
Audio Decoding Not supported Use platform-specific library
Camera Capture Not supported Use platform-specific library
Audio Capture Not supported Use platform-specific library
Screen Capture Not supported Use platform-specific library
OpenGL Processing Not supported Use platform-specific library

To enable these features, reference the appropriate platform-specific library alongside VAST.Common.Ext.ASP:

Troubleshooting

Common Issues

Issue Cause Solution
Request times out Long-running streaming Disable request timeout in Kestrel
WebSocket fails Missing WebSocket middleware Add app.UseWebSockets()
Large uploads fail Request size limit Set MaxRequestBodySize = null
Connection drops Rate limiting Disable MinResponseDataRate

See Also