namespace ytLive.Services;
///
/// Pure filename logic for local recordings (TASK 18). The user-requested naming
/// is ty-yyyymmdd-hhmm-fff-hh2mm2.mp4: ty is the brand marker, the first
/// hhmm is the hour+minute the recording STARTED (saved), fff is
/// milliseconds on the same start timestamp, and the last hh2mm2 is the
/// hour+minute of the recording's LENGTH. Length is only known when recording ends,
/// so the file is created with a 0000 length and renamed on stop (see
/// ).
/// The fff exists so two instances started in the same minute cannot
/// compute the same path — the dev multi-instance use case (record one instance
/// with the other) would otherwise have both ffmpeg processes writing one file.
/// Both names derive from the same _recordStartTime, so the segment survives
/// the rename.
///
public static class RecordingFile
{
/// A start placeholder — the length is filled in on stop.
public const string StartLengthSuffix = "0000";
public static string BuildStartName(DateTime start)
=> $"ty-{start:yyyyMMdd}-{start:HHmm}-{start:fff}-{StartLengthSuffix}";
/// Final name with the real recording length (fractional hour+minute),
/// e.g. 75 minutes → ty-20260829-1405-000-0115.mp4.
public static string BuildFinalName(DateTime start, TimeSpan length)
{
var hh2 = (int)length.TotalHours;
var mm2 = length.Minutes;
return $"ty-{start:yyyyMMdd}-{start:HHmm}-{start:fff}-{hh2:00}{mm2:00}";
}
}