g_return_val_if_fail (stream != NULL, FALSE);
if (tsmux_stream_is_pcr (stream)) {
- gint64 cur_pts = tsmux_stream_get_pts (stream);
+ gint64 cur_ts;
gboolean write_pat;
gboolean write_si;
GList *cur;
+ if (tsmux_stream_get_dts (stream) != G_MININT64)
+ cur_ts = tsmux_stream_get_dts (stream);
+ else
+ cur_ts = tsmux_stream_get_pts (stream);
+
cur_pcr = 0;
- if (cur_pts != G_MININT64) {
- TS_DEBUG ("TS for PCR stream is %" G_GINT64_FORMAT, cur_pts);
+ if (cur_ts != G_MININT64) {
+ TS_DEBUG ("TS for PCR stream is %" G_GINT64_FORMAT, cur_ts);
}
/* FIXME: The current PCR needs more careful calculation than just
* writing a fixed offset */
- if (cur_pts != G_MININT64) {
+ if (cur_ts != G_MININT64) {
/* CLOCK_BASE >= TSMUX_PCR_OFFSET */
- cur_pts += CLOCK_BASE;
- cur_pcr = (cur_pts - TSMUX_PCR_OFFSET) *
+ cur_ts += CLOCK_BASE;
+ cur_pcr = (cur_ts - TSMUX_PCR_OFFSET) *
(TSMUX_SYS_CLOCK_FREQ / TSMUX_CLOCK_FREQ);
}
/* check if we need to rewrite pat */
if (mux->last_pat_ts == G_MININT64 || mux->pat_changed)
write_pat = TRUE;
- else if (cur_pts >= mux->last_pat_ts + mux->pat_interval)
+ else if (cur_ts >= mux->last_pat_ts + mux->pat_interval)
write_pat = TRUE;
else
write_pat = FALSE;
if (write_pat) {
- mux->last_pat_ts = cur_pts;
+ mux->last_pat_ts = cur_ts;
if (!tsmux_write_pat (mux))
return FALSE;
}
/* check if we need to rewrite sit */
if (mux->last_si_ts == G_MININT64 || mux->si_changed)
write_si = TRUE;
- else if (cur_pts >= mux->last_si_ts + mux->si_interval)
+ else if (cur_ts >= mux->last_si_ts + mux->si_interval)
write_si = TRUE;
else
write_si = FALSE;
if (write_si) {
- mux->last_si_ts = cur_pts;
+ mux->last_si_ts = cur_ts;
if (!tsmux_write_si (mux))
return FALSE;
}
if (program->last_pmt_ts == G_MININT64 || program->pmt_changed)
write_pmt = TRUE;
- else if (cur_pts >= program->last_pmt_ts + program->pmt_interval)
+ else if (cur_ts >= program->last_pmt_ts + program->pmt_interval)
write_pmt = TRUE;
else
write_pmt = FALSE;
if (write_pmt) {
- program->last_pmt_ts = cur_pts;
+ program->last_pmt_ts = cur_ts;
if (!tsmux_write_pmt (mux, program))
return FALSE;
}
if (stream->cur_buffer_consumed == 0 && stream->cur_buffer->size != 0)
return;
- if (GST_CLOCK_STIME_IS_VALID (stream->cur_buffer->pts)) {
+ if (GST_CLOCK_STIME_IS_VALID (stream->cur_buffer->pts))
stream->last_pts = stream->cur_buffer->pts;
- stream->last_dts = stream->cur_buffer->dts;
- } else if (GST_CLOCK_STIME_IS_VALID (stream->cur_buffer->dts))
+ if (GST_CLOCK_STIME_IS_VALID (stream->cur_buffer->dts))
stream->last_dts = stream->cur_buffer->dts;
if (stream->cur_buffer_consumed == stream->cur_buffer->size) {
packet->pts = pts;
packet->dts = dts;
- if (stream->bytes_avail == 0)
+ if (stream->bytes_avail == 0) {
stream->last_pts = pts;
+ stream->last_dts = dts;
+ }
stream->bytes_avail += len;
stream->buffers = g_list_append (stream->buffers, packet);
*
* Returns: the PTS of the last buffer in @stream.
*/
-guint64
+gint64
tsmux_stream_get_pts (TsMuxStream * stream)
{
g_return_val_if_fail (stream != NULL, GST_CLOCK_STIME_NONE);
return stream->last_pts;
}
+
+/**
+ * tsmux_stream_get_dts:
+ * @stream: a #TsMuxStream
+ *
+ * Return the DTS of the last buffer that has had bytes written and
+ * which _had_ a DTS in @stream.
+ *
+ * Returns: the DTS of the last buffer in @stream.
+ */
+gint64
+tsmux_stream_get_dts (TsMuxStream * stream)
+{
+ g_return_val_if_fail (stream != NULL, GST_CLOCK_STIME_NONE);
+
+ return stream->last_dts;
+}