|
LiveKit C++ SDK
Real-time audio/video SDK for C++
|
Represents a raw PCM audio frame with interleaved int16 samples. More...
#include <audio_frame.h>
Public Member Functions | |
| AudioFrame (std::vector< std::int16_t > data, int sample_rate, int num_channels, int samples_per_channel) | |
| const std::vector< std::int16_t > & | data () const noexcept |
| std::vector< std::int16_t > & | data () noexcept |
| std::size_t | total_samples () const noexcept |
| Number of samples in the buffer (per all channels). | |
| int | sample_rate () const noexcept |
| Sample rate in Hz. | |
| int | num_channels () const noexcept |
| Number of channels. | |
| int | samples_per_channel () const noexcept |
| Samples per channel. | |
| double | duration () const noexcept |
| Duration in seconds (samples_per_channel / sample_rate). | |
| std::string | to_string () const |
| A human-readable description. | |
Static Public Member Functions | |
| static AudioFrame | create (int sample_rate, int num_channels, int samples_per_channel) |
| static AudioFrame | fromOwnedInfo (const proto::OwnedAudioFrameBuffer &owned) |
Protected Member Functions | |
| proto::AudioFrameBufferInfo | toProto () const |
Friends | |
| class | AudioSource |
Represents a raw PCM audio frame with interleaved int16 samples.
AudioFrame holds decoded audio data along with metadata such as sample rate, number of channels, and samples per channel. It is used for capturing and processing audio in the LiveKit SDK.
| livekit::AudioFrame::AudioFrame | ( | std::vector< std::int16_t > | data, |
| int | sample_rate, | ||
| int | num_channels, | ||
| int | samples_per_channel | ||
| ) |
Construct an AudioFrame from raw PCM samples.
| data | Interleaved PCM samples (int16). |
| sample_rate | Sample rate (Hz). |
| num_channels | Number of channels. |
| samples_per_channel | Number of samples per channel. |
Throws std::invalid_argument if the data size is inconsistent with num_channels * samples_per_channel.
|
static |
Create a new zero-initialized AudioFrame instance.
|
static |
Construct an AudioFrame by copying data out of an OwnedAudioFrameBuffer.