summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-08 05:16:17 +0300
committerDevaev Maxim <[email protected]>2018-11-08 05:16:17 +0300
commit363bbdac57fb20cda7a261196105ab4b5f61e7ff (patch)
tree495c3ac16e698010a5e8e0867e521160db7df94a /kvmd
parent4927d3e17334dfe6768396457c49b11aa8e16e21 (diff)
new ustreamer
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/__init__.py2
-rw-r--r--kvmd/apps/kvmd/server.py14
-rw-r--r--kvmd/apps/kvmd/streamer.py18
3 files changed, 17 insertions, 17 deletions
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py
index b58b6df3..01737b01 100644
--- a/kvmd/apps/kvmd/__init__.py
+++ b/kvmd/apps/kvmd/__init__.py
@@ -57,7 +57,7 @@ def main() -> None:
init_delay=float(config["streamer"]["init_delay"]),
init_restart_after=float(config["streamer"]["init_restart_after"]),
quality=int(config["streamer"]["quality"]),
- soft_fps=int(config["streamer"]["soft_fps"]),
+ desired_fps=int(config["streamer"]["desired_fps"]),
cmd=list(map(str, config["streamer"]["cmd"])),
loop=loop,
)
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 8522cb16..cd89c433 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -139,7 +139,7 @@ class Server: # pylint: disable=too-many-instance-attributes
self.__reset_streamer = False
self.__streamer_quality = streamer.get_current_quality()
- self.__streamer_soft_fps = streamer.get_current_soft_fps()
+ self.__streamer_desired_fps = streamer.get_current_desired_fps()
def run(self, host: str, port: int) -> None:
self.__hid.start()
@@ -354,9 +354,9 @@ class Server: # pylint: disable=too-many-instance-attributes
quality = request.query.get("quality")
if quality:
self.__streamer_quality = _valid_int("quality", quality, 1, 100)
- soft_fps = request.query.get("soft_fps")
- if soft_fps:
- self.__streamer_soft_fps = _valid_int("soft_fps", soft_fps, 1, 30)
+ desired_fps = request.query.get("desired_fps")
+ if desired_fps:
+ self.__streamer_desired_fps = _valid_int("desired_fps", desired_fps, 0, 30)
return _json()
async def __streamer_reset_handler(self, _: aiohttp.web.Request) -> aiohttp.web.Response:
@@ -402,7 +402,7 @@ class Server: # pylint: disable=too-many-instance-attributes
cur = len(self.__sockets)
if prev == 0 and cur > 0:
if not self.__streamer.is_running():
- await self.__streamer.start(self.__streamer_quality, self.__streamer_soft_fps)
+ await self.__streamer.start(self.__streamer_quality, self.__streamer_desired_fps)
await self.__broadcast_event("streamer_state", **self.__streamer.get_state())
elif prev > 0 and cur == 0:
shutdown_at = time.time() + self.__streamer_shutdown_delay
@@ -414,11 +414,11 @@ class Server: # pylint: disable=too-many-instance-attributes
if (
self.__reset_streamer
or self.__streamer_quality != self.__streamer.get_current_quality()
- or self.__streamer_soft_fps != self.__streamer.get_current_soft_fps()
+ or self.__streamer_desired_fps != self.__streamer.get_current_desired_fps()
):
if self.__streamer.is_running():
await self.__streamer.stop()
- await self.__streamer.start(self.__streamer_quality, self.__streamer_soft_fps, no_init_restart=True)
+ await self.__streamer.start(self.__streamer_quality, self.__streamer_desired_fps, no_init_restart=True)
await self.__broadcast_event("streamer_state", **self.__streamer.get_state())
self.__reset_streamer = False
diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py
index bfb77d28..983dee6e 100644
--- a/kvmd/apps/kvmd/streamer.py
+++ b/kvmd/apps/kvmd/streamer.py
@@ -21,7 +21,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
init_delay: float,
init_restart_after: float,
quality: int,
- soft_fps: int,
+ desired_fps: int,
cmd: List[str],
loop: asyncio.AbstractEventLoop,
) -> None:
@@ -32,22 +32,22 @@ class Streamer: # pylint: disable=too-many-instance-attributes
self.__init_delay = init_delay
self.__init_restart_after = init_restart_after
self.__quality = quality
- self.__soft_fps = soft_fps
+ self.__desired_fps = desired_fps
self.__cmd = cmd
self.__loop = loop
self.__proc_task: Optional[asyncio.Task] = None
- async def start(self, quality: int, soft_fps: int, no_init_restart: bool=False) -> None:
+ async def start(self, quality: int, desired_fps: int, no_init_restart: bool=False) -> None:
logger = get_logger()
logger.info("Starting streamer ...")
assert 1 <= quality <= 100
self.__quality = quality
- assert 1 <= soft_fps <= 30
- self.__soft_fps = soft_fps
+ assert 0 <= desired_fps <= 30
+ self.__desired_fps = desired_fps
await self.__inner_start()
if self.__init_restart_after > 0.0 and not no_init_restart:
@@ -66,14 +66,14 @@ class Streamer: # pylint: disable=too-many-instance-attributes
def get_current_quality(self) -> int:
return self.__quality
- def get_current_soft_fps(self) -> int:
- return self.__soft_fps
+ def get_current_desired_fps(self) -> int:
+ return self.__desired_fps
def get_state(self) -> Dict:
return {
"is_running": self.is_running(),
"quality": self.__quality,
- "soft_fps": self.__soft_fps,
+ "desired_fps": self.__desired_fps,
}
def get_app(self) -> str:
@@ -121,7 +121,7 @@ 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(quality=self.__quality, soft_fps=self.__soft_fps) for part in self.__cmd]
+ cmd = [part.format(quality=self.__quality, desired_fps=self.__desired_fps) for part in self.__cmd]
proc = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,