API reference

Stream Interface

Extends Closeable
Interface for managing media streaming capabilities owned by a Camera.
A Stream handles video streaming and photo capture from Meta glasses. Streams are obtained from Camera.stream after adding a camera via DeviceSession.addCamera, and are automatically stopped when the parent session stops (cascading stop). They can also be stopped individually via Stream.stop or removed together with their camera via DeviceSession.removeCamera.
Video frames are delivered through the Stream.videoStream Flow and photos through the Stream.capturePhoto suspend function.

See Also

  • Camera.stream to obtain a stream from a camera capability
  • StreamConfiguration for quality and frame rate options
  • StreamState for stream lifecycle states

Signature

interface Stream : Closeable

Properties

errorStream : Flow<StreamError>
[Get]
Flow of errors from the streaming session.
Emits StreamError values when error conditions occur during streaming. Non-critical errors (e.g., StreamError.STREAM_ERROR) are informational and do not stop the stream, while critical errors (e.g., StreamError.CRITICAL_STREAM_ERROR) indicate the stream should be terminated.
Signature
abstract val errorStream: Flow<StreamError>
state : StateFlow<StreamState>
[Get]
The current state of the streaming session.
State transitions:
  • STOPPED -> STARTING -> STARTED -> STREAMING (when device connects and streaming begins)
  • STREAMING -> STOPPING -> STOPPED (on device disconnect or error)
  • Any state -> STOPPING -> STOPPED -> CLOSED (on close/stop)
Signature
abstract val state: StateFlow<StreamState>
videoStream : Flow<VideoFrame>
[Get]
Flow of video frames from the streaming session.
Video frames are delivered while the stream is in STREAMING state. The flow automatically handles buffer overflow by dropping the oldest frames to ensure smooth streaming.
Signature
abstract val videoStream: Flow<VideoFrame>

Methods

capturePhoto ()
Captures a still photo during active video streaming.
Triggers a photo capture while video streaming is active. Only one capture can be in progress at a time—attempting a second capture while one is pending returns CaptureError.CaptureInProgress.
Signature
abstract suspend fun capturePhoto(): DatResult<PhotoData, CaptureError>
Returns
DatResult DatResult containing PhotoData on success, or CaptureError on failure.
close ()
Signature
abstract override fun close()
start ()
Starts the stream, activating the camera on glasses and beginning the streaming pipeline.
Call this after obtaining a Stream from Camera.stream. Adding the camera via DeviceSession.addCamera registers the capability, while start() activates the camera and begins video frame delivery.
Signature
abstract fun start(): DatResult<Unit, StreamError>
Returns
DatResult DatResult with Unit on success, or StreamError on failure
stop ()
Stops this stream, releasing its resources and detaching it from the parent session.
After calling Stream.stop, the stream is invalidated and cannot be reused. Calling Stream.stop on an already-stopped stream is a no-op. Stream.close delegates to Stream.stop for Closeable compatibility.
Signature
abstract fun stop()