Receive: Config of decode sample rate/channels (#265)

* Receive: Config of decode sample rate/channels

This PR allows for dynamic configuration of the output sample rate and
channel count of received Opus audio. Users who rely on supported
formats should no longer need to manually resample & downmix audio
decoded from SSRCs in a call.

Opus exposes tuples of (Mono, Stereo) x (8, 12, 16, 24, 48)kHz.
Changing this at runtime (mid-call) may cause some audio glitches, as
decoder state must be reconstructed from scratch for all affected SSRCs.

* Fix doc typo, consistent naming with MixMode.
This commit is contained in:
Kyle Simpson
2024-11-16 11:57:52 +00:00
committed by GitHub
parent 312799d231
commit 91bf1538fc
6 changed files with 134 additions and 11 deletions

View File

@@ -30,9 +30,14 @@ pub struct VoiceData {
pub packet: Option<RtpData>,
/// PCM audio obtained from a user.
///
/// Valid audio data (`Some(audio)` where `audio.len >= 0`) typically contains 20ms of 16-bit stereo PCM audio
/// at 48kHz, using native endianness. Channels are interleaved (i.e., `L, R, L, R, ...`).
/// Valid audio data (`Some(audio)` where `audio.len >= 0`) typically contains 20ms of 16-bit PCM audio
/// using native endianness. This defaults to stereo audio at 48kHz, and can be configured via
/// [`Config::decode_channels`] and [`Config::decode_sample_rate`] -- channels are interleaved
/// (i.e., `L, R, L, R, ...`) if stereo.
///
/// This value will be `None` if Songbird is not configured to decode audio.
///
/// [`Config::decode_channels`]: crate::Config::decode_channels
/// [`Config::decode_sample_rate`]: crate::Config::decode_sample_rate
pub decoded_voice: Option<Vec<i16>>,
}