summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-07-31 23:36:19 -0400
committerirungentoo <irungentoo@gmail.com>2015-07-31 23:36:19 -0400
commit87c9ac242b2087787a0472cb83cd49314d052062 (patch)
tree87540bc11044534461524670703676fdfabb18c4
parent23fbdf4ddfcdc276b97d7f1ce10bcb075a10495a (diff)
parentf05fdae055cb01ed03008d964485dfda16b2df18 (diff)
Merge branch 'Opus-Codec-Settings' of https://github.com/JasonLocklin/toxcore
-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 ) {