Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
The page plays a camera's H.264 through video-pane.js when it offers it and WebCodecs exists, and falls back to the frame feed when no picture comes within 3 s #422
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
The viewer now plays a camera's H.264 through video-pane.js and video-player.js when the relay flags the camera h264: true and the browser has WebCodecs. If no picture arrives within 3 s, or the socket closes later, that camera drops back to the /camera/ /ws frame feed.
shipped merged
1 earlier comment · 1 event
The viewer now plays a camera's H.264 through video-pane.js and video-player.js when the relay flags the camera h264: true and the browser has WebCodecs. If no picture arrives within 3 s, or the socket closes later, that camera drops back to the /camera/<id>/ws frame feed.
I ran bun test src/ui src/server.test.ts: 189 pass, 1 fails. The failure is "serves the model, its meshes and the vendored libraries", which also fails on the base commit, so I left it alone. I didn't run the whole suite after the final edit. bun x tsc --noEmit printed only "bun is unable to write files to tempdir", so the type check did not run here. I haven't tried it against a real camera or the preview.
- Imports:
viewer.htmlimports both modules dynamically, only insideplayH264, whichstartFeedreaches only whenc.h264 === true. There is no preload and no static import, so the first-visit gzip budget test passes without shortening any comments. - Fallback: the fallback is permanent for that camera until the page reloads (
c.noH264). - Display: a canvas sits in the same pane as the
<img>. The two swap withhidden, so the camera box keeps its size. - Quality select: it is built by
qualitySelectfrom the ladder the relay sends, plus "Auto". It shows only while the H.264 picture is live. - Liveness: the once-a-second loop reads the H.264 feed's own
liveflag instead ofvideo.isLive. - Test: I added one served-page assertion in
src/server.test.ts. It checks that neither module is preloaded or statically imported, that there is exactly one dynamic import line, and that theh264guard and the fallback line are present. It does not exercise the player or the 3 s timer itself. - Existing test constraint:
ui/video.test.tsmatches the text ofshowCam, soshowH264(c, false)goes beforeclearTimeout(c.timer); stopFeed(c);.
🤖 Generated with Claude Code
Fix first: the quality select goes dead after the pane is hidden and shown again. c.qsel is built once, and its change callback closes over the first VideoPlayer p. showCam stops that player, and the next playH264 makes a new one. The !c.qsel guard then skips rebuilding, so the select still calls .quality() on the stopped player. Choosing a rendition does nothing on every later view, and there is no error. The same happens after a socket drop and a reload of the feed. Fix it by making the callback read the current feed (for example (v) => c.feed?.player?.quality(v), with the player stored on feed), or by removing and rebuilding c.qsel per player. The ladder also arrives on each new player, so the options should be refreshed with it.
Second: the one new test only string-matches viewer.html. It would still pass if the 3 s fallback, the swap between canvas and img, or the select wiring were broken, so the stale-select bug above gets through. Add a test that runs the behaviour. Use a fake VideoPlayer and drive playH264 through live, none, and a hide/show cycle, then assert which element is hidden and that the select reaches the current player.
The preview and the module split are fine, and the lazy imports keep the first-paint budget. The 44 px touch size for the select should be checked at 360px, because .q is absolutely positioned bottom-right over the video.
The quality select now always reaches the current player, and a new behaviour test covers the cases you listed. In the tests I ran, only the model-routes test failed, and it already fails on main. The 360px check on the 44 px select is not done.
- Stale select fixed: the H.264 start-up logic moved out of
viewer.htmlintoplayH264insrc/ui/video-pane.js, withshowH264beside it.
- The player now lives on the feed (feed.player). The select's callback calls c.feed?.player?.quality(v), so it can't point at a stopped player.
- Each new player rebuilds the select from its own ladder, removing the old one. If the ladder changes mid-feed, the select is rebuilt again. Status from a feed that is no longer current is ignored.
- Behaviour test:
src/ui/video-pane.test.tsrunsplayH264against a fakeVideoPlayer. It checks:
- it doesn't start without a flag or WebCodecs;
- the URL is /camera/<id>/video;
- "live" hides the img and shows the canvas and select;
- "none" calls the fallback, and showH264(c, false) restores the img and hides the select;
- after a hide/show cycle the select pins on the second player and never on the first, and the old select is removed.
The page-string test in server.test.ts stays as a check that viewer.html still imports lazily and calls pane.playH264(c,.
- Not done: the real wiring in
viewer.html(thefallbackcallback,startFeed) is not run by any test, and neither is the 3 s timer, which belongs toVideoPlayerand already has its own tests. I did not check the select at 360 px in a browser..qisright: 8px; bottom: 8pxand the camera name tag sits at the bottom-left, so the select'smin-widthandmin-heightof 44 px should leave the two apart. Please look at it on the preview at that width.
🤖 Generated with Claude Code
Approved. The preview serves the lazy playH264 wiring. The modules load only for a camera flagged h264, so first paint is unchanged. The canvas and img swap with hidden, so the pane keeps its size. The quality select has an aria-label and a 44px minimum, and it is hidden until the picture is live. A dead feed falls back to frames, and the stale-select bug is covered by a behaviour test. Nothing here is outside the video roadmap (#70).
Two things I would do next:
- Add a test for the viewer.html fallback callback (stopFeed, then showH264(c,false), noH264, startFeed). Today it is only string-matched in server.test.ts.
- Check the .q select against the camera name tag at 360px in a real browser. I only read the CSS.
The viewer now plays a camera's H.264 through
video-pane.jsandvideo-player.jswhen the relay flags the camerah264: trueand the browser has WebCodecs. If no picture arrives within 3 s, or the socket closes later, that camera drops back to the/camera/<id>/wsframe feed.I ran
bun test src/ui src/server.test.ts: 189 pass, 1 fails. The failure is "serves the model, its meshes and the vendored libraries", which also fails on the base commit, so I left it alone. I didn't run the whole suite after the final edit.bun x tsc --noEmitprinted only "bun is unable to write files to tempdir", so the type check did not run here. I haven't tried it against a real camera or the preview.viewer.htmlimports both modules dynamically, only insideplayH264, whichstartFeedreaches only whenc.h264 === true. There is no preload and no static import, so the first-visit gzip budget test passes without shortening any comments.c.noH264).<img>. The two swap withhidden, so the camera box keeps its size.qualitySelectfrom the ladder the relay sends, plus "Auto". It shows only while the H.264 picture is live.liveflag instead ofvideo.isLive.src/server.test.ts. It checks that neither module is preloaded or statically imported, that there is exactly one dynamic import line, and that theh264guard and the fallback line are present. It does not exercise the player or the 3 s timer itself.ui/video.test.tsmatches the text ofshowCam, soshowH264(c, false)goes beforeclearTimeout(c.timer); stopFeed(c);.🤖 Generated with Claude Code
Closes #383