From e245e907613046fd5d9afc665e9aaca5cec7ef0b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 13 Oct 2014 13:05:57 -0500 Subject: [PATCH] fix some jitterbuffer constants --- src/switch_core_media.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 5602af5036..14a4f9e4fa 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -5264,22 +5264,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi } } - if (jb_msec < 0 && jb_msec > -10) { + if (jb_msec < 0 && jb_msec > -20) { jb_msec = (a_engine->read_codec.implementation->microseconds_per_packet / 1000) * abs(jb_msec); } + if (maxlen < 0 && maxlen > -20) { + maxlen = (a_engine->read_codec.implementation->microseconds_per_packet / 1000) * abs(maxlen); + } + if (jb_msec < 20 || jb_msec > 10000) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Jitterbuffer spec [%d] must be between 20 and 10000\n", jb_msec); } else { - int qlen, maxqlen = 50; + int qlen, maxqlen = 10; qlen = jb_msec / (a_engine->read_impl.microseconds_per_packet / 1000); - if (qlen < 1) { - qlen = 3; - } - if (maxlen) { maxqlen = maxlen / (a_engine->read_impl.microseconds_per_packet / 1000); } @@ -7666,7 +7666,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER: { if (switch_rtp_ready(a_engine->rtp_session)) { - int len = 0, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0; + int len = 0, maxlen = 0, qlen = 0, maxqlen = 10, max_drift = 0; if (msg->string_arg) { char *p, *q; @@ -7691,7 +7691,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se if ((len = atoi(msg->string_arg))) { qlen = len / (a_engine->read_impl.microseconds_per_packet / 1000); if (qlen < 1) { - qlen = 3; + qlen = 1; } } @@ -7707,6 +7707,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se } + if (qlen < 0 && qlen > -20) { + qlen = (a_engine->read_codec.implementation->microseconds_per_packet / 1000) * abs(qlen); + } + + if (maxlen < 0 && maxlen > -20) { + maxlen = (a_engine->read_codec.implementation->microseconds_per_packet / 1000) * abs(maxlen); + } + if (maxlen) { maxqlen = maxlen / (a_engine->read_impl.microseconds_per_packet / 1000); }