diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index f50e057d5f..93e0588b11 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1373,6 +1373,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if ((len = atoi(msg->string_arg))) { qlen = len / (tech_pvt->read_impl.microseconds_per_packet / 1000); + if (qlen < 1) { + qlen = 3; + } } if (qlen) { @@ -1393,6 +1396,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } if (qlen) { + if (maxqlen < qlen) { + maxqlen = qlen * 5; + } if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 3ca14e921d..44cf96b6e9 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3196,10 +3196,17 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f qlen = jb_msec / (tech_pvt->read_impl.microseconds_per_packet / 1000); + if (qlen < 1) { + qlen = 3; + } + if (maxlen) { maxqlen = maxlen / (tech_pvt->read_impl.microseconds_per_packet / 1000); } + if (maxqlen < qlen) { + maxqlen = qlen * 5; + } if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index e81812a463..0398ba91c1 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1919,6 +1919,14 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * return SWITCH_STATUS_FALSE; } + if (queue_frames < 1) { + queue_frames = 3; + } + + if (max_queue_frames < queue_frames) { + max_queue_frames = queue_frames * 3; + } + READ_INC(rtp_session); if (rtp_session->jb) { stfu_n_resize(rtp_session->jb, queue_frames);