Adds normalized audio playback pipeline

This commit is contained in:
BinaryAlley committed 2026-10-17 20:52:08 +03:00
1 parent 6991640710
commit 4e13b23f16
35 files changed
+3817 -41

No files matched your search

@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
/// <summary>
/// Data transfer object for the normalized audio of a track, produced and cached as a sequence of fixed duration segments.
/// </summary>
/// <param name="TrackId">The Id of the track whose audio the cached entry holds, so the caller can verify that the entry is the one it authorized.</param>
/// <param name="CacheId">The opaque identifier of the cached entry that holds the normalized audio.</param>
/// <param name="Mode">The way the audio is delivered, which is a remux or a transcode.</param>
/// <param name="Container">The container of the delivered audio.</param>
/// <param name="Codec">The codec of the delivered audio.</param>
/// <param name="SegmentDurationSeconds">The duration of each segment of the delivered audio, in seconds.</param>
/// <param name="DurationInSeconds">
/// The duration of the produced and cached audio, in seconds, rounded up to the next second. It is the produced end rather than the probed duration, so
/// it always covers every produced segment.
/// </param>
/// <param name="Segments">The segments that make up the delivered audio, in playback order.</param>
[DebuggerDisplay("TrackId: {TrackId} CacheId: {CacheId} Container: {Container} Codec: {Codec}")]
public sealed record NormalizedTrackDto(
Guid TrackId,
string CacheId,
PlaybackDeliveryMode Mode,
string Container,
string Codec,
int SegmentDurationSeconds,
int DurationInSeconds,
IReadOnlyList<NormalizedTrackSegmentDto> Segments
);
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
/// <summary>
/// Data transfer object for the request to produce the normalized audio of a track, as the delivery decision of a playback manifest describes it.
/// </summary>
/// <param name="TrackId">The Id of the track whose audio is normalized. It binds the produced cache entry to the track the caller authorized.</param>
/// <param name="SourcePath">The file system path of the stored audio file of the track.</param>
/// <param name="AllowedRoots">
/// The content locations the source path is allowed to be inside. The service validates the path against them and re-checks it after opening, so a
/// caller that forgets to enforce containment cannot hand an arbitrary path to the transcoder.
/// </param>
/// <param name="SourceContainer">The container of the stored audio file, as captured by the probe, used to pin the ffmpeg demuxer. Optional.</param>
/// <param name="Mode">The way the audio is delivered, which is a remux or a transcode.</param>
/// <param name="Container">The container of the delivered audio, as chosen by the delivery decision.</param>
/// <param name="Codec">The codec of the delivered audio, as chosen by the delivery decision.</param>
/// <param name="SegmentDurationSeconds">The duration of each segment of the delivered audio, in seconds.</param>
/// <param name="DurationInSeconds">The duration of the audio of the track, in seconds.</param>
/// <param name="Bitrate">The stored audio bitrate of the track, in kbps, used to estimate a remux of a lossy codec. Optional.</param>
/// <param name="SampleRate">The sample rate of the stored audio of the track, in Hz, used to estimate the size of a lossless delivery.</param>
/// <param name="Channels">The number of audio channels of the track, used to estimate the size of a lossless delivery.</param>
/// <param name="BitDepth">The bit depth of the stored audio of the track, if applicable, used to estimate the size of a lossless delivery.</param>
/// <param name="Quality">The quality cap applied to the delivered audio when it has to be re-encoded.</param>
[DebuggerDisplay("TrackId: {TrackId} Mode: {Mode} Container: {Container} Codec: {Codec}")]
public sealed record NormalizedTrackRequestDto(
Guid TrackId,
string SourcePath,
IReadOnlyList<string> AllowedRoots,
string? SourceContainer,
PlaybackDeliveryMode Mode,
string Container,
string Codec,
int SegmentDurationSeconds,
int DurationInSeconds,
int? Bitrate,
int SampleRate,
int Channels,
int? BitDepth,
PlaybackStreamingQuality Quality
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Playback;
/// <summary>
/// Data transfer object for a single fixed duration segment of the normalized audio of a track.
/// </summary>
/// <param name="Index">The zero based position of the segment in the delivered audio.</param>
/// <param name="StartSeconds">The time, in seconds from the start of the track, at which the segment starts.</param>
/// <param name="DurationSeconds">The duration of the segment, in seconds.</param>
/// <param name="Length">The length of the segment, in bytes.</param>
[DebuggerDisplay("Index: {Index} StartSeconds: {StartSeconds} DurationSeconds: {DurationSeconds}")]
public sealed record NormalizedTrackSegmentDto(
int Index,
decimal StartSeconds,
decimal DurationSeconds,
long Length
);