Skip to content

Commit 3f91dc6

Browse files
Fix: User controlled pacing sync for st2110-20
A mechanism that allows the session to move the pacing window if the current epoch is just a little bit behind was applied to user controlled pacing, which in turn made the scenarios where big PTP updates or other small issues may cause incremental delays, which is not really a problem as long as we don't enable user controlled pacing. Fix it by ignoring all discrepancies for user controlled pacing scenarios (required_tai) and just forcing the session to send the packets asap.
1 parent 9168009 commit 3f91dc6

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

lib/src/st2110/st_tx_video_session.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -645,34 +645,45 @@ static int tv_sync_pacing(struct mtl_main_impl* impl, struct st_tx_video_session
645645
", ptp_time %" PRIu64 "ms\n",
646646
__func__, idx, to_epoch, epochs, pacing->cur_epochs, ptp_time / 1000 / 1000);
647647
s->stat_epoch_troffset_mismatch++;
648-
epochs++; /* assign to next */
649-
start_time_ptp = pacing_start_time(pacing, epochs);
650-
to_epoch = start_time_ptp - ptp_time;
651-
}
652648

653-
if (to_epoch < 0) {
654-
/* should never happen */
655-
err("%s(%d), error to_epoch %f, ptp_time %" PRIu64 ", epochs %" PRIu64 " %" PRIu64
656-
"\n",
657-
__func__, idx, to_epoch, ptp_time, epochs, pacing->cur_epochs);
658-
to_epoch = 0;
649+
/* in case of user controlled pacing we need to send this even if late
650+
as close to the user defiend time as possible*/
651+
if (required_tai) {
652+
to_epoch = 0;
653+
} else {
654+
to_epoch = start_time_ptp - ptp_time;
655+
epochs++; /* assign to next */
656+
start_time_ptp = pacing_start_time(pacing, epochs);
657+
658+
if (to_epoch < 0) {
659+
/* should never happen */
660+
err("%s(%d), error to_epoch %f, ptp_time %" PRIu64 ", epochs %" PRIu64 " %" PRIu64
661+
"\n",
662+
__func__, idx, to_epoch, ptp_time, epochs, pacing->cur_epochs);
663+
to_epoch = 0;
664+
}
665+
}
659666
}
660667

661668
if (epochs > next_epochs) {
662669
dbg("%s(%d), epochs %" PRIu64 " next_epochs %" PRIu64 "\n", __func__, idx, epochs,
663670
next_epochs);
664671
s->stat_epoch_drop += (epochs - next_epochs);
672+
} else if (epochs < next_epochs) {
673+
s->stat_epoch_onward += (next_epochs - epochs);
665674
}
666-
if (epochs < next_epochs) s->stat_epoch_onward += (next_epochs - epochs);
675+
667676
pacing->cur_epochs = epochs;
668677
pacing->cur_epoch_time = pacing_time(pacing, epochs);
669678
pacing->rtp_time_stamp = pacing_time_stamp(s, pacing, epochs);
670679
dbg("%s(%d), old time_cursor %fms\n", __func__, idx,
671680
pacing->tsc_time_cursor / 1000 / 1000);
681+
672682
pacing->tsc_time_cursor = (double)mt_get_tsc(impl) + to_epoch;
673683
dbg("%s(%d), epochs %" PRIu64 " time_stamp %u time_cursor %fms to_epoch %fms\n",
674684
__func__, idx, pacing->cur_epochs, pacing->rtp_time_stamp,
675685
pacing->tsc_time_cursor / 1000 / 1000, to_epoch / 1000 / 1000);
686+
676687
pacing->ptp_time_cursor = start_time_ptp;
677688
pacing->tsc_time_frame_start = pacing->tsc_time_cursor;
678689

0 commit comments

Comments
 (0)