Adding features
This commit is contained in:
@@ -124,11 +124,92 @@ public sealed class ClipJobRecord
|
||||
public Dictionary<string, string> Payload { get; set; } = [];
|
||||
public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
|
||||
public int? ClipAssetId { get; set; }
|
||||
public int AttemptCount { get; set; }
|
||||
public int MaxAttempts { get; set; } = 2;
|
||||
public string? ErrorMessage { get; set; }
|
||||
public DateTime? LastAttemptedAtUtc { get; set; }
|
||||
public DateTime? RetryAfterUtc { get; set; }
|
||||
public DateTime? StartedAtUtc { get; set; }
|
||||
public DateTime? CompletedAtUtc { get; set; }
|
||||
}
|
||||
|
||||
public sealed class RenderJobContract
|
||||
{
|
||||
public const string CurrentVersion = "1";
|
||||
public const string DefaultCameraMode = "killer_pov";
|
||||
public const string DefaultOutputFormat = "mp4";
|
||||
public const string DefaultResolution = "1920x1080";
|
||||
public const string DefaultFps = "60";
|
||||
|
||||
public string Version { get; set; } = CurrentVersion;
|
||||
public int DemoId { get; set; }
|
||||
public int MatchId { get; set; }
|
||||
public int HighlightId { get; set; }
|
||||
public int SourceEventId { get; set; }
|
||||
public int StartTick { get; set; }
|
||||
public int EndTick { get; set; }
|
||||
public string CameraMode { get; set; } = DefaultCameraMode;
|
||||
public string OutputFormat { get; set; } = DefaultOutputFormat;
|
||||
public string Resolution { get; set; } = DefaultResolution;
|
||||
public string Fps { get; set; } = DefaultFps;
|
||||
|
||||
public Dictionary<string, string> ToPayload()
|
||||
{
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
["version"] = Version,
|
||||
["demoId"] = DemoId.ToString(),
|
||||
["matchId"] = MatchId.ToString(),
|
||||
["highlightId"] = HighlightId.ToString(),
|
||||
["sourceEventId"] = SourceEventId.ToString(),
|
||||
["startTick"] = StartTick.ToString(),
|
||||
["endTick"] = EndTick.ToString(),
|
||||
["cameraMode"] = CameraMode,
|
||||
["outputFormat"] = OutputFormat,
|
||||
["resolution"] = Resolution,
|
||||
["fps"] = Fps
|
||||
};
|
||||
}
|
||||
|
||||
public static RenderJobContract FromPayload(IReadOnlyDictionary<string, string> payload)
|
||||
{
|
||||
return new RenderJobContract
|
||||
{
|
||||
Version = ReadString(payload, "version", CurrentVersion),
|
||||
DemoId = ReadInt(payload, "demoId"),
|
||||
MatchId = ReadInt(payload, "matchId"),
|
||||
HighlightId = ReadInt(payload, "highlightId"),
|
||||
SourceEventId = ReadInt(payload, "sourceEventId"),
|
||||
StartTick = ReadInt(payload, "startTick"),
|
||||
EndTick = ReadInt(payload, "endTick"),
|
||||
CameraMode = ReadString(payload, "cameraMode", DefaultCameraMode),
|
||||
OutputFormat = ReadString(payload, "outputFormat", DefaultOutputFormat),
|
||||
Resolution = ReadString(payload, "resolution", DefaultResolution),
|
||||
Fps = ReadString(payload, "fps", DefaultFps)
|
||||
};
|
||||
}
|
||||
|
||||
public string GetSuggestedFileExtension()
|
||||
{
|
||||
if (string.Equals(OutputFormat, "webm", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".webm";
|
||||
}
|
||||
|
||||
return ".mp4";
|
||||
}
|
||||
|
||||
private static int ReadInt(IReadOnlyDictionary<string, string> payload, string key)
|
||||
{
|
||||
return payload.TryGetValue(key, out var raw) && int.TryParse(raw, out var value) ? value : 0;
|
||||
}
|
||||
|
||||
private static string ReadString(IReadOnlyDictionary<string, string> payload, string key, string fallback)
|
||||
{
|
||||
return payload.TryGetValue(key, out var value) && !string.IsNullOrWhiteSpace(value) ? value : fallback;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ClipAssetRecord
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user