flvmux: Use the last DTS for the metadata timestamp

This avoids creating a timestamp regression during a stream.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/429
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-12-12 10:59:35 +01:00
parent 625eb00c06
commit 9e0eb77810
No known key found for this signature in database
GPG key ID: DE5E0C5F25941CA5

View file

@ -833,12 +833,21 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
const GstTagList *tags; const GstTagList *tags;
GstBuffer *script_tag, *tmp; GstBuffer *script_tag, *tmp;
GstMapInfo map; GstMapInfo map;
guint32 dts;
guint8 *data; guint8 *data;
gint i, n_tags, tags_written = 0; gint i, n_tags, tags_written = 0;
tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (mux)); tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (mux));
GST_DEBUG_OBJECT (mux, "tags = %" GST_PTR_FORMAT, tags); dts = mux->last_dts;
/* Timestamp must start at zero */
if (GST_CLOCK_STIME_IS_VALID (mux->first_timestamp)) {
dts -= mux->first_timestamp / GST_MSECOND;
}
GST_DEBUG_OBJECT (mux, "Creating metadata, dts %i, tags = %" GST_PTR_FORMAT,
dts, tags);
/* FIXME perhaps some bytewriter'ing here ... */ /* FIXME perhaps some bytewriter'ing here ... */
@ -852,7 +861,8 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
data[3] = 0; data[3] = 0;
/* Timestamp */ /* Timestamp */
data[4] = data[5] = data[6] = data[7] = 0; GST_WRITE_UINT24_BE (data + 4, dts);
data[7] = (((guint) dts) >> 24) & 0xff;
/* Stream ID */ /* Stream ID */
data[8] = data[9] = data[10] = 0; data[8] = data[9] = data[10] = 0;