FS-10892: [mod_av] Lip Sync Improvements #resolve

This commit is contained in:
Brian West 2017-11-29 14:27:00 -06:00 committed by Muteesa Fred
parent 0d40025e09
commit 105a291bb7
3 changed files with 22 additions and 12 deletions

View File

@ -132,6 +132,7 @@ struct av_file_context {
switch_size_t mux_buf_len;
switch_time_t last_vid_write;
int audio_timer;
};
typedef struct av_file_context av_file_context_t;
@ -1585,11 +1586,17 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
context->seek_ts = -1;
context->offset = DFT_RECORD_OFFSET;
context->handle = handle;
context->audio_timer = 1;
if (handle->params) {
if ((tmp = switch_event_get_header(handle->params, "av_video_offset"))) {
context->offset = atoi(tmp);
}
if ((tmp = switch_event_get_header(handle->params, "video_time_audio"))) {
if (tmp && switch_false(tmp)) {
context->audio_timer = 0;
}
}
}
switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
@ -1910,9 +1917,12 @@ GCC_DIAG_ON(deprecated-declarations)
delta = context->video_timer.samplecount - context->last_vid_write;
if (delta >= 60) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Video timer sync: %ld/%d %ld\n", context->audio_st[0].next_pts, context->video_timer.samplecount, context->audio_st[0].next_pts- context->video_timer.samplecount);
sample_start = context->video_timer.samplecount * (handle->samplerate / 1000);
if (context->audio_timer || delta >= 60) {
uint32_t new_pts = context->video_timer.samplecount * (handle->samplerate / 1000);
if (!context->audio_timer) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Delta of %d detected. Video timer sync: %ld/%d %ld\n", delta, context->audio_st[0].next_pts, context->video_timer.samplecount, new_pts - context->audio_st[0].next_pts);
}
sample_start = new_pts;
}
context->last_vid_write = context->video_timer.samplecount;

View File

@ -233,7 +233,7 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
flags |= SWITCH_FILE_FLAG_VIDEO;
if (canvas) {
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
rec->path = switch_core_sprintf(rec->pool, "{video_time_audio=false,channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels,
conference->rate,
canvas->width,
@ -241,7 +241,7 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
conference->video_fps.fps,
orig_path);
} else {
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
rec->path = switch_core_sprintf(rec->pool, "{video_time_audio=false,channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels,
conference->rate,
conference->canvas_width,

View File

@ -1353,6 +1353,12 @@ switch_status_t conference_video_attach_video_layer(conference_member_t *member,
return SWITCH_STATUS_FALSE;
}
switch_mutex_lock(canvas->mutex);
layer = &canvas->layers[idx];
layer->tagged = 0;
if (!zstr(member->video_role_id) && !zstr(layer->geometry.role_id) && !strcmp(layer->geometry.role_id, member->video_role_id)) {
conference_utils_member_set_flag(member, MFLAG_DED_VID_LAYER);
}
@ -1363,12 +1369,6 @@ switch_status_t conference_video_attach_video_layer(conference_member_t *member,
}
}
switch_mutex_lock(canvas->mutex);
layer = &canvas->layers[idx];
layer->tagged = 0;
if (layer->fnode || layer->geometry.fileonly) {
switch_goto_status(SWITCH_STATUS_FALSE, end);
}