mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
rename
This commit is contained in:
parent
4d4fb69d2e
commit
61f52a36a2
@ -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.has_tight
|
||||||
assert self._encodings.tight_jpeg_quality > 0
|
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)
|
await self._write_fb_update(self._width, self._height, RfbEncodings.TIGHT, drain=False)
|
||||||
length = len(jpeg)
|
length = len(data)
|
||||||
if length <= 127:
|
if length <= 127:
|
||||||
await self._write_struct("", bytes([0b10011111, length & 0x7F]), jpeg)
|
await self._write_struct("", bytes([0b10011111, length & 0x7F]), data)
|
||||||
elif length <= 16383:
|
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:
|
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:
|
async def _send_resize(self, width: int, height: int) -> None:
|
||||||
assert self._encodings.has_resize
|
assert self._encodings.has_resize
|
||||||
|
|||||||
@ -194,12 +194,12 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
streaming = False
|
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:
|
if not streaming:
|
||||||
logger.info("[%s] %s: Streaming ...", name, self._remote)
|
logger.info("[%s] %s: Streaming ...", name, self._remote)
|
||||||
streaming = True
|
streaming = True
|
||||||
if online:
|
if online:
|
||||||
await self.__send_fb_real(width, height, jpeg)
|
await self.__send_fb_real(width, height, data)
|
||||||
else:
|
else:
|
||||||
await self.__send_fb_stub("No signal")
|
await self.__send_fb_stub("No signal")
|
||||||
except StreamerError as err:
|
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 self.__send_fb_stub("Waiting for stream ...")
|
||||||
await asyncio.sleep(1)
|
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:
|
async with self.__lock:
|
||||||
if self.__fb_requested:
|
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.width = width
|
||||||
self.__shared_params.height = height
|
self.__shared_params.height = height
|
||||||
if not self._encodings.has_resize:
|
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)
|
await self.__send_fb_stub(msg, no_lock=True)
|
||||||
return
|
return
|
||||||
await self._send_resize(width, height)
|
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_text = ""
|
||||||
self.__fb_stub_quality = 0
|
self.__fb_stub_quality = 0
|
||||||
self.__fb_requested = False
|
self.__fb_requested = False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user