summaryrefslogtreecommitdiff
path: root/gst/mpegtsdemux/mpegtspacketizer.c
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2014-06-13 11:46:19 +0200
committerEdward Hervey <bilboed@bilboed.com>2014-06-13 11:52:15 +0200
commit97b3382c80ba3f9ef2479e7b0bb2a6944e26c765 (patch)
tree84ad55e36948dcd2c58fd92321f855b2bfdec99d /gst/mpegtsdemux/mpegtspacketizer.c
parentfdf9bdf9295ff9ec781e0e1551ed18c581d1af34 (diff)
downloadgstreamer-plugins-bad-97b3382c80ba3f9ef2479e7b0bb2a6944e26c765.tar.gz
mpegtspacketizer: live: handle pcr/dts discrepancies some more
When wrapover/reset occur, we end up with a small window of time where the PTS/DTS will still be using the previous/next time-range. In order not to return bogus values, return GST_CLOCK_TIME_NONE if the PTS/DTS value to convert differs by more than 15s against the last seen PCR https://bugzilla.gnome.org/show_bug.cgi?id=674536
Diffstat (limited to 'gst/mpegtsdemux/mpegtspacketizer.c')
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index d39edefcc..b504739df 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -2135,12 +2135,24 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
/* Use clock skew if present */
if (packetizer->calculate_skew
&& GST_CLOCK_TIME_IS_VALID (pcrtable->base_time)) {
- GST_DEBUG ("pts %" G_GUINT64_FORMAT " base_pcrtime:%" G_GUINT64_FORMAT
- " base_time:%" GST_TIME_FORMAT, pts, pcrtable->base_pcrtime,
- GST_TIME_ARGS (pcrtable->base_time));
- res =
- pts + pcrtable->pcroffset - pcrtable->base_pcrtime +
- pcrtable->base_time + pcrtable->skew;
+ GST_DEBUG ("pts %" GST_TIME_FORMAT " base_pcrtime:%" GST_TIME_FORMAT
+ " base_time:%" GST_TIME_FORMAT " pcroffset:%" GST_TIME_FORMAT,
+ GST_TIME_ARGS (pts),
+ GST_TIME_ARGS (pcrtable->base_pcrtime),
+ GST_TIME_ARGS (pcrtable->base_time),
+ GST_TIME_ARGS (pcrtable->pcroffset));
+ res = pts + pcrtable->pcroffset;
+
+ /* Don't return anything if we differ too much against last seen PCR */
+ /* FIXME : Ideally we want to figure out whether we have a wraparound or
+ * a reset so we can provide actual values.
+ * That being said, this will only happen for the small interval of time
+ * where PTS/DTS are wrapping just before we see the first reset/wrap PCR
+ */
+ if (G_UNLIKELY (ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
+ res = GST_CLOCK_TIME_NONE;
+ else
+ res += pcrtable->base_time + pcrtable->skew - pcrtable->base_pcrtime;
} else if (packetizer->calculate_offset && pcrtable->groups) {
gint64 refpcr = G_MAXINT64, refpcroffset;
PCROffsetGroup *group = pcrtable->current->group;