summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2015-08-08 18:01:36 +0200
committermannol <eniz_vukovic@hotmail.com>2015-08-08 18:01:36 +0200
commit6ab4308581f6b06b2a4516614b4f1e2f9b3667a9 (patch)
treee7d1df14b35258f91690177e6a9c5225e4dc6898
parent3c8cae72d08cabe870e2fd6b6ffdd78a32c2b410 (diff)
Apply OPUS codec fixes
-rw-r--r--toxav/audio.c22
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)
343OpusEncoder* create_audio_encoder (int32_t bit_rate, int32_t sampling_rate, int32_t channel_count) 343OpusEncoder* 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 ) {