From 4fb227b340dd6b87dcc91bf81fa4610bd1b59bbd Mon Sep 17 00:00:00 2001 From: Victor Gottardi Date: Wed, 5 Dec 2012 10:06:38 -0500 Subject: [PATCH] hlssink: round segment duration to nearest number of seconds E.g. for 1s period, duration can be 0.99s, rounds down to 0, results in invalid playlist https://bugzilla.gnome.org/show_bug.cgi?id=689822 --- gst/hls/gstm3u8playlist.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gst/hls/gstm3u8playlist.c b/gst/hls/gstm3u8playlist.c index e1838b79cf..88a7d0fcf3 100644 --- a/gst/hls/gstm3u8playlist.c +++ b/gst/hls/gstm3u8playlist.c @@ -82,7 +82,8 @@ gst_m3u8_entry_render (GstM3U8Entry * entry, guint version) if (TRUE) return g_strdup_printf ("%s" M3U8_INT_INF_TAG, entry->discontinuous ? M3U8_DISCONTINUITY_TAG : "", - (gint) (entry->duration / GST_SECOND), entry->title, entry->url); + (gint) ((entry->duration + 500 * GST_MSECOND) / GST_SECOND), + entry->title, entry->url); return g_strdup_printf ("%s" M3U8_FLOAT_INF_TAG, entry->discontinuous ? M3U8_DISCONTINUITY_TAG : "", @@ -161,7 +162,7 @@ gst_m3u8_playlist_target_duration (GstM3U8Playlist * playlist) target_duration = entry->duration; } - return (guint) (target_duration / GST_SECOND); + return (guint) ((target_duration + 500 * GST_MSECOND) / GST_SECOND); } static void