mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
kvmd: supported unix sockets for ustreamer
This commit is contained in:
parent
d4d15d8b74
commit
7b6f4b20ea
@ -1,7 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
import aiohttp
|
||||
|
||||
from ...application import init
|
||||
from ...logging import get_logger
|
||||
|
||||
@ -21,7 +19,6 @@ def main() -> None:
|
||||
config = init()["kvmd"]
|
||||
with gpio.bcm():
|
||||
loop = asyncio.get_event_loop()
|
||||
http_session = aiohttp.ClientSession(loop=loop)
|
||||
|
||||
info_manager = InfoManager(
|
||||
meta_path=str(config["info"]["meta"]),
|
||||
@ -72,14 +69,14 @@ def main() -> None:
|
||||
quality=int(config["streamer"]["quality"]),
|
||||
desired_fps=int(config["streamer"]["desired_fps"]),
|
||||
|
||||
host=str(config["streamer"]["host"]),
|
||||
port=int(config["streamer"]["port"]),
|
||||
host=str(config["streamer"].get("host", "localhost")),
|
||||
port=int(config["streamer"].get("port", 0)),
|
||||
unix_path=str(config["streamer"].get("unix", "")),
|
||||
timeout=float(config["streamer"]["timeout"]),
|
||||
|
||||
cmd=list(map(str, config["streamer"]["cmd"])),
|
||||
|
||||
loop=loop,
|
||||
http_session=http_session,
|
||||
)
|
||||
|
||||
Server(
|
||||
|
||||
@ -31,12 +31,12 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
host: str,
|
||||
port: int,
|
||||
unix_path: str,
|
||||
timeout: float,
|
||||
|
||||
cmd: List[str],
|
||||
|
||||
loop: asyncio.AbstractEventLoop,
|
||||
http_session: aiohttp.ClientSession,
|
||||
) -> None:
|
||||
|
||||
self.__cap_power = (gpio.set_output(cap_power) if cap_power > 0 else cap_power)
|
||||
@ -52,14 +52,19 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
"desired_fps": desired_fps,
|
||||
}
|
||||
|
||||
assert port or unix_path
|
||||
self.__host = host
|
||||
self.__port = port
|
||||
self.__unix_path = unix_path
|
||||
self.__timeout = timeout
|
||||
|
||||
self.__cmd = cmd
|
||||
|
||||
self.__loop = loop
|
||||
self.__http_session = http_session
|
||||
if self.__unix_path:
|
||||
self.__http_session = aiohttp.ClientSession(connector=aiohttp.UnixConnector(path=self.__unix_path))
|
||||
else:
|
||||
self.__http_session = aiohttp.ClientSession()
|
||||
|
||||
self.__proc_task: Optional[asyncio.Task] = None
|
||||
|
||||
@ -154,7 +159,15 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
while True: # pylint: disable=too-many-nested-blocks
|
||||
proc: Optional[asyncio.subprocess.Process] = None # pylint: disable=no-member
|
||||
try:
|
||||
cmd = [part.format(host=self.__host, port=self.__port, **self.__params) for part in self.__cmd]
|
||||
cmd = [
|
||||
part.format(
|
||||
host=self.__host,
|
||||
port=self.__port,
|
||||
unix=self.__unix_path,
|
||||
**self.__params,
|
||||
)
|
||||
for part in self.__cmd
|
||||
]
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
*cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user