FS-10269: [mod_conference] conference recording pause doesn't work correctly for video -- fix regression from change re: FS-10249
This commit is contained in:
parent
0a19bb5d45
commit
d99efb6997
|
@ -82,9 +82,8 @@ typedef struct record_helper_s {
|
|||
switch_mm_t *mm;
|
||||
int finalize;
|
||||
switch_file_handle_t *fh;
|
||||
int record_timer_offset;
|
||||
int record_timer_paused;
|
||||
int record_timer_resumed;
|
||||
switch_time_t record_timer_paused;
|
||||
uint64_t last_ts;
|
||||
} record_helper_t;
|
||||
|
||||
|
||||
|
@ -718,7 +717,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||
switch_image_t *img = NULL;
|
||||
int d_w = context->eh.video_st->width, d_h = context->eh.video_st->height;
|
||||
int size = 0, skip = 0, skip_freq = 0, skip_count = 0, skip_total = 0, skip_total_count = 0;
|
||||
uint64_t delta_avg = 0, delta_sum = 0, delta_i = 0, delta = 0, last_ts = 0;
|
||||
uint64_t delta_avg = 0, delta_sum = 0, delta_i = 0, delta = 0;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "video thread start\n");
|
||||
switch_assert(context->eh.video_queue);
|
||||
|
@ -790,6 +789,11 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||
continue;
|
||||
}
|
||||
|
||||
if (context->eh.record_timer_paused) {
|
||||
context->eh.last_ts = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
fill_avframe(context->eh.video_st->frame, img);
|
||||
|
||||
if (context->eh.finalize) {
|
||||
|
@ -812,28 +816,8 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||
uint64_t delta_tmp;
|
||||
|
||||
switch_core_timer_sync(context->eh.video_timer);
|
||||
|
||||
if (context->eh.record_timer_paused) {
|
||||
continue;
|
||||
} else if (context->eh.record_timer_resumed) {
|
||||
context->eh.record_timer_resumed = 0;
|
||||
|
||||
if (delta_avg) {
|
||||
delta = delta_avg;
|
||||
} else if (context->eh.mm->fps) {
|
||||
delta = 1000 / context->eh.mm->fps;
|
||||
} else {
|
||||
delta = 33;
|
||||
}
|
||||
|
||||
context->eh.video_st->frame->pts += delta;
|
||||
delta_tmp = delta;
|
||||
context->eh.record_timer_offset = context->eh.video_timer->samplecount - context->eh.video_st->frame->pts;
|
||||
context->eh.record_timer_offset = context->eh.record_timer_offset > 0 ? context->eh.record_timer_offset : 0;
|
||||
} else {
|
||||
delta_tmp = context->eh.video_timer->samplecount - last_ts;
|
||||
}
|
||||
|
||||
delta_tmp = context->eh.video_timer->samplecount - context->eh.last_ts;
|
||||
|
||||
if (delta_tmp != 0) {
|
||||
delta_sum += delta_tmp;
|
||||
delta_i++;
|
||||
|
@ -847,14 +831,14 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||
if ((delta_i % 10) == 0) {
|
||||
delta_avg = (int)(double)(delta_sum / delta_i);
|
||||
}
|
||||
|
||||
context->eh.video_st->frame->pts = context->eh.video_timer->samplecount - context->eh.record_timer_offset;
|
||||
|
||||
context->eh.video_st->frame->pts = context->eh.video_timer->samplecount;
|
||||
} else {
|
||||
context->eh.video_st->frame->pts = (context->eh.video_timer->samplecount) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
last_ts = context->eh.video_st->frame->pts;
|
||||
context->eh.last_ts = context->eh.video_st->frame->pts;
|
||||
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pts: %ld\n", context->eh.video_st->frame->pts);
|
||||
|
||||
|
@ -2167,6 +2151,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
|||
static switch_status_t av_file_command(switch_file_handle_t *handle, switch_file_command_t command)
|
||||
{
|
||||
av_file_context_t *context = (av_file_context_t *)handle->private_info;
|
||||
uint32_t offset = 0;
|
||||
|
||||
switch(command) {
|
||||
case SCFC_FLUSH_AUDIO:
|
||||
|
@ -2185,13 +2170,20 @@ static switch_status_t av_file_command(switch_file_handle_t *handle, switch_file
|
|||
break;
|
||||
case SCFC_PAUSE_WRITE:
|
||||
context->vid_ready = 0;
|
||||
context->eh.record_timer_paused = 1;
|
||||
context->eh.record_timer_paused = switch_micro_time_now();
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s pause write\n", handle->file_path);
|
||||
break;
|
||||
case SCFC_RESUME_WRITE:
|
||||
context->eh.record_timer_paused = 0;
|
||||
context->eh.record_timer_resumed = 1;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s resume write\n", handle->file_path);
|
||||
if (context->eh.record_timer_paused) {
|
||||
context->eh.last_ts = 0;
|
||||
offset = (uint32_t)(switch_micro_time_now() - context->eh.record_timer_paused);
|
||||
context->video_timer.start += offset;
|
||||
switch_core_timer_sync(&context->video_timer);
|
||||
context->audio_timer.start += offset;
|
||||
switch_core_timer_sync(&context->audio_timer);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s resume write\n", handle->file_path);
|
||||
context->eh.record_timer_paused = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue