summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward.hervey@collabora.co.uk>2012-07-20 09:56:14 +0200
committerEdward Hervey <edward@collabora.com>2013-04-12 12:04:33 +0200
commit2c918dac65abfbc68cc8fa35dbd825c7b61fb501 (patch)
tree5259249e84693af81686698e641a3474e00b641b
parent0aa8f1aa9563e0a4eebae14072001ae393d68f02 (diff)
!!WIP MPEG-TS0.10
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c2
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c8
-rw-r--r--gst/mpegtsdemux/tsdemux.c95
3 files changed, 27 insertions, 78 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index bbabdd97d..905ae1e1e 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -1585,7 +1585,7 @@ mpegts_base_loop (MpegTSBase * base)
case BASE_MODE_SCANNING:
/* Find first sync point */
ret = mpegts_base_scan (base);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
+ if (G_UNLIKELY (ret != GST_FLOW_OK && ret != GST_FLOW_EOS))
goto error;
base->mode = BASE_MODE_STREAMING;
GST_DEBUG ("Changing to Streaming");
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index 572e3e49b..a52c34d08 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -3338,7 +3338,8 @@ record_pcr (MpegTSPacketizer2 * packetizer, guint64 pcr, guint64 offset)
priv->nb_seen_offsets++;
} else
/* If we didn't update the first PCR, let's check against last PCR */
- if (priv->last_pcr == -1 || priv->last_offset < offset) {
+ if (offset != pcrtable->first_offset && (pcrtable->last_pcr == -1
+ || pcrtable->last_offset < offset)) {
GST_DEBUG ("Recording last value. PCR:%" G_GUINT64_FORMAT " offset:%"
G_GUINT64_FORMAT, pcr, offset);
if (G_UNLIKELY (priv->first_pcr != -1 && pcr < priv->first_pcr)) {
@@ -3373,6 +3374,11 @@ mpegts_packetizer_offset_to_ts (MpegTSPacketizer2 * packetizer, guint64 offset)
if (G_UNLIKELY (offset < priv->refoffset))
return GST_CLOCK_TIME_NONE;
+ pcrtable = get_pcr_table (packetizer, pid);
+
+ if (G_UNLIKELY (pcrtable->last_pcr == -1))
+ return GST_CLOCK_TIME_NONE;
+
/* Convert byte difference into time difference */
res = PCRTIME_TO_GSTTIME (gst_util_uint64_scale (offset - priv->refoffset,
priv->last_pcr - priv->first_pcr,
diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c
index 60329ef4d..84fb497bb 100644
--- a/gst/mpegtsdemux/tsdemux.c
+++ b/gst/mpegtsdemux/tsdemux.c
@@ -134,18 +134,6 @@ struct _TSDemuxStream
/* Current PTS/DTS for this stream */
GstClockTime pts;
GstClockTime dts;
- /* Last seen valid PTS/DTS */
- GstClockTime last_pts;
- GstClockTime last_dts;
- /* Raw value of current PTS/DTS */
- guint64 raw_pts;
- guint64 raw_dts;
- /* PTS/DTS with rollover fixed */
- guint64 fixed_pts;
- guint64 fixed_dts;
- /* Number of rollover seen for PTS/DTS (default:0) */
- guint nb_pts_rollover;
- guint nb_dts_rollover;
/* Whether this stream needs to send a newsegment */
gboolean need_newsegment;
@@ -1018,12 +1006,6 @@ gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * bstream,
stream->need_newsegment = TRUE;
stream->pts = GST_CLOCK_TIME_NONE;
stream->dts = GST_CLOCK_TIME_NONE;
- stream->raw_pts = 0;
- stream->raw_dts = 0;
- stream->fixed_pts = 0;
- stream->fixed_dts = 0;
- stream->nb_pts_rollover = 0;
- stream->nb_dts_rollover = 0;
}
stream->flow_return = GST_FLOW_OK;
}
@@ -1100,12 +1082,6 @@ gst_ts_demux_stream_flush (TSDemuxStream * stream)
stream->need_newsegment = TRUE;
stream->pts = GST_CLOCK_TIME_NONE;
stream->dts = GST_CLOCK_TIME_NONE;
- stream->raw_pts = 0;
- stream->raw_dts = 0;
- stream->fixed_pts = 0;
- stream->fixed_dts = 0;
- stream->nb_pts_rollover = 0;
- stream->nb_dts_rollover = 0;
}
static void
@@ -1216,33 +1192,13 @@ gst_ts_demux_record_pts (GstTSDemux * demux, TSDemuxStream * stream,
{
MpegTSBaseStream *bs = (MpegTSBaseStream *) stream;
- GST_LOG ("pid 0x%04x pts:%" G_GUINT64_FORMAT " at offset %"
+ GST_LOG ("pid 0x%04x raw pts:%" G_GUINT64_FORMAT " at offset %"
G_GUINT64_FORMAT, bs->pid, pts, offset);
- if (G_UNLIKELY (GST_CLOCK_TIME_IS_VALID (stream->pts) &&
- ABSDIFF (stream->raw_pts, pts) > 900000)) {
- /* Detect rollover if diff > 10s */
- GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
- G_GUINT64_FORMAT ")", stream->raw_pts, pts);
- if (pts < stream->raw_pts) {
- /* Forward rollover */
- GST_LOG ("Forward rollover, incrementing nb_pts_rollover");
- stream->nb_pts_rollover++;
- } else {
- /* Reverse rollover */
- GST_LOG ("Reverse rollover, decrementing nb_pts_rollover");
- stream->nb_pts_rollover--;
- }
- }
-
/* Compute PTS in GstClockTime */
- stream->raw_pts = pts;
- stream->fixed_pts = pts + stream->nb_pts_rollover * PTS_DTS_MAX_VALUE;
- stream->pts = MPEGTIME_TO_GSTTIME (stream->fixed_pts);
-
- GST_LOG ("pid 0x%04x Stored PTS %" G_GUINT64_FORMAT " (%" GST_TIME_FORMAT ")",
- bs->pid, stream->raw_pts, GST_TIME_ARGS (stream->pts));
-
+ stream->pts =
+ mpegts_packetizer_pts_to_ts (MPEG_TS_BASE_PACKETIZER (demux),
+ MPEGTIME_TO_GSTTIME (pts), demux->program->pcr_pid);
if (G_UNLIKELY (demux->emit_statistics)) {
GstStructure *st;
@@ -1262,32 +1218,18 @@ gst_ts_demux_record_dts (GstTSDemux * demux, TSDemuxStream * stream,
{
MpegTSBaseStream *bs = (MpegTSBaseStream *) stream;
- GST_LOG ("pid 0x%04x dts:%" G_GUINT64_FORMAT " at offset %"
- G_GUINT64_FORMAT, bs->pid, dts, offset);
-
- if (G_UNLIKELY (GST_CLOCK_TIME_IS_VALID (stream->dts) &&
- ABSDIFF (stream->raw_dts, dts) > 900000)) {
- /* Detect rollover if diff > 10s */
- GST_LOG ("Detected rollover (previous:%" G_GUINT64_FORMAT " new:%"
- G_GUINT64_FORMAT ")", stream->raw_dts, dts);
- if (dts < stream->raw_dts) {
- /* Forward rollover */
- GST_LOG ("Forward rollover, incrementing nb_dts_rollover");
- stream->nb_dts_rollover++;
- } else {
- /* Reverse rollover */
- GST_LOG ("Reverse rollover, decrementing nb_dts_rollover");
- stream->nb_dts_rollover--;
- }
+ if (dts == -1) {
+ stream->dts = GST_CLOCK_TIME_NONE;
+ return;
}
- /* Compute DTS in GstClockTime */
- stream->raw_dts = dts;
- stream->fixed_dts = dts + stream->nb_dts_rollover * PTS_DTS_MAX_VALUE;
- stream->dts = MPEGTIME_TO_GSTTIME (stream->fixed_dts);
+ GST_LOG ("pid 0x%04x raw dts:%" G_GUINT64_FORMAT " at offset %"
+ G_GUINT64_FORMAT, bs->pid, dts, offset);
- GST_LOG ("pid 0x%04x Stored DTS %" G_GUINT64_FORMAT " (%" GST_TIME_FORMAT ")",
- bs->pid, stream->raw_dts, GST_TIME_ARGS (stream->dts));
+ /* Compute DTS in GstClockTime */
+ stream->dts =
+ mpegts_packetizer_pts_to_ts (MPEG_TS_BASE_PACKETIZER (demux),
+ MPEGTIME_TO_GSTTIME (dts), demux->program->pcr_pid);
if (G_UNLIKELY (demux->emit_statistics)) {
GstStructure *st;
@@ -1452,7 +1394,7 @@ gst_ts_demux_push_tags (GstTSDemux * demux, TSDemuxStream * stream)
static void
calculate_and_push_newsegment (GstTSDemux * demux, TSDemuxStream * stream)
{
- MpegTSBase *base = (MpegTSBase *) demux;
+ /* MpegTSBase *base = (MpegTSBase *) demux; */
GstClockTime lowest_pts = GST_CLOCK_TIME_NONE;
GstClockTime firstts = 0;
GList *tmp;
@@ -1482,7 +1424,7 @@ calculate_and_push_newsegment (GstTSDemux * demux, TSDemuxStream * stream)
}
}
if (GST_CLOCK_TIME_IS_VALID (lowest_pts))
- firstts = mpegts_packetizer_pts_to_ts (base->packetizer, lowest_pts);
+ firstts = lowest_pts;
GST_DEBUG ("lowest_pts %" G_GUINT64_FORMAT " => clocktime %" GST_TIME_FORMAT,
lowest_pts, GST_TIME_ARGS (firstts));
@@ -1550,7 +1492,7 @@ gst_ts_demux_push_pending_data (GstTSDemux * demux, TSDemuxStream * stream)
MpegTSBaseStream *bs = (MpegTSBaseStream *) stream;
/* MpegTSBase *base = (MpegTSBase*) demux; */
GstBuffer *buffer = NULL;
- MpegTSPacketizer2 *packetizer = MPEG_TS_BASE_PACKETIZER (demux);
+ /* MpegTSPacketizer2 *packetizer = MPEG_TS_BASE_PACKETIZER (demux); */
GST_DEBUG_OBJECT (stream->pad,
"stream:%p, pid:0x%04x stream_type:%d state:%d", stream, bs->pid,
@@ -1591,8 +1533,9 @@ gst_ts_demux_push_pending_data (GstTSDemux * demux, TSDemuxStream * stream)
GST_DEBUG_OBJECT (stream->pad, "stream->pts %" GST_TIME_FORMAT,
GST_TIME_ARGS (stream->pts));
if (GST_CLOCK_TIME_IS_VALID (stream->pts))
- GST_BUFFER_TIMESTAMP (buffer) =
- mpegts_packetizer_pts_to_ts (packetizer, stream->pts);
+ GST_BUFFER_PTS (buffer) = stream->pts;
+ if (GST_CLOCK_TIME_IS_VALID (stream->dts))
+ GST_BUFFER_DTS (buffer) = stream->dts;
GST_DEBUG_OBJECT (stream->pad,
"Pushing buffer with timestamp: %" GST_TIME_FORMAT,