cameras/src/app/cameras/[id]/live/stream-select.tsx
Michael Mainguy 41021a62ad Add live video: WHEP relay route and WebRTC player
- POST/DELETE /api/cameras/[id]/live/whep check the session, resolve the
  camera from the registry, and relay WebRTC signaling to MediaMTX on
  localhost. The browser never sees MediaMTX's address, its error text or
  a camera login; video flows browser↔MediaMTX, not through Next.
- LivePlayer negotiates with the browser's own RTCPeerConnection and
  shows connecting, reconnecting and failed states with Retry.
- The camera page gains a Live section; the pop-out plays live video and
  falls back to snapshot polling if it can't. Both offer Main/Sub.
- Stop a leftover MediaMTX from a server that didn't exit cleanly: record
  its pid and, on startup, stop it only if that pid is still our binary
  with our config.
- Export vrek log: both cameras watched live on main and sub (4 of the
  goal's 6 checks).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 16:40:21 -05:00

29 lines
761 B
TypeScript

"use client";
import { Video } from "lucide-react";
import type { StreamKind } from "./use-whep";
/** Main is the camera's full-resolution stream; Sub is its smaller, lighter one. */
export default function StreamSelect({
value,
onChange,
}: {
value: StreamKind;
onChange: (stream: StreamKind) => void;
}) {
return (
<label className="flex items-center gap-2">
<Video aria-hidden className="size-4" />
Stream
<select
value={value}
onChange={(e) => onChange(e.target.value as StreamKind)}
className="rounded border border-zinc-600 bg-black/40 px-2 py-1"
>
<option value="main">Main (full size)</option>
<option value="sub">Sub (smaller)</option>
</select>
</label>
);
}