mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
hlsdemux: m3u8: add support to get the duration from a playlist
This commit is contained in:
parent
c599e4a9a1
commit
09b2b31422
2 changed files with 22 additions and 0 deletions
|
@ -450,3 +450,24 @@ gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
|
||||||
|
|
||||||
return file->uri;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data);
|
||||||
void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
|
void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
|
||||||
const gchar *gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
|
const gchar *gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
|
||||||
gboolean * discontinuity);
|
gboolean * discontinuity);
|
||||||
|
GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client);
|
||||||
#define gst_m3u8_client_get_uri(Client) ((Client)->main->uri)
|
#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_has_variant_playlist(Client) ((Client)->main->lists)
|
||||||
#define gst_m3u8_client_is_live(Client) (!(Client)->main->lists && !(Client)->current->endlist)
|
#define gst_m3u8_client_is_live(Client) (!(Client)->main->lists && !(Client)->current->endlist)
|
||||||
|
|
Loading…
Reference in a new issue