OSDN Git Service

mod: 環境変数START_TIMEを追加
authorSushi-k <epgrec@park.mda.or.jp>
Mon, 24 May 2010 09:34:48 +0000 (18:34 +0900)
committerSushi-k <epgrec@park.mda.or.jp>
Mon, 24 May 2010 09:34:48 +0000 (18:34 +0900)
recorder.php
templates/index.html

index aeaea82..24efd4f 100755 (executable)
@@ -21,6 +21,8 @@ $reserve_id = $argv[1];
 $msgh_r = null;                // 受信用メッセージハンドラ
 $msgh_w = null;                // 送信用メッセージハンドラ
 
+
+
 $logfile = INSTALL_PATH."/settings/recorder_".$reserve_id.".log";
 
 // ノンブロッキングメッセージ受信
@@ -44,13 +46,13 @@ function epgrec_send_message( $msg ) {
 }
 
 
-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;
@@ -78,6 +80,7 @@ function epgrec_childproc( $ppid )
        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] );
                }
@@ -152,11 +155,13 @@ $msgh_w = msg_get_queue( $ipc_key );
 
 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;    // 終わったことにする
@@ -164,6 +169,34 @@ try{
        }
        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 ) {
@@ -188,7 +221,7 @@ try{
        // 録画開始
        
        $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;
@@ -248,7 +281,7 @@ try{
                        $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 ) {
index e249319..7f62d58 100755 (executable)
                        });
                },
                cancel:function(id){
+                       $('#floatBox4Dialog').html('予約取り消し中....');
                        $.get(INISet.prgCancelURL, { program_id: id } ,function(data){
                                if(data.match(/^error/i)){
                                        alert(data);