mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
kvmd-media: renamed kind to type
This commit is contained in:
parent
43e6cd3e26
commit
a12163a797
@ -45,7 +45,7 @@ from ...clients.streamer import BaseStreamerClient
|
||||
# =====
|
||||
@dataclasses.dataclass
|
||||
class _Source:
|
||||
kind: str
|
||||
type: str
|
||||
fmt: str
|
||||
streamer: BaseStreamerClient
|
||||
meta: dict = dataclasses.field(default_factory=dict)
|
||||
@ -90,7 +90,7 @@ class MediaServer(HttpServer):
|
||||
async with self._ws_session(req) as ws:
|
||||
media: dict = {self.__K_VIDEO: {}}
|
||||
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)
|
||||
return (await self._ws_loop(ws))
|
||||
|
||||
@ -101,15 +101,15 @@ class MediaServer(HttpServer):
|
||||
@exposed_ws("start")
|
||||
async def __ws_start_handler(self, ws: WsSession, event: dict) -> None:
|
||||
try:
|
||||
kind = str(event.get("kind"))
|
||||
fmt = str(event.get("format"))
|
||||
req_type = str(event.get("type"))
|
||||
req_fmt = str(event.get("format"))
|
||||
except Exception:
|
||||
return
|
||||
src: (_Source | None) = None
|
||||
for cand in self.__srcs:
|
||||
if ws in cand.clients:
|
||||
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
|
||||
if src:
|
||||
client = _Client(ws, src, asyncio.Queue(self.__Q_SIZE))
|
||||
|
||||
@ -220,7 +220,7 @@ export function MediaStreamer(__setActive, __setInactive, __setInfo) {
|
||||
|
||||
__ws.send(JSON.stringify({
|
||||
"event_type": "start",
|
||||
"event": {"kind": "video", "format": "h264"},
|
||||
"event": {"type": "video", "format": "h264"},
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user