From 5866ad351085d0744c983b8d20861bc3c615974d Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Tue, 14 Apr 2026 09:21:09 -0400 Subject: [PATCH] Add backend/app/models.py --- backend/app/models.py | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 backend/app/models.py diff --git a/backend/app/models.py b/backend/app/models.py new file mode 100644 index 0000000..62b1a83 --- /dev/null +++ b/backend/app/models.py @@ -0,0 +1,76 @@ +from enum import Enum +from datetime import datetime +from pydantic import BaseModel, Field, ConfigDict +from typing import Optional + + +class CodecType(str, Enum): + """Supported video codec types""" + PRORES = "prores" + DNXHD = "dnxhd" + UNCOMPRESSED = "uncompressed" + H264 = "h264" + + +class RecorderConfig(BaseModel): + """Configuration for a recorder port""" + model_config = ConfigDict(use_enum_values=False) + + port_index: int = Field(..., description="Index of the recorder port (0-based)") + codec: CodecType = Field(..., description="Selected codec for recording") + bitrate: int = Field(..., description="Target bitrate in Mbps") + quality_profile: str = Field( + ..., + description="Quality profile name (high, medium, low)" + ) + recording_path: str = Field( + ..., + description="Directory path for recording output files" + ) + srt_enabled: bool = Field( + default=False, description="Enable SRT streaming output" + ) + srt_destination: Optional[str] = Field( + default=None, description="SRT destination address (host:port)" + ) + preview_enabled: bool = Field( + default=True, description="Enable live HLS preview" + ) + + +class PortStatus(BaseModel): + """Real-time status of a recorder port""" + model_config = ConfigDict(use_enum_values=False) + + port_index: int = Field(..., description="Index of the recorder port") + is_recording: bool = Field(..., description="Whether this port is currently recording") + frame_count: int = Field(..., description="Total frames recorded") + fps: float = Field(..., description="Frames per second") + bitrate_mbps: float = Field(..., description="Current bitrate in Mbps") + uptime_seconds: int = Field(..., description="Recording uptime in seconds") + current_file: str = Field(..., description="Current output file path") + codec: CodecType = Field(..., description="Codec being used") + + +class SCTE35Marker(BaseModel): + """SCTE-35/SCTE-104 advertisement marker""" + model_config = ConfigDict(use_enum_values=False) + + event_id: str = Field( + ..., description="Unique identifier for this ad break event" + ) + duration_seconds: int = Field( + ..., description="Duration of the ad break in seconds" + ) + out_of_network: bool = Field( + ..., description="Whether this is an out-of-network ad" + ) + splice_immediate: bool = Field( + ..., description="Whether splice should happen immediately" + ) + timestamp: datetime = Field( + ..., description="Timestamp when marker was created/triggered" + ) + webhook_url: Optional[str] = Field( + default=None, description="Webhook URL to notify on ad break" + )