flvmux: Ensure Timestamp starts at 0

FLV documentation stipulates that timestamp must start at zero.
In order to respect this rule, keep the first timestamp around
and offset the timestamp from this value. This allow for longer
recording time in presence of timestamp that does not start
at 0 already.

https://bugzilla.gnome.org/show_bug.cgi?id=731352
This commit is contained in:
Nicolas Dufresne 2014-07-28 20:58:59 -04:00 committed by Nicolas Dufresne
parent ff2bce7b26
commit c1e7bec616
2 changed files with 8 additions and 0 deletions

View file

@ -529,6 +529,7 @@ gst_flv_mux_reset_pad (GstFlvMux * mux, GstFlvPad * cpad, gboolean video)
gst_buffer_unref (cpad->video_codec_data);
cpad->video_codec_data = NULL;
cpad->video_codec = G_MAXUINT;
cpad->first_timestamp = GST_CLOCK_TIME_NONE;
cpad->last_timestamp = 0;
}
@ -1020,6 +1021,12 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
else
cts = 0;
if (!GST_CLOCK_TIME_IS_VALID (cpad->first_timestamp))
cpad->first_timestamp = dts;
/* Timestamp must start at zero */
dts -= cpad->first_timestamp;
GST_LOG_OBJECT (mux, "got pts %i dts %i cts %i\n", pts, dts, cts);
gst_buffer_map (buffer, &map, GST_MAP_READ);

View file

@ -53,6 +53,7 @@ typedef struct
GstBuffer *video_codec_data;
GstClockTime last_timestamp;
GstClockTime first_timestamp;
} GstFlvPad;
typedef enum