summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--configs/kvmd/main/v0-hdmi.yaml1
-rw-r--r--configs/kvmd/main/v0-vga.yaml6
-rw-r--r--configs/kvmd/main/v1-hdmi.yaml1
-rw-r--r--configs/kvmd/main/v1-vga.yaml6
-rw-r--r--kvmd/apps/__init__.py5
-rw-r--r--kvmd/apps/kvmd/streamer.py13
-rw-r--r--kvmd/validators/kvm.py2
-rw-r--r--testenv/Dockerfile11
-rw-r--r--testenv/main.yaml5
-rw-r--r--testenv/tests/validators/test_kvm.py4
-rw-r--r--testenv/tox.ini2
-rw-r--r--web/kvm/index.html2
-rw-r--r--web/share/js/kvm/stream.js3
14 files changed, 46 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 3dd4917a..13123cf8 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,10 @@ TESTENV_HID ?= /dev/ttyS10
TESTENV_VIDEO ?= /dev/video0
TESTENV_LOOP ?= /dev/loop7
+USTREAMER_VERSION = $(shell curl --silent "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=ustreamer" \
+ | grep "^pkgver=" \
+ | grep -Po "\d+\.\d+[^\"']*")
+
# =====
all:
@@ -28,7 +32,12 @@ all:
testenv:
- docker build $(if $(NC),--no-cache,) --rm --tag $(TESTENV_IMAGE) -f testenv/Dockerfile .
+ docker build \
+ $(if $(NC),--no-cache,) \
+ --rm \
+ --tag $(TESTENV_IMAGE) \
+ --build-arg USTREAMER_VERSION=$(USTREAMER_VERSION) \
+ -f testenv/Dockerfile .
tox: testenv
diff --git a/configs/kvmd/main/v0-hdmi.yaml b/configs/kvmd/main/v0-hdmi.yaml
index 6f505168..43babe0b 100644
--- a/configs/kvmd/main/v0-hdmi.yaml
+++ b/configs/kvmd/main/v0-hdmi.yaml
@@ -36,6 +36,7 @@ kvmd:
- "--dv-timings"
- "--format=uyvy"
- "--encoder=omx"
+ - "--glitched-resolutions=720x480,720x576"
- "--workers=3"
- "--quality={quality}"
- "--desired-fps={desired_fps}"
diff --git a/configs/kvmd/main/v0-vga.yaml b/configs/kvmd/main/v0-vga.yaml
index ed31739a..4fe5618b 100644
--- a/configs/kvmd/main/v0-vga.yaml
+++ b/configs/kvmd/main/v0-vga.yaml
@@ -37,10 +37,8 @@ kvmd:
- "--encoder=cpu"
- "--quality={quality}"
- "--desired-fps={desired_fps}"
- - "--width=720"
- - "--height=576"
- - "--fake-width=800"
- - "--fake-height=600"
+ - "--resolution=720x756"
+ - "--fake-resolution=800x600"
- "--unix={unix}"
- "--unix-rm"
- "--unix-mode=0660"
diff --git a/configs/kvmd/main/v1-hdmi.yaml b/configs/kvmd/main/v1-hdmi.yaml
index 5e78b971..84ace7e1 100644
--- a/configs/kvmd/main/v1-hdmi.yaml
+++ b/configs/kvmd/main/v1-hdmi.yaml
@@ -38,6 +38,7 @@ kvmd:
- "--dv-timings"
- "--format=uyvy"
- "--encoder=omx"
+ - "--glitched-resolutions=720x480,720x576"
- "--workers=3"
- "--quality={quality}"
- "--desired-fps={desired_fps}"
diff --git a/configs/kvmd/main/v1-vga.yaml b/configs/kvmd/main/v1-vga.yaml
index 3eb9be94..171ca0ed 100644
--- a/configs/kvmd/main/v1-vga.yaml
+++ b/configs/kvmd/main/v1-vga.yaml
@@ -42,10 +42,8 @@ kvmd:
- "--encoder=cpu"
- "--quality={quality}"
- "--desired-fps={desired_fps}"
- - "--width=720"
- - "--height=576"
- - "--fake-width=800"
- - "--fake-height=600"
+ - "--resolution=720x576"
+ - "--fake-resolution=800x600"
- "--unix={unix}"
- "--unix-rm"
- "--unix-mode=0660"
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index a2e21b84..70c012db 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -228,8 +228,9 @@ def _get_config_scheme(sections: List[str]) -> Dict:
"shutdown_delay": Option(10.0, type=valid_float_f01),
"state_poll": Option(1.0, type=valid_float_f01),
- "quality": Option(80, type=valid_stream_quality),
- "desired_fps": Option(0, type=valid_stream_fps),
+ "quality": Option(80, type=valid_stream_quality),
+ "desired_fps": Option(0, type=valid_stream_fps),
+ "max_fps": Option(120, type=valid_stream_fps),
"host": Option("localhost", type=valid_ip_or_host),
"port": Option(0, type=valid_port),
diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py
index ef3816c1..5a3ec0ee 100644
--- a/kvmd/apps/kvmd/streamer.py
+++ b/kvmd/apps/kvmd/streamer.py
@@ -55,6 +55,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
quality: int,
desired_fps: int,
+ max_fps: int,
host: str,
port: int,
@@ -77,6 +78,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
"quality": quality,
"desired_fps": desired_fps,
}
+ self.__max_fps = max_fps
assert port or unix_path
self.__host = host
@@ -95,9 +97,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes
logger = get_logger()
logger.info("Starting streamer ...")
- self.__params = {key: params[key] for key in self.__params} # Only known params
- assert 1 <= self.__params["quality"] <= 100
- assert 0 <= self.__params["desired_fps"] <= 30
+ self.__params = {
+ key: min(max(params.get(key, self.__params[key]), a), b)
+ for (key, a, b) in [
+ ("quality", 0, 100),
+ ("desired_fps", 0, self.__max_fps),
+ ]
+ }
await self.__inner_start()
if self.__init_restart_after > 0.0 and not no_init_restart:
@@ -134,6 +140,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
except Exception:
get_logger().exception("Invalid streamer response from /state")
return {
+ "limits": {"max_fps": self.__max_fps},
"params": self.get_params(),
"state": state,
}
diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py
index 170c0cc9..6cd12478 100644
--- a/kvmd/validators/kvm.py
+++ b/kvmd/validators/kvm.py
@@ -51,7 +51,7 @@ def valid_stream_quality(arg: Any) -> int:
def valid_stream_fps(arg: Any) -> int:
- return int(valid_number(arg, min=0, max=30, name="stream FPS"))
+ return int(valid_number(arg, min=0, max=120, name="stream FPS"))
# =====
diff --git a/testenv/Dockerfile b/testenv/Dockerfile
index 41bdf976..ba8a71ee 100644
--- a/testenv/Dockerfile
+++ b/testenv/Dockerfile
@@ -13,27 +13,30 @@ RUN pacman -Syu --noconfirm \
RUN useradd -r -c "Packer build user" -m -d /var/packer -s /sbin/nologin packer \
&& cd /tmp \
- && sudo -u packer git clone https://aur.archlinux.org/packer-kit.git \
+ && sudo -u packer git clone https://github.com/pi-kvm/packer-kit.git \
&& cd packer-kit \
&& sudo -u packer makepkg \
&& pacman --noconfirm -U packer-kit-*.pkg.tar.xz \
&& cd - \
&& rm -rf /tmp/packer-kit
-RUN pkg-install \
+RUN pkg-install -S \
python \
python-pip \
python-tox \
python-systemd \
python-dbus \
python-mako \
- libevent-patched \
nginx-mainline \
- ustreamer \
socat \
htmlhint \
eslint
+ARG USTREAMER_VERSION
+ENV USTREAMER_VERSION $USTREAMER_VERSION
+RUN echo $USTREAMER_VERSION
+RUN pkg-install -S ustreamer
+
COPY testenv/requirements.txt requirements.txt
RUN pip install -r requirements.txt
diff --git a/testenv/main.yaml b/testenv/main.yaml
index eaa2917b..f7ef220d 100644
--- a/testenv/main.yaml
+++ b/testenv/main.yaml
@@ -26,14 +26,15 @@ kvmd:
cap_pin: 17
conv_pin: 18
init_restart_after: 1
+ desired_fps: 30
+ max_fps: 40
unix: /run/kvmd/ustreamer.sock
cmd:
- "/usr/bin/ustreamer"
- "--device=/dev/kvmd-video"
- "--quality={quality}"
- "--desired-fps={desired_fps}"
- - "--width=800"
- - "--height=600"
+ - "--resolution=800x600"
- "--unix={unix}"
- "--unix-rm"
- "--unix-mode=0666"
diff --git a/testenv/tests/validators/test_kvm.py b/testenv/tests/validators/test_kvm.py
index a15a3168..920dcb10 100644
--- a/testenv/tests/validators/test_kvm.py
+++ b/testenv/tests/validators/test_kvm.py
@@ -104,14 +104,14 @@ def test_fail__valid_stream_quality(arg: Any) -> None:
# =====
[email protected]("arg", ["1 ", 30])
[email protected]("arg", ["1 ", 120])
def test_ok__valid_stream_fps(arg: Any) -> None:
value = valid_stream_fps(arg)
assert type(value) == int # pylint: disable=unidiomatic-typecheck
assert value == int(str(arg).strip())
[email protected]("arg", ["test", "", None, 31, 1.1])
[email protected]("arg", ["test", "", None, 121, 1.1])
def test_fail__valid_stream_fps(arg: Any) -> None:
with pytest.raises(ValidatorError):
print(valid_stream_fps(arg))
diff --git a/testenv/tox.ini b/testenv/tox.ini
index 08d4d905..4baf7548 100644
--- a/testenv/tox.ini
+++ b/testenv/tox.ini
@@ -54,7 +54,7 @@ deps =
[testenv:eslint]
whitelist_externals = eslint
-commands = eslint --config=testenv/linters/eslintrc.yaml --color --ext .js web/share/js
+commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.yaml --color --ext .js web/share/js
[testenv:htmlhint]
whitelist_externals = htmlhint
diff --git a/web/kvm/index.html b/web/kvm/index.html
index dae4b9c3..56279005 100644
--- a/web/kvm/index.html
+++ b/web/kvm/index.html
@@ -100,7 +100,7 @@
</div>
<hr>
<div class="menu-item-content-text">
- Stream FPS: <span id="stream-desired-fps-value">30</span>
+ Stream FPS: <span id="stream-desired-fps-value">0</span>
<div class="stream-slider-box">
<input disabled type="range" id="stream-desired-fps-slider" class="slider" />
</div>
diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js
index f6d19718..a73d0d2d 100644
--- a/web/share/js/kvm/stream.js
+++ b/web/share/js/kvm/stream.js
@@ -42,7 +42,7 @@ function Streamer() {
tools.setOnUpSlider($("stream-quality-slider"), 1000, __updateQualityValue, (value) => __sendParam("quality", value));
$("stream-desired-fps-slider").min = 0;
- $("stream-desired-fps-slider").max = 30;
+ $("stream-desired-fps-slider").max = 120;
$("stream-desired-fps-slider").step = 1;
$("stream-desired-fps-slider").value = 0;
tools.setOnUpSlider($("stream-desired-fps-slider"), 1000, __updateDesiredFpsValue, (value) => __sendParam("desired_fps", value));
@@ -80,6 +80,7 @@ function Streamer() {
}
if (!$("stream-desired-fps-slider").activated) {
+ $("stream-desired-fps-slider").max = state.limits.max_fps;
wm.switchDisabled($("stream-desired-fps-slider"), false);
if ($("stream-desired-fps-slider").value !== source.desired_fps) {
$("stream-desired-fps-slider").value = source.desired_fps;