This is done by using new feature of the CollectPad clip function
which sets the DTS as a gint64 in the collected data. It also simplify
the code a bit.
https://bugzilla.gnome.org/show_bug.cgi?id=740575
mux->have_audio = mux->have_video = FALSE;
mux->duration = GST_CLOCK_TIME_NONE;
mux->new_tags = FALSE;
mux->have_audio = mux->have_video = FALSE;
mux->duration = GST_CLOCK_TIME_NONE;
mux->new_tags = FALSE;
- mux->first_timestamp = GST_CLOCK_TIME_NONE;
+ mux->first_timestamp = GST_CLOCK_STIME_NONE;
mux->state = GST_FLV_MUX_STATE_HEADER;
mux->state = GST_FLV_MUX_STATE_HEADER;
cpad->video_codec_data = NULL;
cpad->video_codec = G_MAXUINT;
cpad->last_timestamp = 0;
cpad->video_codec_data = NULL;
cpad->video_codec = G_MAXUINT;
cpad->last_timestamp = 0;
+ cpad->pts = GST_CLOCK_STIME_NONE;
+ cpad->dts = GST_CLOCK_STIME_NONE;
guint8 *data, *bdata;
gsize bsize;
guint8 *data, *bdata;
gsize bsize;
- if (GST_BUFFER_DTS_IS_VALID (buffer))
- dts = GST_BUFFER_DTS (buffer) / GST_MSECOND;
- else if (GST_BUFFER_PTS_IS_VALID (buffer))
- dts = GST_BUFFER_PTS (buffer) / GST_MSECOND;
- else
- dts = cpad->last_timestamp / GST_MSECOND;
-
- if (GST_BUFFER_PTS_IS_VALID (buffer))
- pts = GST_BUFFER_PTS (buffer) / GST_MSECOND;
- else
- pts = dts;
+ if (GST_CLOCK_STIME_IS_VALID (cpad->dts)) {
+ pts = dts = cpad->last_timestamp / GST_MSECOND;
+ } else {
+ pts = cpad->pts / GST_MSECOND;
+ dts = cpad->dts / GST_MSECOND;
+ }
+ /* Be safe in case TS are buggy */
if (pts > dts)
cts = pts - dts;
else
cts = 0;
/* Timestamp must start at zero */
if (pts > dts)
cts = pts - dts;
else
cts = 0;
/* Timestamp must start at zero */
- if (GST_CLOCK_TIME_IS_VALID (mux->first_timestamp)) {
+ if (GST_CLOCK_STIME_IS_VALID (mux->first_timestamp)) {
dts -= mux->first_timestamp / GST_MSECOND;
pts = dts + cts;
}
dts -= mux->first_timestamp / GST_MSECOND;
pts = dts + cts;
}
{
GstFlvMux *mux = GST_FLV_MUX (user_data);
GstFlvPad *best;
{
GstFlvMux *mux = GST_FLV_MUX (user_data);
GstFlvPad *best;
- GstClockTime best_time;
GstFlowReturn ret;
if (mux->state == GST_FLV_MUX_STATE_HEADER) {
GstFlowReturn ret;
if (mux->state == GST_FLV_MUX_STATE_HEADER) {
return ret;
mux->state = GST_FLV_MUX_STATE_DATA;
return ret;
mux->state = GST_FLV_MUX_STATE_DATA;
- if (GST_BUFFER_DTS_IS_VALID (buffer))
- mux->first_timestamp = GST_BUFFER_DTS (buffer);
+ if (GST_COLLECT_PADS_DTS_IS_VALID (cdata))
+ mux->first_timestamp = GST_COLLECT_PADS_DTS (cdata);
else
mux->first_timestamp = 0;
}
else
mux->first_timestamp = 0;
}
best = (GstFlvPad *) cdata;
if (best) {
g_assert (buffer);
best = (GstFlvPad *) cdata;
if (best) {
g_assert (buffer);
- best_time = GST_BUFFER_DTS (buffer);
+ best->dts = GST_COLLECT_PADS_DTS (cdata);
+
+ if (GST_CLOCK_STIME_IS_VALID (best->dts))
+ best_time = best->dts - mux->first_timestamp;
+
+ if (GST_BUFFER_PTS_IS_VALID (buffer))
+ best->pts = GST_BUFFER_PTS (buffer);
+ else
+ best->pts = best->dts;
+
+ GST_LOG_OBJECT (mux, "got buffer PTS %" GST_TIME_FORMAT " DTS %"
+ GST_STIME_FORMAT "\n", GST_TIME_ARGS (best->pts),
+ GST_STIME_ARGS (best->dts));
- best_time = GST_CLOCK_TIME_NONE;
+ best_time = GST_CLOCK_STIME_NONE;
}
/* The FLV timestamp is an int32 field. For non-live streams error out if a
bigger timestamp is seen, for live the timestamp will get wrapped in
gst_flv_mux_buffer_to_tag */
}
/* The FLV timestamp is an int32 field. For non-live streams error out if a
bigger timestamp is seen, for live the timestamp will get wrapped in
gst_flv_mux_buffer_to_tag */
- if (!mux->streamable && GST_CLOCK_TIME_IS_VALID (best_time)
+ if (!mux->streamable && (GST_CLOCK_STIME_IS_VALID (best_time))
&& best_time / GST_MSECOND > G_MAXINT32) {
GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS");
gst_buffer_unref (buffer);
&& best_time / GST_MSECOND > G_MAXINT32) {
GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS");
gst_buffer_unref (buffer);
GstBuffer *video_codec_data;
GstClockTime last_timestamp;
GstBuffer *video_codec_data;
GstClockTime last_timestamp;
+ gint64 pts;
+ gint64 dts;
} GstFlvPad;
typedef enum
} GstFlvPad;
typedef enum
GList *index;
guint64 byte_count;
guint64 duration;
GList *index;
guint64 byte_count;
guint64 duration;
- GstClockTime first_timestamp;
+ gint64 first_timestamp;
} GstFlvMux;
typedef struct _GstFlvMuxClass {
} GstFlvMux;
typedef struct _GstFlvMuxClass {