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

Platform audio device manager backed by WebRTC's Audio Device Module. More...

#include <platform_audio.h>

Public Member Functions

 PlatformAudio ()
 Create a platform audio manager.
 
 PlatformAudio (const PlatformAudio &other)=default
 Copy the platform audio manager.
 
PlatformAudiooperator= (const PlatformAudio &other)=default
 Copy-assign the platform audio manager.
 
 PlatformAudio (PlatformAudio &&other) noexcept=default
 Move the platform audio manager.
 
PlatformAudiooperator= (PlatformAudio &&other) noexcept=default
 Move-assign the platform audio manager.
 
std::int32_t recordingDeviceCount () const
 Return the current number of recording devices.
 
std::int32_t playoutDeviceCount () const
 Return the current number of playout devices.
 
std::vector< AudioDeviceInforecordingDevices () const
 Enumerate available microphones.
 
std::vector< AudioDeviceInfoplayoutDevices () const
 Enumerate available speakers/headphones.
 
void setRecordingDevice (const std::string &device_id) const
 Select the microphone by device ID.
 
void setPlayoutDevice (const std::string &device_id) const
 Select the speaker/headphones by device ID.
 
std::shared_ptr< PlatformAudioSourcecreateAudioSource (const PlatformAudioOptions &options={}) const
 Create an automatically captured microphone source for LocalAudioTrack.
 

Detailed Description

Platform audio device manager backed by WebRTC's Audio Device Module.

Use PlatformAudio for microphone capture when built-in echo cancellation, noise suppression, automatic gain control, and speaker playout are desired. Use AudioSource instead when the application needs direct access to raw PCM frames or custom audio generation.

Constructor & Destructor Documentation

◆ PlatformAudio() [1/3]

livekit::PlatformAudio::PlatformAudio ( )

Create a platform audio manager.

Enables WebRTC's platform Audio Device Module for microphone capture and speaker playout.

Exceptions
PlatformAudioErrorIf the FFI response is malformed or the platform Audio Device Module cannot be created.
Note
This operation is thread-safe.

◆ PlatformAudio() [2/3]

livekit::PlatformAudio::PlatformAudio ( const PlatformAudio other)
default

Copy the platform audio manager.

The copy shares the same underlying platform audio handle.

Parameters
otherManager to copy from.
Note
This operation is not thread-safe.

◆ PlatformAudio() [3/3]

livekit::PlatformAudio::PlatformAudio ( PlatformAudio &&  other)
defaultnoexcept

Move the platform audio manager.

Parameters
otherManager to move from.
Note
This operation is not thread-safe.

Member Function Documentation

◆ createAudioSource()

std::shared_ptr< PlatformAudioSource > livekit::PlatformAudio::createAudioSource ( const PlatformAudioOptions options = {}) const

Create an automatically captured microphone source for LocalAudioTrack.

Each call returns a new track source handle backed by the shared platform Audio Device Module; it does not create a separate ADM instance.

Parameters
optionsAudio processing options for the platform microphone path.
Returns
Platform-backed audio source suitable for LocalAudioTrack.
Exceptions
PlatformAudioErrorIf the FFI response is malformed or source creation fails.
Note
This operation is thread-safe.

◆ operator=() [1/2]

PlatformAudio & livekit::PlatformAudio::operator= ( const PlatformAudio other)
default

Copy-assign the platform audio manager.

The assigned instance shares the same underlying platform audio handle.

Parameters
otherManager to copy from.
Returns
Reference to this manager.
Note
This operation is not thread-safe.

◆ operator=() [2/2]

PlatformAudio & livekit::PlatformAudio::operator= ( PlatformAudio &&  other)
defaultnoexcept

Move-assign the platform audio manager.

Parameters
otherManager to move from.
Returns
Reference to this manager.
Note
This operation is not thread-safe.

◆ playoutDeviceCount()

std::int32_t livekit::PlatformAudio::playoutDeviceCount ( ) const

Return the current number of playout devices.

Exceptions
PlatformAudioErrorIf the FFI response is malformed or device enumeration fails.
Note
This operation is thread-safe.

◆ playoutDevices()

std::vector< AudioDeviceInfo > livekit::PlatformAudio::playoutDevices ( ) const

Enumerate available speakers/headphones.

Returns
List of available playout devices.
Exceptions
PlatformAudioErrorIf the FFI response is malformed or device enumeration fails.
Note
This operation is thread-safe.

◆ recordingDeviceCount()

std::int32_t livekit::PlatformAudio::recordingDeviceCount ( ) const

Return the current number of recording devices.

Exceptions
PlatformAudioErrorIf the FFI response is malformed or device enumeration fails.
Note
This operation is thread-safe.

◆ recordingDevices()

std::vector< AudioDeviceInfo > livekit::PlatformAudio::recordingDevices ( ) const

Enumerate available microphones.

Returns
List of available recording devices.
Exceptions
PlatformAudioErrorIf the FFI response is malformed or device enumeration fails.
Note
This operation is thread-safe.

◆ setPlayoutDevice()

void livekit::PlatformAudio::setPlayoutDevice ( const std::string &  device_id) const

Select the speaker/headphones by device ID.

Parameters
device_idStable device identifier from AudioDeviceInfo::id.
Exceptions
PlatformAudioErrorIf the FFI response is malformed or device selection fails.
Note
This operation is thread-safe.

◆ setRecordingDevice()

void livekit::PlatformAudio::setRecordingDevice ( const std::string &  device_id) const

Select the microphone by device ID.

Parameters
device_idStable device identifier from AudioDeviceInfo::id.
Exceptions
PlatformAudioErrorIf the FFI response is malformed or device selection fails.
Note
This operation is thread-safe.

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