FS-11127: [freeswitch-core] Improvements to Video JB and audio jb sync #resolve

This commit is contained in:
Anthony Minessale 2018-04-20 13:33:57 -05:00 committed by Muteesa Fred
parent bb7013817b
commit 74f8ec7772
2 changed files with 15 additions and 20 deletions

View File

@ -2565,7 +2565,7 @@ static void check_jb_sync(switch_core_session_t *session)
uint32_t cur_frames = 0;
switch_media_handle_t *smh;
switch_rtp_engine_t *v_engine = NULL;
int sync_audio = 0, sync_video = 0;
int sync_audio = 0;
const char *var;
@ -2607,34 +2607,29 @@ static void check_jb_sync(switch_core_session_t *session)
if (!fps) return;
sync_audio = 1;
if (!frames) {
sync_audio = 1;
if (cur_frames && min_frames && cur_frames >= min_frames) {
frames = cur_frames;
} else if (min_frames) {
frames = min_frames;
} else {
frames = fps / 15;
if (frames < 1) frames = 1;
frames = 0;
sync_audio = 0;
}
}
if (!jb_sync_msec) {
if (!jb_sync_msec && frames) {
jb_sync_msec = (double)(1000 / fps) * frames;
}
if (frames != cur_frames && frames > min_frames) {
switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames, 0);
sync_audio = 1;
sync_video = 1;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_DEBUG1, "%s %s \"%s\" Sync A/V JB to %dms %u VFrames FPS %u a:%s v:%s sync_ms:%d\n",
SWITCH_LOG_DEBUG1, "%s %s \"%s\" Sync A/V JB to %dms %u VFrames, FPS %u a:%s sync_ms:%d\n",
switch_core_session_get_uuid(session),
switch_channel_get_name(session->channel),
switch_channel_get_variable_dup(session->channel, "caller_id_name", SWITCH_FALSE, -1),
jb_sync_msec, frames, video_globals.fps, sync_audio ? "yes" : "no", sync_video ? "yes" : "no", jb_sync_msec);
jb_sync_msec, frames, video_globals.fps, sync_audio ? "yes" : "no", jb_sync_msec);
if (sync_audio) {
check_jb(session, NULL, jb_sync_msec, 0, SWITCH_TRUE);

View File

@ -934,9 +934,13 @@ SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb)
switch_core_session_request_video_refresh(jb->session);
}
}
jb_debug(jb, 2, "%s", "RESET BUFFER\n");
switch_mutex_lock(jb->mutex);
hide_nodes(jb);
switch_mutex_unlock(jb->mutex);
jb->drop_flag = 0;
jb->last_target_seq = 0;
jb->target_seq = 0;
@ -958,10 +962,6 @@ SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb)
jb->period_miss_inc = 0;
jb->target_ts = 0;
jb->last_target_ts = 0;
switch_mutex_lock(jb->mutex);
hide_nodes(jb);
switch_mutex_unlock(jb->mutex);
}
SWITCH_DECLARE(switch_status_t) switch_jb_peek_frame(switch_jb_t *jb, uint32_t ts, uint16_t seq, int peek, switch_frame_t *frame)
@ -1377,7 +1377,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
if (!jb->read_init) jb->read_init = 1;
} else {
if (jb->type == SJB_VIDEO) {
switch_jb_reset(jb);
//switch_jb_reset(jb);
switch(status) {
case SWITCH_STATUS_RESTART: