]> git.sesse.net Git - vlc/commitdiff
stream_filter/httplive.c: #EXTINF: accepts integer (version < 3) or floating points...
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 11 May 2011 10:45:36 +0000 (12:45 +0200)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 11 May 2011 10:45:36 +0000 (12:45 +0200)
Update logic in parse_SegmentationInformation() to accept float values
for duration as mentioned in later version of the draft specification.

modules/stream_filter/httplive.c

index 5ce7e78f23edef456106d07d5302c9da4d24397f..5f07c0db6c59a6a2427460fed8f4d32a43f571d6 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include <limits.h>
+#include <errno.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -515,7 +516,30 @@ static int parse_SegmentInformation(hls_stream_t *hls, char *p_read, int *durati
     if (token == NULL)
         return VLC_EGENERIC;
 
-    *duration = atoi(token);
+    int value;
+    if (hls->version < 3)
+    {
+       value = strtol(token, NULL, 10);
+       if (errno == ERANGE)
+       {
+           *duration = -1;
+           return VLC_EGENERIC;
+       }
+       *duration = value;
+    }
+    else
+    {
+        double d = strtod(token, (char **) NULL);
+        if (errno == ERANGE)
+        {
+            *duration = -1;
+            return VLC_EGENERIC;
+        }
+        if ((d) - ((int)d) >= 0.5)
+            value = ((int)d) + 1;
+        else
+            value = ((int)d);
+    }
 
     /* Ignore the rest of the line */