tsmux: Fix PCR calculation for CBR live streams

Take the first ever timestamp as an offset

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1431>
This commit is contained in:
Vivia Nikolaidou 2020-07-10 21:14:01 +03:00 committed by GStreamer Merge Bot
parent 5a358b7687
commit d8b37973d2
2 changed files with 10 additions and 1 deletions

View file

@ -157,6 +157,8 @@ tsmux_new (void)
mux->new_stream_func = (TsMuxNewStreamFunc) tsmux_stream_new;
mux->new_stream_data = NULL;
mux->first_pcr_ts = G_MININT64;
return mux;
}
@ -1252,7 +1254,12 @@ get_current_pcr (TsMux * mux, gint64 cur_ts)
if (!mux->bitrate)
return ts_to_pcr (cur_ts);
return ts_to_pcr (CLOCK_BASE) +
if (mux->first_pcr_ts == G_MININT64) {
g_assert (cur_ts != G_MININT64);
mux->first_pcr_ts = cur_ts;
}
return ts_to_pcr (mux->first_pcr_ts) +
gst_util_uint64_scale (mux->n_bytes * 8, TSMUX_SYS_CLOCK_FREQ,
mux->bitrate);
}

View file

@ -200,6 +200,8 @@ struct TsMux {
/* For the per-PID continuity counter */
guint8 pid_packet_counts[8192];
gint64 first_pcr_ts;
};
/* create/free new muxer session */