/** * 信号流状态 (1-启动 0-停止) * @name stream_status * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $id int 频道ID * @return $tip array (stream_status:1-->启动, 2-->停止, 0-->操作失败) * @include tvie_api.php */ public function stream_status() { $id = intval($this->input['id']); if (!$id) { $this->errorOutput('未传入频道信号ID'); } $sql = "SELECT ch_id,s_status FROM " . DB_PREFIX . "stream WHERE id=" . $id; $ret = $this->db->query_first($sql); $ch_id = $ret['ch_id']; $status = $ret['s_status']; if ($this->settings['tvie']['open']) { include CUR_CONF_PATH . 'lib/tvie_api.php'; $tvie_api = new TVie_api($this->settings['tvie']['up_stream_server']); $channel_info = $tvie_api->get_channel_by_id($ch_id); //查询的频道信息 $stream_info = $channel_info['channel']['streams']; } $new_status = ""; if (!$status) { $sql = "UPDATE " . DB_PREFIX . "stream SET s_status = 1 WHERE id=" . $id; if ($stream_info) { foreach ($stream_info as $key => $value) { $ret_stream = $tvie_api->start_stream($value['id']); } if ($ret_stream['message'] == 'Handled') { $new_status = 1; } else { $new_status = 0; } } } else { $sql = "UPDATE " . DB_PREFIX . "stream SET s_status = 0 WHERE id=" . $id; if ($stream_info) { foreach ($stream_info as $key => $value) { $ret_stream = $tvie_api->stop_stream($value['id']); } if ($ret_stream['message'] == 'Handled') { $new_status = 2; } else { $new_status = 0; } } } if ($this->db->query($sql)) { $tip = array('stream_status' => $new_status); $this->addItem($tip); $this->output(); } else { $this->errorOutput(); } }
/** * 信号流状态 (1-启动 0-停止) * @name stream_state * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $id int 频道ID * @return $tip array (status:1-->启动, 2-->停止, 0-->操作失败) * @include tvie_api.php */ public function stream_state() { $id = intval($this->input['id']); if (!$id) { $this->errorOutput('该频道不存在或已被删除'); } else { $updsql = "UPDATE " . DB_PREFIX . "channel SET chg2_stream_id=" . 0 . " WHERE id=" . $id; $this->db->query($updsql); } $sql = "SELECT delay_id,chg_id,ch_id,stream_state,level,uri_in_num FROM " . DB_PREFIX . "channel WHERE id=" . $id; $ret = $this->db->query_first($sql); $delay_id = $ret['delay_id']; $chg_id = $ret['chg_id']; $out_id = $ret['ch_id']; $stream_state = $ret['stream_state']; $level = $ret['level']; $uri_in_num = $ret['uri_in_num']; if ($this->settings['tvie']['open']) { include CUR_CONF_PATH . 'lib/tvie_api.php'; //延时层 $delay_tvie = new TVie_api($this->settings['tvie']['up_stream_server']); $delay_channel_info = $delay_tvie->get_channel_by_id($delay_id); $delay_stream_info = $delay_channel_info['channel']['streams']; //切播层 $chg_tvie = $delay_tvie; $chg_channel_info = $chg_tvie->get_channel_by_id($chg_id); $chg_stream_info = $chg_channel_info['channel']['streams']; //输出层 $out_tvie = new TVie_api($this->settings['tvie']['stream_server']); $out_channel_info = $out_tvie->get_channel_by_id($out_id); $out_stream_info = $out_channel_info['channel']['streams']; } $new_stream_state = ""; if (!$stream_state) { $sql = "UPDATE " . DB_PREFIX . "channel SET stream_state = 1 WHERE id=" . $id; if ($level == 2 && $chg_stream_info) { foreach ($chg_stream_info as $value) { $ret_chg = $chg_tvie->start_stream($value['id']); } } if ($level == 3 && $delay_stream_info && $chg_stream_info) { foreach ($delay_stream_info as $value) { $ret_delay = $delay_tvie->start_stream($value['id']); } foreach ($chg_stream_info as $value) { $ret_chg = $chg_tvie->start_stream($value['id']); } } if ($out_stream_info) { foreach ($out_stream_info as $value) { $ret_out = $out_tvie->start_stream($value['id']); } } if ($ret_delay['message'] == 'Handled' || $ret_chg['message'] == 'Handled' || $ret_out['message'] == 'Handled') { $new_stream_state = 1; } else { $new_stream_state = 0; } } else { $sql = "UPDATE " . DB_PREFIX . "channel SET stream_state = 0 WHERE id=" . $id; if ($level == 2 && $chg_stream_info) { foreach ($chg_stream_info as $value) { $ret_chg = $chg_tvie->stop_stream($value['id']); } } if ($level == 3 && $delay_stream_info && $chg_stream_info) { foreach ($delay_stream_info as $value) { $ret_delay = $delay_tvie->stop_stream($value['id']); } foreach ($chg_stream_info as $value) { $ret_chg = $chg_tvie->stop_stream($value['id']); } } if ($out_stream_info) { foreach ($out_stream_info as $value) { $ret_out = $out_tvie->stop_stream($value['id']); } } if ($ret_delay['message'] == 'Handled' || $ret_chg['message'] == 'Handled' || $ret_out['message'] == 'Handled') { $new_stream_state = 2; } else { $new_stream_state = 0; } } if ($this->db->query($sql)) { $tip = array('status' => $new_stream_state); $this->addItem($tip); $this->output(); } else { $this->errorOutput(); } }