mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
send i-frame first
This commit is contained in:
parent
d95367e0b4
commit
c54c1daebd
@ -247,10 +247,11 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def __fb_sender_task_loop(self) -> None:
|
async def __fb_sender_task_loop(self) -> None:
|
||||||
|
has_h264_key = False
|
||||||
|
last: Optional[Dict] = None
|
||||||
while True:
|
while True:
|
||||||
await self.__fb_notifier.wait()
|
await self.__fb_notifier.wait()
|
||||||
|
|
||||||
last: Optional[Dict] = None
|
|
||||||
while True:
|
while True:
|
||||||
frame = await self.__fb_queue.get()
|
frame = await self.__fb_queue.get()
|
||||||
if (
|
if (
|
||||||
@ -264,6 +265,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
|
|||||||
or len(last["data"]) + len(frame["data"]) > 4194304
|
or len(last["data"]) + len(frame["data"]) > 4194304
|
||||||
))
|
))
|
||||||
):
|
):
|
||||||
|
has_h264_key = (frame["format"] == StreamFormats.H264 and frame["key"])
|
||||||
last = dict(frame)
|
last = dict(frame)
|
||||||
if self.__fb_queue.qsize() == 0:
|
if self.__fb_queue.qsize() == 0:
|
||||||
break
|
break
|
||||||
@ -283,17 +285,26 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
|
|||||||
f" -> {last['width']}x{last['height']}\nPlease reconnect"
|
f" -> {last['width']}x{last['height']}\nPlease reconnect"
|
||||||
)
|
)
|
||||||
await self._send_fb_jpeg((await self.__make_text_frame(msg))["data"])
|
await self._send_fb_jpeg((await self.__make_text_frame(msg))["data"])
|
||||||
return
|
continue
|
||||||
await self._send_resize(last["width"], last["height"])
|
await self._send_resize(last["width"], last["height"])
|
||||||
|
|
||||||
|
if len(last["data"]) == 0:
|
||||||
|
# Вдруг какой-то баг
|
||||||
|
await self.__fb_notifier.notify()
|
||||||
|
continue
|
||||||
|
|
||||||
if last["format"] == StreamFormats.JPEG:
|
if last["format"] == StreamFormats.JPEG:
|
||||||
await self._send_fb_jpeg(last["data"])
|
await self._send_fb_jpeg(last["data"])
|
||||||
elif last["format"] == StreamFormats.H264:
|
elif last["format"] == StreamFormats.H264:
|
||||||
if not self._encodings.has_h264:
|
if not self._encodings.has_h264:
|
||||||
raise RfbError("The client doesn't want to accept H264 anymore")
|
raise RfbError("The client doesn't want to accept H264 anymore")
|
||||||
|
if has_h264_key:
|
||||||
await self._send_fb_h264(last["data"])
|
await self._send_fb_h264(last["data"])
|
||||||
|
else:
|
||||||
|
await self.__fb_notifier.notify()
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Unknown format: {last['format']}")
|
raise RuntimeError(f"Unknown format: {last['format']}")
|
||||||
|
last["data"] = b""
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user