API reference

Stream Interface

Extends Capability
Interface for managing media streaming capabilities attached to a Session.
A Stream handles video streaming and photo capture from Meta glasses. Streams are created via Session.addStream and automatically stopped when the parent session stops (cascading stop). They can also be stopped individually via Stream.stop or removed via Session.removeStream.
Video frames are delivered through the Stream.videoStream Flow and photos through the Stream.capturePhoto suspend function.

See Also

Signature

interface Stream : Capability

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 Session.addStream. The addStream() call registers the stream 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 capability, releasing its resources and removing it from the parent session.
After calling Capability.stop, the capability is invalidated and cannot be reused. The parent session's capability slot is released, allowing a new capability of the same type to be added.
Calling Capability.stop on an already-stopped capability is a no-op.
Signature
abstract fun stop()