optimize parameters for streaming video
1 files changed, 21 insertions(+), 5 deletions(-)

M wispserve/serve.w
M wispserve/serve.w +21 -5
@@ 311,6 311,8 @@ define : guess-content-type path
           . `(video/mp4 (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".mpg" path
           . `(video/mpeg (charset  . "ISO-8859-1"))
+        : string-suffix-ci? ".mpeg" path
+          . `(video/mpeg (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".webm" path
           . `(video/webm (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".ogv" path

          
@@ 320,7 322,7 @@ define : guess-content-type path
         : string-suffix-ci? ".mp3" path
           . `(audio/mpeg (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".avi" path
-          . `(video/avi (charset  . "ISO-8859-1"))
+          . `(video/x-msvideo (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".txt" path
           . `(text/plain (charset  . "ISO-8859-1"))
         : string-suffix-ci? ".w" path

          
@@ 349,18 351,32 @@ define : hash-if-unknown! served-file
 
 
 define : server-serve-file range-requested begin-end path
-   define 32KiB : expt 2 15
+   define 16B : expt 2 4
    define 4KiB : expt 2 12
-   define 16B : expt 2 4
+   define 32KiB : expt 2 15
+   define 64KiB : expt 2 16
+   define 128KiB : expt 2 17
+   define 256KiB : expt 2 18
+   define 2MiB : expt 2 21
+   define 32MiB : expt 2 25
    define range-begin : car begin-end
    define served-file : resolve-path path
    define filesize
        or : and=> (and=> (and=> (and=> served-file cdr) served-accesspath) stat) stat:size
           . 32KiB
-   set! range-requested : or range-requested (> filesize 32KiB)
+   set! range-requested : or range-requested (> filesize 32MiB)
    define range-end
        if range-requested
-          or (cdr begin-end) : min filesize (+ range-begin 32KiB)
+          or
+              cdr begin-end
+              min filesize
+                  + range-begin
+                      cond
+                        : zero? range-begin
+                          . 32KiB
+                        : < range-begin 2MiB
+                          . 256KiB
+                        else 2MiB
           . #f
    let*
        :