using System; using Jellyfin.Plugin.JRay.Configuration; namespace Jellyfin.Plugin.JRay.Services; /// /// The outcome of comparing a local audio signature against a remote one. /// /// /// Produced only when the two signatures actually align; a comparison that /// reaches no tier yields no result at all rather than a zero-scored one, so a /// caller cannot mistake "did not match" for "matched at the bottom". /// public readonly struct AudioSignatureMatch : IEquatable { /// /// Gets the fraction of overlapping frames whose peak band agreed, in [0, 1]. /// public double Score { get; init; } /// /// Gets the best-scoring alignment, in frames, between the two analysis /// windows. /// /// /// Positive means the local window lags the remote one. This is a /// window-relative quantity and is not the offset to apply to /// timings — see , which additionally accounts for /// the two windows being anchored at different points in their files. /// public int OffsetFrames { get; init; } /// /// Gets the seconds to add to every remote window to bring it into the local /// file's timebase. /// /// /// This is the quantity JR-030 applies at store time, and the one /// takes. /// public double OffsetSec { get; init; } /// Gets the tier this score earns. public MatchTier Tier { get; init; } /// Compares two matches for equality. /// Left operand. /// Right operand. /// true when the two are equal. public static bool operator ==(AudioSignatureMatch left, AudioSignatureMatch right) => left.Equals(right); /// Compares two matches for inequality. /// Left operand. /// Right operand. /// true when the two differ. public static bool operator !=(AudioSignatureMatch left, AudioSignatureMatch right) => !left.Equals(right); /// public bool Equals(AudioSignatureMatch other) => Score.Equals(other.Score) && OffsetFrames == other.OffsetFrames && OffsetSec.Equals(other.OffsetSec) && Tier == other.Tier; /// public override bool Equals(object? obj) => obj is AudioSignatureMatch other && Equals(other); /// public override int GetHashCode() => HashCode.Combine(Score, OffsetFrames, OffsetSec, Tier); }