]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10892: [mod_av] Lip Sync Improvements #resolve
authorBrian West <brian@freeswitch.org>
Wed, 29 Nov 2017 20:27:00 +0000 (14:27 -0600)
committerMuteesa Fred <muteesafred@hotmail.com>
Tue, 24 Jul 2018 07:21:37 +0000 (07:21 +0000)
src/mod/applications/mod_av/avformat.c
src/mod/applications/mod_conference/conference_record.c
src/mod/applications/mod_conference/conference_video.c

index 644261699f845ad0227341287ae93dd81d63f24c..04101629c4ff31508c976314477d2d0b085ed1f5 100644 (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;             
index 784101fb7f9dc4c33ecf1ebca6cd2ba0109d2b66..e54c8fcb9678a4b318bddc46737e1e878dadd71a 100644 (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,
index d94847d0982026f0b2002a7a3f9f87929c396fb3..19732ffbc5fc060ef1141eba5c112cb685bd109b 100644 (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);
        }