tsdemux: Don't check SCTE events for being too far from the PCR

Otherwise it happens that SCTE events can only be scheduled up to 15
seconds since the last seen PCR, which is a useless restriction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2021>
This commit is contained in:
Vivia Nikolaidou 2022-03-24 19:55:48 +02:00 committed by GStreamer Marge Bot
parent 09ebe06fdf
commit fabf948194
3 changed files with 29 additions and 8 deletions

View file

@ -2253,9 +2253,9 @@ mpegts_packetizer_offset_to_ts (MpegTSPacketizer2 * packetizer,
/* Input : local PTS (in GHz units)
* Return : Stream time (in GHz units) */
GstClockTime
mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid)
static GstClockTime
mpegts_packetizer_pts_to_ts_internal (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid, gboolean check_diff)
{
GstClockTime res = GST_CLOCK_TIME_NONE;
MpegTSPCR *pcrtable;
@ -2281,14 +2281,14 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
res = pts + pcrtable->pcroffset + packetizer->extra_shift;
/* Don't return anything if we differ too much against last seen PCR */
if (G_UNLIKELY (pcr_pid != 0x1fff &&
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
if (G_UNLIKELY (check_diff && pcr_pid != 0x1fff &&
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND)) {
res = GST_CLOCK_TIME_NONE;
else {
} else {
GstClockTime tmp = pcrtable->base_time + pcrtable->skew;
if (tmp + res >= pcrtable->base_pcrtime) {
res += tmp - pcrtable->base_pcrtime;
} else if (ABSDIFF (tmp + res + PCR_GST_MAX_VALUE,
} else if (!check_diff || ABSDIFF (tmp + res + PCR_GST_MAX_VALUE,
pcrtable->base_pcrtime) < PCR_GST_MAX_VALUE / 2) {
/* Handle wrapover */
res += tmp + PCR_GST_MAX_VALUE - pcrtable->base_pcrtime;
@ -2388,6 +2388,24 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
return res;
}
/* Input : local PTS (in GHz units)
* Return : Stream time (in GHz units) */
GstClockTime
mpegts_packetizer_pts_to_ts_unchecked (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid)
{
return mpegts_packetizer_pts_to_ts_internal (packetizer, pts, pcr_pid, FALSE);
}
/* Input : local PTS (in GHz units)
* Return : Stream time (in GHz units) */
GstClockTime
mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid)
{
return mpegts_packetizer_pts_to_ts_internal (packetizer, pts, pcr_pid, TRUE);
}
/* Stream time to offset */
guint64
mpegts_packetizer_ts_to_offset (MpegTSPacketizer2 * packetizer,

View file

@ -373,6 +373,9 @@ G_GNUC_INTERNAL GstClockTime
mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid);
G_GNUC_INTERNAL GstClockTime
mpegts_packetizer_pts_to_ts_unchecked (MpegTSPacketizer2 * packetizer,
GstClockTime pts, guint16 pcr_pid);
G_GNUC_INTERNAL GstClockTime
mpegts_packetizer_get_current_time (MpegTSPacketizer2 * packetizer,
guint16 pcr_pid);
G_GNUC_INTERNAL void

View file

@ -1179,7 +1179,7 @@ handle_psi (MpegTSBase * base, GstMpegtsSection * section)
if (sevent->program_splice_time_specified) {
pts =
mpegts_packetizer_pts_to_ts (base->packetizer,
mpegts_packetizer_pts_to_ts_unchecked (base->packetizer,
MPEGTIME_TO_GSTTIME (sevent->program_splice_time +
sit->pts_adjustment), demux->program->pcr_pid);
field_name =