diff options
author | Devaev Maxim <[email protected]> | 2019-07-13 04:52:19 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-07-13 04:52:19 +0300 |
commit | ad97aecaf4d043c59d018310b4d8f4852d30b6e0 (patch) | |
tree | 90f6fbcdacc9aefd54cd093a77d337f1fb4543c9 /kvmd/apps | |
parent | dfe58d81efcc14b4ff8a3e6e2204bfdcce7a620b (diff) |
new ustreamer and fps max
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/__init__.py | 5 | ||||
-rw-r--r-- | kvmd/apps/kvmd/streamer.py | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index a2e21b84..70c012db 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -228,8 +228,9 @@ def _get_config_scheme(sections: List[str]) -> Dict: "shutdown_delay": Option(10.0, type=valid_float_f01), "state_poll": Option(1.0, type=valid_float_f01), - "quality": Option(80, type=valid_stream_quality), - "desired_fps": Option(0, type=valid_stream_fps), + "quality": Option(80, type=valid_stream_quality), + "desired_fps": Option(0, type=valid_stream_fps), + "max_fps": Option(120, type=valid_stream_fps), "host": Option("localhost", type=valid_ip_or_host), "port": Option(0, type=valid_port), diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py index ef3816c1..5a3ec0ee 100644 --- a/kvmd/apps/kvmd/streamer.py +++ b/kvmd/apps/kvmd/streamer.py @@ -55,6 +55,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes quality: int, desired_fps: int, + max_fps: int, host: str, port: int, @@ -77,6 +78,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes "quality": quality, "desired_fps": desired_fps, } + self.__max_fps = max_fps assert port or unix_path self.__host = host @@ -95,9 +97,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes logger = get_logger() logger.info("Starting streamer ...") - self.__params = {key: params[key] for key in self.__params} # Only known params - assert 1 <= self.__params["quality"] <= 100 - assert 0 <= self.__params["desired_fps"] <= 30 + self.__params = { + key: min(max(params.get(key, self.__params[key]), a), b) + for (key, a, b) in [ + ("quality", 0, 100), + ("desired_fps", 0, self.__max_fps), + ] + } await self.__inner_start() if self.__init_restart_after > 0.0 and not no_init_restart: @@ -134,6 +140,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes except Exception: get_logger().exception("Invalid streamer response from /state") return { + "limits": {"max_fps": self.__max_fps}, "params": self.get_params(), "state": state, } |