Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use Opus in the CBR mode #2757

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions toxav/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ static OpusEncoder *create_audio_encoder(const Logger *log, uint32_t bit_rate, u
goto FAILURE;
}

/*
* The libopus library defaults to VBR, which is unsafe in any VoIP environment
* (see for example doi:10.1109/SP.2011.34). Switching to CBR very slightly
* decreases audio quality at lower bitrates.
*
* Parameters:
* `[in]` `x` `opus_int32`: Whether to use VBR mode, 1 (VBR) is default
*/
status = opus_encoder_ctl(rc, OPUS_SET_VBR(0));

if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
goto FAILURE;
}

/*
* Configures the encoder's use of inband forward error correction.
* Note:
Expand Down
Loading