$msgh_r = null; // 受信用メッセージハンドラ
$msgh_w = null; // 送信用メッセージハンドラ
+
+
$logfile = INSTALL_PATH."/settings/recorder_".$reserve_id.".log";
// ノンブロッキングメッセージ受信
}
-function epgrec_exec( $cmd ) {
+function epgrec_exec( $cmd, $env = null ) {
$descspec = array(
0 => array( 'file','/dev/null','r' ),
1 => array( 'file','/dev/null','w' ),
2 => array( 'file','/dev/null','w' ),
);
- $p = proc_open( $cmd, $descspec, $pipes );
+ $p = proc_open( $cmd, $descspec, $pipes, INSTALL_PATH, $env );
if( is_resource( $p ) ) return $p;
return false;
while( ! feof( $pipes[1] ) ) {
$line = trim(fgets( $pipes[1] ));
$pids = preg_split( "/[\s]+/", $line );
+ if( ! isset( $pids[1]) ) continue;
if( $pids[1] == $ppid ) {
array_push( $cpids, $pids[0] );
}
try{
$rrec = new DBRecord( RESERVE_TBL, "id" , $reserve_id );
+ $crec = new DBRecord( CHANNEL_TBL, "id" , $rrec->channel_id) ;
// 時刻を得る
$starttime = toTimestamp($rrec->starttime);
$endtime = toTimestamp($rrec->endtime);
+
if( time() > $starttime ) {
// 過去の録画予約
$rrec->complete = 1; // 終わったことにする
}
reclog("recorder:: 録画ID".$rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画ジョブ開始" );
+ // tuner
+ $type_str = ($crec->type == "GR") ? "type = 'GR' " : "(type = 'BS' OR type = 'CS') ";
+ $tuner = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
+ "AND ".$type_str.
+ "AND id <> '".$rrec->id."' ".
+ "AND starttime < '".$rrec->endtime."' ".
+ "AND endtime > '".$rrec->starttime."'"
+ );
+
+ // program_start;
+
+ $program_start = $starttime + (int)($settings->former_time);
+
+ $env_rec = array(
+ "CHANNEL" => $rrec->channel,
+ "DURATION" => $endtime - $starttime,
+ "OUTPUT" => INSTALL_PATH.$settings->spool."/".$rrec->path,
+ "TYPE" => $crec->type,
+ "TUNER" => $tuner,
+ "MODE" => $rrec->mode,
+ "THUMB" => INSTALL_PATH.$settings->thumbs."/".$rrec->path.".jpg",
+ "FORMER" => "".$settings->former_time,
+ "FFMPEG" => "".$settings->ffmpeg,
+ "SID" => $crec->sid,
+ "START_TIME" => date( "YmdHis", $program_start ),
+ );
+
+
// 録画開始まで待つ
while( time() < $starttime ) {
if( ($message = epgrec_get_message() ) != null ) {
// 録画開始
$proch = false;
- if( ( $proch = epgrec_exec(DO_RECORD) ) !== false ) {
+ if( ( $proch = epgrec_exec(DO_RECORD, $env_rec) ) !== false ) {
reclog("recorder:: 録画ID".$rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画開始" );
// 録画完了待ち
$rec_cont = true;
$gen_thumbnail = INSTALL_PATH."/gen-thumbnail.sh";
if( defined("GEN_THUMBNAIL") )
$gen_thumbnail = GEN_THUMBNAIL;
- @exec($gen_thumbnail);
+ @exec($gen_thumbnail, $env_rec);
}
if( $settings->mediatomb_update == 1 ) {