diff options
author | Devaev Maxim <[email protected]> | 2018-06-29 22:44:04 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-06-29 22:44:04 +0300 |
commit | 607e5a9877659563cd96618bdf4948ac28830a27 (patch) | |
tree | 779a259607cace8b18f8695672e2064ba91ed13c /kvmd | |
parent | 8fccd507175ccb5ea251dd9aa5e28ddf216b2b59 (diff) |
RESTART_VIDEO command
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/kvmd/server.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kvmd/kvmd/server.py b/kvmd/kvmd/server.py index b05c82a4..6a4c6d6a 100644 --- a/kvmd/kvmd/server.py +++ b/kvmd/kvmd/server.py @@ -55,6 +55,8 @@ class Server: # pylint: disable=too-many-instance-attributes self.__system_tasks: List[asyncio.Task] = [] + self.__restart_video = False + def run(self, host: str, port: int) -> None: self.__keyboard.start() @@ -122,6 +124,7 @@ class Server: # pylint: disable=too-many-instance-attributes async def __stream_controller(self) -> None: prev = 0 shutdown_at = 0.0 + while True: cur = len(self.__sockets) if prev == 0 and cur > 0: @@ -132,6 +135,13 @@ class Server: # pylint: disable=too-many-instance-attributes elif prev == 0 and cur == 0 and time.time() > shutdown_at: if self.__streamer.is_running(): await self.__streamer.stop() + + if self.__restart_video: + if self.__streamer.is_running(): + await self.__streamer.stop() + await self.__streamer.start() + self.__restart_video = False + prev = cur await asyncio.sleep(0.1) @@ -168,6 +178,9 @@ class Server: # pylint: disable=too-many-instance-attributes if method: await method() return None + elif command == "RESTART_VIDEO": + self.__restart_video = True + return None get_logger().warning("Received an incorrect command: %r", command) return "ERROR incorrect command" |