This commit is contained in:
Devaev Maxim 2021-01-23 07:35:34 +03:00
parent 4d4fb69d2e
commit 61f52a36a2
2 changed files with 11 additions and 11 deletions

View File

@ -151,18 +151,18 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute
# =====
async def _send_fb_jpeg(self, jpeg: bytes) -> None:
async def _send_fb_jpeg(self, data: bytes) -> None:
assert self._encodings.has_tight
assert self._encodings.tight_jpeg_quality > 0
assert len(jpeg) <= 4194303, len(jpeg)
assert len(data) <= 4194303, len(data)
await self._write_fb_update(self._width, self._height, RfbEncodings.TIGHT, drain=False)
length = len(jpeg)
length = len(data)
if length <= 127:
await self._write_struct("", bytes([0b10011111, length & 0x7F]), jpeg)
await self._write_struct("", bytes([0b10011111, length & 0x7F]), data)
elif length <= 16383:
await self._write_struct("", bytes([0b10011111, length & 0x7F | 0x80, length >> 7 & 0x7F]), jpeg)
await self._write_struct("", bytes([0b10011111, length & 0x7F | 0x80, length >> 7 & 0x7F]), data)
else:
await self._write_struct("", bytes([0b10011111, length & 0x7F | 0x80, length >> 7 & 0x7F | 0x80, length >> 14 & 0xFF]), jpeg)
await self._write_struct("", bytes([0b10011111, length & 0x7F | 0x80, length >> 7 & 0x7F | 0x80, length >> 14 & 0xFF]), data)
async def _send_resize(self, width: int, height: int) -> None:
assert self._encodings.has_resize

View File

@ -194,12 +194,12 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
while True:
try:
streaming = False
async for (online, width, height, jpeg) in streamer.read_stream():
async for (online, width, height, data) in streamer.read_stream():
if not streaming:
logger.info("[%s] %s: Streaming ...", name, self._remote)
streaming = True
if online:
await self.__send_fb_real(width, height, jpeg)
await self.__send_fb_real(width, height, data)
else:
await self.__send_fb_stub("No signal")
except StreamerError as err:
@ -211,10 +211,10 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
await self.__send_fb_stub("Waiting for stream ...")
await asyncio.sleep(1)
async def __send_fb_real(self, width: int, height: int, jpeg: bytes) -> None:
async def __send_fb_real(self, width: int, height: int, data: bytes) -> None:
async with self.__lock:
if self.__fb_requested:
if (self._width, self._height) != (width, height):
if self._width != width or self._height != height:
self.__shared_params.width = width
self.__shared_params.height = height
if not self._encodings.has_resize:
@ -222,7 +222,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
await self.__send_fb_stub(msg, no_lock=True)
return
await self._send_resize(width, height)
await self._send_fb_jpeg(jpeg)
await self._send_fb_jpeg(data)
self.__fb_stub_text = ""
self.__fb_stub_quality = 0
self.__fb_requested = False