OSDN Git Service

mod: キーワード予約のログの位置を変えた
[epgrec/epgrec.git] / sendstream.php
1 <?php
2 header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
3 header("Last-Modified: ". gmdate("D, d M Y H:i:s"). " GMT");
4 header("Cache-Control: no-cache, must-revalidate");
5 header("Cache-Control: post-check=0, pre-check=0", false);
6 header("Pragma: no-cache");
7
8
9 include_once("config.php");
10 include_once(INSTALL_PATH . "/DBRecord.class.php" );
11 include_once(INSTALL_PATH . "/reclib.php" );
12 include_once(INSTALL_PATH . "/Settings.class.php" );
13
14 $settings = Settings::factory();
15
16 if( ! isset( $_GET['reserve_id'] )) jdialog("予約番号が指定されていません", "recordedTable.php");
17 $reserve_id = $_GET['reserve_id'];
18
19
20 try{
21         $rrec = new DBRecord( RESERVE_TBL, "id", $reserve_id );
22
23         $start_time = toTimestamp($rrec->starttime);
24         $end_time = toTimestamp($rrec->endtime );
25         $duration = $end_time - $start_time;
26         
27         $size = 3 * 1024 * 1024 * $duration;    // 1秒あたり3MBと仮定
28
29         header('Content-type: video/mpeg');
30         header('Content-Disposition: inline; filename="'.$rrec->path.'"');
31         header('Content-Length: ' . $size );
32         
33         ob_clean();
34         flush();
35         
36         $fp = @fopen( INSTALL_PATH.$settings->spool."/".$rrec->path, "r" );
37         if( $fp !== false ) {
38                 do {
39                         $start = microtime(true);
40                         if( feof( $fp ) ) break;
41                         echo fread( $fp, 6292 );
42                         @usleep( 2000 - (int)((microtime(true) - $start) * 1000 * 1000));
43                 }
44                 while( connection_aborted() == 0 );
45         }
46         fclose($fp);
47 }
48 catch(exception $e ) {
49         exit( $e->getMessage() );
50 }
51 ?>