Skip to content

Commit

Permalink
fix: Use Opus in the CBR mode
Browse files Browse the repository at this point in the history
A diff sent by an anonymous IRC user.
  • Loading branch information
nurupo committed May 10, 2024
1 parent 102a1fa commit 9d3c83e
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 9d3c83e

Please sign in to comment.