feat: Introduce explicit start, stop, and status commands, including minimum recording duration.
This commit is contained in:
@@ -14,15 +14,15 @@ public class StateTracker : IRecordingStateTracker
|
||||
public void SetRecording(int ffmpegPid)
|
||||
{
|
||||
Logger.LogDebug($"Setting recording state with PID {ffmpegPid}");
|
||||
File.WriteAllText(StateFilePath, ffmpegPid.ToString());
|
||||
File.WriteAllText(StateFilePath, $"{ffmpegPid}\n{DateTime.UtcNow.Ticks}");
|
||||
}
|
||||
|
||||
public int? GetRecordingPid()
|
||||
{
|
||||
if (File.Exists(StateFilePath))
|
||||
{
|
||||
var content = File.ReadAllText(StateFilePath).Trim();
|
||||
if (int.TryParse(content, out var pid))
|
||||
var lines = File.ReadAllLines(StateFilePath);
|
||||
if (lines.Length > 0 && int.TryParse(lines[0], out var pid))
|
||||
{
|
||||
Logger.LogDebug($"Read recording PID {pid} from state file");
|
||||
return pid;
|
||||
@@ -31,6 +31,19 @@ public class StateTracker : IRecordingStateTracker
|
||||
return null;
|
||||
}
|
||||
|
||||
public DateTime? GetRecordingStartTime()
|
||||
{
|
||||
if (File.Exists(StateFilePath))
|
||||
{
|
||||
var lines = File.ReadAllLines(StateFilePath);
|
||||
if (lines.Length > 1 && long.TryParse(lines[1], out var ticks))
|
||||
{
|
||||
return new DateTime(ticks, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ClearRecording()
|
||||
{
|
||||
if (File.Exists(StateFilePath))
|
||||
|
||||
Reference in New Issue
Block a user