From 5878f71233bad39583b797ee6c9bc2ac56544c52 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Tue, 16 Aug 2011 19:43:08 +0000 Subject: [PATCH] hlsdemux: Set buffer timestamp since we send a TIME segment --- gst/hls/gsthlsdemux.c | 4 +++- gst/hls/m3u8.c | 13 ++++++++++++- gst/hls/m3u8.h | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gst/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c index 8d5ba4eb19..c8069344c0 100644 --- a/gst/hls/gsthlsdemux.c +++ b/gst/hls/gsthlsdemux.c @@ -1069,10 +1069,11 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry) guint avail; const gchar *next_fragment_uri; GstClockTime duration; + GstClockTime timestamp; gboolean discont; if (!gst_m3u8_client_get_next_fragment (demux->client, &discont, - &next_fragment_uri, &duration)) { + &next_fragment_uri, &duration, ×tamp)) { GST_INFO_OBJECT (demux, "This playlist doesn't contain more fragments"); demux->end_of_playlist = TRUE; GST_TASK_SIGNAL (demux->task); @@ -1087,6 +1088,7 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry) avail = gst_adapter_available (demux->download); buf = gst_adapter_take_buffer (demux->download, avail); GST_BUFFER_DURATION (buf) = duration; + GST_BUFFER_TIMESTAMP (buf) = timestamp; /* We actually need to do this every time we switch bitrate */ if (G_UNLIKELY (demux->do_typefind)) { diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c index 20252f01df..66b4f16421 100644 --- a/gst/hls/m3u8.c +++ b/gst/hls/m3u8.c @@ -442,9 +442,11 @@ _find_next (GstM3U8MediaFile * file, GstM3U8Client * client) gboolean gst_m3u8_client_get_next_fragment (GstM3U8Client * client, - gboolean * discontinuity, const gchar ** uri, GstClockTime * duration) + gboolean * discontinuity, const gchar ** uri, GstClockTime * duration, + GstClockTime * timestamp) { GList *l; + GList *walk; GstM3U8MediaFile *file; g_return_val_if_fail (client != NULL, FALSE); @@ -464,6 +466,15 @@ gst_m3u8_client_get_next_fragment (GstM3U8Client * client, *uri = file->uri; *duration = file->duration * GST_SECOND; + + *timestamp = 0; + for (walk = client->current->files; walk; walk = walk->next) { + if (walk == l) + break; + *timestamp += GST_M3U8_MEDIA_FILE (walk->data)->duration; + } + *timestamp *= GST_SECOND; + return TRUE; } diff --git a/gst/hls/m3u8.h b/gst/hls/m3u8.h index 7f37cdd739..97a8ee2142 100644 --- a/gst/hls/m3u8.h +++ b/gst/hls/m3u8.h @@ -76,7 +76,8 @@ void gst_m3u8_client_free (GstM3U8Client * client); gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data); void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8); gboolean gst_m3u8_client_get_next_fragment (GstM3U8Client * client, - gboolean * discontinuity, const gchar ** uri, GstClockTime * duration); + gboolean * discontinuity, const gchar ** uri, GstClockTime * duration, + GstClockTime * timestamp); GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client); const gchar *gst_m3u8_client_get_uri(GstM3U8Client * client); gboolean gst_m3u8_client_has_variant_playlist(GstM3U8Client * client);