summaryrefslogtreecommitdiff
path: root/gst/hls
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2011-03-12 12:20:32 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2011-03-30 09:19:22 +0200
commit09b2b31422d0276b776d26b7dde066f85c3964d8 (patch)
tree558bfceb0af456b9f88d519a7711d3e0f1436eb7 /gst/hls
parentc599e4a9a13ee354dcd13b2c7f2fe447f42ddc95 (diff)
hlsdemux: m3u8: add support to get the duration from a playlist
Diffstat (limited to 'gst/hls')
-rw-r--r--gst/hls/m3u8.c21
-rw-r--r--gst/hls/m3u8.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/gst/hls/m3u8.c b/gst/hls/m3u8.c
index ea5aa6859..5ad06052b 100644
--- a/gst/hls/m3u8.c
+++ b/gst/hls/m3u8.c
@@ -450,3 +450,24 @@ gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
return file->uri;
}
+
+static void
+_sum_duration (GstM3U8MediaFile * self, GstClockTime * duration)
+{
+ *duration += self->duration;
+}
+
+GstClockTime
+gst_m3u8_client_get_duration (GstM3U8Client * client)
+{
+ GstClockTime duration = 0;
+
+ g_return_val_if_fail (client != NULL, GST_CLOCK_TIME_NONE);
+
+ /* We can only get the duration for on-demand streams */
+ if (!client->current->endlist)
+ return GST_CLOCK_TIME_NONE;
+
+ g_list_foreach (client->current->files, (GFunc) _sum_duration, &duration);
+ return duration;
+}
diff --git a/gst/hls/m3u8.h b/gst/hls/m3u8.h
index df893e08d..499aa5255 100644
--- a/gst/hls/m3u8.h
+++ b/gst/hls/m3u8.h
@@ -77,6 +77,7 @@ gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data);
void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
const gchar *gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity);
+GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client);
#define gst_m3u8_client_get_uri(Client) ((Client)->main->uri)
#define gst_m3u8_client_has_variant_playlist(Client) ((Client)->main->lists)
#define gst_m3u8_client_is_live(Client) (!(Client)->main->lists && !(Client)->current->endlist)