comparison src/http.c @ 183:27e5f99f8991

Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Mon, 05 May 2014 22:08:21 +0900
parents 726fe10d9e4a
children
comparison
equal deleted inserted replaced
182:13f0666bd088 183:27e5f99f8991
610 http_write, 610 http_write,
611 http_seek, 611 http_seek,
612 http_close 612 http_close
613 }; 613 };
614 614
615 // TS_BITRATEはやっつけ仕事過ぎる気がします
616 #define TS_BITRATE (10*1000*1000/8)
617 #define MAX_STREAMING ((off_t)100*1000*1000*1000) 615 #define MAX_STREAMING ((off_t)100*1000*1000*1000)
618 static off_t 616 static off_t
619 get_streaming_length (void) 617 get_streaming_length (void)
620 { 618 {
621 off_t length = 0; 619 return MAX_STREAMING;
622 extern thread_data *gp_tdata; 620 }
623 thread_data *tdata = gp_tdata;
624 time_t cur_time;
625 struct timespec cur;
626 struct timespec diff;
627 clock_gettime(CLOCK_REALTIME, &cur);
628 off_t bitrate = 0;
629
630 if ( tdata->indefinite ) {
631 return MAX_STREAMING;
632 }
633 diff.tv_nsec = cur.tv_nsec - tdata->streamer->start.tv_nsec;
634 diff.tv_sec = cur.tv_sec - tdata->streamer->start.tv_sec;
635
636 if ( diff.tv_sec < 1 ) {
637 bitrate = TS_BITRATE;
638 } else {
639 bitrate = (((off_t)tdata->streamer->total_byte)*1e9) /
640 ( (((off_t)diff.tv_sec)*1e9) + diff.tv_nsec);
641 }
642
643 time(&cur_time);
644 length = (tdata->start_time +tdata->recsec -cur_time) * bitrate;
645 if ( length < 0 ) {
646 length = 0;
647 }
648 length = length - (length % LENGTH_PACKET);
649 return length;
650 }