LiveKit C++ SDK
Real-time audio/video SDK for C++
Loading...
Searching...
No Matches
livekit::AudioStream Class Reference

#include <audio_stream.h>

Classes

struct  Options
 Configuration options for AudioStream creation. More...
 

Public Member Functions

 AudioStream (const AudioStream &)=delete
 No copy, assignment constructors.
 
AudioStreamoperator= (const AudioStream &)=delete
 
 AudioStream (AudioStream &&) noexcept
 
AudioStreamoperator= (AudioStream &&) noexcept
 
bool read (AudioFrameEvent &out_event)
 
void close ()
 

Static Public Member Functions

static std::shared_ptr< AudioStreamfromTrack (const std::shared_ptr< Track > &track, const Options &options)
 Factory: create an AudioStream bound to a specific Track.
 
static std::shared_ptr< AudioStreamfromParticipant (Participant &participant, TrackSource track_source, const Options &options)
 Factory: create an AudioStream from a Participant + TrackSource.
 

Detailed Description

Represents a pull-based stream of decoded PCM audio frames coming from a remote (or local) LiveKit track. Similar to VideoStream, but for audio.

Typical usage:

AudioStream::Options opts; auto stream = AudioStream::fromTrack(remoteAudioTrack, opts);

AudioFrameEvent ev; while (stream->read(ev)) { // ev.frame contains interleaved int16 PCM samples }

stream->close(); // optional, called automatically in destructor

Member Function Documentation

◆ close()

void livekit::AudioStream::close ( )

Signal that we are no longer interested in audio frames.

This disposes the underlying FFI audio stream, unregisters the listener from FfiClient, marks the stream as closed, and wakes any blocking read(). After calling close(), further calls to read() will return false.

◆ read()

bool livekit::AudioStream::read ( AudioFrameEvent out_event)

Blocking read: waits until there is an AudioFrameEvent available in the internal queue, or the stream reaches EOS / is closed.

Parameters
out_eventOn success, filled with the next audio frame.
Returns
true if a frame was delivered; false if the stream ended (end-of-stream or close()) and no more data is available.

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