Skip to content

Commit 25c4f75

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 f2e7955 commit 25c4f75

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

lib/src/st2110/st_tx_video_session.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -649,25 +649,32 @@ static int tv_sync_pacing(struct mtl_main_impl* impl, struct st_tx_video_session
649649
", ptp_time %" PRIu64 "ms\n",
650650
__func__, idx, to_epoch, epochs, pacing->cur_epochs, ptp_time / 1000 / 1000);
651651
ST_SESSION_STAT_INC(s, port_user_stats, stat_epoch_troffset_mismatch);
652-
epochs++; /* assign to next */
653-
start_time_ptp = pacing_start_time(pacing, epochs);
654-
to_epoch = start_time_ptp - ptp_time;
655-
}
656652

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

665672
if (epochs > next_epochs) {
666673
dbg("%s(%d), epochs %" PRIu64 " next_epochs %" PRIu64 "\n", __func__, idx, epochs,
667674
next_epochs);
668-
s->stat_epoch_drop += (epochs - next_epochs);
669-
}
670-
if (epochs < next_epochs) {
675+
ST_SESSION_STAT_ADD(s, port_user_stats.common, stat_epoch_drop,
676+
(epochs - next_epochs));
677+
} else if (epochs < next_epochs) {
671678
ST_SESSION_STAT_ADD(s, port_user_stats.common, stat_epoch_onward,
672679
(next_epochs - epochs));
673680
}
@@ -677,10 +684,12 @@ static int tv_sync_pacing(struct mtl_main_impl* impl, struct st_tx_video_session
677684
pacing->rtp_time_stamp = pacing_time_stamp(s, pacing, epochs);
678685
dbg("%s(%d), old time_cursor %fms\n", __func__, idx,
679686
pacing->tsc_time_cursor / 1000 / 1000);
687+
680688
pacing->tsc_time_cursor = (double)mt_get_tsc(impl) + to_epoch;
681689
dbg("%s(%d), epochs %" PRIu64 " time_stamp %u time_cursor %fms to_epoch %fms\n",
682690
__func__, idx, pacing->cur_epochs, pacing->rtp_time_stamp,
683691
pacing->tsc_time_cursor / 1000 / 1000, to_epoch / 1000 / 1000);
692+
684693
pacing->ptp_time_cursor = start_time_ptp;
685694
pacing->tsc_time_frame_start = pacing->tsc_time_cursor;
686695

0 commit comments

Comments
 (0)