summaryrefslogtreecommitdiff
path: root/toxav
diff options
context:
space:
mode:
Diffstat (limited to 'toxav')
-rw-r--r--toxav/codec.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/toxav/codec.c b/toxav/codec.c
index ae146ccf..8940aa25 100644
--- a/toxav/codec.c
+++ b/toxav/codec.c
@@ -294,7 +294,7 @@ static int init_audio_encoder(CSSession *cs)
294{ 294{
295 int rc = OPUS_OK; 295 int rc = OPUS_OK;
296 cs->audio_encoder = opus_encoder_create(cs->audio_encoder_sample_rate, 296 cs->audio_encoder = opus_encoder_create(cs->audio_encoder_sample_rate,
297 cs->audio_encoder_channels, OPUS_APPLICATION_AUDIO, &rc); 297 cs->audio_encoder_channels, OPUS_APPLICATION_VOIP, &rc);
298 298
299 if ( rc != OPUS_OK ) { 299 if ( rc != OPUS_OK ) {
300 LOGGER_ERROR("Error while starting audio encoder: %s", opus_strerror(rc)); 300 LOGGER_ERROR("Error while starting audio encoder: %s", opus_strerror(rc));
@@ -308,6 +308,23 @@ static int init_audio_encoder(CSSession *cs)
308 return -1; 308 return -1;
309 } 309 }
310 310
311 /* Enable in-band forward error correction in codec */
312 rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_INBAND_FEC(1));
313
314 if ( rc != OPUS_OK ) {
315 LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(rc));
316 return -1;
317 }
318
319 /* Make codec resistant to up to 10% packet loss */
320 rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_PACKET_LOSS_PERC(10));
321
322 if ( rc != OPUS_OK ) {
323 LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(rc));
324 return -1;
325 }
326
327 /* Set algorithm to the highest complexity, maximizing compression */
311 rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10)); 328 rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10));
312 329
313 if ( rc != OPUS_OK ) { 330 if ( rc != OPUS_OK ) {