37232ae1b9
cuda-grid-controller (Python 3.11+) — control plane между HA/MQTT/HTTP
и FFmpeg's vf_cuda_grid filter через ZMQ.
Modules (~700 LOC Python):
- config.py — Pydantic schema (broker, instances[], ha_discovery, http, log) + YAML loader
- layouts.py — registry известных layouts (sync с vf_cuda_grid.c Phase 2)
- ha_discovery.py — HA MQTT Discovery payloads (select.layout, sensor.current_layout,
binary_sensor.online per instance + global device entry)
- zmq_client.py — async ZMQ REQ socket к FFmpeg zmq filter
(target command args → reply parsing)
- state.py — in-memory ControllerState (active_layout per instance, asyncio.Lock)
- mqtt_loop.py — aiomqtt async loop: subscribe cuda_grid/cmd/<inst>/+/+,
publish cuda_grid/state/* (retained) + cuda_grid/event/*, LWT, HA status reconnect
- dispatch.py — CommandDispatcher: layout.set action → ZMQ send_command + state update + events
- http_api.py — FastAPI: /health, /layouts, /state, POST /layout/{inst}/set
- __main__.py — typer CLI, asyncio.gather(mqtt_loop, uvicorn.server)
Examples + Dockerfile:
- examples/controller.yaml — 2 instances (livingroom_tv, public_stream)
- Dockerfile — python:3.11-slim, ENTRYPOINT cuda-grid-controller
- README — overview, usage, FFmpeg side filter graph
End-to-end flow ready:
HA dashboard → MQTT → controller → ZMQ → FFmpeg process_command → layout switch
↓
state публикуется обратно в MQTT → HA UI обновляется
Phase 3 deliverable per gx/vf-cuda-grid#1. Phase 4 = overlays (rect/text/icon).
48 lines
1.0 KiB
TOML
48 lines
1.0 KiB
TOML
[project]
|
|
name = "cuda-grid-controller"
|
|
version = "0.1.0"
|
|
description = "Control-plane sidecar для vf_cuda_grid FFmpeg filter — ZeroMQ + MQTT + HTTP REST + HA Discovery"
|
|
readme = "README.md"
|
|
license = { text = "LGPL-2.1-or-later" }
|
|
authors = [{ name = "gx", email = "gx@goldix.org" }]
|
|
requires-python = ">=3.11"
|
|
|
|
dependencies = [
|
|
"fastapi>=0.110",
|
|
"uvicorn[standard]>=0.27",
|
|
"pydantic>=2.5",
|
|
"pydantic-settings>=2.1",
|
|
"aiomqtt>=2.0",
|
|
"pyzmq>=25.0",
|
|
"pyyaml>=6.0",
|
|
"structlog>=24.1",
|
|
"typer>=0.9",
|
|
"sse-starlette>=2.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.0",
|
|
"pytest-asyncio>=0.23",
|
|
"mypy>=1.8",
|
|
"ruff>=0.2",
|
|
]
|
|
|
|
[project.scripts]
|
|
cuda-grid-controller = "cuda_grid_controller.__main__:main"
|
|
|
|
[build-system]
|
|
requires = ["setuptools>=68", "wheel"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[tool.setuptools.packages.find]
|
|
where = ["."]
|
|
include = ["cuda_grid_controller*"]
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py311"
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|