Files
deepdrft/DeepDrftContent/Processors/Opus/ResolvedAudio.cs
T

24 lines
1.5 KiB
C#

using DeepDrftContent.FileDatabase.Models;
using DeepDrftModels.Enums;
namespace DeepDrftContent.Processors.Opus;
/// <summary>
/// The outcome of resolving a track + requested <see cref="AudioFormat"/> to a concrete artifact
/// (Phase 18.2). Carries the bytes, the content-type that matches <em>what was actually returned</em>,
/// and the format actually served — which may differ from the requested one when the C2 fallback fires
/// (Opus requested, no Opus artifact → the lossless artifact + its content-type). The delivery layer
/// (18.3) sets the response <c>Content-Type</c> from <see cref="ContentType"/> so the eventual decoder
/// picks the right decoder for the bytes it receives, not the bytes the listener asked for.
/// </summary>
/// <param name="Audio">The resolved audio artifact (never null when a resolution succeeds).</param>
/// <param name="ContentType">The MIME type of <paramref name="Audio"/> (e.g. <c>audio/ogg</c> for Opus,
/// or the source's real MIME for lossless).</param>
/// <param name="ResolvedFormat">The format actually returned. Equal to the requested format on a direct
/// hit; <see cref="AudioFormat.Lossless"/> when an Opus request fell back.</param>
public sealed record ResolvedAudio(AudioBinary Audio, string ContentType, AudioFormat ResolvedFormat)
{
/// <summary>True when an Opus request was served the lossless artifact because no Opus existed (C2).</summary>
public bool DidFallBack(AudioFormat requested) => requested != ResolvedFormat;
}