resindvd/mpegdemux: Send both PTS and DTS downstream

Now that we can.
This commit is contained in:
Jan Schmidt 2012-08-31 15:28:29 -07:00
parent f3e66bd80d
commit f2d0c6a89e
2 changed files with 26 additions and 23 deletions

View file

@ -430,7 +430,7 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
GstBuffer * buf) GstBuffer * buf)
{ {
GstFlowReturn result; GstFlowReturn result;
guint64 timestamp; GstClockTime pts = GST_CLOCK_TIME_NONE, dts = GST_CLOCK_TIME_NONE;
guint size; guint size;
if (stream == NULL) if (stream == NULL)
@ -438,9 +438,9 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
/* timestamps */ /* timestamps */
if (G_UNLIKELY (demux->next_pts != G_MAXUINT64)) if (G_UNLIKELY (demux->next_pts != G_MAXUINT64))
timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts); pts = MPEGTIME_TO_GSTTIME (demux->next_pts);
else if (G_UNLIKELY (demux->next_dts != G_MAXUINT64))
timestamp = GST_CLOCK_TIME_NONE; dts = MPEGTIME_TO_GSTTIME (demux->next_dts);
if (demux->current_scr != G_MAXUINT64) { if (demux->current_scr != G_MAXUINT64) {
GstClockTime cur_scr_time = MPEGTIME_TO_GSTTIME (demux->current_scr); GstClockTime cur_scr_time = MPEGTIME_TO_GSTTIME (demux->current_scr);
@ -456,12 +456,14 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
} }
/* OK, sent new segment now prepare the buffer for sending */ /* OK, sent new segment now prepare the buffer for sending */
GST_BUFFER_TIMESTAMP (buf) = timestamp; GST_BUFFER_PTS (buf) = pts;
GST_BUFFER_DTS (buf) = dts;
/* Set the buffer discont flag, and clear discont state on the stream */ /* Set the buffer discont flag, and clear discont state on the stream */
if (stream->discont) { if (stream->discont) {
GST_DEBUG_OBJECT (demux, "discont buffer to pad %" GST_PTR_FORMAT GST_DEBUG_OBJECT (demux, "discont buffer to pad %" GST_PTR_FORMAT
" with TS %" GST_TIME_FORMAT, stream->pad, GST_TIME_ARGS (timestamp)); " with PTS %" GST_TIME_FORMAT " DTS %" GST_TIME_FORMAT,
stream->pad, GST_TIME_ARGS (pts), GST_TIME_ARGS (dts));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
stream->discont = FALSE; stream->discont = FALSE;
@ -472,9 +474,9 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
demux->next_dts = G_MAXUINT64; demux->next_dts = G_MAXUINT64;
result = gst_pad_push (stream->pad, buf); result = gst_pad_push (stream->pad, buf);
GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, time: %" GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, pts time: %"
GST_TIME_FORMAT ", size %d. result: %s", GST_TIME_FORMAT ", size %d. result: %s",
stream->id, stream->type, GST_TIME_ARGS (timestamp), stream->id, stream->type, GST_TIME_ARGS (pts),
size, gst_flow_get_name (result)); size, gst_flow_get_name (result));
return result; return result;

View file

@ -475,7 +475,7 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
GstBuffer * buf) GstBuffer * buf)
{ {
GstFlowReturn result; GstFlowReturn result;
guint64 timestamp; GstClockTime pts = GST_CLOCK_TIME_NONE, dts = GST_CLOCK_TIME_NONE;
guint size; guint size;
if (stream == NULL) if (stream == NULL)
@ -483,9 +483,9 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
/* timestamps */ /* timestamps */
if (G_UNLIKELY (demux->next_pts != G_MAXUINT64)) if (G_UNLIKELY (demux->next_pts != G_MAXUINT64))
timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts); pts = MPEGTIME_TO_GSTTIME (demux->next_pts);
else if (G_UNLIKELY (demux->next_dts != G_MAXUINT64))
timestamp = GST_CLOCK_TIME_NONE; dts = MPEGTIME_TO_GSTTIME (demux->next_dts);
/* discont */ /* discont */
if (G_UNLIKELY (stream->need_segment)) { if (G_UNLIKELY (stream->need_segment)) {
@ -493,9 +493,9 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
GstSegment segment; GstSegment segment;
GstEvent *newsegment; GstEvent *newsegment;
GST_DEBUG ("timestamp:%" GST_TIME_FORMAT " base_time %" GST_TIME_FORMAT GST_DEBUG ("PTS timestamp:%" GST_TIME_FORMAT " base_time %" GST_TIME_FORMAT
" src_segment.start:%" GST_TIME_FORMAT " .stop:%" GST_TIME_FORMAT, " src_segment.start:%" GST_TIME_FORMAT " .stop:%" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (demux->base_time), GST_TIME_ARGS (pts), GST_TIME_ARGS (demux->base_time),
GST_TIME_ARGS (demux->src_segment.start), GST_TIME_ARGS (demux->src_segment.start),
GST_TIME_ARGS (demux->src_segment.stop)); GST_TIME_ARGS (demux->src_segment.stop));
@ -511,13 +511,13 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
else else
stop = -1; stop = -1;
if (timestamp != GST_CLOCK_TIME_NONE) { if (pts != GST_CLOCK_TIME_NONE) {
if (demux->src_segment.rate > 0) { if (demux->src_segment.rate > 0) {
if (GST_CLOCK_DIFF (start, timestamp) > GST_SECOND) if (GST_CLOCK_DIFF (start, pts) > GST_SECOND)
start = timestamp; start = pts;
} else { } else {
if (GST_CLOCK_DIFF (stop, timestamp) > GST_SECOND) if (GST_CLOCK_DIFF (stop, pts) > GST_SECOND)
stop = timestamp; stop = pts;
} }
} }
if (GST_CLOCK_TIME_IS_VALID (demux->base_time) && start > demux->base_time) if (GST_CLOCK_TIME_IS_VALID (demux->base_time) && start > demux->base_time)
@ -546,7 +546,8 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
} }
/* OK, sent new segment now prepare the buffer for sending */ /* OK, sent new segment now prepare the buffer for sending */
GST_BUFFER_TIMESTAMP (buf) = timestamp; GST_BUFFER_PTS (buf) = pts;
GST_BUFFER_DTS (buf) = dts;
/* update position in the segment */ /* update position in the segment */
gst_segment_set_position (&demux->src_segment, GST_FORMAT_TIME, gst_segment_set_position (&demux->src_segment, GST_FORMAT_TIME,
@ -574,7 +575,7 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
/* Set the buffer discont flag, and clear discont state on the stream */ /* Set the buffer discont flag, and clear discont state on the stream */
if (stream->discont) { if (stream->discont) {
GST_DEBUG_OBJECT (demux, "discont buffer to pad %" GST_PTR_FORMAT GST_DEBUG_OBJECT (demux, "discont buffer to pad %" GST_PTR_FORMAT
" with TS %" GST_TIME_FORMAT, stream->pad, GST_TIME_ARGS (timestamp)); " with TS %" GST_TIME_FORMAT, stream->pad, GST_TIME_ARGS (dts));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
stream->discont = FALSE; stream->discont = FALSE;
@ -585,9 +586,9 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
demux->next_dts = G_MAXUINT64; demux->next_dts = G_MAXUINT64;
result = gst_pad_push (stream->pad, buf); result = gst_pad_push (stream->pad, buf);
GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, time: %" GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, pts time: %"
GST_TIME_FORMAT ", size %d. result: %s", GST_TIME_FORMAT ", size %d. result: %s",
stream->id, stream->type, GST_TIME_ARGS (timestamp), stream->id, stream->type, GST_TIME_ARGS (pts),
size, gst_flow_get_name (result)); size, gst_flow_get_name (result));
return result; return result;