view sendstream.php @ 115:7a64d5e3baee

mod: ¥­¡¼¥ï¡¼¥É¸¡º÷¤òÀ°Íý
author yoneda <epgrec@park.mda.or.jp>
date Sat, 13 Mar 2010 23:00:51 +0900
parents 01079b81f125
children
line wrap: on
line source

<?php
header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
header("Last-Modified: ". gmdate("D, d M Y H:i:s"). " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");


include_once("config.php");
include_once(INSTALL_PATH . "/DBRecord.class.php" );
include_once(INSTALL_PATH . "/reclib.php" );
include_once(INSTALL_PATH . "/Settings.class.php" );

$settings = Settings::factory();

if( ! isset( $_GET['reserve_id'] )) jdialog("予約番å·ãŒæŒ‡å®šã•ã‚Œã¦ã„ã¾ã›ã‚“", "recordedTable.php");
$reserve_id = $_GET['reserve_id'];


try{
	$rrec = new DBRecord( RESERVE_TBL, "id", $reserve_id );

	$start_time = toTimestamp($rrec->starttime);
	$end_time = toTimestamp($rrec->endtime );
	$duration = $end_time - $start_time;
	
	$size = 3 * 1024 * 1024 * $duration;	// 1秒ã‚ãŸã‚Š3MBã¨ä»®å®š

	header('Content-type: video/mpeg');
	header('Content-Disposition: inline; filename="'.$rrec->path.'"');
	header('Content-Length: ' . $size );
	
	ob_clean();
	flush();
	
	$fp = @fopen( INSTALL_PATH.$settings->spool."/".$rrec->path, "r" );
	if( $fp !== false ) {
		do {
			$start = microtime(true);
			if( feof( $fp ) ) break;
			echo fread( $fp, 6292 );
			@usleep( 2000 - (int)((microtime(true) - $start) * 1000 * 1000));
		}
		while( connection_aborted() == 0 );
	}
	fclose($fp);
}
catch(exception $e ) {
	exit( $e->getMessage() );
}
?>