-
Notifications
You must be signed in to change notification settings - Fork 35
Exposing flv client #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/LiveStreamingServerNet.Flv/Contracts/IFlvClientHandle.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
/// <summary> | ||
/// Represents a handle to an FLV client connection, providing methods to manage the connection. | ||
/// </summary> | ||
public interface IFlvClientHandle : IFlvClientInfo | ||
{ | ||
/// <summary> | ||
/// Stops the FLV client. | ||
/// </summary> | ||
void Stop(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/LiveStreamingServerNet.Flv/Contracts/IFlvClientInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
/// <summary> | ||
/// Provides information about an FLV client connection. | ||
/// </summary> | ||
public interface IFlvClientInfo | ||
{ | ||
/// <summary> | ||
/// Gets the unique identifier for the FLV client. | ||
/// </summary> | ||
string ClientId { get; } | ||
|
||
/// <summary> | ||
/// Gets the resolved path of the requested stream. | ||
/// </summary> | ||
string StreamPath { get; } | ||
|
||
/// <summary> | ||
/// Gets the arguments provided when the client requested the stream. | ||
/// </summary> | ||
IReadOnlyDictionary<string, string> StreamArguments { get; } | ||
|
||
/// <summary> | ||
/// Gets request details associated with the FLV client connection. | ||
/// </summary> | ||
IFlvRequest Request { get; } | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
src/LiveStreamingServerNet.Flv/Contracts/IFlvRequest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Primitives; | ||
using System.Net; | ||
using System.Security.Cryptography.X509Certificates; | ||
|
||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
public interface IFlvRequest | ||
{ | ||
/// <summary> | ||
/// Gets or sets the HTTP request scheme. | ||
/// </summary> | ||
/// <returns>The HTTP request scheme.</returns> | ||
string Scheme { get; } | ||
|
||
/// <summary> | ||
/// Returns true if the RequestScheme is https. | ||
/// </summary> | ||
/// <returns>true if this request is using https; otherwise, false.</returns> | ||
bool IsHttps { get; } | ||
|
||
/// <summary> | ||
/// Gets the Host header. May include the port. | ||
/// </summary> | ||
/// <return>The Host header.</return> | ||
HostString Host { get; } | ||
|
||
/// <summary> | ||
/// Gets the base path for the request. The path base should not end with a trailing slash. | ||
/// </summary> | ||
/// <returns>The base path for the request.</returns> | ||
PathString PathBase { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the request path from RequestPath. | ||
/// </summary> | ||
/// <returns>The request path from RequestPath.</returns> | ||
PathString Path { get; } | ||
|
||
/// <summary> | ||
/// Gets the raw query string used to create the query collection in Request.Query. | ||
/// </summary> | ||
/// <returns>The raw query string.</returns> | ||
QueryString QueryString { get; } | ||
|
||
/// <summary> | ||
/// Gets the query value collection parsed from Request.QueryString. | ||
/// </summary> | ||
/// <returns>The query value collection parsed from Request.QueryString.</returns> | ||
IQueryCollection Query { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the request protocol (e.g. HTTP/1.1). | ||
/// </summary> | ||
/// <returns>The request protocol.</returns> | ||
string Protocol { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the request headers. | ||
/// </summary> | ||
/// <returns>The request headers.</returns> | ||
IReadOnlyDictionary<string, StringValues> Headers { get; } | ||
|
||
/// <summary> | ||
/// Gets the collection of Cookies for this request. | ||
/// </summary> | ||
/// <returns>The collection of Cookies for this request.</returns> | ||
IRequestCookieCollection Cookies { get; } | ||
|
||
/// <summary> | ||
/// Gets the collection of route values for this request. | ||
/// </summary> | ||
/// <returns>The collection of route values for this request.</returns> | ||
IReadOnlyDictionary<string, object?> RouteValues { get; } | ||
|
||
/// <summary> | ||
/// Gets the IP address of the remote target. Can be null. | ||
/// </summary> | ||
IPAddress? RemoteIpAddress { get; } | ||
|
||
/// <summary> | ||
/// Gets the port of the remote target. | ||
/// </summary> | ||
int RemotePort { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the IP address of the local host. | ||
/// </summary> | ||
IPAddress? LocalIpAddress { get; } | ||
|
||
/// <summary> | ||
/// Gets the port of the local host. | ||
/// </summary> | ||
int LocalPort { get; } | ||
|
||
/// <summary> | ||
/// Gets the client certificate. | ||
/// </summary> | ||
X509Certificate2? ClientCertificate { get; } | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/LiveStreamingServerNet.Flv/Contracts/IFlvStreamEventHandler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using LiveStreamingServerNet.Utilities.Contracts; | ||
|
||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
/// <summary> | ||
/// Handles FLV stream playback events. | ||
/// </summary> | ||
public interface IFlvServerStreamEventHandler | ||
{ | ||
/// <summary> | ||
/// Gets the execution order of this handler. Lower numbers execute first. | ||
/// </summary> | ||
/// <returns>The order value, default is 0</returns> | ||
int GetOrder() => 0; | ||
|
||
/// <summary> | ||
/// Called when a client begins playing/subscribing to a stream. | ||
/// </summary> | ||
/// <param name="context">The event context</param> | ||
/// <param name="client">The client handle interface</param> | ||
ValueTask OnFlvStreamSubscribedAsync(IEventContext context, IFlvClientHandle client); | ||
|
||
/// <summary> | ||
/// Called when a client stops playing/subscribing to a stream. | ||
/// </summary> | ||
/// <param name="context">The event context</param> | ||
/// <param name="clientId">The ID of the client</param> | ||
/// <param name="streamPath">The path of the stream</param> | ||
ValueTask OnFlvStreamUnsubscribedAsync(IEventContext context, string clientId, string streamPath); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/LiveStreamingServerNet.Flv/Contracts/IFlvStreamInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
/// <summary> | ||
/// Provides information about an active FLV stream. | ||
/// </summary> | ||
public interface IFlvStreamInfo | ||
{ | ||
/// <summary> | ||
/// Gets the path identifier of the stream. | ||
/// </summary> | ||
string StreamPath { get; } | ||
|
||
/// <summary> | ||
/// Gets the arguments provided when the stream was published. | ||
/// </summary> | ||
IReadOnlyDictionary<string, string> StreamArguments { get; } | ||
|
||
/// <summary> | ||
/// Gets the stream metadata sent by the publisher, if any. | ||
/// Contains information like video dimensions, framerate, etc. | ||
/// </summary> | ||
IReadOnlyDictionary<string, object>? MetaData { get; } | ||
|
||
/// <summary> | ||
/// Gets a list of client handle interfaces for all current subscribers/viewers. | ||
/// </summary> | ||
IReadOnlyList<IFlvClientHandle> Subscribers { get; } | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/LiveStreamingServerNet.Flv/Contracts/IFlvStreamInfoManager.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace LiveStreamingServerNet.Flv.Contracts | ||
{ | ||
/// <summary> | ||
/// Manages and provides information about FLV streams. | ||
/// </summary> | ||
public interface IFlvStreamInfoManager | ||
{ | ||
/// <summary> | ||
/// Gets a list of all active stream paths. | ||
/// </summary> | ||
/// <returns>List of stream path identifiers</returns> | ||
IList<string> GetStreamPaths(); | ||
|
||
/// <summary> | ||
/// Gets information about all active streams. | ||
/// </summary> | ||
/// <returns>List of stream information objects</returns> | ||
IList<IFlvStreamInfo> GetStreamInfos(); | ||
|
||
/// <summary> | ||
/// Gets information about a specific stream. | ||
/// </summary> | ||
/// <param name="streamPath">The path identifier of the stream</param> | ||
/// <returns>Stream information object if the stream exists, null otherwise</returns> | ||
IFlvStreamInfo? GetStreamInfo(string streamPath); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.