summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-02-03 21:38:16 +0300
committerDevaev Maxim <[email protected]>2021-02-03 21:38:16 +0300
commit32bd2453eb55b5a2516a2b6bf66739e975b867f4 (patch)
tree332623418527b767c2415990ff93c97519b5e24e /kvmd/apps
parentdb4dc5de4586f4f30dfacb0c9a5d0c40c2c67b68 (diff)
fixed h264 accumulating
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/vnc/server.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py
index a14af8c9..5c915abb 100644
--- a/kvmd/apps/vnc/server.py
+++ b/kvmd/apps/vnc/server.py
@@ -242,6 +242,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
if not self._encodings.has_h264:
self.__fb_h264_data = b""
raise StreamerPermError("The client doesn't want to accept H264 anymore")
+ self.__append_h264_data(frame)
await self._send_fb_h264(self.__fb_h264_data)
else:
raise RuntimeError(f"Unknown format: {frame['format']}")
@@ -251,13 +252,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
self.__fb_h264_data = b""
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
- get_logger(0).info("Accumulated H264 buffer is too big; resetting ...")
- self.__fb_h264_data = frame["data"]
- else:
- self.__fb_h264_data += frame["data"]
+ self.__append_h264_data(frame)
async def __resize_fb_unsafe(self, frame: Dict) -> bool:
width = frame["width"]
@@ -272,6 +267,15 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
await self._send_resize(width, height)
return True
+ def __append_h264_data(self, frame: Dict) -> None:
+ if frame["key"]:
+ self.__fb_h264_data = frame["data"]
+ elif len(self.__fb_h264_data) + len(frame["data"]) > 4194304: # 4Mb
+ get_logger(0).info("Accumulated H264 buffer is too big; resetting ...")
+ self.__fb_h264_data = frame["data"]
+ else:
+ self.__fb_h264_data += frame["data"]
+
async def __send_fb_stub(self, text: str, no_lock: bool=False) -> None:
if not no_lock:
await self.__lock.acquire()