tsdemux: handle pcr_pid == 0x1fff

Streams without PCR make senses in HLS, where the playlist timestamps
can be used to seek or calculate the duration.

https://bugzilla.gnome.org/show_bug.cgi?id=608148
This commit is contained in:
Michael Olbrich 2016-05-31 13:09:43 +02:00 committed by Edward Hervey
parent 7a3d189250
commit 36e6590335

View file

@ -557,6 +557,7 @@ void
mpegts_packetizer_clear (MpegTSPacketizer2 * packetizer) mpegts_packetizer_clear (MpegTSPacketizer2 * packetizer)
{ {
guint i; guint i;
MpegTSPCR *pcrtable;
packetizer->packet_size = 0; packetizer->packet_size = 0;
@ -579,6 +580,10 @@ mpegts_packetizer_clear (MpegTSPacketizer2 * packetizer)
packetizer->map_offset = 0; packetizer->map_offset = 0;
packetizer->last_in_time = GST_CLOCK_TIME_NONE; packetizer->last_in_time = GST_CLOCK_TIME_NONE;
pcrtable = packetizer->observations[packetizer->pcrtablelut[0x1fff]];
if (pcrtable)
pcrtable->base_time = GST_CLOCK_TIME_NONE;
/* Close current PCR group */ /* Close current PCR group */
PACKETIZER_GROUP_LOCK (packetizer); PACKETIZER_GROUP_LOCK (packetizer);
@ -595,6 +600,7 @@ void
mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer, gboolean hard) mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer, gboolean hard)
{ {
guint i; guint i;
MpegTSPCR *pcrtable;
GST_DEBUG ("Flushing"); GST_DEBUG ("Flushing");
if (packetizer->streams) { if (packetizer->streams) {
@ -614,6 +620,10 @@ mpegts_packetizer_flush (MpegTSPacketizer2 * packetizer, gboolean hard)
packetizer->map_offset = 0; packetizer->map_offset = 0;
packetizer->last_in_time = GST_CLOCK_TIME_NONE; packetizer->last_in_time = GST_CLOCK_TIME_NONE;
pcrtable = packetizer->observations[packetizer->pcrtablelut[0x1fff]];
if (pcrtable)
pcrtable->base_time = GST_CLOCK_TIME_NONE;
/* Close current PCR group */ /* Close current PCR group */
PACKETIZER_GROUP_LOCK (packetizer); PACKETIZER_GROUP_LOCK (packetizer);
for (i = 0; i < MAX_PCR_OBS_CHANNELS; i++) { for (i = 0; i < MAX_PCR_OBS_CHANNELS; i++) {
@ -2189,6 +2199,12 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
PACKETIZER_GROUP_LOCK (packetizer); PACKETIZER_GROUP_LOCK (packetizer);
pcrtable = get_pcr_table (packetizer, pcr_pid); pcrtable = get_pcr_table (packetizer, pcr_pid);
if (!GST_CLOCK_TIME_IS_VALID (pcrtable->base_time) && pcr_pid == 0x1fff &&
GST_CLOCK_TIME_IS_VALID (packetizer->last_in_time)) {
pcrtable->base_time = packetizer->last_in_time;
pcrtable->base_pcrtime = pts;
}
/* Use clock skew if present */ /* Use clock skew if present */
if (packetizer->calculate_skew if (packetizer->calculate_skew
&& GST_CLOCK_TIME_IS_VALID (pcrtable->base_time)) { && GST_CLOCK_TIME_IS_VALID (pcrtable->base_time)) {
@ -2206,7 +2222,8 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
* That being said, this will only happen for the small interval of time * 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 * 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)) if (G_UNLIKELY (pcr_pid != 0x1fff &&
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
res = GST_CLOCK_TIME_NONE; res = GST_CLOCK_TIME_NONE;
else { else {
GstClockTime tmp = pcrtable->base_time + pcrtable->skew; GstClockTime tmp = pcrtable->base_time + pcrtable->skew;