Refactor capture engine architecture, rename PictureStream to PictureSource, and split API modules
- Separate CaptureEngine into stateless factory + stateful CaptureStream session - Add LiveStream/LiveStreamManager for shared capture with reference counting - Rename PictureStream to PictureSource across storage, API, and UI - Remove legacy migration logic and unused compatibility code - Split monolithic routes.py (1935 lines) into 5 focused route modules - Split schemas.py (480 lines) into 7 schema modules with re-exports - Extract dependency injection into dedicated dependencies.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
75
server/src/wled_controller/api/schemas/templates.py
Normal file
75
server/src/wled_controller/api/schemas/templates.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""Capture template and engine schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class TemplateCreate(BaseModel):
|
||||
"""Request to create a capture template."""
|
||||
|
||||
name: str = Field(description="Template name", min_length=1, max_length=100)
|
||||
engine_type: str = Field(description="Engine type (e.g., 'mss', 'dxcam', 'wgc')", min_length=1)
|
||||
engine_config: Dict = Field(default_factory=dict, description="Engine-specific configuration")
|
||||
description: Optional[str] = Field(None, description="Template description", max_length=500)
|
||||
|
||||
|
||||
class TemplateUpdate(BaseModel):
|
||||
"""Request to update a template."""
|
||||
|
||||
name: Optional[str] = Field(None, description="Template name", min_length=1, max_length=100)
|
||||
engine_type: Optional[str] = Field(None, description="Capture engine type (mss, dxcam, wgc)")
|
||||
engine_config: Optional[Dict] = Field(None, description="Engine-specific configuration")
|
||||
description: Optional[str] = Field(None, description="Template description", max_length=500)
|
||||
|
||||
|
||||
class TemplateResponse(BaseModel):
|
||||
"""Template information response."""
|
||||
|
||||
id: str = Field(description="Template ID")
|
||||
name: str = Field(description="Template name")
|
||||
engine_type: str = Field(description="Engine type identifier")
|
||||
engine_config: Dict = Field(description="Engine-specific configuration")
|
||||
created_at: datetime = Field(description="Creation timestamp")
|
||||
updated_at: datetime = Field(description="Last update timestamp")
|
||||
description: Optional[str] = Field(None, description="Template description")
|
||||
|
||||
|
||||
class TemplateListResponse(BaseModel):
|
||||
"""List of templates response."""
|
||||
|
||||
templates: List[TemplateResponse] = Field(description="List of templates")
|
||||
count: int = Field(description="Number of templates")
|
||||
|
||||
|
||||
class EngineInfo(BaseModel):
|
||||
"""Capture engine information."""
|
||||
|
||||
type: str = Field(description="Engine type identifier (e.g., 'mss', 'dxcam')")
|
||||
name: str = Field(description="Human-readable engine name")
|
||||
default_config: Dict = Field(description="Default configuration for this engine")
|
||||
available: bool = Field(description="Whether engine is available on this system")
|
||||
|
||||
|
||||
class EngineListResponse(BaseModel):
|
||||
"""List of available engines response."""
|
||||
|
||||
engines: List[EngineInfo] = Field(description="Available capture engines")
|
||||
count: int = Field(description="Number of engines")
|
||||
|
||||
|
||||
class TemplateAssignment(BaseModel):
|
||||
"""Request to assign template to device."""
|
||||
|
||||
template_id: str = Field(description="Template ID to assign")
|
||||
|
||||
|
||||
class TemplateTestRequest(BaseModel):
|
||||
"""Request to test a capture template."""
|
||||
|
||||
engine_type: str = Field(description="Capture engine type to test")
|
||||
engine_config: Dict = Field(default={}, description="Engine configuration")
|
||||
display_index: int = Field(description="Display index to capture")
|
||||
border_width: int = Field(default=10, ge=1, le=100, description="Border width in pixels")
|
||||
capture_duration: float = Field(default=5.0, ge=1.0, le=30.0, description="Duration to capture in seconds")
|
||||
Reference in New Issue
Block a user