From ef086a5897ab2f3296ba777e7e1229384981313c Mon Sep 17 00:00:00 2001 From: Jason Locklin Date: Fri, 31 Jul 2015 11:08:51 -0400 Subject: [PATCH] Set packet loss percentage Make the Codec resistant to up to 10% packet loss (default 0) at the expense of some bandwidth. 10% is aggressive (1-5% should be typical for voip systems, but can be higher when users are on WiFi connections. This could also be adjusted on the fly, rather than hard-coded, with feedback from the receiving client. --- toxav/codec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/toxav/codec.c b/toxav/codec.c index 7b76929c..9f705db4 100644 --- a/toxav/codec.c +++ b/toxav/codec.c @@ -315,6 +315,14 @@ static int init_audio_encoder(CSSession *cs) return -1; } + /* Make codec resistant to up to 10% packet loss */ + rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_PACKET_LOSS_PERC(10)); + + if ( rc != OPUS_OK ) { + LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(rc)); + return -1; + } + rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10)); if ( rc != OPUS_OK ) {