]> git.sesse.net Git - vlc/commitdiff
stream_filter/httplive.c: fix EXT-X-MEDIA-SEQUENCE error message for HLS live streams.
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 21 Dec 2011 10:16:27 +0000 (11:16 +0100)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 21 Dec 2011 10:21:00 +0000 (11:21 +0100)
The error message  "EXT-X-MEDIA-SEQUENCE already present in playlist (new=%d, old=%d)" was
triggered way to often for HLS live streams. In addition the new metadata from a new HLS
playlist was not updated in the internal list.

modules/stream_filter/httplive.c

index 299c23b1100b983d21f6ff3c825332de4786fbb6..4d60d8a30e6574eb3514bca608b0349c23cf4ce4 100644 (file)
@@ -76,7 +76,7 @@ typedef struct hls_stream_s
     int         id;         /* program id */
     int         version;    /* protocol version should be 1 */
     int         sequence;   /* media sequence number */
-    int         duration;   /* maximum duration per segment (ms) */
+    int         duration;   /* maximum duration per segment (s) */
     uint64_t    bandwidth;  /* bandwidth usage of segments (bits per second)*/
     uint64_t    size;       /* stream length (segment->duration * hls->bandwidth/8) */
 
@@ -680,9 +680,18 @@ static int parse_MediaSequence(stream_t *s, hls_stream_t *hls, char *p_read)
     }
 
     if (hls->sequence > 0)
-        msg_Err(s, "EXT-X-MEDIA-SEQUENCE already present in playlist (new=%d, old=%d)",
-                    sequence, hls->sequence);
-
+    {
+        if (s->p_sys->b_live)
+        {
+            hls_stream_t *last = hls_GetLast(s->p_sys->hls_stream);
+            if ((last->sequence < sequence) && (sequence - last->sequence != 1))
+                msg_Err(s, "EXT-X-MEDIA-SEQUENCE gap in playlist (new=%d, old=%d)",
+                            sequence, last->sequence);
+        }
+        else
+            msg_Err(s, "EXT-X-MEDIA-SEQUENCE already present in playlist (new=%d, old=%d)",
+                        sequence, hls->sequence);
+    }
     hls->sequence = sequence;
     return VLC_SUCCESS;
 }
@@ -1098,6 +1107,13 @@ static int hls_UpdatePlaylist(stream_t *s, hls_stream_t *hls_new, hls_stream_t *
         }
         vlc_mutex_unlock(&(*hls)->lock);
     }
+
+    /* update meta information */
+    vlc_mutex_lock(&(*hls)->lock);
+    (*hls)->sequence = hls_new->sequence;
+    (*hls)->duration = (hls_new->duration == -1) ? (*hls)->duration : hls_new->duration;
+    (*hls)->b_cache = hls_new->b_cache;
+    vlc_mutex_unlock(&(*hls)->lock);
     return VLC_SUCCESS;
 
 fail_and_unlock: