Ejemplo n.º 1
0
 public function show()
 {
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $condition = $this->get_condition();
     $orderby = '  ORDER BY order_id DESC,id DESC ';
     $limit = ' LIMIT ' . $offset . ' , ' . $count;
     $ret = $this->mode->show($condition, $orderby, $limit);
     $video_ids = array();
     $channel_ids = array();
     foreach ($ret as $k => $v) {
         $video_ids[] = $v['video_id'];
         $channel_ids[] = $v['channel_id'];
     }
     /*******************此处是为了请求视频库的图片******************/
     if ($video_ids) {
         $livmedia = new livmedia();
         $video = $livmedia->get_videos(implode(',', $video_ids));
         $video_img = array();
         $video_url = array();
         if ($video && $video[0]) {
             foreach ($video[0] as $k => $v) {
                 $video_img[$v['id']] = @unserialize($v['img_info']);
                 $video_url[$v['id']] = $v['hostwork'] . '/' . $v['video_path'] . $v['video_filename'];
             }
         }
     }
     /*******************此处是为了请求视频库的图片*****************/
     /*******************此处是为了频道名称***********************/
     if ($channel_ids) {
         $mLive = new live();
         $channel = $mLive->getChannelById(implode(',', $channel_ids), -1);
         $channel_name[] = array();
         if ($channel) {
             foreach ($channel as $k => $v) {
                 $channel_name[$v['id']] = $v['name'];
             }
         }
     }
     /*******************此处是为了频道名称***********************/
     if (!empty($ret)) {
         foreach ($ret as $k => $v) {
             if ($video_img) {
                 $v['img_info'] = $video_img[$v['video_id']];
             }
             if ($channel_name) {
                 $v['channel_name'] = $channel_name[$v['channel_id']];
             }
             if ($video_url) {
                 $v['video_url'] = $video_url[$v['video_id']];
             }
             $this->addItem($v);
         }
         $this->output();
     }
 }
Ejemplo n.º 2
0
 public function show()
 {
     if (!$this->input['server_id']) {
         $this->errorOutput(NO_SERVER_ID);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "transcode_center  WHERE id = '" . intval($this->input['server_id']) . "'";
     $arr = $this->db->query_first($sql);
     $trans = new transcode(array('host' => $arr['trans_host'], 'port' => $arr['trans_port']));
     $ret = $trans->get_transcode_status();
     $ret = json_decode($ret, 1);
     $status = array();
     $task_ids = array();
     $more_task = array();
     if ($ret['return'] != 'fail') {
         foreach ((array) $ret['running'] as $k => $v) {
             $ret['running'][$k]['status'] = 'running';
         }
         if ($ret['running']) {
             //如果存在等待也加进去
             if ($ret['waiting']) {
                 foreach ((array) $ret['waiting'] as $k => $v) {
                     $ret['waiting'][$k]['status'] = 'waiting';
                 }
                 $ret['running'] = array_merge($ret['running'], $ret['waiting']);
             }
             $status['status'] = $ret['running'];
             foreach ($ret['running'] as $k => $v) {
                 //处理多码流
                 if (strstr($v['id'], '_more')) {
                     $more_task[] = $v['id'];
                     //保存多码流任务id
                     $m_ids = explode('_', $v['id']);
                     $task_ids[] = $m_ids[0];
                     continue;
                 }
                 $task_ids[] = $v['id'];
             }
             $livmedia = new livmedia();
             $video_info = $livmedia->get_videos(implode(',', $task_ids));
             if ($video_info && $video_info[0]) {
                 foreach ($status['status'] as $k => $v) {
                     if (in_array($v['id'], $more_task)) {
                         $t_ids = explode('_', $v['id']);
                         $status['status'][$k]['title'] = '多码流:(' . $video_info[0][$t_ids[0]]['title'] . ')';
                         continue;
                     }
                     $status['status'][$k]['title'] = $video_info[0][$v['id']]['title'];
                 }
             }
         }
     }
     $this->total = count($status[0]['status']);
     $this->addItem($status);
     $this->output();
 }
Ejemplo n.º 3
0
 public function create()
 {
     $ids = trim($this->input['pid']) ? trim($this->input['pid']) : '';
     if (!$ids) {
         $this->errorOutput(NOID);
     }
     //视频outpush
     if ($this->input['pushType'] == "vod") {
         include_once ROOT_DIR . 'lib/class/livmedia.class.php';
         $outpush = new livmedia();
         $res = $outpush->get_videos_info($ids);
         file_put_contents('data.txt', var_export($res, 1));
         if (!$res) {
             $this->errorOutput(NOSOURCE);
         }
         foreach ($res as $key => $vo) {
             $task['id'] = md5('hoge' . rand(1, 100000000) . time());
             //必填 任务ID,最长不超过36个字符
             $task['name'] = $vo['title'];
             //必填 任务名称
             $task['resourceId'] = md5('hoge' . rand(1, 200000000) . time());
             //必填 资源ID
             $task['resourceType'] = 0;
             //必填 资源类型 0:视音频资源 1:纯音频资源 3:图片资源 4:文档资源
             $task['sourceType'] = 4;
             //必填 1:信号采集 2:导入 3:esb 4:webservice/rest 5:dirwatch 6:launcher 7:web 8:收录 9:quickcut
             $task['sourceSystem'] = SYSMARK_VDO;
             //必填 来源于厚建M2O-视频填:hoge;来源于厚建M2O-文稿填:hoge-news
             $task['ccid'] = '';
             //可选 编目类
             $task['programCode'] = '';
             //可选 节目代码
             $task['programType'] = '';
             //可选 节目类型 0 节目 1 素材
             $task['hdFlag'] = 0;
             //可选 高标清标识 0标清 1高清
             $task['afd'] = 0;
             //可选 AFD值(0-15)
             $task['creatorId'] = '';
             //可选 创建人ID
             $task['creatorName'] = '';
             //可选 创建人名称
             $task['segmentInfo'] = '';
             //可选 Segment信息
             $task['memo'] = '';
             //可选 描述
             $task['priority'] = 0;
             //可选 优先级
             $task['inpoint'] = 0;
             //可选 入点,单位帧
             $task['outpoint'] = 0;
             //可选 出点,单位帧
             $task['duration'] = '';
             //可选 时长,单位帧
             $task['metadataInfo'] = '';
             //可选 元数据信息
             $task['files'] = array(array('id' => 'HOGE' . $task['id'], 'source' => '<?xml version="1.0" encoding="UTF-8"?><SourceInfo><SourceFile FileType="0" Channel="0" FileName="' . $vo['video_filename'] . '" PathID="" Path="' . $vo['hostwork'] . '/' . $vo['video_path'] . '" TrimIn="0" TrimOut="0" RelativePath="" MD5Code="" StreamMediaInfoID=""/></SourceInfo>'));
             $taskList['taskList'][0] = $task;
             $sendata = json_encode($taskList);
             $res = $this->postData(SEND_URL, $sendata);
             file_put_contents('result.txt', var_export($res, 1));
         }
         //res返回成功,则更改相应数据库outpush_id字段
         if (strpos($res, 'false') == false && strpos($res, 'true')) {
             $change = $this->changeOutpushState('dev_media', 'vodinfo', $ids);
             if (!$change) {
                 $this->errorOutput(MYSQL_WRONG);
             }
             $this->addItem('success');
             $this->output();
         } else {
             $this->errorOutput(SQL_FAILED);
         }
         //文稿推送
     } elseif ($this->input['pushType'] == "news") {
         include_once ROOT_DIR . 'lib/class/news.class.php';
         $new = new news();
         $res = $new->details($ids);
         file_put_contents('res.txt', var_export($res, 1));
         if (!$res) {
             $this->errorOutput(NOSOURCE);
         }
         foreach ($res as $vo) {
             $task['id'] = md5('hoge' . rand(1, 100000000) . time());
             //必填 任务ID,最长不超过36个字符
             $task['name'] = $vo['title'];
             //必填 任务名称
             $task['resourceId'] = md5('hoge' . rand(1, 200000000) . time());
             //必填 资源ID
             $task['resourceType'] = 10;
             //必填 资源类型 0:视音频资源 1:纯音频资源 3:图片资源 4:文档资源 10:全媒体稿件资源
             $task['sourceType'] = 4;
             //必填 1:信号采集 2:导入 3:esb 4:webservice/rest 5:dirwatch 6:launcher 7:web 8:收录 9:quickcut
             $task['sourceSystem'] = SYSMARK_NEWS;
             //必填 来源于厚建M2O-视频填:hoge;来源于厚建M2O-文稿填:hoge-news
             $task['ccid'] = '';
             //可选 编目类
             $task['programCode'] = '';
             //可选 节目代码
             $task['programType'] = '';
             //可选 节目类型 0 节目 1 素材
             $task['hdFlag'] = 0;
             //可选 高标清标识 0标清 1高清
             $task['afd'] = 0;
             //可选 AFD值(0-15)
             $task['creatorId'] = '';
             //可选 创建人ID
             $task['creatorName'] = '';
             //可选 创建人名称
             $task['segmentInfo'] = '';
             //可选 Segment信息
             $task['memo'] = '';
             //可选 描述
             $task['priority'] = 0;
             //可选 优先级
             $task['inpoint'] = 0;
             //可选 入点,单位帧
             $task['outpoint'] = 0;
             //可选 出点,单位帧
             $task['duration'] = '';
             //可选 时长,单位帧
             //文稿必选 元数据信息
             $task['metadataInfo'] = '<?xml version="1.0" encoding="UTF-8"?><MetaData MetaDataCount="3"><sAttribute enumType="0" strName="标题"><![CDATA[' . $vo['title'] . ']]></sAttribute><sAttribute enumType="0" strName="创建人"><![CDATA[' . $vo['author'] . ']]></sAttribute><sAttribute enumType="0" strName="富文本内容"><![CDATA[' . $vo['content'] . ']]></sAttribute></MetaData>';
             $id = 'HOGE' . $task['id'];
             //主键,36位GUID
             $source = '<?xml version="1.0" encoding="UTF-8"?><SourceInfo>';
             //验证是否有图片
             if ($vo['is_img'] == 1) {
                 foreach ($vo['material'] as $m) {
                     $source .= '<SourceFile FileType="9" Channel="0" FileName="' . $m['pic']['filename'] . '" PathID="" Path="' . $m['pic']['host'] . $m['pic']['dir'] . $m['pic']['filepath'] . '" TrimIn="" TrimOut="" RelativePath="" MD5Code="" StreamMediaInfoID=""/>';
                 }
             }
             //验证是否有图集或视频
             if ($vo['file_info'] != array()) {
                 $tuji_id = array();
                 foreach ($vo['file_info'] as $a => $f) {
                     if ($f['app'] == 'tuji') {
                         $tuji_id[] = substr($a, 5);
                     } elseif ($f['app'] == 'livmedia') {
                         $source .= '<SourceFile FileType="5" Channel="0" FileName="' . basename($f['video_url']) . '" PathID="" Path="' . dirname($f['video_url']) . '/' . '" TrimIn="0" TrimOut="0" RelativePath="" MD5Code="" StreamMediaInfoID=""/>';
                     }
                 }
                 //文稿中若有图集则首先推送,获取返回resourceId,此处重写$_INPUT.调用图集入库
                 if ($tuji_id != array()) {
                     $this->input['ids'] = $tuji_id;
                     $this->input['pushType'] = 'tuji';
                     $this->input['inner'] = TRUE;
                     $res = $this->create($this->input);
                     if ($res == array()) {
                         $this->errorOutput(TUJI_PUSH_ERROR);
                     }
                     $task['relationResourceIds'] = implode(',', $res);
                 }
             }
             $source .= '</SourceInfo>';
             if (strpos($source, 'SourceFile') !== FALSE) {
                 $task['files'] = array(array('id' => $id, 'source' => $source));
                 //文稿如有图片和视频,以此文件形式推送。
             }
             file_put_contents('vod.txt', var_export($task, 1));
             $taskList['taskList'][0] = $task;
             $sendata = json_encode($taskList);
             $res = $this->postData(SEND_URL, $sendata);
             file_put_contents('sss444.txt', var_export($res, 1));
             //判断文稿是否推送成功
             //成功则更改对应数据库的outpush_id值,返回对应id以及outpush_id
         }
         if (strpos($res, 'false') === FALSE && strpos($res, 'true')) {
             $change = $this->changeOutpushState('dev_news', 'article', $ids);
             if (!$change) {
                 $this->errorOutput(MYSQL_WRONG);
             }
             $this->addItem('success');
             $this->output();
         } else {
             $this->errorOutput(SQL_FAILED);
         }
         //图集推送
     } elseif ($this->input['pushType'] == "tuji") {
         include_once ROOT_DIR . 'lib/class/tuji.class.php';
         $tuji = new tuji();
         $res = $tuji->details($ids);
         if (!$res) {
             $this->errorOutput(NOSOURCE);
         }
         foreach ($res as $vo) {
             $task['id'] = md5('hoge' . rand(1, 1000000000) . time());
             //必填 任务ID,最长不超过36个字符
             $task['name'] = $vo['title'];
             //必填 任务名称
             $task['resourceId'] = 'HOGE' . $vo['id'];
             //必填 资源ID
             $task['resourceType'] = 2;
             //必填 资源类型 0:视音频资源 1:纯音频资源 3:图片资源 4:文档资源
             $task['sourceType'] = 4;
             //必填 1:信号采集 2:导入 3:esb 4:webservice/rest 5:dirwatch 6:launcher 7:web 8:收录 9:quickcut
             $task['sourceSystem'] = SYSMARK_TUJI;
             //必填 来源于厚建M2O-视频填:hoge;来源于厚建M2O-文稿填:hoge-news
             $task['ccid'] = '图集类';
             //可选 编目类
             $task['programCode'] = '';
             //可选 节目代码
             $task['programType'] = 1;
             //可选 节目类型 0 节目 1 素材
             $task['hdFlag'] = '';
             //可选 高标清标识 0标清 1高清
             $task['afd'] = '';
             //可选 AFD值(0-15)
             $task['creatorId'] = '';
             //可选 创建人ID
             $task['creatorName'] = '';
             //可选 创建人名称
             $task['segmentInfo'] = '';
             //可选 Segment信息
             $task['memo'] = '';
             //可选 描述
             $task['priority'] = 0;
             //可选 优先级
             $task['inpoint'] = '0';
             //可选 入点,单位帧
             $task['outpoint'] = '0';
             //可选 出点,单位帧
             $task['duration'] = '0';
             //可选 时长,单位帧
             $taskList['taskList'][0] = $task;
             if (isset($vo['pics']) && !empty($vo['pics'])) {
                 $img = array();
                 $i = 1;
                 foreach ($vo['pics'] as $n => $p) {
                     $img['id'] = md5('hoge' . rand(1, 1000000000) . time());
                     $img['name'] = $vo['title'] . '-图片 ' . $i;
                     $img['resourceId'] = $n;
                     $img['parentId'] = 'HOGE' . $vo['id'];
                     $img['resourceType'] = 3;
                     //必填 资源类型 0:视音频资源 1:纯音频资源 3:图片资源 4:文档资源
                     $img['sourceType'] = 4;
                     //必填 1:信号采集 2:导入 3:esb 4:webservice/rest 5:dirwatch 6:launcher 7:web 8:收录 9:quickcut
                     $img['sourceSystem'] = SYSMARK_PICS;
                     //必填 来源于厚建M2O-视频填:hoge;来源于厚建M2O-文稿填:hoge-news
                     $img['ccid'] = '图片类';
                     //可选 编目类
                     $img['programCode'] = '';
                     //可选 节目代码
                     $img['programType'] = 1;
                     //可选 节目类型 0 节目 1 素材
                     $img['hdFlag'] = '';
                     //可选 高标清标识 0标清 1高清
                     $img['afd'] = '';
                     //可选 AFD值(0-15)
                     $img['creatorId'] = '';
                     //可选 创建人ID
                     $img['creatorName'] = '';
                     //可选 创建人名称
                     $img['segmentInfo'] = '';
                     //可选 Segment信息
                     $img['memo'] = '';
                     //可选 描述
                     $img['priority'] = 0;
                     //可选 优先级
                     $img['inpoint'] = '0';
                     //可选 入点,单位帧
                     $img['outpoint'] = '0';
                     //可选 出点,单位帧
                     $img['duration'] = '';
                     //可选 时长,单位帧
                     $source = '<?xml version="1.0" encoding="UTF-8"?><SourceInfo><SourceFile FileType="9" Channel="0" FileName="' . $p['filename'] . '" PathID="" Path="' . $p['host'] . $p['dir'] . $p['filepath'] . '" TrimIn="" TrimOut="" RelativePath="" MD5Code="" StreamMediaInfoID="" />';
                     $img['files'] = array(array('source' => $source));
                     $taskList['taskList'][$i] = $img;
                     $i++;
                 }
             } else {
                 $this->errorOutput(NOPICS);
             }
             $sendata = json_encode($taskList);
             $res = $this->postData(SEND_URL, $sendata);
             file_put_contents('sss.txt', $res);
             //此处判断是否推送成功
             $return[] = 'HOGE' . $vo["id"];
         }
         if ($this->input['inner']) {
             return $return;
         } else {
             if (strpos($res, 'false') === FALSE && strpos($res, 'true')) {
                 $change = $this->changeOutpushState('dev_tuji', 'tuji', $ids);
                 if (!$change) {
                     $this->errorOutput(MYSQL_WRONG);
                 }
                 $this->addItem('success');
                 $this->output();
             } else {
                 $this->errorOutput(SQL_FAILED);
             }
         }
     }
 }
Ejemplo n.º 4
0
 public function show($condition, $data_limit, $dates = '')
 {
     $sql = "select p.* from " . DB_PREFIX . "program_record p ";
     if ($dates) {
         $sql .= "left join " . DB_PREFIX . "program_record_relation r on r.record_id = p.id ";
     }
     $sql .= " where 1 " . $condition . " ORDER BY p.is_record ASC,p.start_time ASC " . $data_limit;
     $q = $this->db->query($sql);
     $week_day_arr = array('1' => '一', '2' => '二', '3' => '三', '4' => '四', '5' => '五', '6' => '六', '7' => '日');
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     $conid = $space = "";
     $data = $channel = array();
     while ($row = $this->db->fetch_array($q)) {
         $channel[$row['channel_id']] = $row['channel_id'];
         $conid .= $space . $row['conid'];
         $space = ',';
         $data[] = $row;
     }
     if (!empty($channel)) {
         $channel_ids = implode(',', $channel);
         $channel = array();
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel_tmp = $newLive->getChannelById($channel_ids, -1, 1);
         if (!empty($channel_tmp)) {
             foreach ($channel_tmp as $k => $v) {
                 $channel[$v['id']] = $v;
             }
         }
     }
     $log = array();
     if ($conid) {
         $sql = "SELECT log_id FROM " . DB_PREFIX . "program_queue WHERE id IN(" . $conid . ")";
         $log_id = $space = '';
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $log_id .= $space . $row['log_id'];
             $space = ',';
         }
         if ($log_id) {
             $sql = "SELECT a.*,q.conid FROM " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE a.id IN (" . $log_id . ")";
             $q = $this->db->query($sql);
             $log = array();
             while ($row = $this->db->fetch_array($q)) {
                 $log[$row['record_id']] = $row;
             }
         }
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
     $q = $this->db->query($sql);
     $server_config = array();
     while ($row = $this->db->fetch_array($q)) {
         $server_config[$row['id']] = $row;
     }
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     foreach ($data as $k => $v) {
         if (empty($channel[$v['channel_id']])) {
             $channel[$v['channel_id']]['name'] = '频道关闭';
         }
         $v['channel'] = $channel[$v['channel_id']]['name'];
         $v['status'] = $channel[$v['channel_id']]['status'];
         $dates = date('Y-m-d', $v['start_time']);
         $channel_id = $v['channel_id'];
         $start_time = $v['start_time'];
         $week_day = unserialize($v['week_day']);
         $v['start_time'] = date('H:i:s', $start_time);
         $v['end_time'] = date('H:i:s', $v['toff'] + $start_time);
         $mins = floor($v['toff'] / 60);
         $sen = $v['toff'] - $mins * 60;
         $v['toff_decode'] = ($mins ? $mins . "'" : '') . ($sen ? $sen . "''" : '');
         $v['dates'] = $dates;
         //$v['w'] = date('w',strtotime($start_time));
         $v['sort_name'] = $sort_name[$v['item']];
         $tmp = $log[$v['id']];
         if (!empty($week_day)) {
             if (count($week_day) == 7) {
                 $v['cycle'] = '每天';
             } else {
                 $spac = '';
                 foreach ($week_day as $kk => $vv) {
                     $v['cycle'] .= $spac . $week_day_arr[$vv];
                     $spac = '&nbsp;|&nbsp;';
                 }
             }
         } else {
             $v['cycle'] = date('Y-m-d', $start_time);
         }
         if ($server_config && $server_config[$v['server_id']]) {
             if ($tmp) {
                 $obj_curl = new curl($server_config[$v['server_id']]['host'] . ':' . $server_config[$v['server_id']]['port'], $server_config[$v['server_id']]['dir']);
                 switch (intval($tmp['state'])) {
                     case 0:
                         //录制等待录制
                         $obj_curl->setSubmitType('get');
                         $obj_curl->initPostData();
                         $obj_curl->addRequestData('action', 'SELECT');
                         $obj_curl->addRequestData('id', $tmp['conid']);
                         $record_xml = $obj_curl->request('');
                         $record_array = xml2Array($record_xml);
                         if (!empty($record_array) && $record_array['result']) {
                             if ($record_array['record']['status'] == 'running') {
                                 $v['action'] = '录制中';
                             }
                             if ($record_array['record']['status'] == 'waiting') {
                                 if ($start_time + $v['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                                     $v['action'] = '录制超时';
                                 } else {
                                     $v['action'] = '等待录制';
                                 }
                             }
                         } else {
                             $v['action'] = '录制超时';
                         }
                         break;
                     case 1:
                         //录制成功
                         if ($tmp['week_day']) {
                             $v['action'] = '等待录制';
                         } else {
                             $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                         }
                         break;
                     case 2:
                         //录制失败
                         if ($tmp['week_day']) {
                             $v['action'] = '等待录制';
                         } else {
                             $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                         }
                         break;
                 }
             } else {
                 if ($start_time >= TIMENOW) {
                     $v['action'] = '等待录制';
                 } else {
                     if (TIMENOW > $start_time && TIMENOW < $v['toff'] + $start_time) {
                         $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                     } else {
                         if ($v['toff'] + $start_time <= TIMENOW) {
                             $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                             //假如is_record 存在video 在上传,否则就是录制成功
                         }
                     }
                 }
             }
         } else {
             $v['action'] = '服务停止';
         }
         if ($v['is_out']) {
             //$row['action'] = '录制超时';
         }
         if (!$v['status']) {
             $v['action'] = '频道关闭';
         }
         if (!$v['server_id']) {
             $v['action'] = '服务停止';
         }
         $info[] = $v;
     }
     return $info;
 }
Ejemplo n.º 5
0
 function getItem()
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $ret = $livmedia->getAutoItem();
     $data = array();
     foreach ($ret as $k => $v) {
         $data[$v['id']] = $v['name'];
     }
     echo json_encode($data);
 }
Ejemplo n.º 6
0
 function check_day()
 {
     $id = $this->input['id'];
     $channel_id = $this->input['channel_id'];
     if (!$channel_id) {
         $this->errorOutput("未传入频道ID");
     }
     $start_time = $this->input['start_time'];
     if (!$start_time) {
         $this->errorOutput("未传入开始时间");
     }
     $end_time = $this->input['end_time'];
     if (!$end_time) {
         $this->errorOutput("未传入结束时间");
     }
     //该频道的录播记录
     $sql = "SELECT p.id,r.start_time,r.end_time,r.channel_id,r.week_num,p.item FROM " . DB_PREFIX . "program_record p LEFT JOIN " . DB_PREFIX . "program_record_relation r ON p.id = r.record_id WHERE r.channel_id=" . $channel_id . " AND r.week_num=" . date('N', strtotime($dates)) . " AND r.start_time='" . date('H:i:s', $start_time) . "' AND r.end_time='" . date('H:i:s', $end_time) . "'";
     $f = $this->db->query_first($sql);
     if ($f['id']) {
         $this->addItem(array('tips' => 1));
     } else {
         include_once ROOT_PATH . 'lib/class/livmedia.class.php';
         $livmedia = new livmedia();
         $sort_name = $livmedia->getAutoItem();
         $this->addItem($sort_name);
     }
     $this->output();
 }
Ejemplo n.º 7
0
 public function play_episode()
 {
     //剧集的id
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     //根据剧集的id获得该剧集的视频id
     $episode = $this->mode->get_episode_info($this->input['id']);
     if (!$episode) {
         $this->errorOutput(NO_DATA);
     }
     $video_id = $episode[0]['video_id'];
     $media = new livmedia();
     $video = $media->get_videos($video_id);
     $this->addItem($video[0]);
     $this->output();
 }
Ejemplo n.º 8
0
 public function get_vod_info_by_id($vod_id)
 {
     if (!$vod_id) {
         return false;
     }
     if (!$this->settings['App_livmedia']) {
         return false;
         //$this->errorOutput('NO_APP_LIVMEDIA');
     }
     $mLivMedia = new livmedia();
     $video = $mLivMedia->getVodInfoById($vod_id);
     if (!$video) {
         return false;
     }
     if (is_array($video)) {
         foreach ($video as $k => $v) {
             $return[$v['id']] = array('id' => $v['id'], 'img_info' => $v['img'] ? $v['img'] : '', 'is_audio' => $v['is_audio'], 'upload_type' => $v['is_audio'] ? '音频' : '视频', 'title' => $v['title'], 'url' => $v['video_url'], 'pic_arr' => $v['img_info']['filename'] ? $v['img_info'] : '', 'video_arr' => array('hostwork' => $v['hostwork'], 'video_base_path' => $v['video_base_path'], 'video_path' => $v['video_path'], 'video_filename' => $v['video_filename']), 'duration' => trim(str_replace('\'', ':', $v['duration']), '"'));
         }
     }
     return $return;
 }
Ejemplo n.º 9
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     if ($this->mNeedCheckIn && !$this->prms['show']) {
         $this->errorOutput(NO_OPRATION_PRIVILEGE);
     }
     $condition = $this->get_condition();
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $data_limit = " LIMIT " . $offset . " , " . $count;
     $sql = "select p.*,c.name as channel,c.stream_state from " . DB_PREFIX . "program_record p left join " . DB_PREFIX . "channel c on c.id=p.channel_id ";
     $sql .= " where 1 " . $condition . " ORDER BY p.is_record ASC,p.start_time ASC " . $data_limit;
     $q = $this->db->query($sql);
     $week_day_arr = array('1' => '一', '2' => '二', '3' => '三', '4' => '四', '5' => '五', '6' => '六', '7' => '日');
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     $conid = $space = "";
     $data = array();
     while ($row = $this->db->fetch_array($q)) {
         $conid .= $space . $row['conid'];
         $space = ',';
         $data[] = $row;
     }
     $log = array();
     if ($conid) {
         $sql = "SELECT log_id FROM " . DB_PREFIX . "program_queue WHERE id IN(" . $conid . ")";
         $log_id = $space = '';
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $log_id .= $space . $row['log_id'];
             $space = ',';
         }
         if ($log_id) {
             $sql = "SELECT a.*,q.conid FROM " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE a.id IN (" . $log_id . ")";
             $q = $this->db->query($sql);
             $log = array();
             while ($row = $this->db->fetch_array($q)) {
                 $log[$row['record_id']] = $row;
             }
         }
     }
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
     foreach ($data as $k => $v) {
         $dates = date('Y-m-d', $v['start_time']);
         $channel_id = $v['channel_id'];
         $start_time = $v['start_time'];
         $week_day = unserialize($v['week_day']);
         $v['start_time'] = date('H:i:s', $start_time);
         $v['end_time'] = date('H:i:s', $v['toff'] + $start_time);
         $mins = floor($v['toff'] / 60);
         $sen = $v['toff'] - $mins * 60;
         $v['toff_decode'] = ($mins ? $mins . "'" : '') . ($sen ? $sen . "''" : '');
         $v['dates'] = $dates;
         //$v['w'] = date('w',strtotime($start_time));
         $v['sort_name'] = $sort_name[$v['item']];
         $tmp = $log[$v['id']];
         if (!empty($week_day)) {
             if (count($week_day) == 7) {
                 $v['cycle'] = '每天';
             } else {
                 $spac = '';
                 foreach ($week_day as $kk => $vv) {
                     $v['cycle'] .= $spac . $week_day_arr[$vv];
                     $spac = '&nbsp;|&nbsp;';
                 }
             }
         } else {
             $v['cycle'] = date('Y-m-d', $start_time);
         }
         if ($tmp) {
             switch (intval($tmp['state'])) {
                 case 0:
                     //录制等待录制
                     $obj_curl->setSubmitType('get');
                     $obj_curl->initPostData();
                     $obj_curl->addRequestData('action', 'SELECT');
                     $obj_curl->addRequestData('id', $tmp['conid']);
                     $record_xml = $obj_curl->request('');
                     $record_array = xml2Array($record_xml);
                     if (!empty($record_array) && $record_array['result']) {
                         if ($record_array['record']['status'] == 'running') {
                             $v['action'] = '录制中';
                         }
                         if ($record_array['record']['status'] == 'waiting') {
                             if ($start_time + $v['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                                 $v['action'] = '录制超时';
                             } else {
                                 $v['action'] = '等待录制';
                             }
                         }
                     } else {
                         $v['action'] = '录制超时';
                     }
                     break;
                 case 1:
                     //录制成功
                     if ($tmp['week_day']) {
                         $v['action'] = '等待录制';
                     } else {
                         $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                     }
                     break;
                 case 2:
                     //录制失败
                     if ($tmp['week_day']) {
                         $v['action'] = '等待录制';
                     } else {
                         $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                     }
                     break;
             }
         } else {
             if ($start_time >= TIMENOW) {
                 $v['action'] = '等待录制';
             } else {
                 if (TIMENOW > $start_time && TIMENOW < $v['toff'] + $start_time) {
                     $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                 } else {
                     if ($v['toff'] + $start_time <= TIMENOW) {
                         $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                         //假如is_record 存在video 在上传,否则就是录制成功
                     }
                 }
             }
         }
         if ($v['is_out']) {
             //$row['action'] = '录制超时';
         }
         if (!$v['stream_state']) {
             $v['action'] = '频道关闭';
         }
         $info[] = $v;
     }
     foreach ($info as $key => $value) {
         $spa = '';
         $start_time = strtotime($value['dates'] . " " . $value['start_time']);
         $end_time = strtotime($value['dates'] . " " . $value['start_time']) + $value['toff'];
         $value['title'] = $value['title'] ? $value['title'] : $this->program_plan($value['channel_id'], $start_time, $end_time);
         $value['title'] = $value['title'] ? $value['title'] : '精彩节目';
         $value['source'] = $value['program_id'] ? '节目单' : ($value['plan_id'] ? '节目单计划' : '计划收录');
         //hg_pre($value);
         $this->addItem($value);
     }
     $this->output();
 }
Ejemplo n.º 10
0
 }
 private function photo_detail($id)
 {
     include_once ROOT_PATH . 'lib/class/tuji.class.php';
     $picApi = new tuji();
     $photo_info = $picApi->detail($id);
     if (!$photo_info['tuji']['id']) {
         return false;
     }
     return $photo_info;
 }
 private function video_detail($id)
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $videoApi = new livmedia();
     $info = $videoApi->get_videos($id);
     $info = $info[0][$id];
     if ($info['column_id']) {
         $info['column_id'] = unserialize($info['column_id']);
Ejemplo n.º 11
0
 public function get_vod_info_by_id($vod_id, $need_key = 1)
 {
     if (!$vod_id) {
         return false;
     }
     if (!$this->settings['App_livmedia']) {
         return false;
         //$this->errorOutput('NO_APP_LIVMEDIA');
     }
     $mLivMedia = new livmedia();
     $video = $mLivMedia->getVodInfoById($vod_id, 100);
     if (!$video) {
         return false;
     }
     if (is_array($video)) {
         foreach ($video as $k => $v) {
             $mp4 = $v['hostwork'] . '/' . $v['video_path'] . $v['video_filename'];
             $m3u8 = str_replace('.mp4', '.m3u8', $mp4);
             $vid[] = $return[$v['id']] = array('id' => $v['id'], 'img_info' => $v['img'] ? $v['img'] : '', 'is_audio' => $v['is_audio'], 'upload_type' => $v['is_audio'] ? '音频' : '视频', 'title' => $v['title'], 'url' => $v['video_url'], 'm3u8' => $m3u8, 'pic_arr' => $v['img_info'], 'video_arr' => array('hostwork' => $v['hostwork'], 'video_base_path' => $v['video_base_path'], 'video_path' => $v['video_path'], 'video_filename' => $v['video_filename']));
         }
     }
     return $need_key ? $return : $vid;
 }
Ejemplo n.º 12
0
 private function deleteVideosOfLivmedia($video_ids = '')
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $livmedia->delete($video_ids);
 }
Ejemplo n.º 13
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
     $q = $this->db->query($sql);
     $server_config = array();
     while ($row = $this->db->fetch_array($q)) {
         $server_config[$row['id']] = $row;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE is_record=0 and start_time < " . (strtotime(date('Y-m-d', TIMENOW)) + 86399);
     $record_info = $channel_info = $item_info = array();
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $channel_info[$row['channel_id']] = $row['channel_id'];
         $item_info[$row['item']] = $row['item'];
         $record_info[] = $row;
     }
     if (empty($record_info)) {
         return '';
     }
     $channel = array();
     if (!empty($channel_info)) {
         $channel_ids = implode(',', $channel_info);
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel_tmp = $newLive->getChannelInfoById(array('id' => $channel_ids, 'is_stream' => 1, 'live' => 1, 'is_sys' => -1, 'fetch_live' => 1));
         foreach ($channel_tmp as $k => $v) {
             $channel[$v['id']] = $v;
         }
         if (empty($channel)) {
             return '';
         }
     }
     if (!empty($item_info)) {
         include_once ROOT_PATH . 'lib/class/livmedia.class.php';
         $livmedia = new livmedia();
         $item_info = $livmedia->getAutoItem();
     }
     include_once ROOT_PATH . 'lib/class/program.class.php';
     $program_plan = new program();
     foreach ($record_info as $k => $row) {
         if (empty($server_config[$row['server_id']])) {
             continue;
         }
         $check_server = $this->checkServer($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'] . $server_config[$row['server_id']]['dir']);
         if (!$check_server) {
             continue;
         }
         $channel_tmp = $channel[$row['channel_id']];
         $row['code'] = $channel_tmp['code'];
         $row['name'] = $channel_tmp['name'];
         $row['is_audio'] = $channel_tmp['is_audio'];
         $row['save_time'] = $channel_tmp['time_shift'];
         $row['main_stream_name'] = $channel_tmp['main_stream_name'];
         $row['stream_state'] = $channel_tmp['status'];
         $row['record_time'] = $channel_tmp['record_time'];
         $row['stream_id'] = $channel_tmp['stream_id'];
         $row['sort_name'] = $row['item'] > 0 ? $item_info[$row['item']]['name'] : '';
         $return = array();
         if (!$row['channel_id']) {
             continue;
         }
         $ret = $log_data = array();
         $ret['id'] = $log_data['id'] = $row['id'];
         $ret['channel_id'] = $log_data['channel_id'] = $row['channel_id'];
         $ret['name'] = rawurlencode($row['name']);
         $ret['startTime'] = date('YmdHis', $row['start_time'] + $row['record_time'] - 1);
         $row['toff'] = $row['toff'] + 2;
         $program = $row['title'] ? $row['title'] : trim($program_plan->get_program_plan($ret['channel_id'], $ret['starttime'], $ret['endtime']));
         $ret['title'] = base64_encode(json_encode(trim($program ? $program : '精彩节目')));
         $log_data['title'] = rawurlencode(trim($program ? $program : '精彩节目'));
         $log_data['start_time'] = $row['start_time'];
         $log_data['toff'] = $row['toff'];
         $log_data['week_day'] = $row['week_day'];
         $log_data['item'] = $row['item'];
         $log_data['columnid'] = $row['columnid'];
         $log_data['column_name'] = $row['column_name'];
         $log_data['ip'] = $row['ip'];
         if (empty($channel_tmp['record_stream'])) {
             continue;
         }
         $ret['stream'] = $channel_tmp['record_uri'] ? $channel_tmp['record_uri'] : $channel_tmp['record_stream'][0]['output_url_rtmp'];
         $callback = $this->settings['App_program_record']['protocol'] . $this->settings['App_program_record']['host'] . '/' . $this->settings['App_program_record']['dir'] . 'admin/record_callback.php';
         $ret['vod_sort_id'] = $row['item'];
         $ret['week_flag'] = $row['week_day'] ? 1 : 0;
         $ret['column_id'] = $row['columnid'] ? $row['columnid'] : 0;
         $ret['audit_auto'] = $row['audit_auto'] ? 2 : 0;
         $ret['exit_status'] = $row['audit_auto'];
         $ret['save_time'] = $row['save_time'];
         //$ret['delay_time'] = $row['live_delay'] * 60;
         //$ret['source'] = $row['channel_id'];
         $ret['is_allow'] = $row['is_mark'];
         $ret['is_audio'] = $row['is_audio'];
         $ret['extend'] = base64_encode(json_encode(array('_user_id' => $row['user_id'], '_user_name' => $row['user_name'], 'org_id' => $row['org_id'], 'force_codec' => $row['force_codec'], 'source' => $row['name'], 'callback_extra' => $row['callback_extra'])));
         if (!$row['stream_state']) {
             $ret = array('errortext' => '视频流未开启!');
             $str = 'ID-' . $row['id'] . ($ret['errortext'] ? $ret['errortext'] : '录制成功');
             $this->tips($str, TIMENOW);
         } else {
             switch ($row['is_record']) {
                 case 0:
                     //录制未进行提交
                     $this->curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
                     $this->curl->setSubmitType('get');
                     $this->curl->initPostData();
                     $this->curl->addRequestData('action', 'INSERT');
                     $this->curl->addRequestData('url', $ret['stream']);
                     $this->curl->addRequestData('callback', $callback);
                     //urlencode
                     //$this->curl->addRequestData('startTime', $ret['starttime']-1);
                     $this->curl->addRequestData('duration', $row['toff']);
                     $this->curl->addRequestData('uploadFile', '0');
                     $this->curl->addRequestData('app', 'live');
                     $this->curl->addRequestData('streamname', $channel_tmp['code'] . '_' . $channel_tmp['main_stream_name']);
                     $this->curl->addRequestData('html', 1);
                     $this->curl->addRequestData('appid', $this->input['appid']);
                     $this->curl->addRequestData('appkey', $this->input['appkey']);
                     foreach ($ret as $k => $v) {
                         $this->curl->addRequestData($k, $v);
                     }
                     $ret = array();
                     $record_xml = $this->curl->request('');
                     $record_array = xml2Array($record_xml);
                     if (is_array($record_array)) {
                         $ret['id'] = $record_array['record']['id'] ? $record_array['record']['id'] : 0;
                         if (!$record_array['result']) {
                             $ret['errortext'] = '录制超时,重复提交';
                             //报错
                             $ret['isError'] = 1;
                             $ret['id'] = -1;
                         } else {
                             $ret['errortext'] = '等待录制';
                             $ret['isError'] = 0;
                         }
                     } else {
                         $ret['id'] = 0;
                         $ret['errortext'] = '录制失败,无内容!';
                         $ret['isError'] = 1;
                     }
                     $is_record = $ret['id'] ? 1 : 0;
                     $conid = $this->add_queue($row['id']);
                     if (!$ret['isError']) {
                         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=0,conid=" . $conid . ",is_record=" . $is_record . " WHERE id=" . $row['id'];
                         $this->db->query($sql_update);
                         $log_data['text'] = $ret['errortext'];
                         $log_data['state'] = $ret['isError'] ? 2 : 0;
                         $log_id = $this->record->addLogs($log_data);
                         $this->update_queue($conid, $log_id);
                     } else {
                         $week_day = unserialize($row['week_day']);
                         $select_curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
                         $select_curl->setSubmitType('get');
                         $select_curl->initPostData();
                         $select_curl->addRequestData('action', 'SELECT');
                         $select_curl->addRequestData('id', $row['id']);
                         $select_record = $this->curl->request('');
                         $select_array = xml2Array($select_record);
                         if (is_array($select_array)) {
                             if (!$select_array['result']) {
                                 if (is_array($week_day) && $week_day) {
                                     $week_now = date('N', $row['start_time']);
                                     $new_arr = array_flip($week_day);
                                     if (count($week_day) > $new_arr[$week_now] + 1) {
                                         $ks = $new_arr[$week_now] + 1;
                                     } else {
                                         $ks = 0;
                                     }
                                     $week_day = array_flip($new_arr);
                                     $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
                                     $start_time = $row['start_time'] + $next_week * 86400;
                                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET conid=0,is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
                                     $this->db->query($sql_update);
                                 } else {
                                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=1,conid=0,is_record=1 WHERE id=" . $row['id'];
                                     $this->db->query($sql_update);
                                 }
                             } else {
                             }
                         }
                         $log_data['text'] = $ret['errortext'];
                         $log_data['state'] = 2;
                         $log_id = $this->record->addLogs($log_data);
                         $this->update_queue($conid, $log_id);
                     }
                     $str = 'ID-' . $row['id'] . ($ret['errortext'] ? $ret['errortext'] : '录制成功');
                     $this->tips($str, TIMENOW);
                     break;
                 case 1:
                     //正在录制,录制超时,只处理周期性的录制超时
                     if ($row['start_time'] + $row['toff'] < TIMENOW - 120) {
                         $week_day = unserialize($row['week_day']);
                         if (is_array($week_day) && $week_day) {
                             $week_now = date('N', $row['start_time']);
                             $new_arr = array_flip($week_day);
                             if (count($week_day) > $new_arr[$week_now] + 1) {
                                 $ks = $new_arr[$week_now] + 1;
                             } else {
                                 $ks = 0;
                             }
                             $week_day = array_flip($new_arr);
                             $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
                             $start_time = $row['start_time'] + $next_week * 86400;
                             $sql_update = "UPDATE " . DB_PREFIX . "program_record SET conid=0,is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
                             $this->db->query($sql_update);
                             $str = 'ID-' . $row['id'] . '录制超时处理成功';
                             $this->tips($str, TIMENOW);
                         }
                     }
                     break;
             }
         }
     }
 }
Ejemplo n.º 14
0
 public function insertQueueToLivmediaByVideoID($tv_play_id, $video_id, $op, $column_id, $now_column, $pub_time)
 {
     /*$sql = "SELECT * FROM " .DB_PREFIX. "tv_episode WHERE tv_play_id = '" .$tv_play['id']. "' AND expand_id = 0 ";
     		$q = $this->db->query($sql);
     		$video_id_arr = array();
     		while ($r = $this->db->fetch_array($q))
     		{
     			$video_id_arr[] = $r['video_id'];
     		}*/
     if ($video_id && $tv_play_id) {
         //查询剧集信息
         $sql = "SELECT * FROM " . DB_PREFIX . "tv_episode WHERE tv_play_id = {$tv_play_id} AND video_id = {$video_id}";
         $ep_info = $this->db->query_first($sql);
         publish_insert_query($ep_info, 'insert', $column_id, 1);
         include_once ROOT_PATH . 'lib/class/livmedia.class.php';
         $livmedia = new livmedia();
         $livmedia->insertQueueToLivmedia($video_id, $op, implode(',', $column_id), $now_column, $pub_time);
     }
 }
Ejemplo n.º 15
0
 function get_item()
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     return $sort_name;
 }
Ejemplo n.º 16
0
 function getItem()
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $ret = $livmedia->getAutoItem();
     if (!empty($ret)) {
         foreach ($ret as $k => $v) {
             $this->addItem($v);
         }
         $this->output();
     }
 }
Ejemplo n.º 17
0
 public function get_item()
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     foreach ($sort_name as $k => $v) {
         $this->addItem($v);
     }
     $this->output();
 }
Ejemplo n.º 18
0
 private function video_column($id, $column_id)
 {
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $videoApi = new livmedia();
     return $videoApi->update_column($id, $column_id);
 }