summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Crête <olivier.crete@collabora.com>2018-10-27 19:27:12 +0100
committerSebastian Dröge <sebastian@centricular.com>2018-11-07 23:23:58 +0200
commit3a8bb77f1a95b3337a5e40c934e291c1487a1549 (patch)
treed2d3d7ce91773c6c50bed66dda900f5a204207df
parente7699621ba3c638342d718a0b1161f97dabbc88f (diff)
downloadgstreamer-plugins-good-3a8bb77f1a95b3337a5e40c934e291c1487a1549.tar.gz
flvmux: Force timestamps to always be increasing
https://bugzilla.gnome.org/show_bug.cgi?id=796382
-rw-r--r--gst/flv/gstflvmux.c15
-rw-r--r--gst/flv/gstflvmux.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c
index 516d45c1d..55d8b8422 100644
--- a/gst/flv/gstflvmux.c
+++ b/gst/flv/gstflvmux.c
@@ -319,6 +319,7 @@ gst_flv_mux_reset (GstElement * element)
mux->duration = GST_CLOCK_TIME_NONE;
mux->new_tags = FALSE;
mux->first_timestamp = GST_CLOCK_STIME_NONE;
+ mux->last_dts = 0;
mux->state = GST_FLV_MUX_STATE_HEADER;
@@ -1070,6 +1071,19 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
dts = pad->dts / GST_MSECOND;
}
+ /* We prevent backwards timestamps because they confuse librtmp,
+ * it expects timestamps to go forward not only inside one stream, but
+ * also between the audio & video streams.
+ */
+ if (dts < mux->last_dts) {
+ GST_WARNING_OBJECT (pad, "Got backwards dts! (%" GST_TIME_FORMAT
+ " < %" GST_TIME_FORMAT ")", GST_TIME_ARGS (dts),
+ GST_TIME_ARGS (mux->last_dts));
+ dts = mux->last_dts;
+ }
+ mux->last_dts = dts;
+
+
/* Be safe in case TS are buggy */
if (pts > dts)
cts = pts - dts;
@@ -1115,6 +1129,7 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
data[2] = ((size - 11 - 4) >> 8) & 0xff;
data[3] = ((size - 11 - 4) >> 0) & 0xff;
+
GST_WRITE_UINT24_BE (data + 4, dts);
data[7] = (((guint) dts) >> 24) & 0xff;
diff --git a/gst/flv/gstflvmux.h b/gst/flv/gstflvmux.h
index 4db50938b..ab676d876 100644
--- a/gst/flv/gstflvmux.h
+++ b/gst/flv/gstflvmux.h
@@ -96,6 +96,7 @@ typedef struct _GstFlvMux {
guint64 byte_count;
guint64 duration;
gint64 first_timestamp;
+ GstClockTime last_dts;
} GstFlvMux;
typedef struct _GstFlvMuxClass {