Table of Contents

Class HLSSettings

Namespace
VisioForge.Core.Types.Output
Assembly
VisioForge.Core.dll

Represents configuration settings specific to HLS (HTTP Live Streaming) segmentation, playlist generation, and delivery.

public sealed class HLSSettings

Inheritance

Inherited Members

Remarks

This class controls how video content is divided into segments, how playlists are generated, where output files are stored, and optionally configures a built-in HTTP server for streaming delivery. These settings are crucial for optimizing HLS streaming performance and compatibility.

Constructors

HLSSettings()

Initializes a new instance of the VisioForge.Core.Types.Output.HLSSettings class with default values.

public HLSSettings()

Remarks

Default configuration:

  • Segment duration: 10 seconds
  • Number of segments: 0 (keep all)
  • Playlist name: "playlist.m3u8"
  • Segment prefix: "part"
  • Output folder: "c:\inetpub\wwwroot\hls\"
  • Playlist type: Live
  • Custom HTTP server: Disabled
  • HTTP server port: 80

These defaults are suitable for VOD streaming from an IIS web server. Adjust settings based on your specific streaming requirements (live vs. VOD) and infrastructure.

Properties

Custom_HTTP_Server_Enabled

Gets or sets a value indicating whether the built-in lightweight HTTP server should be enabled.

public bool Custom_HTTP_Server_Enabled { get; set; }

Property Value

bool

Remarks

When enabled, the SDK creates a simple HTTP server to handle requests for the playlist and segment files. This is useful for:

  • Testing and development without setting up IIS or Apache
  • Embedded applications or scenarios where installing a full web server is impractical
  • Quick prototyping and demos

For production deployments, consider using a dedicated web server (IIS, nginx, Apache) which provides better performance, security, and features like SSL/TLS support, CDN integration, and advanced caching.

Custom_HTTP_Server_Port

Gets or sets the port number for the custom HTTP server.

public int Custom_HTTP_Server_Port { get; set; }

Property Value

int

Remarks

Common port choices:

  • 80: Standard HTTP (requires administrator privileges on Windows)
  • 8080: Alternative HTTP port (doesn't require admin privileges)
  • 8000-9000: Development/testing ports

Ensure the chosen port is not already in use by another application and that firewall rules allow incoming connections on this port if streaming to external clients.

NumSegments

Gets or sets the maximum number of segments to keep on disk for live streams.

public int NumSegments { get; set; }

Property Value

int

Remarks

For live streaming, older segments can be automatically deleted to conserve disk space. The playlist will reference only the most recent segments. A value of 0 disables automatic deletion, keeping all segments.

Common settings:

  • 0: Keep all segments (VOD or archival recording)
  • 5-10: Short DVR window for live streams
  • 30-60: Longer DVR window allowing time-shifting

OutputFolder

Gets or sets the output folder path where playlist and segment files will be stored.

public string OutputFolder { get; set; }

Property Value

string

Remarks

This folder must be writable by the application. For web delivery, it should be within your web server's document root or a location accessible via HTTP.

Ensure the folder exists before starting HLS output, or the application should create it. The path should end with a directory separator for consistency.

PartName

Gets or sets the base filename prefix for video segment files.

public string PartName { get; set; }

Property Value

string

Remarks

Segments will be named using this prefix followed by a sequential number and .ts extension. For example, with prefix "part", segments will be named: part0.ts, part1.ts, part2.ts, etc.

Choose a descriptive prefix that makes it easy to identify segments belonging to this stream if multiple streams share the same output folder.

PlaylistName

Gets or sets the filename for the HLS playlist (M3U8 file).

public string PlaylistName { get; set; }

Property Value

string

Remarks

This file contains the list of all video segments and is the entry point for HLS players. The filename should have an .m3u8 extension to ensure proper MIME type handling by web servers.

PlaylistType

Gets or sets the type of HLS playlist to generate.

public HLSPlaylistType PlaylistType { get; set; }

Property Value

HLSPlaylistType

Remarks

Live playlists are continuously updated as new segments become available, suitable for real-time broadcasts. VOD playlists contain all segments upfront and are suitable for on-demand playback of pre-recorded content.

SegmentDuration

Gets or sets the duration of each video segment in seconds.

public int SegmentDuration { get; set; }

Property Value

int

Remarks

Typical segment durations range from 2 to 10 seconds. Shorter segments provide:

  • Faster seeking and startup time
  • More frequent bitrate adaptation opportunities
  • Higher overhead (more files to manage)

Longer segments provide:

  • Better compression efficiency
  • Fewer files to manage
  • Higher latency for live streams

For live streaming, 2-6 seconds is common. For VOD, 10 seconds is typical.

Methods

Load(string)

Deserializes HLS settings from a JSON string.

public static HLSSettings Load(string json)

Parameters

json string

The JSON string containing the serialized HLS settings.

Returns

HLSSettings

A new VisioForge.Core.Types.Output.HLSSettings instance with settings restored from the JSON string.

Remarks

This method restores all HLS configuration settings from a previously saved state.

Exceptions

JsonException

Thrown when the JSON string is invalid or cannot be deserialized to an HLSSettings object.

Save()

Serializes the current HLS settings to a JSON string.

public string Save()

Returns

string

A JSON string representation of all HLS configuration settings.

Remarks

The resulting JSON can be used to restore settings later using the VisioForge.Core.Types.Output.HLSSettings.Load(System.String) method. All segmentation, playlist, and server settings are included in the serialization.