summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-03-06 00:47:12 +0300
committerDevaev Maxim <[email protected]>2021-03-06 00:47:12 +0300
commitc54c1daebd800e580abb9797eed8c80ae4e3980c (patch)
treeac28937899b99715fa6c9907dbefce8c53ca6164 /kvmd
parentd95367e0b452a8455066278863a6aae46fd8dd4b (diff)
send i-frame first
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/vnc/server.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py
index e0bc5b57..a3710c5c 100644
--- a/kvmd/apps/vnc/server.py
+++ b/kvmd/apps/vnc/server.py
@@ -247,10 +247,11 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
}
async def __fb_sender_task_loop(self) -> None:
+ has_h264_key = False
+ last: Optional[Dict] = None
while True:
await self.__fb_notifier.wait()
- last: Optional[Dict] = None
while True:
frame = await self.__fb_queue.get()
if (
@@ -264,6 +265,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
or len(last["data"]) + len(frame["data"]) > 4194304
))
):
+ has_h264_key = (frame["format"] == StreamFormats.H264 and frame["key"])
last = dict(frame)
if self.__fb_queue.qsize() == 0:
break
@@ -283,17 +285,26 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
f" -> {last['width']}x{last['height']}\nPlease reconnect"
)
await self._send_fb_jpeg((await self.__make_text_frame(msg))["data"])
- return
+ continue
await self._send_resize(last["width"], last["height"])
+ if len(last["data"]) == 0:
+ # Вдруг какой-то баг
+ await self.__fb_notifier.notify()
+ continue
+
if last["format"] == StreamFormats.JPEG:
await self._send_fb_jpeg(last["data"])
elif last["format"] == StreamFormats.H264:
if not self._encodings.has_h264:
raise RfbError("The client doesn't want to accept H264 anymore")
- await self._send_fb_h264(last["data"])
+ if has_h264_key:
+ await self._send_fb_h264(last["data"])
+ else:
+ await self.__fb_notifier.notify()
else:
raise RuntimeError(f"Unknown format: {last['format']}")
+ last["data"] = b""
# =====