summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-07-19 15:01:29 +0300
committerDevaev Maxim <[email protected]>2020-07-19 15:01:29 +0300
commit2cdd55386bf0448023a08ea14e6cce8e47a36a83 (patch)
treec762e95ee5eed7bc0e35eb52b48ed9c916b3e705 /kvmd
parentab13399a2afa07346f635f9c70fca93ec9201e5e (diff)
exc for unsupported streamer params
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/server.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 51589a16..14c975f0 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -91,6 +91,17 @@ from .api.streamer import StreamerApi
# =====
+class StreamerQualityNotSupported(OperationError):
+ def __init__(self) -> None:
+ super().__init__("This streamer does not support quality settings")
+
+
+class StreamerResolutionNotSupported(OperationError):
+ def __init__(self) -> None:
+ super().__init__("This streamer does not support resolution settings")
+
+
+# =====
@dataclasses.dataclass(frozen=True)
class _Component:
name: str
@@ -191,12 +202,15 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
@exposed_http("POST", "/streamer/set_params")
async def __streamer_set_params_handler(self, request: aiohttp.web.Request) -> aiohttp.web.Response:
current_params = self.__streamer.get_params()
- for (name, validator) in [
- ("quality", valid_stream_quality),
- ("desired_fps", valid_stream_fps),
- ("resolution", valid_stream_resolution),
+ for (name, validator, exc_cls) in [
+ ("quality", valid_stream_quality, StreamerQualityNotSupported),
+ ("desired_fps", valid_stream_fps, None),
+ ("resolution", valid_stream_resolution, StreamerResolutionNotSupported),
]:
if (value := request.query.get(name)):
+ if name not in current_params:
+ assert exc_cls is not None, name
+ raise exc_cls()
value = validator(value)
if current_params[name] != value:
self.__new_streamer_params[name] = value