Binary uplink takes audio chunks beside image frames (openpanel VS4)

This commit is contained in:
Melvin Strobl
2026-10-19 16:04:39 +02:00
parent d18ddad789
commit 80e0201612
3 changed files with 49 additions and 15 deletions
+30 -1
View File
@@ -248,7 +248,7 @@ def test_a_frame_the_device_may_not_send_is_dropped(
# By fixed keys, never in the words the device chose.
said = [r.getMessage() for r in caplog.records if "Dropped a frame" in r.message]
for key in ("not_image", "not_wired", "media_type", "not_a_frame"):
for key in ("not_media", "not_wired", "media_type", "not_a_frame"):
assert f"Dropped a frame from cam1: {FRAME_REFUSALS[key]}" in said
assert any(FRAME_REFUSALS["not_a_device"] in line for line in said)
assert not any("elsewhere" in line or "text/html" in line for line in said)
@@ -268,6 +268,35 @@ def test_an_unpaired_device_is_closed_and_its_frames_stop(
assert closed.value.code == 1008
def test_a_device_streams_audio_chunks_on_its_socket(
client: TestClient, superuser_token_headers: dict[str, str]
) -> None:
"""A microphone's chunks take the camera's path, in their own family."""
_panels(client, superuser_token_headers, {"panels": [{"id": "mic1"}]})
device = _pair(client, superuser_token_headers, "mic1")
port = {"port": "mic", "direction": "in", "dtype": "audio"}
reported = client.put(
f"{PREFIX}/mic1/report", headers=device, json={**REPORT, "ports": [port]}
)
assert reported.status_code == 200, reported.text
node = _device_node(
"mic1",
node="panel",
provides=[{"name": "mic", "port": "mic", "dtype": "audio"}],
)
_publish_flow(client, superuser_token_headers, "voice", [node])
controller = client.app.state.flow_controller
with client.websocket_connect(SOCKET, headers=device) as ws:
ws.receive_json()
ws.send_bytes(frame("voice.mic", b"\x00\x01")) # an image on an audio port
ws.send_bytes(frame("voice.mic", b"\x00\x02", "audio/L16;rate=16000"))
value = wait_for(
lambda: (controller.values().get("voice.mic") or {}).get("value")
)
assert value["media_type"] == "audio/L16;rate=16000"
assert client.app.state.artifact_store.volatile.get(value["digest"]) == b"\x00\x02"
def test_a_frame_past_the_cap_is_dropped(
client: TestClient, camera, monkeypatch: pytest.MonkeyPatch
) -> None: