diff src/http.c @ 132:7b663556757f

modify CONTENT-LENGTH for indefinite recording.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Wed, 13 Oct 2010 01:39:24 +0900
parents cc3e3f370aec
children 0db6ccf0fe31
line wrap: on
line diff
--- a/src/http.c	Tue Oct 12 05:56:26 2010 +0900
+++ b/src/http.c	Wed Oct 13 01:39:24 2010 +0900
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
+#include <stdint.h>
 
 #include <upnp/upnp.h>
 #include <upnp/upnptools.h>
@@ -602,6 +603,7 @@
 
 // TS_BITRATEはやっつけ仕事過ぎる気がします
 #define TS_BITRATE (10*1000*1000/8)
+#define MAX_STREAMING ((off_t)100*1000*1000*1000)
 static off_t
 get_streaming_length (void)
 {
@@ -614,20 +616,17 @@
     clock_gettime(CLOCK_REALTIME, &cur);
     off_t bitrate = 0;
 
-    if ( cur.tv_nsec < tdata->streamer->start.tv_nsec ) {
-        diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec +1e9;
-        diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec -1;
-    } else {
-        diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec;
-        diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec;
+    if ( tdata->indefinite ) {
+        return MAX_STREAMING;
     }
+    diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec;
+    diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec;
 
     if ( diff.tv_sec < 1 ) {
         bitrate = TS_BITRATE;
     } else {
         bitrate = (((off_t)tdata->streamer->total_byte)*1e9) /
-            ( (((off_t)diff.tv_sec)*1e9) + (diff.tv_sec/1e9));
-        bitrate = bitrate;
+            ( (((off_t)diff.tv_sec)*1e9) + diff.tv_nsec);
     }
 
     time(&cur_time);