From 27a15e0af6fbf074b2b0ad878f1f54c77f7d147a Mon Sep 17 00:00:00 2001 From: Kanglin Date: Sat, 29 Dec 2012 12:09:17 +0100 Subject: [PATCH 1/2] hlsenc: make EXT-X-MEDIA-SEQUENCE always increase --- libavformat/hlsenc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 43b3505f3c..32b8ab9694 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -39,6 +39,7 @@ typedef struct ListEntry { typedef struct HLSContext { const AVClass *class; // Class for private options. int number; + int64_t sequence; AVOutputFormat *oformat; AVFormatContext *avf; float time; // Set by a private option. @@ -105,6 +106,8 @@ static int append_entry(HLSContext *hls, uint64_t duration) } else hls->nb_entries++; + hls->sequence++; + return 0; } @@ -138,8 +141,8 @@ static int hls_window(AVFormatContext *s, int last) avio_printf(hls->pb, "#EXTM3U\n"); avio_printf(hls->pb, "#EXT-X-VERSION:3\n"); avio_printf(hls->pb, "#EXT-X-TARGETDURATION:%d\n", target_duration); - avio_printf(hls->pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", - FFMAX(0, hls->number - hls->size)); + avio_printf(hls->pb, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", + FFMAX(0, hls->sequence - hls->size)); for (en = hls->list; en; en = en->next) { avio_printf(hls->pb, "#EXTINF:%d,\n", en->duration); From 30a76487304e7250294c9c0e9fa179bf07fd822a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 29 Dec 2012 12:31:01 +0100 Subject: [PATCH 2/2] hlsenc: make segment number unsigned It will overflow if somebody keeps streaming for a time long enough. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 32b8ab9694..4f74b5f04b 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -38,7 +38,7 @@ typedef struct ListEntry { typedef struct HLSContext { const AVClass *class; // Class for private options. - int number; + unsigned number; int64_t sequence; AVOutputFormat *oformat; AVFormatContext *avf;