hlsenc: make EXT-X-MEDIA-SEQUENCE always increase
authorKanglin <kl222@126.com>
Sat, 29 Dec 2012 11:09:17 +0000 (12:09 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Sat, 29 Dec 2012 16:26:30 +0000 (17:26 +0100)
libavformat/hlsenc.c

index 43b3505..32b8ab9 100644 (file)
@@ -39,6 +39,7 @@ typedef struct ListEntry {
 typedef struct HLSContext {
     const AVClass *class;  // Class for private options.
     int number;
 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.
     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++;
 
     } else
         hls->nb_entries++;
 
+    hls->sequence++;
+
     return 0;
 }
 
     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, "#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);
 
     for (en = hls->list; en; en = en->next) {
         avio_printf(hls->pb, "#EXTINF:%d,\n", en->duration);