Skip to content

Commit

Permalink
chore: add documentation comments to public classes, interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
josephnhtam committed Oct 27, 2024
1 parent 8391388 commit 8c9f783
Show file tree
Hide file tree
Showing 139 changed files with 2,851 additions and 56 deletions.
29 changes: 29 additions & 0 deletions src/LiveStreamingServerNet.AdminPanelUI/AdminPanelUIOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,42 @@

namespace LiveStreamingServerNet.AdminPanelUI
{
/// <summary>
/// Configuration options for the Admin Panel UI.
/// </summary>
public class AdminPanelUIOptions
{
/// <summary>
/// Base path for the admin panel UI.
/// Default: "/ui".
/// </summary>
public string BasePath { get; set; } = "/ui";

/// <summary>
/// Base URI for stream-related API endpoints.
/// Default: "/api/v1/streams".
/// </summary>
public string StreamsBaseUri { get; set; } = "/api/v1/streams";

/// <summary>
/// Indicates whether HTTP FLV preview functionality is enabled.
/// </summary>
public bool HasHttpFlvPreview { get; set; }

/// <summary>
/// URI pattern for HTTP FLV streams.
/// Default: "{streamPath}.flv".
/// </summary>
public string HttpFlvUriPattern { get; set; } = "{streamPath}.flv";

/// <summary>
/// File provider for serving static files.
/// </summary>
public IFileProvider? FileProvider { get; set; }

/// <summary>
/// Provider for determining content types of served files.
/// </summary>
public IContentTypeProvider? ContentTypeProvider { get; set; }

public AdminPanelUIOptions()
Expand Down
21 changes: 19 additions & 2 deletions src/LiveStreamingServerNet.AdminPanelUI/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@

namespace LiveStreamingServerNet.AdminPanelUI
{
/// <summary>
/// Contains extension methods for WebApplication configurations
/// </summary>
public static class Extensions
{
public static WebApplication UseAdminPanelUI(this WebApplication app, AdminPanelUIOptions? options = null)
/// <summary>
/// Adds the Admin Panel UI middleware to the application's request pipeline.
/// </summary>
/// <param name="app">The WebApplication instance to configure.</param>
/// <returns>The WebApplication instance for method chaining.</returns>
public static WebApplication UseAdminPanelUI(this WebApplication app)
=> UseAdminPanelUI(app, new AdminPanelUIOptions());

/// <summary>
/// Adds the Admin Panel UI middleware to the application's request pipeline.
/// </summary>
/// <param name="app">The WebApplication instance to configure.</param>
/// <param name="options">Optional configuration options for the Admin Panel UI.</param>
/// <returns>The WebApplication instance for method chaining.</returns>
public static WebApplication UseAdminPanelUI(this WebApplication app, AdminPanelUIOptions options)
{
app.UseMiddleware<AdminPanelUIMiddleware>(options ?? new AdminPanelUIOptions());
app.UseMiddleware<AdminPanelUIMiddleware>(options);
return app;
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/LiveStreamingServerNet.Flv/Configurations/FlvConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
namespace LiveStreamingServerNet.Flv.Configurations
{
/// <summary>
/// Configuration settings for FLV streaming
/// </summary>
public class FlvConfiguration
{
/// <summary>
/// Maximum time to wait for a stream to become ready (receiving the first non-header packet).
/// Default: 15 seconds.
/// </summary>
public TimeSpan ReadinessTimeout { get; set; } = TimeSpan.FromSeconds(15);

/// <summary>
/// Timeout duration for stream continuation after interruption.
/// A value of Zero indicates no continuation allowed.
/// Default: TimeSpan.Zero.
/// </summary>
public TimeSpan StreamContinuationTimeout { get; set; } = TimeSpan.Zero;
}
}
13 changes: 13 additions & 0 deletions src/LiveStreamingServerNet.Flv/Configurations/HttpFlvOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

namespace LiveStreamingServerNet.Flv.Configurations
{
/// <summary>
/// Configuration options for HTTP FLV streaming.
/// </summary>
public class HttpFlvOptions
{
/// <summary>
/// Resolves stream paths for HTTP FLV requests.
/// If not set, default path resolution will be used.
/// </summary>
public IStreamPathResolver? StreamPathResolver { get; set; }

/// <summary>
/// Callback function executed before sending the FLV response.
/// Returns true to continue with the response, false to abort.
/// Allows for custom validation and response preparation.
/// </summary>
public Func<FlvStreamContext, Task<bool>>? OnPrepareResponse { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
namespace LiveStreamingServerNet.Flv.Configurations
{
/// <summary>
/// Configuration settings for media streaming buffer management.
/// </summary>
public class MediaStreamingConfiguration
{
/// <summary>
/// Target number of media packets to maintain in the buffer.
/// Default: 64 packets.
/// </summary>
public int TargetOutstandingMediaPacketsCount { get; set; } = 64;

/// <summary>
/// Target total size of buffered media packets in bytes.
/// Default: 1MB (1,048,576 bytes).
/// </summary>
public long TargetOutstandingMediaPacketsSize { get; set; } = 1024 * 1024;

/// <summary>
/// Maximum number of media packets allowed in the buffer.
/// When exceeded, newer packets will be dropped.
/// Default: 512 packets.
/// </summary>
public int MaxOutstandingMediaPacketsCount { get; set; } = 512;

/// <summary>
/// Maximum total size of buffered media packets in bytes.
/// When exceeded, newer packets will be dropped.
/// Default: 8MB (8,388,608 bytes).
/// </summary>
public long MaxOutstandingMediaPacketsSize { get; set; } = 8 * 1024 * 1024;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,28 @@

namespace LiveStreamingServerNet.Flv.Configurations
{
/// <summary>
/// Configuration options for WebSocket FLV streaming.
/// </summary>
public class WebSocketFlvOptions
{
/// <summary>
/// Resolves stream paths for WebSocket FLV requests.
/// If not set, default path resolution will be used.
/// </summary>
public IStreamPathResolver? StreamPathResolver { get; set; }

/// <summary>
/// Context for accepting WebSocket connections.
/// Allows configuration of WebSocket-specific options like subprotocols and buffer sizes.
/// </summary>
public WebSocketAcceptContext? WebSocketAcceptContext { get; set; }

/// <summary>
/// Callback function executed before establishing the WebSocket connection.
/// Returns true to accept the connection, false to reject.
/// Allows for custom validation and connection preparation.
/// </summary>
public Func<FlvStreamContext, Task<bool>>? OnPrepareResponse { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/LiveStreamingServerNet.Flv/Contracts/IStreamPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

namespace LiveStreamingServerNet.Flv.Contracts
{
/// <summary>
/// Interface for resolving stream paths and arguments from HTTP requests.
/// </summary>
public interface IStreamPathResolver
{
/// <summary>
/// Attempts to extract the stream path and arguments from the HTTP request.
/// </summary>
/// <param name="context">The HTTP context containing the request information.</param>
/// <param name="streamPath">The resolved stream path.</param>
/// <param name="streamArguments">Dictionary of additional stream arguments extracted from the request.</param>
/// <returns>True if path resolution was successful, false otherwise.</returns>
bool ResolveStreamPathAndArguments(HttpContext context, out string streamPath, out IDictionary<string, string> streamArguments);
}
}
5 changes: 5 additions & 0 deletions src/LiveStreamingServerNet.Flv/DefaultStreamPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace LiveStreamingServerNet.Flv
{
/// <summary>
/// Default implementation of IStreamPathResolver that handles standard FLV stream paths.
/// Expects paths ending in '.flv' and converts query parameters to stream arguments.
/// e.g. '/live/stream.flv?arg1=value1&arg2=value2'
/// </summary>
public class DefaultStreamPathResolver : IStreamPathResolver
{
public bool ResolveStreamPathAndArguments(HttpContext context, out string streamPath, out IDictionary<string, string> streamArguments)
Expand Down
6 changes: 6 additions & 0 deletions src/LiveStreamingServerNet.Flv/FlvStreamContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@

namespace LiveStreamingServerNet.Flv
{
/// <summary>
/// Record containing context information for an FLV stream request.
/// </summary>
/// <param name="HttpContext">The HTTP context of the request.</param>
/// <param name="StreamPath">The resolved path of the requested stream.</param>
/// <param name="StreamArguments">Collection of key-value pairs containing stream parameters from the request.</param>
public record FlvStreamContext(HttpContext HttpContext, string StreamPath, IReadOnlyDictionary<string, string> StreamArguments);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@

namespace LiveStreamingServerNet.Flv.Installer.Contracts
{
/// <summary>
/// Interface for configuring FLV streaming settings.
/// </summary>
public interface IFlvConfigurator
{
/// <summary>
/// Configures general FLV streaming options like timeouts.
/// </summary>
/// <param name="configure">Action to modify the FLV configuration.</param>
/// <returns>The configurator instance for method chaining.</returns>
IFlvConfigurator Configure(Action<FlvConfiguration>? configure);

/// <summary>
/// Configures media streaming settings like buffer sizes and packet limits.
/// </summary>
/// <param name="configure">Action to modify the media streaming configuration.</param>
/// <returns>The configurator instance for method chaining.</returns>
IFlvConfigurator ConfigureMediaStreaming(Action<MediaStreamingConfiguration>? configure);
}
}
85 changes: 81 additions & 4 deletions src/LiveStreamingServerNet.Flv/Installer/FlvInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,26 @@

namespace LiveStreamingServerNet.Flv.Installer
{
/// <summary>
/// Static class providing extension methods for installing and configuring FLV streaming capabilities.
/// </summary>
public static class FlvInstaller
{
public static IRtmpServerConfigurator AddFlv(this IRtmpServerConfigurator configurator, Action<IFlvConfigurator>? configure = null)
/// <summary>
/// Adds FLV streaming support to the RTMP server configuration.
/// </summary>
/// <param name="configurator">The RTMP server configurator.</param>
/// <returns>The RTMP server configurator for method chaining.</returns>
public static IRtmpServerConfigurator AddFlv(this IRtmpServerConfigurator configurator)
=> AddFlv(configurator, null);

/// <summary>
/// Adds FLV streaming support to the RTMP server configuration.
/// </summary>
/// <param name="configurator">The RTMP server configurator.</param>
/// <param name="configure">Optional action to configure FLV-specific settings.</param>
/// <returns>The RTMP server configurator for method chaining.</returns>
public static IRtmpServerConfigurator AddFlv(this IRtmpServerConfigurator configurator, Action<IFlvConfigurator>? configure)
{
var services = configurator.Services;

Expand All @@ -46,7 +63,23 @@ public static IRtmpServerConfigurator AddFlv(this IRtmpServerConfigurator config
return configurator;
}

public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, IServer liveStreamingServer, HttpFlvOptions? options = null)
/// <summary>
/// Adds HTTP-FLV streaming middleware with a specified streaming server.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="liveStreamingServer">The live streaming server instance.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, IServer liveStreamingServer)
=> UseHttpFlv(app, liveStreamingServer, null);

/// <summary>
/// Adds HTTP-FLV streaming middleware with a specified streaming server.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="liveStreamingServer">The live streaming server instance.</param>
/// <param name="options">Optional HTTP-FLV configuration options.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, IServer liveStreamingServer, HttpFlvOptions? options)
{
if (options == null)
app.UseMiddleware<HttpFlvMiddleware>(liveStreamingServer);
Expand All @@ -56,7 +89,21 @@ public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, IServ
return app;
}

public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, HttpFlvOptions? options = null)
/// <summary>
/// Adds HTTP-FLV streaming middleware.
/// </summary>
/// <param name="app">The application builder.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app)
=> UseHttpFlv(app, options: null);

/// <summary>
/// Adds HTTP-FLV streaming middleware.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="options">Optional HTTP-FLV configuration options.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, HttpFlvOptions? options)
{
if (options == null)
app.UseMiddleware<HttpFlvMiddleware>();
Expand All @@ -66,7 +113,23 @@ public static IApplicationBuilder UseHttpFlv(this IApplicationBuilder app, HttpF
return app;
}

public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app, IServer liveStreamingServer, WebSocketFlvOptions? options = null)
/// <summary>
/// Adds WebSocket-FLV streaming middleware with a specified streaming server.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="liveStreamingServer">The live streaming server instance.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app, IServer liveStreamingServer)
=> UseWebSocketFlv(app, liveStreamingServer, null);

/// <summary>
/// Adds WebSocket-FLV streaming middleware with a specified streaming server.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="liveStreamingServer">The live streaming server instance.</param>
/// <param name="options">Optional WebSocket-FLV configuration options.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app, IServer liveStreamingServer, WebSocketFlvOptions? options)
{
if (options == null)
app.UseMiddleware<WebSocketFlvMiddleware>(liveStreamingServer);
Expand All @@ -76,6 +139,20 @@ public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app,
return app;
}

/// <summary>
/// Adds WebSocket-FLV streaming middleware.
/// </summary>
/// <param name="app">The application builder.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app)
=> UseWebSocketFlv(app, options: null);

/// <summary>
/// Adds WebSocket-FLV streaming middleware.
/// </summary>
/// <param name="app">The application builder.</param>
/// <param name="options">Optional WebSocket-FLV configuration options.</param>
/// <returns>The application builder for method chaining.</returns>
public static IApplicationBuilder UseWebSocketFlv(this IApplicationBuilder app, WebSocketFlvOptions? options = null)
{
if (options == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using LiveStreamingServerNet.KubernetesPod.Internal.Services.Contracts;
using LiveStreamingServerNet.KubernetesPod.Utilities;
using LiveStreamingServerNet.KubernetesPod.Utilities.Contracts;
using LiveStreamingServerNet.Utilities.Common;
using Microsoft.Extensions.Logging;
using System.Text.Json;
using LiveStreamingServerNet.Utilities.Common;

namespace LiveStreamingServerNet.KubernetesPod.Internal.Services
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

namespace LiveStreamingServerNet.Networking.Client.Configurations
{
/// <summary>
/// Configuration class for SSL/TLS security settings.
/// </summary>
public class SecurityConfiguration
{
/// <summary>
/// Gets or sets SSL client authentication options.
/// </summary>
public SslClientAuthenticationOptions? AuthenticationOptions { get; set; }
}
}
Loading

0 comments on commit 8c9f783

Please sign in to comment.