summaryrefslogtreecommitdiff
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
parent4927d3e17334dfe6768396457c49b11aa8e16e21 (diff)
new ustreamer
-rw-r--r--configs/kvmd/v1-hdmi.conf4
-rw-r--r--configs/kvmd/v1-vga.conf4
-rw-r--r--kvmd/apps/kvmd/__init__.py2
-rw-r--r--kvmd/apps/kvmd/server.py14
-rw-r--r--kvmd/apps/kvmd/streamer.py18
-rw-r--r--testenv/kvmd.conf4
-rw-r--r--web/index.html4
-rw-r--r--web/js/stream.js61
8 files changed, 57 insertions, 54 deletions
diff --git a/configs/kvmd/v1-hdmi.conf b/configs/kvmd/v1-hdmi.conf
index aa8b1ce6..7c663ce9 100644
--- a/configs/kvmd/v1-hdmi.conf
+++ b/configs/kvmd/v1-hdmi.conf
@@ -51,7 +51,7 @@ kvmd:
shutdown_delay: 10.0
quality: 20
- soft_fps: 30
+ desired_fps: 0
cmd:
- "/usr/bin/ustreamer"
@@ -61,7 +61,7 @@ kvmd:
- "--encoder=omx"
- "--workers=3"
- "--quality={quality}"
- - "--soft-fps={soft_fps}"
+ - "--desired-fps={desired_fps}"
- "--dv-timings"
- "--host=127.0.0.1"
- "--port=8082"
diff --git a/configs/kvmd/v1-vga.conf b/configs/kvmd/v1-vga.conf
index 779ccc64..fe2cafa0 100644
--- a/configs/kvmd/v1-vga.conf
+++ b/configs/kvmd/v1-vga.conf
@@ -51,7 +51,7 @@ kvmd:
shutdown_delay: 10.0
quality: 80
- soft_fps: 30
+ desired_fps: 0
cmd:
- "/usr/bin/ustreamer"
@@ -60,7 +60,7 @@ kvmd:
- "--format=yuyv"
- "--encoder=cpu"
- "--quality={quality}"
- - "--soft-fps={soft_fps}"
+ - "--desired-fps={desired_fps}"
- "--width=720"
- "--height=576"
- "--fake-width=800"
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,
diff --git a/testenv/kvmd.conf b/testenv/kvmd.conf
index 5afb6c85..a0cc72a0 100644
--- a/testenv/kvmd.conf
+++ b/testenv/kvmd.conf
@@ -50,13 +50,13 @@ kvmd:
shutdown_delay: 10.0
quality: 80
- soft_fps: 30
+ desired_fps: 0
cmd:
- "/usr/bin/ustreamer"
- "--device=/dev/kvmd-streamer"
- "--quality={quality}"
- - "--soft-fps={soft_fps}"
+ - "--desired-fps={desired_fps}"
- "--width=800"
- "--height=600"
- "--host=0.0.0.0"
diff --git a/web/index.html b/web/index.html
index 0fac2724..4ecf7928 100644
--- a/web/index.html
+++ b/web/index.html
@@ -86,9 +86,9 @@
</div>
<hr>
<div class="ctl-dropdown-content-text">
- Soft FPS limit: <span id="stream-soft-fps-value">30</span>
+ Stream FPS: <span id="stream-desired-fps-value">30</span>
<div class="stream-slider-box">
- <input disabled type="range" id="stream-soft-fps-slider" class="slider" />
+ <input disabled type="range" id="stream-desired-fps-slider" class="slider" />
</div>
</div>
<hr>
diff --git a/web/js/stream.js b/web/js/stream.js
index d9c1e788..2b431e89 100644
--- a/web/js/stream.js
+++ b/web/js/stream.js
@@ -6,9 +6,9 @@ function Stream() {
var __prev_state = false;
var __resolution = {width: 640, height: 480};
var __size_factor = 1;
- var __key = tools.makeId();
+ var __client_key = tools.makeId();
var __client_id = "";
- var __fps = -1;
+ var __client_fps = -1;
var __init__ = function() {
$("stream-led").title = "Stream inactive";
@@ -21,12 +21,12 @@ function Stream() {
$("stream-quality-value").innerHTML = value + "%";
}, __sendQuality);
- $("stream-soft-fps-slider").min = 1;
- $("stream-soft-fps-slider").max = 30;
- $("stream-soft-fps-slider").step = 1;
- $("stream-soft-fps-slider").value = 30;
- tools.setOnUpSlider($("stream-soft-fps-slider"), 1000, function(value) {
- $("stream-soft-fps-value").innerHTML = value;
+ $("stream-desired-fps-slider").min = 0;
+ $("stream-desired-fps-slider").max = 30;
+ $("stream-desired-fps-slider").step = 1;
+ $("stream-desired-fps-slider").value = 0;
+ tools.setOnUpSlider($("stream-desired-fps-slider"), 1000, function(value) {
+ $("stream-desired-fps-value").innerHTML = (value == 0 ? "Unlimited" : value);
}, __sendSoftFps);
$("stream-size-slider").min = 20;
@@ -61,31 +61,34 @@ function Stream() {
$("stream-screenshot-button").disabled = true;
__setStreamerControlsDisabled(true);
__updateStreamHeader(false);
- __key = tools.makeId();
+ __client_key = tools.makeId();
__client_id = "";
- __fps = -1;
+ __client_fps = -1;
__prev_state = false;
}
} else if (http.status === 200) {
- if (!$("stream-soft-fps-slider").activated) {
- $("stream-soft-fps-slider").disabled = false;
- if ($("stream-soft-fps-slider").value !== response.source.soft_fps) {
- $("stream-soft-fps-slider").value = response.source.soft_fps;
- $("stream-soft-fps-value").innerHTML = response.source.soft_fps;
+ var source = response.result.source;
+ var stream = response.result.stream;
+
+ if (!$("stream-desired-fps-slider").activated) {
+ $("stream-desired-fps-slider").disabled = false;
+ if ($("stream-desired-fps-slider").value !== source.desired_fps) {
+ $("stream-desired-fps-slider").value = source.desired_fps;
+ $("stream-desired-fps-value").innerHTML = (source.desired_fps == 0 ? "Unlimited" : source.desired_fps);
}
}
if (!$("stream-quality-slider").activated) {
$("stream-quality-slider").disabled = false;
- if ($("stream-quality-slider").value !== response.source.quality) {
- $("stream-quality-slider").value = response.source.quality;
- $("stream-quality-value").innerHTML = response.source.quality + "%";
+ if ($("stream-quality-slider").value !== source.quality) {
+ $("stream-quality-slider").value = source.quality;
+ $("stream-quality-value").innerHTML = source.quality + "%";
}
}
- if (__resolution.width !== response.source.resolution.width || __resolution.height !== response.source.resolution.height) {
- __resolution = response.source.resolution;
+ if (__resolution.width !== source.resolution.width || __resolution.height !== source.resolution.height) {
+ __resolution = source.resolution;
if ($("stream-auto-resize-checkbox").checked) {
__adjustSizeFactor();
} else {
@@ -94,21 +97,21 @@ function Stream() {
}
var stream_client = tools.getCookie("stream_client");
- if (!__client_id && stream_client && stream_client.startsWith(__key + "/")) {
+ if (!__client_id && stream_client && stream_client.startsWith(__client_key + "/")) {
tools.info("Stream: found acceptable stream_client cookie:", stream_client);
__client_id = stream_client.slice(stream_client.indexOf("/") + 1);
}
- if (response.stream.clients_stat.hasOwnProperty(__client_id)) {
- __fps = response.stream.clients_stat[__client_id].fps;
+ if (stream.clients_stat.hasOwnProperty(__client_id)) {
+ __client_fps = stream.clients_stat[__client_id].fps;
} else {
- __fps = -1;
+ __client_fps = -1;
}
__updateStreamHeader(true);
if (!__prev_state) {
- var path = "/streamer/stream?key=" + __key;
+ var path = "/streamer/stream?key=" + __client_key;
if (tools.browser.is_chrome || tools.browser.is_blink) {
// uStreamer fix for Blink https://bugs.chromium.org/p/chromium/issues/detail?id=527446
tools.info("Stream: using advance_headers=1 to fix Blink MJPG bugs");
@@ -138,7 +141,7 @@ function Stream() {
var el_grab = document.querySelector("#stream-window-header .window-grab");
var el_info = $("stream-info");
if (online) {
- var fps_suffix = (__fps >= 0 ? " / " + __fps + " fps" : "");
+ var fps_suffix = (__client_fps >= 0 ? " / " + __client_fps + " fps" : "");
el_grab.innerHTML = el_info.innerHTML = "Stream &ndash; " + __resolution.width + "x" + __resolution.height + fps_suffix;
} else {
el_grab.innerHTML = el_info.innerHTML = "Stream &ndash; offline";
@@ -179,12 +182,12 @@ function Stream() {
var __sendSoftFps = function(value) {
__setStreamerControlsDisabled(true);
- var http = tools.makeRequest("POST", "/kvmd/streamer/set_params?soft_fps=" + value, function() {
+ var http = tools.makeRequest("POST", "/kvmd/streamer/set_params?desired_fps=" + value, function() {
if (http.readyState === 4) {
if (http.status !== 200) {
ui.error("Can't configure stream:<br>", http.responseText);
}
- $("stream-soft-fps-slider").activated = false;
+ $("stream-desired-fps-slider").activated = false;
}
});
};
@@ -192,7 +195,7 @@ function Stream() {
var __setStreamerControlsDisabled = function(disabled) {
$("stream-reset-button").disabled = disabled;
$("stream-quality-slider").disabled = disabled;
- $("stream-soft-fps-slider").disabled = disabled;
+ $("stream-desired-fps-slider").disabled = disabled;
};
var __resize = function(center=false) {