mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds audio player seeking, resync, underrun recovery and gapless transitions.
- Adds the media pipeline engine, seek-aware byte source, schedulers and manifest client. - Implements seeking, resync, underrun recovery, bounded gapless prefetch and clean failure handling. - Pins manifest, stream and configuration requests to validated page-origin routes. - Adds why comments to the complex pipeline and download paths.
This commit is contained in:
1 parent
c05978fac0
commit
e6fa85f7c6
14 files changed
+3958
-85
No files matched your search
@@ -1,7 +1,7 @@
|
||||
namespace Lumina.Presentation.Web.Common.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for generating absolute URLs from the application route templates, with URL localization.
|
||||
/// Interface for the service for generating URLs from the application route templates, with URL localization.
|
||||
/// </summary>
|
||||
public interface IUrlService
|
||||
{
|
||||
@@ -12,4 +12,13 @@ public interface IUrlService
|
||||
/// <param name="additionalRouteValues">Optional additional route values, like route parameters.</param>
|
||||
/// <returns>An absolute URL to the specified route.</returns>
|
||||
string? GetAbsoluteUrl(string routeTemplate, object? additionalRouteValues = null);
|
||||
|
||||
/// <summary>
|
||||
/// Generates a root relative URL for the specified route template, including the path base and the culture, but not the scheme or the host.
|
||||
/// A browser resolves it against the origin of the page, so it does not depend on how the server sees its own host behind a proxy.
|
||||
/// </summary>
|
||||
/// <param name="routeTemplate">The route template of the target page or endpoint, taken from the <see cref="Lumina.Presentation.Web.Common.Routes.WebRoutes"/> constants.</param>
|
||||
/// <param name="additionalRouteValues">Optional additional route values, like route parameters.</param>
|
||||
/// <returns>A root relative URL to the specified route.</returns>
|
||||
string? GetRelativeUrl(string routeTemplate, object? additionalRouteValues = null);
|
||||
}
|
||||
@@ -38,7 +38,20 @@ public class UrlService : IUrlService
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="routeTemplate"/> is not one of the route templates defined in the <see cref="WebRoutes"/> constants.</exception>
|
||||
public string? GetAbsoluteUrl(string routeTemplate, object? additionalRouteValues = null)
|
||||
{
|
||||
// fail fast when the route template is not one of the ones defined in the WebRoutes constants, instead of silently generating a broken URL
|
||||
string? path = GetRelativeUrl(routeTemplate, additionalRouteValues);
|
||||
if (path is null)
|
||||
return null;
|
||||
HttpContext? httpContext = _httpContextAccessor.HttpContext;
|
||||
if (httpContext is null)
|
||||
return null;
|
||||
// Build the absolute URL from the request's scheme, host and the already localized path base.
|
||||
return $"{httpContext.Request.Scheme}://{httpContext.Request.Host}{path}";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string? GetRelativeUrl(string routeTemplate, object? additionalRouteValues = null)
|
||||
{
|
||||
// Fail fast when the route template is not one of the ones defined in the WebRoutes constants, instead of silently generating a broken URL.
|
||||
if (!s_knownRouteTemplates.Contains(routeTemplate))
|
||||
throw new ArgumentException($"The route template '{routeTemplate}' is not defined in the WebRoutes constants.", nameof(routeTemplate));
|
||||
|
||||
@@ -50,11 +63,12 @@ public class UrlService : IUrlService
|
||||
if (additionalRouteValues is not null)
|
||||
foreach (PropertyInfo property in additionalRouteValues.GetType().GetProperties())
|
||||
path = path.Replace($"{{{property.Name}}}", property.GetValue(additionalRouteValues)?.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
// ensure the path starts with a slash, so that it is relative to the server root when concatenated with the host and the path base
|
||||
// Ensure the path starts with a slash, so that it is relative to the server root when concatenated with the path base.
|
||||
if (!path.StartsWith('/'))
|
||||
path = "/" + path;
|
||||
// build the absolute URL from the request's scheme, host and path base
|
||||
return $"{httpContext.Request.Scheme}://{httpContext.Request.Host}{httpContext.Request.PathBase}{path}";
|
||||
// The scheme and host are deliberately omitted. A browser resolves this against its own origin, so the value stays
|
||||
// correct behind a reverse proxy even when the request headers do not describe the origin the browser used.
|
||||
return $"{httpContext.Request.PathBase}{path}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user