diff options
author | Devaev Maxim <[email protected]> | 2021-02-03 20:40:02 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-02-03 20:40:02 +0300 |
commit | db4dc5de4586f4f30dfacb0c9a5d0c40c2c67b68 (patch) | |
tree | ec7e06dd1a2d9de6583771903fc4dace81754e41 /kvmd | |
parent | 18805b34995919255bf98cba25e70bd45c016c9b (diff) |
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/server.py | 12 | ||||
-rw-r--r-- | kvmd/clients/streamer.py | 1 |
2 files changed, 7 insertions, 6 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index a39d4087..a14af8c9 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -201,7 +201,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes logger.info("[streamer] %s: Streaming ...", self._remote) streaming = True if frame["online"]: - await self.__send_fb_real(frame, streamer.get_format()) + await self.__send_fb_real(frame) else: await self.__send_fb_stub("No signal") except StreamerError as err: @@ -230,27 +230,27 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes get_logger(0).info("[streamer] %s: Using default %s", self._remote, streamer) return streamer - async def __send_fb_real(self, frame: Dict, fmt: int) -> None: + async def __send_fb_real(self, frame: Dict) -> None: async with self.__lock: if self.__fb_requested: if not (await self.__resize_fb_unsafe(frame)): return - if fmt == StreamFormats.JPEG: + if frame["format"] == StreamFormats.JPEG: await self._send_fb_jpeg(frame["data"]) - elif fmt == StreamFormats.H264: + elif frame["format"] == StreamFormats.H264: if not self._encodings.has_h264: self.__fb_h264_data = b"" raise StreamerPermError("The client doesn't want to accept H264 anymore") await self._send_fb_h264(self.__fb_h264_data) else: - raise RuntimeError(f"Unknown format: {fmt}") + raise RuntimeError(f"Unknown format: {frame['format']}") self.__fb_stub = None self.__fb_requested = False self.__fb_h264_data = b"" - elif self._encodings.has_h264 and fmt == StreamFormats.H264: + elif self._encodings.has_h264 and frame["format"] == StreamFormats.H264: if frame["key"]: self.__fb_h264_data = frame["data"] elif len(self.__fb_h264_data) + len(frame["data"]) > 4194304: # 4Mb diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py index a42dcb20..9ab3b856 100644 --- a/kvmd/clients/streamer.py +++ b/kvmd/clients/streamer.py @@ -114,6 +114,7 @@ class HttpStreamerClient(BaseStreamerClient): "width": int(frame.headers["X-UStreamer-Width"]), "height": int(frame.headers["X-UStreamer-Height"]), "data": data, + "format": StreamFormats.JPEG, } except Exception as err: # Тут бывают и ассерты, и KeyError, и прочая херня if isinstance(err, StreamerTempError): |