diff options
Diffstat (limited to 'toxav')
-rw-r--r-- | toxav/audio.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/toxav/audio.c b/toxav/audio.c index afb9f26c..ff1e1782 100644 --- a/toxav/audio.c +++ b/toxav/audio.c | |||
@@ -343,7 +343,7 @@ static RTPMessage *jbuf_read(struct JitterBuffer *q, int32_t *success) | |||
343 | OpusEncoder* create_audio_encoder (int32_t bit_rate, int32_t sampling_rate, int32_t channel_count) | 343 | OpusEncoder* create_audio_encoder (int32_t bit_rate, int32_t sampling_rate, int32_t channel_count) |
344 | { | 344 | { |
345 | int status = OPUS_OK; | 345 | int status = OPUS_OK; |
346 | OpusEncoder* rc = opus_encoder_create(sampling_rate, channel_count, OPUS_APPLICATION_AUDIO, &status); | 346 | OpusEncoder* rc = opus_encoder_create(sampling_rate, channel_count, OPUS_APPLICATION_VOIP, &status); |
347 | 347 | ||
348 | if ( status != OPUS_OK ) { | 348 | if ( status != OPUS_OK ) { |
349 | LOGGER_ERROR("Error while starting audio encoder: %s", opus_strerror(status)); | 349 | LOGGER_ERROR("Error while starting audio encoder: %s", opus_strerror(status)); |
@@ -357,6 +357,26 @@ OpusEncoder* create_audio_encoder (int32_t bit_rate, int32_t sampling_rate, int3 | |||
357 | goto FAILURE; | 357 | goto FAILURE; |
358 | } | 358 | } |
359 | 359 | ||
360 | /* Enable in-band forward error correction in codec */ | ||
361 | status = opus_encoder_ctl(rc, OPUS_SET_INBAND_FEC(1)); | ||
362 | |||
363 | if ( status != OPUS_OK ) { | ||
364 | LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(status)); | ||
365 | goto FAILURE; | ||
366 | } | ||
367 | |||
368 | /* Make codec resistant to up to 10% packet loss | ||
369 | * NOTE This could also be adjusted on the fly, rather than hard-coded, | ||
370 | * with feedback from the receiving client. | ||
371 | */ | ||
372 | status = opus_encoder_ctl(rc, OPUS_SET_PACKET_LOSS_PERC(10)); | ||
373 | |||
374 | if ( status != OPUS_OK ) { | ||
375 | LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(status)); | ||
376 | goto FAILURE; | ||
377 | } | ||
378 | |||
379 | /* Set algorithm to the highest complexity, maximizing compression */ | ||
360 | status = opus_encoder_ctl(rc, OPUS_SET_COMPLEXITY(10)); | 380 | status = opus_encoder_ctl(rc, OPUS_SET_COMPLEXITY(10)); |
361 | 381 | ||
362 | if ( status != OPUS_OK ) { | 382 | if ( status != OPUS_OK ) { |