diff options
author | Devaev Maxim <[email protected]> | 2020-03-20 15:33:47 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-03-20 15:33:47 +0300 |
commit | 3cafcaf4314e9a8fe66219d72ed4ae99abc04ab1 (patch) | |
tree | df4d10e8197f38eb42d4a8a6d1642b52f2e0b901 | |
parent | 55307fe8da9b483a5d99f459cee5178879f69911 (diff) |
configurable desired_fps
-rw-r--r-- | kvmd/apps/__init__.py | 3 | ||||
-rw-r--r-- | kvmd/apps/vnc/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/vnc/server.py | 23 |
3 files changed, 16 insertions, 11 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 8d0ce28f..9af30205 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -322,7 +322,8 @@ def _get_config_scheme() -> Dict: }, "vnc": { - "keymap": Option("", type=valid_abs_path), + "desired_fps": Option(30, type=valid_stream_fps), + "keymap": Option("", type=valid_abs_path), "server": { "host": Option("::", type=valid_ip_or_host), diff --git a/kvmd/apps/vnc/__init__.py b/kvmd/apps/vnc/__init__.py index 49f7fcbe..568a34d7 100644 --- a/kvmd/apps/vnc/__init__.py +++ b/kvmd/apps/vnc/__init__.py @@ -43,6 +43,7 @@ def main(argv: Optional[List[str]]=None) -> None: VncServer( kvmd=KvmdClient(**config.kvmd._unpack()), streamer=StreamerClient(**config.streamer._unpack()), + desired_fps=config.desired_fps, symmap=build_symmap(config.keymap), **config.server._unpack(), ).run() diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index adf6f32d..e55e51a1 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -63,6 +63,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes kvmd: KvmdClient, streamer: StreamerClient, + desired_fps: int, symmap: Dict[int, str], shared_params: _SharedParams, @@ -72,6 +73,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes self.__kvmd = kvmd self.__streamer = streamer + self.__desired_fps = desired_fps self.__symmap = symmap self.__shared_params = shared_params @@ -244,10 +246,9 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes async def _on_set_encodings(self) -> None: assert self.__authorized.done() (user, passwd) = self.__authorized.result() - (quality, desired_fps) = (self._encodings.tight_jpeg_quality, 30) get_logger(0).info("[main] Client %s: Applying streamer params: quality=%d%%; desired_fps=%d ...", - self._remote, quality, desired_fps) - await self.__kvmd.set_streamer_params(user, passwd, quality=quality, desired_fps=desired_fps) + self._remote, self._encodings.tight_jpeg_quality, self.__desired_fps) + await self.__kvmd.set_streamer_params(user, passwd, self._encodings.tight_jpeg_quality, self.__desired_fps) async def _on_fb_update_request(self) -> None: self.__fb_requested = True @@ -264,6 +265,7 @@ class VncServer: kvmd: KvmdClient, streamer: StreamerClient, + desired_fps: int, symmap: Dict[int, str], ) -> None: @@ -271,12 +273,13 @@ class VncServer: self.__port = port self.__max_clients = max_clients - self.__kvmd = kvmd - self.__streamer = streamer - - self.__symmap = symmap - - self.__shared_params = _SharedParams() + self.__client_kwargs = { + "kvmd": kvmd, + "streamer": streamer, + "desired_fps": desired_fps, + "symmap": symmap, + "shared_params": _SharedParams(), + } def run(self) -> None: logger = get_logger(0) @@ -309,4 +312,4 @@ class VncServer: logger.info("Bye-bye") async def __handle_client(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None: - await _Client(reader, writer, self.__kvmd, self.__streamer, self.__symmap, self.__shared_params).run() + await _Client(reader, writer, **self.__client_kwargs).run() # type: ignore |