switch_mutex_lock(jb->mutex);
+ if (jb->complete_frames == 0) {
+ switch_goto_status(SWITCH_STATUS_BREAK, end);
+ }
+
if (jb->complete_frames < jb->frame_len) {
jb_debug(jb, 2, "BUFFERING %u/%u\n", jb->complete_frames , jb->frame_len);
switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
uint8_t has_rtp;
uint8_t has_rtcp;
uint8_t has_ice;
+ uint8_t punts;
+ uint8_t clean;
#ifdef ENABLE_ZRTP
zrtp_session_t *zrtp_session;
zrtp_profile_t *zrtp_profile;
max_queue_frames = queue_frames * 3;
}
- READ_INC(rtp_session);
+
if (rtp_session->jb) {
status = switch_jb_set_frames(rtp_session->jb, queue_frames, max_queue_frames);
} else {
+ READ_INC(rtp_session);
status = switch_jb_create(&rtp_session->jb, SJB_AUDIO, queue_frames, max_queue_frames, rtp_session->pool);
switch_jb_set_session(rtp_session->jb, rtp_session->session);
if (switch_true(switch_channel_get_variable_dup(switch_core_session_get_channel(rtp_session->session), "jb_use_timestamps", SWITCH_FALSE, -1))) {
switch_jb_ts_mode(rtp_session->jb, samples_per_packet, samples_per_second);
}
//switch_jb_debug_level(rtp_session->jb, 10);
+ READ_DEC(rtp_session);
}
- READ_DEC(rtp_session);
+
return status;
}
tries++;
if (tries > 20) {
+ if (rtp_session->jb && !rtp_session->pause_jb && jb_valid(rtp_session)) {
+ switch_jb_reset(rtp_session->jb);
+ }
+ rtp_session->punts++;
+ rtp_session->clean = 0;
+ *bytes = 0;
return SWITCH_STATUS_BREAK;
}
}
}
- rtp_session->missed_count = 0;
if (rtp_session->has_rtp) {
+ rtp_session->missed_count = 0;
switch_cp_addr(rtp_session->rtp_from_addr, rtp_session->from_addr);
rtp_session->last_rtp_hdr = rtp_session->recv_msg.header;
}
switch(jstatus) {
case SWITCH_STATUS_MORE_DATA:
- block = 1;
- goto more;
+ if (rtp_session->punts < 4) {
+ block = 1;
+ goto more;
+ }
+ *bytes = 0;
+ break;
case SWITCH_STATUS_NOTFOUND:
{
int pt = get_recv_payload(rtp_session);
rtp_session->stats.inbound.jb_packet_count++;
status = SWITCH_STATUS_SUCCESS;
rtp_session->last_rtp_hdr = rtp_session->recv_msg.header;
-
+ if (++rtp_session->clean > 200) {
+ rtp_session->punts = 0;
+ }
if (!xcheck_jitter) {
check_jitter(rtp_session);
xcheck_jitter = *bytes;
ret = -1;
goto end;
}
-
+
if (rtp_session->max_missed_packets && read_loops == 1 && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
- if (bytes) {
+ if (bytes && status == SWITCH_STATUS_SUCCESS) {
rtp_session->missed_count = 0;
} else if (++rtp_session->missed_count >= rtp_session->max_missed_packets) {
ret = -2;