kvmd-media: renamed kind to type

This commit is contained in:
Maxim Devaev 2025-01-05 14:43:20 +02:00
parent 43e6cd3e26
commit a12163a797
2 changed files with 6 additions and 6 deletions

View File

@ -45,7 +45,7 @@ from ...clients.streamer import BaseStreamerClient
# ===== # =====
@dataclasses.dataclass @dataclasses.dataclass
class _Source: class _Source:
kind: str type: str
fmt: str fmt: str
streamer: BaseStreamerClient streamer: BaseStreamerClient
meta: dict = dataclasses.field(default_factory=dict) meta: dict = dataclasses.field(default_factory=dict)
@ -90,7 +90,7 @@ class MediaServer(HttpServer):
async with self._ws_session(req) as ws: async with self._ws_session(req) as ws:
media: dict = {self.__K_VIDEO: {}} media: dict = {self.__K_VIDEO: {}}
for src in self.__srcs: for src in self.__srcs:
media[src.kind][src.fmt] = src.meta media[src.type][src.fmt] = src.meta
await ws.send_event("media", media) await ws.send_event("media", media)
return (await self._ws_loop(ws)) return (await self._ws_loop(ws))
@ -101,15 +101,15 @@ class MediaServer(HttpServer):
@exposed_ws("start") @exposed_ws("start")
async def __ws_start_handler(self, ws: WsSession, event: dict) -> None: async def __ws_start_handler(self, ws: WsSession, event: dict) -> None:
try: try:
kind = str(event.get("kind")) req_type = str(event.get("type"))
fmt = str(event.get("format")) req_fmt = str(event.get("format"))
except Exception: except Exception:
return return
src: (_Source | None) = None src: (_Source | None) = None
for cand in self.__srcs: for cand in self.__srcs:
if ws in cand.clients: if ws in cand.clients:
return # Don't allow any double streaming return # Don't allow any double streaming
if (cand.kind, cand.fmt) == (kind, fmt): if (cand.type, cand.fmt) == (req_type, req_fmt):
src = cand src = cand
if src: if src:
client = _Client(ws, src, asyncio.Queue(self.__Q_SIZE)) client = _Client(ws, src, asyncio.Queue(self.__Q_SIZE))

View File

@ -220,7 +220,7 @@ export function MediaStreamer(__setActive, __setInactive, __setInfo) {
__ws.send(JSON.stringify({ __ws.send(JSON.stringify({
"event_type": "start", "event_type": "start",
"event": {"kind": "video", "format": "h264"}, "event": {"type": "video", "format": "h264"},
})); }));
}; };