diff options
author | Devaev Maxim <[email protected]> | 2020-08-22 22:35:37 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-08-22 22:35:37 +0300 |
commit | f0882df330e6dcdb2b4f9c37b2ea71a9639f9746 (patch) | |
tree | 2cb0c14f71c6dfe2e371184a1d29ffc311a951af /kvmd | |
parent | 7f74d7ee45a8ffc94caf87f9335fbdbf9d79c69d (diff) |
fixed VNC for capture without quality control
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/server.py | 8 | ||||
-rw-r--r-- | kvmd/clients/kvmd.py | 17 |
2 files changed, 20 insertions, 5 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index bfe772a2..28e7db62 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -274,9 +274,11 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes async def _on_set_encodings(self) -> None: assert self.__authorized.done() assert self.__kvmd_session - get_logger(0).info("[main] %s: Applying streamer params: quality=%d%%; desired_fps=%d ...", - self._remote, self._encodings.tight_jpeg_quality, self.__desired_fps) - await self.__kvmd_session.streamer.set_params(self._encodings.tight_jpeg_quality, self.__desired_fps) + has_quality = (await self.__kvmd_session.streamer.get_state())["features"]["quality"] + quality = (self._encodings.tight_jpeg_quality if has_quality else None) + get_logger(0).info("[main] %s: Applying streamer params: quality=%s; desired_fps=%d ...", + self._remote, quality, self.__desired_fps) + await self.__kvmd_session.streamer.set_params(quality, self.__desired_fps) async def _on_fb_update_request(self) -> None: async with self.__lock: diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index e514fb16..d78aedbd 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -66,11 +66,24 @@ class _AuthApiPart(_BaseApiPart): class _StreamerApiPart(_BaseApiPart): - async def set_params(self, quality: int, desired_fps: int) -> None: + async def get_state(self) -> Dict: + session = self._ensure_http_session() + async with session.get(self._make_url("streamer")) as response: + htclient.raise_not_200(response) + return (await response.json())["result"] + + async def set_params(self, quality: Optional[int]=None, desired_fps: Optional[int]=None) -> None: session = self._ensure_http_session() async with session.post( url=self._make_url("streamer/set_params"), - params={"quality": quality, "desired_fps": desired_fps}, + params={ + key: value + for (key, value) in [ + ("quality", quality), + ("desired_fps", desired_fps), + ] + if value is not None + }, ) as response: htclient.raise_not_200(response) |