summaryrefslogtreecommitdiff
path: root/kvmd/clients
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-02-03 06:46:53 +0300
committerDevaev Maxim <[email protected]>2021-02-03 06:46:53 +0300
commita0601faafb333a8e0b90a699d7f4bc7d1d0fefbf (patch)
tree4df37bcc9961e5e9af2e896bcb356d448976965e /kvmd/clients
parent78fc3869f2d859076d4c74a3d6c359c9a3ca0067 (diff)
accumulate h264 frames
Diffstat (limited to 'kvmd/clients')
-rw-r--r--kvmd/clients/streamer.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py
index a0a07bf5..a42dcb20 100644
--- a/kvmd/clients/streamer.py
+++ b/kvmd/clients/streamer.py
@@ -22,7 +22,6 @@
import types
-from typing import Tuple
from typing import Dict
from typing import AsyncGenerator
@@ -62,7 +61,7 @@ class BaseStreamerClient:
def get_format(self) -> int:
raise NotImplementedError()
- async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
+ async def read_stream(self) -> AsyncGenerator[Dict, None]:
if self is not None: # XXX: Vulture and pylint hack
raise NotImplementedError()
yield
@@ -90,7 +89,7 @@ class HttpStreamerClient(BaseStreamerClient):
def get_format(self) -> int:
return StreamFormats.JPEG
- async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
+ async def read_stream(self) -> AsyncGenerator[Dict, None]:
try:
async with self.__make_http_session() as session:
async with session.get(
@@ -110,12 +109,12 @@ class HttpStreamerClient(BaseStreamerClient):
if not data:
break
- yield (
- (frame.headers["X-UStreamer-Online"] == "true"),
- int(frame.headers["X-UStreamer-Width"]),
- int(frame.headers["X-UStreamer-Height"]),
- data,
- )
+ yield {
+ "online": (frame.headers["X-UStreamer-Online"] == "true"),
+ "width": int(frame.headers["X-UStreamer-Width"]),
+ "height": int(frame.headers["X-UStreamer-Height"]),
+ "data": data,
+ }
except Exception as err: # Тут бывают и ассерты, и KeyError, и прочая херня
if isinstance(err, StreamerTempError):
raise
@@ -178,7 +177,7 @@ class MemsinkStreamerClient(BaseStreamerClient):
def get_format(self) -> int:
return self.__fmt
- async def read_stream(self) -> AsyncGenerator[Tuple[bool, int, int, bytes], None]:
+ async def read_stream(self) -> AsyncGenerator[Dict, None]:
if ustreamer is None:
raise StreamerPermError("Missing ustreamer library")
try:
@@ -187,12 +186,7 @@ class MemsinkStreamerClient(BaseStreamerClient):
frame = await aiotools.run_async(sink.wait_frame)
if frame is not None:
self.__check_format(frame["format"])
- yield (
- frame["online"],
- frame["width"],
- frame["height"],
- frame["data"],
- )
+ yield frame
except StreamerPermError:
raise
except FileNotFoundError as err: