Adds seekable normalized audio track delivery

This commit is contained in:
BinaryAlley committed 2026-10-18 14:55:56 +03:00
1 parent 4e13b23f16
commit 45f9aa3bd5
57 files changed
+3452 -344

No files matched your search

@@ -152,12 +152,16 @@ public static class InfrastructureLayerServices
// repackaged into another container, or re-encoded into another codec.
services.AddSingleton<IPlaybackFormatService, PlaybackFormatService>();
// Music playback: issues and resolves the opaque delivery handles reported by a playback manifest, so the segment route never has to
// recompute the delivery decision, the quality cap or the source file identity from values that can change while the track plays.
services.AddSingleton<IPlaybackDeliveryHandleService, PlaybackDeliveryHandleService>();
// Music playback: records the outcome of the ffmpeg probe, so a missing binary or encoder is reported as unavailable for the affected formats.
services.AddSingleton<TranscodingToolchainStatus>();
// Music playback: produces the normalized (remuxed or transcoded) audio of a track with ffmpeg, caches it as fixed duration
// segments and serves it from the cache, bounded in concurrency, cancellable and capped in disk usage. The playback stream surface
// is its intended consumer; no API request path calls it yet.
// segments and serves it from the cache, bounded in concurrency, cancellable and capped in disk usage. The segment route of the
// playback stream surface is its consumer.
services.AddSingleton<ITrackNormalizationService, TrackNormalizationService>();
// Music playback: owns the normalized audio cache lifecycle and verifies the ffmpeg encoders at startup, so a missing or changed toolchain
@@ -36,6 +36,9 @@ public static partial class Errors
public static Error TranscodingFfmpegPathCannotBeEmpty => Error.Validation(description: nameof(TranscodingFfmpegPathCannotBeEmpty));
public static Error TranscodingMaxConcurrentJobsMustBePositive => Error.Validation(description: nameof(TranscodingMaxConcurrentJobsMustBePositive));
public static Error TranscodingMaxConcurrentJobsIsTooLarge => Error.Validation(description: nameof(TranscodingMaxConcurrentJobsIsTooLarge));
public static Error TranscodingMaxConcurrentJobsPerUserMustBePositive => Error.Validation(description: nameof(TranscodingMaxConcurrentJobsPerUserMustBePositive));
public static Error TranscodingMaxConcurrentJobsPerUserIsTooLarge => Error.Validation(description: nameof(TranscodingMaxConcurrentJobsPerUserIsTooLarge));
public static Error TranscodingMaxConcurrentJobsPerUserExceedsGlobal => Error.Validation(description: nameof(TranscodingMaxConcurrentJobsPerUserExceedsGlobal));
public static Error TranscodingMaxCacheBytesMustBePositive => Error.Validation(description: nameof(TranscodingMaxCacheBytesMustBePositive));
public static Error TranscodingJobTimeoutMustBePositive => Error.Validation(description: nameof(TranscodingJobTimeoutMustBePositive));
public static Error TranscodingJobTimeoutIsTooLong => Error.Validation(description: nameof(TranscodingJobTimeoutIsTooLong));
@@ -22,6 +22,12 @@ public sealed class TranscodingSettingsDto
/// </summary>
public int MaxConcurrentJobs { get; set; } = 2;
/// <summary>
/// Gets or sets the maximum number of normalization jobs a single user may have running at the same time. A production that was
/// started by another user can still be waited for, because it is shared by every request for the same track and delivery.
/// </summary>
public int MaxConcurrentJobsPerUser { get; set; } = 1;
/// <summary>
/// Gets or sets the maximum total size of the normalized audio cache, in bytes.
/// </summary>
@@ -53,6 +53,19 @@ public class TranscodingSettingsDtoValidator : AbstractValidator<TranscodingSett
.Must(maxConcurrentJobs => maxConcurrentJobs <= MAX_CONCURRENT_JOBS)
.WithError(Errors.Errors.Configuration.TranscodingMaxConcurrentJobsIsTooLarge);
RuleFor(settings => settings.MaxConcurrentJobsPerUser)
.GreaterThan(0)
.WithError(Errors.Errors.Configuration.TranscodingMaxConcurrentJobsPerUserMustBePositive);
RuleFor(settings => settings.MaxConcurrentJobsPerUser)
.Must(maxConcurrentJobsPerUser => maxConcurrentJobsPerUser <= MAX_CONCURRENT_JOBS)
.WithError(Errors.Errors.Configuration.TranscodingMaxConcurrentJobsPerUserIsTooLarge);
// A per-user limit above the global one can never be reached, and would hide a misconfiguration that looks like a working cap.
RuleFor(settings => settings.MaxConcurrentJobsPerUser)
.Must((settings, maxConcurrentJobsPerUser) => maxConcurrentJobsPerUser <= settings.MaxConcurrentJobs)
.WithError(Errors.Errors.Configuration.TranscodingMaxConcurrentJobsPerUserExceedsGlobal);
RuleFor(settings => settings.MaxCacheBytes)
.GreaterThan(0)
.WithError(Errors.Errors.Configuration.TranscodingMaxCacheBytesMustBePositive);