session.stream starts and stops a live video stream from camera glasses like
Mentra Live. One method, startStream, covers both ways to stream: Mentra hosts
it for you (the default), or you publish straight to a URL you own.
src/background/index.ts
Managed streaming (default)
CallstartStream() with no direct URL and Mentra provisions a hosted stream,
handles transport and reconnection, and returns playback URLs. This is the right
choice for most apps.
src/background/index.ts
WHIP goes through the phone
Withingest: "whip", the glasses don’t publish over their own Wi-Fi. They
start a hotspot, the phone joins it, and the phone relays the stream to Mentra
over its cellular connection. So:
- The phone needs working cellular data (or Ethernet) while it streams.
- Keep the phone near the glasses, and keep the Mentra App running.
- If the phone leaves the glasses’ hotspot, for example to join a known Wi-Fi
network, the relay drops. It reconnects by itself and reports
reconnecting, thenreconnected; see Stream status. While it does, the glasses’ Wi-Fi status can read as disconnected; that is the hotspot being rebuilt, not the cause of the drop.
"srt" or "rtmp" lets
the glasses publish from their own Wi-Fi with no phone relay.
Direct streaming
Passdirect with your own ingest URL (rtmp/rtmps/srt/whip) and the glasses
publish straight to it, with no Mentra relay. You manage the endpoint, and no
playback URLs come back.
src/background/index.ts
video, audio, and sound work the same as managed. destinations and
ingest are ignored for direct streams.
Result
startStream resolves to a StreamResult:
Stream status
onStatus reports what happens to the stream after it starts. It returns an
unsubscribe function.
src/background/index.ts
StreamStatus has streamId, status, and a source saying who reported it:
A stream that reconnects by itself keeps its
streamId and playback URLs. After
an error from "coordinator", call startStream() again.
Stop
stop ends the stream. Pass the streamId from the start result, or omit it to
stop the active stream.
src/background/index.ts

