mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-01 19:20:05 +00:00
FS-9497 #resolve [AV sync record issue]
This commit is contained in:
parent
f6ad006daf
commit
fd724a7b97
@ -615,7 +615,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||||||
switch_image_t *img = NULL, *tmp_img = NULL;
|
switch_image_t *img = NULL, *tmp_img = NULL;
|
||||||
int d_w = eh->video_st->width, d_h = eh->video_st->height;
|
int d_w = eh->video_st->width, d_h = eh->video_st->height;
|
||||||
int size = 0, skip = 0, skip_freq = 0, skip_count = 0, skip_total = 0, skip_total_count = 0;
|
int size = 0, skip = 0, skip_freq = 0, skip_count = 0, skip_total = 0, skip_total_count = 0;
|
||||||
uint64_t hard_delta = 0, delta = 0, last_ts = 0;
|
uint64_t delta_avg = 0, delta_sum = 0, delta_i = 0, delta = 0, last_ts = 0;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "video thread start\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "video thread start\n");
|
||||||
|
|
||||||
@ -626,10 +626,6 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||||||
|
|
||||||
top:
|
top:
|
||||||
|
|
||||||
if (eh->mm->fps) {
|
|
||||||
hard_delta = 1000 / eh->mm->fps;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (switch_queue_pop(eh->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
if (switch_queue_pop(eh->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_img_free(&img);
|
switch_img_free(&img);
|
||||||
|
|
||||||
@ -663,7 +659,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
size = switch_queue_size(eh->video_queue);
|
size = switch_queue_size(eh->video_queue);
|
||||||
|
|
||||||
if (size > 5 && !eh->finalize) {
|
if (size > 5 && !eh->finalize) {
|
||||||
skip = size;
|
skip = size;
|
||||||
|
|
||||||
@ -693,25 +689,38 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
|||||||
|
|
||||||
fill_avframe(eh->video_st->frame, img);
|
fill_avframe(eh->video_st->frame, img);
|
||||||
|
|
||||||
if (hard_delta) {
|
if (eh->finalize) {
|
||||||
delta = hard_delta;
|
if (delta_i && !delta_avg) {
|
||||||
}
|
delta_avg = (int)(double)(delta_sum / delta_i);
|
||||||
|
delta_i = 0;
|
||||||
|
delta_sum = delta_avg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta_avg) {
|
||||||
|
delta = delta_avg;
|
||||||
|
} else if (eh->mm->fps) {
|
||||||
|
delta = 1000 / eh->mm->fps;
|
||||||
|
} else {
|
||||||
|
delta = 33;
|
||||||
|
}
|
||||||
|
|
||||||
if ((eh->finalize && delta) || hard_delta) {
|
|
||||||
eh->video_st->frame->pts += delta;
|
eh->video_st->frame->pts += delta;
|
||||||
} else {
|
} else {
|
||||||
|
uint64_t delta_tmp;
|
||||||
|
|
||||||
switch_core_timer_sync(eh->timer);
|
switch_core_timer_sync(eh->timer);
|
||||||
|
delta_tmp = eh->timer->samplecount - last_ts;
|
||||||
|
|
||||||
if (eh->video_st->frame->pts == eh->timer->samplecount) {
|
if (delta_tmp != last_ts) {
|
||||||
// never use the same pts, or the encoder coughs
|
delta_sum += delta_tmp;
|
||||||
eh->video_st->frame->pts++;
|
delta_i++;
|
||||||
} else {
|
|
||||||
uint64_t delta_tmp = eh->timer->samplecount - last_ts;
|
if (delta_i >= 60) {
|
||||||
|
delta_avg = (int)(double)(delta_sum / delta_i);
|
||||||
if (delta_tmp > 10) {
|
delta_i = 0;
|
||||||
delta = delta_tmp;
|
delta_sum = delta_avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
eh->video_st->frame->pts = eh->timer->samplecount;
|
eh->video_st->frame->pts = eh->timer->samplecount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7091,9 +7091,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
|
|||||||
switch_core_media_parse_rtp_bugs(&v_engine->rtp_bugs, val);
|
switch_core_media_parse_rtp_bugs(&v_engine->rtp_bugs, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
|
//if (switch_channel_test_flag(session->channel, CF_AVPF)) {
|
||||||
smh->mparams->manual_video_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
|
//smh->mparams->manual_video_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
|
||||||
}
|
//}
|
||||||
|
|
||||||
switch_rtp_intentional_bugs(v_engine->rtp_session, v_engine->rtp_bugs | smh->mparams->manual_video_rtp_bugs);
|
switch_rtp_intentional_bugs(v_engine->rtp_session, v_engine->rtp_bugs | smh->mparams->manual_video_rtp_bugs);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user