mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 17:50:29 +08:00
new ustreamer and fps max
This commit is contained in:
parent
dfe58d81ef
commit
ad97aecaf4
11
Makefile
11
Makefile
@ -5,6 +5,10 @@ TESTENV_HID ?= /dev/ttyS10
|
|||||||
TESTENV_VIDEO ?= /dev/video0
|
TESTENV_VIDEO ?= /dev/video0
|
||||||
TESTENV_LOOP ?= /dev/loop7
|
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:
|
all:
|
||||||
@ -28,7 +32,12 @@ all:
|
|||||||
|
|
||||||
|
|
||||||
testenv:
|
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
|
tox: testenv
|
||||||
|
|||||||
@ -36,6 +36,7 @@ kvmd:
|
|||||||
- "--dv-timings"
|
- "--dv-timings"
|
||||||
- "--format=uyvy"
|
- "--format=uyvy"
|
||||||
- "--encoder=omx"
|
- "--encoder=omx"
|
||||||
|
- "--glitched-resolutions=720x480,720x576"
|
||||||
- "--workers=3"
|
- "--workers=3"
|
||||||
- "--quality={quality}"
|
- "--quality={quality}"
|
||||||
- "--desired-fps={desired_fps}"
|
- "--desired-fps={desired_fps}"
|
||||||
|
|||||||
@ -37,10 +37,8 @@ kvmd:
|
|||||||
- "--encoder=cpu"
|
- "--encoder=cpu"
|
||||||
- "--quality={quality}"
|
- "--quality={quality}"
|
||||||
- "--desired-fps={desired_fps}"
|
- "--desired-fps={desired_fps}"
|
||||||
- "--width=720"
|
- "--resolution=720x756"
|
||||||
- "--height=576"
|
- "--fake-resolution=800x600"
|
||||||
- "--fake-width=800"
|
|
||||||
- "--fake-height=600"
|
|
||||||
- "--unix={unix}"
|
- "--unix={unix}"
|
||||||
- "--unix-rm"
|
- "--unix-rm"
|
||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
|
|||||||
@ -38,6 +38,7 @@ kvmd:
|
|||||||
- "--dv-timings"
|
- "--dv-timings"
|
||||||
- "--format=uyvy"
|
- "--format=uyvy"
|
||||||
- "--encoder=omx"
|
- "--encoder=omx"
|
||||||
|
- "--glitched-resolutions=720x480,720x576"
|
||||||
- "--workers=3"
|
- "--workers=3"
|
||||||
- "--quality={quality}"
|
- "--quality={quality}"
|
||||||
- "--desired-fps={desired_fps}"
|
- "--desired-fps={desired_fps}"
|
||||||
|
|||||||
@ -42,10 +42,8 @@ kvmd:
|
|||||||
- "--encoder=cpu"
|
- "--encoder=cpu"
|
||||||
- "--quality={quality}"
|
- "--quality={quality}"
|
||||||
- "--desired-fps={desired_fps}"
|
- "--desired-fps={desired_fps}"
|
||||||
- "--width=720"
|
- "--resolution=720x576"
|
||||||
- "--height=576"
|
- "--fake-resolution=800x600"
|
||||||
- "--fake-width=800"
|
|
||||||
- "--fake-height=600"
|
|
||||||
- "--unix={unix}"
|
- "--unix={unix}"
|
||||||
- "--unix-rm"
|
- "--unix-rm"
|
||||||
- "--unix-mode=0660"
|
- "--unix-mode=0660"
|
||||||
|
|||||||
@ -228,8 +228,9 @@ def _get_config_scheme(sections: List[str]) -> Dict:
|
|||||||
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
||||||
"state_poll": Option(1.0, type=valid_float_f01),
|
"state_poll": Option(1.0, type=valid_float_f01),
|
||||||
|
|
||||||
"quality": Option(80, type=valid_stream_quality),
|
"quality": Option(80, type=valid_stream_quality),
|
||||||
"desired_fps": Option(0, type=valid_stream_fps),
|
"desired_fps": Option(0, type=valid_stream_fps),
|
||||||
|
"max_fps": Option(120, type=valid_stream_fps),
|
||||||
|
|
||||||
"host": Option("localhost", type=valid_ip_or_host),
|
"host": Option("localhost", type=valid_ip_or_host),
|
||||||
"port": Option(0, type=valid_port),
|
"port": Option(0, type=valid_port),
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
quality: int,
|
quality: int,
|
||||||
desired_fps: int,
|
desired_fps: int,
|
||||||
|
max_fps: int,
|
||||||
|
|
||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
@ -77,6 +78,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
"quality": quality,
|
"quality": quality,
|
||||||
"desired_fps": desired_fps,
|
"desired_fps": desired_fps,
|
||||||
}
|
}
|
||||||
|
self.__max_fps = max_fps
|
||||||
|
|
||||||
assert port or unix_path
|
assert port or unix_path
|
||||||
self.__host = host
|
self.__host = host
|
||||||
@ -95,9 +97,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
logger.info("Starting streamer ...")
|
logger.info("Starting streamer ...")
|
||||||
|
|
||||||
self.__params = {key: params[key] for key in self.__params} # Only known params
|
self.__params = {
|
||||||
assert 1 <= self.__params["quality"] <= 100
|
key: min(max(params.get(key, self.__params[key]), a), b)
|
||||||
assert 0 <= self.__params["desired_fps"] <= 30
|
for (key, a, b) in [
|
||||||
|
("quality", 0, 100),
|
||||||
|
("desired_fps", 0, self.__max_fps),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
await self.__inner_start()
|
await self.__inner_start()
|
||||||
if self.__init_restart_after > 0.0 and not no_init_restart:
|
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:
|
except Exception:
|
||||||
get_logger().exception("Invalid streamer response from /state")
|
get_logger().exception("Invalid streamer response from /state")
|
||||||
return {
|
return {
|
||||||
|
"limits": {"max_fps": self.__max_fps},
|
||||||
"params": self.get_params(),
|
"params": self.get_params(),
|
||||||
"state": state,
|
"state": state,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ def valid_stream_quality(arg: Any) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def valid_stream_fps(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"))
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|||||||
@ -13,27 +13,30 @@ RUN pacman -Syu --noconfirm \
|
|||||||
|
|
||||||
RUN useradd -r -c "Packer build user" -m -d /var/packer -s /sbin/nologin packer \
|
RUN useradd -r -c "Packer build user" -m -d /var/packer -s /sbin/nologin packer \
|
||||||
&& cd /tmp \
|
&& 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 \
|
&& cd packer-kit \
|
||||||
&& sudo -u packer makepkg \
|
&& sudo -u packer makepkg \
|
||||||
&& pacman --noconfirm -U packer-kit-*.pkg.tar.xz \
|
&& pacman --noconfirm -U packer-kit-*.pkg.tar.xz \
|
||||||
&& cd - \
|
&& cd - \
|
||||||
&& rm -rf /tmp/packer-kit
|
&& rm -rf /tmp/packer-kit
|
||||||
|
|
||||||
RUN pkg-install \
|
RUN pkg-install -S \
|
||||||
python \
|
python \
|
||||||
python-pip \
|
python-pip \
|
||||||
python-tox \
|
python-tox \
|
||||||
python-systemd \
|
python-systemd \
|
||||||
python-dbus \
|
python-dbus \
|
||||||
python-mako \
|
python-mako \
|
||||||
libevent-patched \
|
|
||||||
nginx-mainline \
|
nginx-mainline \
|
||||||
ustreamer \
|
|
||||||
socat \
|
socat \
|
||||||
htmlhint \
|
htmlhint \
|
||||||
eslint
|
eslint
|
||||||
|
|
||||||
|
ARG USTREAMER_VERSION
|
||||||
|
ENV USTREAMER_VERSION $USTREAMER_VERSION
|
||||||
|
RUN echo $USTREAMER_VERSION
|
||||||
|
RUN pkg-install -S ustreamer
|
||||||
|
|
||||||
COPY testenv/requirements.txt requirements.txt
|
COPY testenv/requirements.txt requirements.txt
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
|||||||
@ -26,14 +26,15 @@ kvmd:
|
|||||||
cap_pin: 17
|
cap_pin: 17
|
||||||
conv_pin: 18
|
conv_pin: 18
|
||||||
init_restart_after: 1
|
init_restart_after: 1
|
||||||
|
desired_fps: 30
|
||||||
|
max_fps: 40
|
||||||
unix: /run/kvmd/ustreamer.sock
|
unix: /run/kvmd/ustreamer.sock
|
||||||
cmd:
|
cmd:
|
||||||
- "/usr/bin/ustreamer"
|
- "/usr/bin/ustreamer"
|
||||||
- "--device=/dev/kvmd-video"
|
- "--device=/dev/kvmd-video"
|
||||||
- "--quality={quality}"
|
- "--quality={quality}"
|
||||||
- "--desired-fps={desired_fps}"
|
- "--desired-fps={desired_fps}"
|
||||||
- "--width=800"
|
- "--resolution=800x600"
|
||||||
- "--height=600"
|
|
||||||
- "--unix={unix}"
|
- "--unix={unix}"
|
||||||
- "--unix-rm"
|
- "--unix-rm"
|
||||||
- "--unix-mode=0666"
|
- "--unix-mode=0666"
|
||||||
|
|||||||
@ -104,14 +104,14 @@ def test_fail__valid_stream_quality(arg: Any) -> None:
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
@pytest.mark.parametrize("arg", ["1 ", 30])
|
@pytest.mark.parametrize("arg", ["1 ", 120])
|
||||||
def test_ok__valid_stream_fps(arg: Any) -> None:
|
def test_ok__valid_stream_fps(arg: Any) -> None:
|
||||||
value = valid_stream_fps(arg)
|
value = valid_stream_fps(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("arg", ["test", "", None, 31, 1.1])
|
@pytest.mark.parametrize("arg", ["test", "", None, 121, 1.1])
|
||||||
def test_fail__valid_stream_fps(arg: Any) -> None:
|
def test_fail__valid_stream_fps(arg: Any) -> None:
|
||||||
with pytest.raises(ValidatorError):
|
with pytest.raises(ValidatorError):
|
||||||
print(valid_stream_fps(arg))
|
print(valid_stream_fps(arg))
|
||||||
|
|||||||
@ -54,7 +54,7 @@ deps =
|
|||||||
|
|
||||||
[testenv:eslint]
|
[testenv:eslint]
|
||||||
whitelist_externals = 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]
|
[testenv:htmlhint]
|
||||||
whitelist_externals = htmlhint
|
whitelist_externals = htmlhint
|
||||||
|
|||||||
@ -100,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="menu-item-content-text">
|
<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">
|
<div class="stream-slider-box">
|
||||||
<input disabled type="range" id="stream-desired-fps-slider" class="slider" />
|
<input disabled type="range" id="stream-desired-fps-slider" class="slider" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -42,7 +42,7 @@ function Streamer() {
|
|||||||
tools.setOnUpSlider($("stream-quality-slider"), 1000, __updateQualityValue, (value) => __sendParam("quality", value));
|
tools.setOnUpSlider($("stream-quality-slider"), 1000, __updateQualityValue, (value) => __sendParam("quality", value));
|
||||||
|
|
||||||
$("stream-desired-fps-slider").min = 0;
|
$("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").step = 1;
|
||||||
$("stream-desired-fps-slider").value = 0;
|
$("stream-desired-fps-slider").value = 0;
|
||||||
tools.setOnUpSlider($("stream-desired-fps-slider"), 1000, __updateDesiredFpsValue, (value) => __sendParam("desired_fps", value));
|
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) {
|
if (!$("stream-desired-fps-slider").activated) {
|
||||||
|
$("stream-desired-fps-slider").max = state.limits.max_fps;
|
||||||
wm.switchDisabled($("stream-desired-fps-slider"), false);
|
wm.switchDisabled($("stream-desired-fps-slider"), false);
|
||||||
if ($("stream-desired-fps-slider").value !== source.desired_fps) {
|
if ($("stream-desired-fps-slider").value !== source.desired_fps) {
|
||||||
$("stream-desired-fps-slider").value = source.desired_fps;
|
$("stream-desired-fps-slider").value = source.desired_fps;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user