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
This commit is contained in:
Edward Hervey 2014-06-13 11:46:19 +02:00
parent fdf9bdf929
commit 97b3382c80

View file

@ -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;