Mercurial > pt1.oyama
comparison 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 |
comparison
equal
deleted
inserted
replaced
131:20442921bff5 | 132:7b663556757f |
---|---|
27 #include <errno.h> | 27 #include <errno.h> |
28 #include <stdio.h> | 28 #include <stdio.h> |
29 #include <stdlib.h> | 29 #include <stdlib.h> |
30 #include <unistd.h> | 30 #include <unistd.h> |
31 #include <errno.h> | 31 #include <errno.h> |
32 #include <stdint.h> | |
32 | 33 |
33 #include <upnp/upnp.h> | 34 #include <upnp/upnp.h> |
34 #include <upnp/upnptools.h> | 35 #include <upnp/upnptools.h> |
35 | 36 |
36 #include "services.h" | 37 #include "services.h" |
600 http_close | 601 http_close |
601 }; | 602 }; |
602 | 603 |
603 // TS_BITRATEはやっつけ仕事過ぎる気がします | 604 // TS_BITRATEはやっつけ仕事過ぎる気がします |
604 #define TS_BITRATE (10*1000*1000/8) | 605 #define TS_BITRATE (10*1000*1000/8) |
606 #define MAX_STREAMING ((off_t)100*1000*1000*1000) | |
605 static off_t | 607 static off_t |
606 get_streaming_length (void) | 608 get_streaming_length (void) |
607 { | 609 { |
608 off_t length = 0; | 610 off_t length = 0; |
609 extern thread_data *gp_tdata; | 611 extern thread_data *gp_tdata; |
612 struct timespec cur; | 614 struct timespec cur; |
613 struct timespec diff; | 615 struct timespec diff; |
614 clock_gettime(CLOCK_REALTIME, &cur); | 616 clock_gettime(CLOCK_REALTIME, &cur); |
615 off_t bitrate = 0; | 617 off_t bitrate = 0; |
616 | 618 |
617 if ( cur.tv_nsec < tdata->streamer->start.tv_nsec ) { | 619 if ( tdata->indefinite ) { |
618 diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec +1e9; | 620 return MAX_STREAMING; |
619 diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec -1; | 621 } |
620 } else { | 622 diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec; |
621 diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec; | 623 diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec; |
622 diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec; | |
623 } | |
624 | 624 |
625 if ( diff.tv_sec < 1 ) { | 625 if ( diff.tv_sec < 1 ) { |
626 bitrate = TS_BITRATE; | 626 bitrate = TS_BITRATE; |
627 } else { | 627 } else { |
628 bitrate = (((off_t)tdata->streamer->total_byte)*1e9) / | 628 bitrate = (((off_t)tdata->streamer->total_byte)*1e9) / |
629 ( (((off_t)diff.tv_sec)*1e9) + (diff.tv_sec/1e9)); | 629 ( (((off_t)diff.tv_sec)*1e9) + diff.tv_nsec); |
630 bitrate = bitrate; | |
631 } | 630 } |
632 | 631 |
633 time(&cur_time); | 632 time(&cur_time); |
634 length = (tdata->start_time +tdata->recsec -cur_time) * bitrate; | 633 length = (tdata->start_time +tdata->recsec -cur_time) * bitrate; |
635 if ( length < 0 ) { | 634 if ( length < 0 ) { |