mssdemux: set timestamp and duration to fragment buffers
authorThiago Santos <thiago.sousa.santos@collabora.com>
Fri, 4 Jan 2013 18:49:02 +0000 (15:49 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 8 May 2013 00:05:11 +0000 (21:05 -0300)
We can get those from the manifest and helps downstream to know
the fragment start time after a seeking operation

ext/smoothstreaming/gstmssdemux.c
ext/smoothstreaming/gstmssmanifest.c
ext/smoothstreaming/gstmssmanifest.h

index 75a9804..ac4a2a4 100644 (file)
@@ -646,12 +646,18 @@ gst_mss_demux_stream_loop (GstMssDemuxStream * stream)
   buffer = gst_fragment_get_buffer (fragment);
   buffer = gst_buffer_make_metadata_writable (buffer);
   gst_buffer_set_caps (buffer, GST_PAD_CAPS (stream->pad));
+  GST_BUFFER_TIMESTAMP (buffer) =
+      gst_mss_stream_get_fragment_gst_timestamp (stream->manifest_stream);
+  GST_BUFFER_DURATION (buffer) =
+      gst_mss_stream_get_fragment_gst_duration (stream->manifest_stream);
 
   if (G_UNLIKELY (stream->pending_newsegment)) {
     gst_pad_push_event (stream->pad, stream->pending_newsegment);
     stream->pending_newsegment = NULL;
   }
 
+  GST_DEBUG_OBJECT (mssdemux, "Pushing buffer of size %u on pad %s",
+      GST_BUFFER_SIZE (buffer), GST_PAD_NAME (stream->pad));
   ret = gst_pad_push (stream->pad, buffer);
   switch (ret) {
     case GST_FLOW_UNEXPECTED:
index 2184bd7..2eb187c 100644 (file)
@@ -562,6 +562,42 @@ gst_mss_stream_get_fragment_url (GstMssStream * stream, gchar ** url)
   return GST_FLOW_OK;
 }
 
+GstClockTime
+gst_mss_stream_get_fragment_gst_timestamp (GstMssStream * stream)
+{
+  guint64 time;
+  guint64 timescale;
+  GstMssStreamFragment *fragment;
+
+  if (!stream->current_fragment)
+    return GST_CLOCK_TIME_NONE;
+
+  fragment = stream->current_fragment->data;
+
+  time = fragment->time;
+  timescale = gst_mss_stream_get_timescale (stream);
+  return (GstClockTime) gst_util_uint64_scale_round (time, GST_SECOND,
+      timescale);
+}
+
+GstClockTime
+gst_mss_stream_get_fragment_gst_duration (GstMssStream * stream)
+{
+  guint64 dur;
+  guint64 timescale;
+  GstMssStreamFragment *fragment;
+
+  if (!stream->current_fragment)
+    return GST_CLOCK_TIME_NONE;
+
+  fragment = stream->current_fragment->data;
+
+  dur = fragment->duration;
+  timescale = gst_mss_stream_get_timescale (stream);
+  return (GstClockTime) gst_util_uint64_scale_round (dur, GST_SECOND,
+      timescale);
+}
+
 GstFlowReturn
 gst_mss_stream_advance_fragment (GstMssStream * stream)
 {
index b75b60e..29741a3 100644 (file)
@@ -50,6 +50,8 @@ GstMssStreamType gst_mss_stream_get_type (GstMssStream *stream);
 GstCaps * gst_mss_stream_get_caps (GstMssStream * stream);
 guint64 gst_mss_stream_get_timescale (GstMssStream * stream);
 GstFlowReturn gst_mss_stream_get_fragment_url (GstMssStream * stream, gchar ** url);
+GstClockTime gst_mss_stream_get_fragment_gst_timestamp (GstMssStream * stream);
+GstClockTime gst_mss_stream_get_fragment_gst_duration (GstMssStream * stream);
 GstFlowReturn gst_mss_stream_advance_fragment (GstMssStream * stream);
 gboolean gst_mss_stream_seek (GstMssStream * stream, guint64 time);