FS-9497 #resolve [AV sync record issue]

This commit is contained in:
Anthony Minessale 2016-09-09 16:48:34 -05:00
parent f6ad006daf
commit fd724a7b97
2 changed files with 31 additions and 22 deletions

View File

@ -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;
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;
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");
@ -626,10 +626,6 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
top:
if (eh->mm->fps) {
hard_delta = 1000 / eh->mm->fps;
}
if (switch_queue_pop(eh->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_img_free(&img);
@ -663,7 +659,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
} else {
size = switch_queue_size(eh->video_queue);
if (size > 5 && !eh->finalize) {
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);
if (hard_delta) {
delta = hard_delta;
}
if (eh->finalize) {
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;
} else {
uint64_t delta_tmp;
switch_core_timer_sync(eh->timer);
delta_tmp = eh->timer->samplecount - last_ts;
if (eh->video_st->frame->pts == eh->timer->samplecount) {
// never use the same pts, or the encoder coughs
eh->video_st->frame->pts++;
} else {
uint64_t delta_tmp = eh->timer->samplecount - last_ts;
if (delta_tmp > 10) {
delta = delta_tmp;
if (delta_tmp != last_ts) {
delta_sum += delta_tmp;
delta_i++;
if (delta_i >= 60) {
delta_avg = (int)(double)(delta_sum / delta_i);
delta_i = 0;
delta_sum = delta_avg;
}
eh->video_st->frame->pts = eh->timer->samplecount;
}
}

View File

@ -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);
}
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
smh->mparams->manual_video_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
}
//if (switch_channel_test_flag(session->channel, CF_AVPF)) {
//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);