LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
livekit::DataTrackStream Class Reference

Represents a pull-based stream of frames from a remote data track. More...

#include <data_track_stream.h>

Classes

struct  Options
 Options for subscribing to a remote data track stream. More...
 

Public Member Functions

 DataTrackStream (const DataTrackStream &)=delete
 
DataTrackStreamoperator= (const DataTrackStream &)=delete
 
 DataTrackStream (DataTrackStream &&) noexcept=delete
 
DataTrackStreamoperator= (DataTrackStream &&) noexcept=delete
 
bool read (DataTrackFrame &out)
 Blocking read: waits until a DataTrackFrame is available, or the stream reaches EOS / is closed.
 
std::optional< SubscribeDataTrackErrorterminalError () const
 Returns the terminal subscription error reported by the FFI stream.
 
void close ()
 End the stream early.
 

Friends

class RemoteDataTrack
 

Detailed Description

Represents a pull-based stream of frames from a remote data track.

Provides a blocking read() interface similar to AudioStream / VideoStream. Frames are delivered via FfiEvent callbacks and stored internally.

Destroying the stream automatically unsubscribes from the remote track by releasing the underlying FFI handle.

Typical usage:

auto sub_result = remoteDataTrack->subscribe(); if (sub_result) { auto sub = sub_result.value(); DataTrackFrame frame; while (sub->read(frame)) { // process frame.payload } }

Member Function Documentation

◆ close()

void livekit::DataTrackStream::close ( )

End the stream early.

Releases the FFI handle (which unsubscribes from the remote track), unregisters the event listener, and wakes any blocking read().

◆ read()

bool livekit::DataTrackStream::read ( DataTrackFrame out)

Blocking read: waits until a DataTrackFrame is available, or the stream reaches EOS / is closed.

Parameters
outOn success, filled with the next data frame.
Returns
true if a frame was delivered; false if the stream ended.

◆ terminalError()

std::optional< SubscribeDataTrackError > livekit::DataTrackStream::terminalError ( ) const

Returns the terminal subscription error reported by the FFI stream.

This is set when read() returns false because subscription establishment failed before any frames were emitted. It remains empty for normal EOS or when close() ends the stream locally.


The documentation for this class was generated from the following file: