view sendstream.php @ 171:c729a68415eb

fix: preg_splitのポカミスを修正
author Sushi-k <epgrec@park.mda.or.jp>
date Mon, 26 Apr 2010 14:54:35 +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() );
}
?>