This is only enabled in push time mode. Furthermore it's only enabled for now if
PCR is to be ignored.
The problem is dealing with streams where the initial PTS/DTS observation might
be greater than following ones (from other PID for example). Before this patch,
this would result in sending buffers without any timestamp which would cause a
wide variety of issues.
Instead, pad segment and buffer timestamps with an extra
value (packetizer->extra_shift, default to 2s), to ensure that we can get valid
timestamps on outgoing buffers (even if that means they are before the segment
start).
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1179>
packetizer->pcr_discont_threshold = GST_SECOND;
packetizer->last_pts = GST_CLOCK_TIME_NONE;
packetizer->last_dts = GST_CLOCK_TIME_NONE;
+ packetizer->extra_shift = 0;
}
static void
GST_TIME_ARGS (pcrtable->base_pcrtime),
GST_TIME_ARGS (pcrtable->base_time),
GST_TIME_ARGS (pcrtable->pcroffset));
- res = pts + pcrtable->pcroffset;
+ 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 &&
/* PTS/DTS of last buffer */
GstClockTime last_pts;
GstClockTime last_dts;
+
+ /* Extra time offset to handle values before initial PCR.
+ * This will be added to all converted timestamps */
+ GstClockTime extra_shift;
};
struct _MpegTSPacketizer2Class {
gboolean early_ret = FALSE;
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
+ if (base->segment.format == GST_FORMAT_TIME && base->ignore_pcr) {
+ /* Shift start/stop values by 2s */
+ base->packetizer->extra_shift = 2 * GST_SECOND;
+ if (GST_CLOCK_TIME_IS_VALID (base->segment.start))
+ base->segment.start += 2 * GST_SECOND;
+ if (GST_CLOCK_TIME_IS_VALID (base->segment.stop))
+ base->segment.stop += 2 * GST_SECOND;
+ if (GST_CLOCK_TIME_IS_VALID (base->segment.position))
+ base->segment.position += 2 * GST_SECOND;
+ }
GST_DEBUG_OBJECT (base, "Ignoring segment event (recreated later)");
gst_event_unref (event);
return TRUE;