private function set_url_wowza($server_info, $channel_info) { $wowzaip_output = $server_info['wowzaip_output']; $suffix_output = $this->settings['wowza']['output']['suffix']; $app_name = $channel_info['code']; $stream_name = $channel_info['main_stream_name'] . $suffix_output; $return = hg_set_stream_url($wowzaip_output, $app_name, $stream_name); return $return; }
public function show_opration() { $id = trim($this->input['id']); if (!$id) { $this->errorOutput('NO_ID'); } $info = $this->mChannel->detail($id); $server_id = $info['server_id']; if ($server_id) { $server_info = $this->mServerConfig->get_server_config_by_id($server_id); $info['server_name'] = $server_info['name']; } $server_info = $this->mChannel->get_server_info($server_info); $wowzaip_output = $server_info['wowzaip_output']; $suffix_output = $this->settings['wowza']['output']['suffix']; if (!empty($info['channel_stream'])) { $channel_stream = array(); foreach ($info['channel_stream'] as $v) { $v['output_url'] = hg_set_stream_url($wowzaip_output, $info['code'], $v['stream_name'] . $suffix_output, 'rtmp://'); if ($info['is_mobile_phone']) { $v['m3u8'] = hg_set_stream_url($wowzaip_output, $info['code'], $v['stream_name'] . $suffix_output, 'm3u8'); } $channel_stream[] = $v; } $info['channel_stream'] = $channel_stream; } //获取截图 $ret_img_url = $this->mChannel->get_img_url(); $img_url = ''; if (!empty($ret_img_url)) { $img_url = $ret_img_url['define']['IMG_URL']; } if (!$info['is_audio']) { $info['preview'] = $img_url . LIVE_CONTROL_LIST_PREVIEWIMG_URL . date('Y') . '/' . date('m') . '/live_' . $info['id'] . '.png?time=' . TIMENOW; } else { if ($info['logo_audio']['host']) { $info['preview'] = hg_material_link($info['logo_audio']['host'], $info['logo_audio']['dir'], $info['logo_audio']['filepath'], $info['logo_audio']['filename']); } else { if ($info['logo_rectangle']['host']) { $info['preview'] = hg_material_link($info['logo_rectangle']['host'], $info['logo_rectangle']['dir'], $info['logo_rectangle']['filepath'], $info['logo_rectangle']['filename']); } else { $info['preview'] = ''; } } } $this->addItem($info); $this->output(); }
public function set_stream_url($server_info, $channel_stream) { $type = $server_info['type']; $is_rand = $server_info['is_rand']; $wowzaip_output = $server_info['wowzaip_output']; $rtmp_output = $server_info['rtmp_output']; $live_wowzaip_output = $server_info['live_wowzaip_output']; $record_wowzaip_output = $server_info['record_wowzaip_output']; $output_append_host = $server_info['output_append_host']; $function = 'set_url_info_' . $type; $set_stream_info = $this->{$function}($server_info, $channel_stream); $app_name = $set_stream_info['app_name']; $stream_name = $set_stream_info['stream_name']; $m3u8_type = $set_stream_info['m3u8_type']; $flv_type = $set_stream_info['flv_type']; $flv = $set_stream_info['flv']; if ($set_stream_info['output_port']) { $output_port = ':' . $set_stream_info['output_port']; } if ($set_stream_info['input_port']) { $input_port = ':' . $set_stream_info['input_port']; } $server_type = $server_info['type']; $_wowzaip_output = $is_rand ? $output_append_host[@array_rand($output_append_host, 1)] . $input_port : $rtmp_output . $input_port; $output_url = hg_set_stream_url($wowzaip_output, $app_name, $stream_name, $flv, $server_type); $output_url_rtmp = hg_set_stream_url($_wowzaip_output, $app_name, $stream_name . '_' . $set_stream_info['stream_name1'], $flv_type, $server_type, '', '', 'rtmp://'); if ($channel_stream['is_mobile_phone'] || true) { if ($this->settings['signleliveaddr']) { $m3u8 = $this->settings['signleliveaddr'] . $app_name . '.stream/playlist.m3u8'; } else { $m3u8 = hg_set_stream_url($wowzaip_output, $app_name, $stream_name, $m3u8_type, $server_type, $starttime, $dvr, 'http://', '/' . $set_stream_info['stream_name1'] . '/live.m3u8'); } } //直播 if ($live_wowzaip_output && $channel_stream['is_live']) { $live_url = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name, $flv, $server_type); $live_url_rtmp = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name . '_' . $set_stream_info['stream_name1'], $flv_type, $server_type, '', '', 'rtmp://'); if ($channel_stream['is_mobile_phone']) { if ($this->settings['signleliveaddr']) { $live_m3u8 = $this->settings['signleliveaddr'] . $app_name . '.stream/playlist.m3u8'; } else { $live_m3u8 = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name, $m3u8_type, $server_type); } } } else { $live_url = $output_url; $live_url_rtmp = $output_url_rtmp; $live_m3u8 = hg_set_stream_url($wowzaip_output, $app_name, $stream_name, $m3u8_type, $server_type, $starttime, $dvr); } //录制 $record_stream = array(); if ($record_wowzaip_output && $channel_stream['is_record']) { $record_stream['output_url'] = hg_set_stream_url($record_wowzaip_output, $app_name, $stream_name, $flv, $server_type); $record_stream['output_url_rtmp'] = hg_set_stream_url($record_wowzaip_output, $app_name, $stream_name . '_' . $set_stream_info['stream_name1'], $flv_type, $server_type, '', '', 'rtmp://'); if ($channel_stream['is_mobile_phone']) { if ($this->settings['signleliveaddr']) { $record_stream['m3u8'] = $this->settings['signleliveaddr'] . $app_name . '.stream/playlist.m3u8'; } else { $record_stream['m3u8'] = hg_set_stream_url($record_wowzaip_output, $app_name, $stream_name, $m3u8_type, $server_type); } } } else { $record_stream['output_url'] = $output_url; $record_stream['output_url_rtmp'] = $output_url_rtmp; $record_stream['m3u8'] = $m3u8; } $return = array('channel_stream' => array('output_url' => $output_url, 'output_url_rtmp' => $output_url_rtmp, 'm3u8' => $m3u8, 'live_url' => $live_url, 'live_url_rtmp' => $live_url_rtmp, 'live_m3u8' => $live_m3u8), 'record_stream' => $record_stream); return $return; }
/** * 直播频道对外输出接口 * Enter description here ... */ public function channels() { $condition = $this->get_condition(); $offset = $this->input['offset'] ? intval($this->input['offset']) : 0; $count = $this->input['count'] ? intval($this->input['count']) : 20; $appid = intval($this->input['appid']); if ($this->settings['App_live_takeover'] && !$this->input['fetch_live']) { $channel_id = trim($this->input['id']); if (!$channel_id) { $channel_id = trim($this->input['channel_id']); } $data = array('offset' => $offset, 'count' => $count, 'channel_id' => $channel_id); $channel_info = $this->get_live_takeover_info($data); } else { $field = 'id, name, code, main_stream_name, is_mobile_phone, logo_square, logo_rectangle, server_id, is_audio, status, drm, client_logo, time_shift, is_live, is_record, logo_audio, aspect'; $channel_info = $this->mChannel->get_channel_info($condition, $offset, $count, '', $field); } if (!empty($channel_info)) { $server_id = array(); foreach ($channel_info as $channel) { $server_id[] = $channel['server_id']; } //服务器配置 if (!empty($server_id)) { $server_id = implode(',', @array_unique($server_id)); $_server_info = $this->mServerConfig->get_server_config($server_id); } if ($this->settings['App_live_takeover'] && !$this->input['fetch_live']) { foreach ($channel_info as $channel) { $logo = array('rectangle' => $channel['logo_rectangle'], 'square' => $channel['logo_rectangle']); //节目单 $program_info = $this->mProgram->getCurrentNextProgram($channel['id']); $cur_program = array('start_time' => $program_info[0]['start'] ? $program_info[0]['start'] : date('H:i'), 'program' => $program_info[0]['theme'] ? $program_info[0]['theme'] : '精彩节目'); $next_program = array('start_time' => $program_info[1]['start'] ? $program_info[1]['start'] : date('H:i', TIMENOW + 3600), 'program' => $program_info[1]['theme'] ? $program_info[1]['theme'] : '精彩节目'); $m3u8 = $channel['channel_stream'][0]['m3u8']; $channel_stream = array(); if (!empty($channel['channel_stream'])) { foreach ($channel['channel_stream'] as $kk => $vv) { $channel_stream[$kk] = array('url' => $vv['output_url'], 'm3u8' => $vv['m3u8'], 'bitrate' => $vv['bitrate'], 'live_url' => $vv['live_url'], 'live_m3u8' => $vv['live_m3u8']); } } $record_stream = array(); if (!empty($channel['record_stream'])) { foreach ($channel['record_stream'] as $kk => $vv) { $record_stream[$kk] = array('url' => $vv['output_url'], 'm3u8' => $vv['m3u8']); } } $return = array('id' => $channel['id'], 'name' => $channel['name'], 'logo' => $logo, 'snap' => $channel['snap'], 'm3u8' => $m3u8, 'cur_program' => $cur_program, 'save_time' => $channel['time_shift'], 'next_program' => $next_program, 'audio_only' => $channel['is_audio'], 'aspect' => $channel['aspect'], 'cmid' => $channel['cmid'], 'channel_stream' => $channel_stream, 'record_stream' => $record_stream); if (($this->input['id'] || $this->input['channel_id']) && $return['id'] && $this->user['user_id'] && $this->input['iscreditsrule']) { $credit_rules = $this->callMemberCreditsRules($this->user['user_id'], APP_UNIQUEID, MOD_UNIQUEID, 0, $return['id']); /**积分文案处理**/ $return['copywriting_credit'] = $this->members->copywriting_credit(array($credit_rules)); } $this->addItem($return); } } else { foreach ($channel_info as $channel) { $type = $_server_info[$channel['server_id']]['type'] ? $_server_info[$channel['server_id']]['type'] : 'wowza'; $server_info = $this->mChannel->get_server_info($_server_info[$channel['server_id']]); $channel['server_info'] = $server_info; $wowzaip_output = $server_info['wowzaip_output']; //直播 $live_wowzaip_output = $server_info['live_wowzaip_output']; //录制 $record_wowzaip_output = $server_info['record_wowzaip_output']; if ($channel['client_logo'][$appid]) { unset($channel['client_logo'][$appid]['appid'], $channel['client_logo'][$appid]['appname']); $channel['logo_rectangle'] = $channel['client_logo'][$appid]; } $logo = array('rectangle' => $channel['logo_rectangle'], 'square' => $channel['logo_rectangle']); $snap = array('host' => $this->mImgUrl . LIVE_CONTROL_LIST_PREVIEWIMG_URL, 'dir' => '', 'filepath' => date('Y') . '/' . date('m') . '/', 'filename' => 'live_' . $channel['id'] . '.png?time=' . TIMENOW); if ($channel['is_audio']) { if ($channel['logo_audio']) { $snap = $channel['logo_audio']; } else { $snap = $channel['logo_rectangle']; } } $channel_stream = $record_stream = array(); if ($channel['channel_stream']) { foreach ($channel['channel_stream'] as $kk => $vv) { if ($channel['m3u8_stream_name']) { $stream_n = $channel['m3u8_stream_name']; } else { $stream_n = $channel['main_stream_name']; } $vv['code'] = $channel['code']; $function = 'set_url_info_' . $type; $set_url_info = $this->mChannel->{$function}(array(), $vv); $app_name = $set_url_info['app_name']; $stream_name = $set_url_info['stream_name']; $m3u8_type = $set_url_info['m3u8_type']; $flv = $set_url_info['flv']; $url = hg_set_stream_url($wowzaip_output, $app_name, $stream_name, $flv); if ($channel['is_mobile_phone']) { if ($this->settings['signleliveaddr']) { $m3u8 = $this->settings['signleliveaddr'] . $channel['code'] . '.stream/playlist.m3u8'; } else { $m3u8 = hg_set_stream_url($wowzaip_output, $app_name, $stream_name, $m3u8_type, '', '', '', 'http://', '/' . $vv['stream_name'] . '/live.m3u8'); } if ($live_wowzaip_output && $channel['is_live']) { $m3u8 = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name, $m3u8_type); } } //直播 if ($live_wowzaip_output && $channel['is_live']) { $live_url = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name, $flv); if ($channel['is_mobile_phone']) { if ($this->settings['signleliveaddr']) { $live_m3u8 = $this->settings['signleliveaddr'] . $channel['code'] . '.stream/playlist.m3u8'; } else { $live_m3u8 = hg_set_stream_url($live_wowzaip_output, $app_name, $stream_name, $m3u8_type); } } } else { $live_url = $url; $live_m3u8 = $m3u8; } //录制 if ($record_wowzaip_output && $channel['is_record']) { $record_stream[$kk]['url'] = hg_set_stream_url($record_wowzaip_output, $app_name, $stream_name, $flv); if ($channel['is_mobile_phone']) { if ($this->settings['signleliveaddr']) { $record_stream[$kk]['m3u8'] = $this->settings['signleliveaddr'] . $channel['code'] . '.stream/playlist.m3u8'; } else { $record_stream[$kk]['m3u8'] = hg_set_stream_url($record_wowzaip_output, $app_name, $stream_name, $m3u8_type); } } } else { $record_stream[$kk]['url'] = $url; $record_stream[$kk]['m3u8'] = $m3u8; } $bitrate = $vv['bitrate']; $channel_stream[] = array('url' => $url, 'name' => $vv['name'], 'stream_name' => $vv['stream_name'], 'm3u8' => $m3u8, 'bitrate' => $bitrate); } } //节目单 $program_info = $this->mProgram->getCurrentNextProgram($channel['id']); $cur_program = array('start_time' => $program_info[0]['start'] ? $program_info[0]['start'] : date('H:i'), 'program' => $program_info[0]['theme'] ? $program_info[0]['theme'] : '精彩节目'); $next_program = array('start_time' => $program_info[1]['start'] ? $program_info[1]['start'] : date('H:i', TIMENOW + 3600), 'program' => $program_info[1]['theme'] ? $program_info[1]['theme'] : '精彩节目'); $return = array('id' => $channel['id'], 'name' => $channel['name'], 'logo' => $logo, 'snap' => $snap, 'm3u8' => $url, 'cur_program' => $cur_program, 'save_time' => $channel['time_shift'], 'next_program' => $next_program, 'audio_only' => $channel['is_audio'], 'aspect' => $channel['aspect'], 'cmid' => $channel['cmid'], 'channel_stream' => $channel_stream); if (($this->input['id'] || $this->input['channel_id']) && $return['id'] && $this->user['user_id'] && $this->input['iscreditsrule']) { $credit_rules = $this->callMemberCreditsRules($this->user['user_id'], APP_UNIQUEID, MOD_UNIQUEID, 0, $return['id']); /**积分文案处理**/ $return['copywriting_credit'] = $this->members->copywriting_credit(array($credit_rules)); } //统计 if ($this->input['need_access']) { include_once ROOT_PATH . 'lib/class/access.class.php'; $access_obj = new access(); $ret = $access_obj->add_access($return['id'], 0, APP_UNIQUEID, MOD_UNIQUEID, $return['name']); } if ($this->input['ad_group']) { $return['ad'] = $this->getAds($this->input['ad_group'], $return); } $this->addItem($return); } } } $this->output(); }
/** * 更新备播频道字段 * Enter description here ... * @param int $channel_id 频道id * @param string $beibo_id 备播频道id */ public function update_beibo() { $channel_id = intval($this->input['channel_id']); $change_id = intval($this->input['change_id']); $stream_id = intval($this->input['stream_id']); $beibo_id = trim($this->input['beibo_id']); if (!$channel_id) { $this->errorOutput('未传入频道id'); } if (!$change_id) { $this->errorOutput('未传入备播频道id'); } if (!$stream_id) { $this->errorOutput('未传入备播信号id'); } if (!$beibo_id) { $this->errorOutput('未传入备播id'); } $channel_data = array('id' => $channel_id, 'is_stream' => 0, 'is_server' => 1, 'field' => ' * '); $channel_info = $this->mLive->getChannelInfoById($channel_data); $channel_info = $channel_info[0]; if (empty($channel_info)) { $this->errorOutput('该频道不存在或已被删除'); } $change_data = array('id' => $change_id, 'is_stream' => 1, 'is_server' => 0, 'field' => ' * '); $change_info = $this->mLive->getChannelInfoById($change_data); $change_info = $change_info[0]; if (empty($change_info) || empty($change_info['channel_stream'])) { $this->errorOutput('备播频道不存在或已被删除'); } $stream_info = $this->mLiveControl->get_live_control_by_id($stream_id); if (empty($stream_info) || !$stream_info['input_id']) { $this->errorOutput('备播信号不存在或已被删除'); } $server_info = $channel_info['server_info']; $host = $server_info['host']; $input_dir = $server_info['input_dir']; $wowzaip_input = $server_info['wowzaip_input']; $app_name_input = $this->settings['wowza']['input']['app_name']; $suffix_input = $this->settings['wowza']['input']['suffix']; $wowzaip_output = $server_info['wowzaip_output']; $suffix_output = $this->settings['wowza']['output']['suffix']; $output_append_host = $server_info['output_append_host']; $input_id = $stream_info['input_id']; if (!$input_id) { $this->errorOutput('备播信号id不存在或已被删除'); } //被选择频道作为输入信号地址 $stream_name = $change_info['channel_stream'][0]['stream_name']; $url = hg_set_stream_url($wowzaip_output, $change_info['code'], $stream_name . $suffix_output); $input_data = array('action' => 'update', 'id' => $input_id, 'url' => $url); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); if (!$ret_input['result']) { $this->errorOutput('更新备播信号失败'); } $input_data = array('action' => 'start', 'id' => $input_id); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); if (!$ret_input['result']) { $this->errorOutput('备播信号重启失败'); } //输入的输出地址 $input_url = hg_set_stream_url($wowzaip_input, $app_name_input, $input_id . $suffix_input); $data_stream = array('id' => $stream_id, 'stream_name' => $stream_name, 'url' => $url, 'change_id' => $change_info['id'], 'change_name' => $change_info['name']); $ret_stream = $this->mLiveControl->update($data_stream); if (empty($ret_stream)) { $this->errorOutput('更新备播信号失败'); } //更新频道里备播信号字段 $data_channel = array('id' => $channel_id, 'beibo' => $beibo_id); $ret_channel = $this->mLive->updateBeibo($data_channel); if (empty($ret_channel)) { $this->errorOutput('更新备播信息失败'); } //记录日志 $pre_data = array('id' => $channel_info['id'], 'beibo' => $channel_info['beibo']); $up_data = $data_channel; $this->addLogs('更新备播信号', $pre_data, $up_data, $channel_info['name'], $channel_info['id']); $ret = array('id' => $stream_info['id'], 'change_id' => $change_info['id'], 'change_name' => $change_info['name'], 'stream_name' => $stream_name, 'input_id' => $input_id, 'input_url' => $input_url); $this->addItem($ret); $this->output(); }
/** * 创建备播信号 * Enter description here ... * @param unknown_type $data */ private function input_stream_create($data) { $host = $data['host']; $input_dir = $data['input_dir']; $wowzaip_input = $data['wowzaip_input']; $app_name_input = $data['app_name_input']; $suffix_input = $data['suffix_input']; $channel_id = $data['channel_id']; $channel_name = $data['channel_name']; $server_id = $data['server_id']; $channel_beibo = $data['channel_beibo']; if (empty($channel_beibo)) { return false; } $ret_input_id = $input_stream = array(); foreach ($channel_beibo as $k => $v) { if (!empty($v['channel_stream']) && $v['channel_stream'][0]['output_url_rtmp']) { if ($v['_stream_id'] && $v['_input_id']) { $ret_input_id[$k] = $v['_input_id']; } if (!$v['_input_id'] || !$v['_stream_id']) { $input_data = array('action' => 'insert', 'url' => $v['channel_stream'][0]['output_url_rtmp'], 'type' => 0); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); $ret_input_id[$k] = $ret_input['input']['id']; if (!$ret_input['result']) { continue; } } $input_stream[$k] = array('channel_id' => $channel_id, 'channel_name' => $channel_name, 'change_id' => $v['id'], 'change_name' => $v['name'], 'stream_name' => $v['channel_stream'][0]['stream_name'], 'url' => $v['channel_stream'][0]['output_url_rtmp'], 'input_id' => $ret_input_id[$k], '_stream_id' => $v['_stream_id']); } } //创建信号过程中有失败的,则删除已创建好的信号 $tmp_insert = 0; foreach ($ret_input_id as $k => $v) { if (!$v) { $tmp_insert = 1; } } if ($tmp_insert) { foreach ($input_stream as $v) { if ($v['input_id'] && !$v['_stream_id']) { $input_data = array('action' => 'delete', 'id' => $v['input_id']); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); } } return -1; //('切播频道数据异常,正在返回直播'); } $ret_start = array(); foreach ($input_stream as $k => $v) { if ($v['input_id']) { if (!$v['_stream_id']) { $input_data = array('action' => 'start', 'id' => $v['input_id']); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); $ret_start[$k] = $ret_input['result']; if (!$ret_input['result']) { continue; } } if ($v['_stream_id']) { $ret_start[$k] = 1; } } } //信号启动过程中有失败的,则停止已启动好的信号 $tmp_start = 0; foreach ($ret_start as $k => $v) { if (!$v) { $tmp_start = 1; } } if ($tmp_start) { foreach ($input_stream as $v) { if ($v['input_id'] && !$v['_stream_id']) { $input_data = array('action' => 'stop', 'id' => $v['input_id']); $ret_input = $this->mLivemms->inputStreamOperate($host, $input_dir, $input_data); } } return -2; //('切播频道启动失败,正在返回直播'); } $return = array(); foreach ($input_stream as $k => $v) { if (!empty($v)) { $return[$k]['change_id'] = $v['change_id']; $return[$k]['change_name'] = $v['change_name']; $return[$k]['stream_name'] = $v['stream_name']; $return[$k]['input_id'] = $v['input_id']; $return[$k]['input_url'] = hg_set_stream_url($wowzaip_input, $app_name_input, $v['input_id'] . $suffix_input); $v['server_id'] = $server_id; $v['user_id'] = $this->user['user_id']; $v['user_name'] = $this->user['user_name']; $v['appid'] = $this->user['appid']; $v['appname'] = $this->user['display_name']; $v['create_time'] = TIMENOW; $v['update_time'] = TIMENOW; $v['start_time'] = TIMENOW; $v['ip'] = hg_getip(); if (!$v['_stream_id']) { unset($v['_stream_id']); $ret = $this->mLiveControl->create($v); if (!$ret) { continue; } $return[$k]['id'] = $ret['id']; } if ($v['_stream_id']) { $return[$k]['id'] = $v['_stream_id']; } } } return $return; }
private function edit_stream_tvie($server_info, $channel_stream) { $host = $server_info['host']; $input_dir = $server_info['input_dir']; $output_dir = $server_info['output_dir']; $wowzaip_input = $server_info['wowzaip_input']; $live_host = $server_info['live_host']; $record_host = $server_info['record_host']; $code = $channel_stream['code']; $delay = $channel_stream['delay']; $is_control = $channel_stream['is_control']; $is_push = $channel_stream['is_push']; $url = $channel_stream['url']; $output_url = $url; $applicationId = $channel_stream['applicationId']; $stream_name = $channel_stream['stream_name']; $is_live = $channel_stream['is_live']; $is_record = $channel_stream['is_record']; $time_shift = $channel_stream['time_shift']; $status = $channel_stream['status']; $stream_type = $is_push ? 'push' : 'pull'; $app_name = $this->settings['tvie']['app_name'] ? $this->settings['tvie']['app_name'] : 'live'; $return = array('ret_input_id' => 0, 'ret_delay_id' => 0, 'ret_change_id' => 0, 'ret_output_id' => 0, 'ret_live_output_id' => 0, 'ret_record_output_id' => 0); $tvie_data = array('type' => $stream_type, 'code' => $code, 'save_time' => $time_shift, 'is_audio' => $channel_stream['is_audio']); //流名称后缀 $stream_name_suffix = $code . '_' . $stream_name; $file = 'edit'; //输入层 if ($delay || $is_control) { $tvie_data['stream_name'] = 'input_' . $stream_name_suffix; $tvie_data['url'] = $output_url; $ret_tvie = $this->tvieLiveEdit($host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_input_id'] = $tvie_data['stream_name']; $input_url = hg_set_stream_url($wowzaip_input, $app_name, $tvie_data['stream_name'], 'flv'); $output_url = $input_url; } //延时层 if ($delay) { $tvie_data['stream_name'] = 'delay_' . $stream_name_suffix; $tvie_data['url'] = $output_url; $ret_tvie = $this->tvieLiveEdit($host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_delay_id'] = $tvie_data['stream_name']; $delay_url = hg_set_stream_url($wowzaip_input, $app_name, $tvie_data['stream_name'], 'flv'); $output_url = $delay_url; } //切播层 if ($is_control) { $tvie_data['stream_name'] = 'change_' . $stream_name_suffix; $tvie_data['url'] = $output_url; $ret_tvie = $this->tvieLiveEdit($host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_change_id'] = $tvie_data['stream_name']; $change_url = hg_set_stream_url($wowzaip_input, $app_name, $tvie_data['stream_name'], 'flv'); $output_url = $change_url; } //输出层 $tvie_data['stream_name'] = 'output_' . $stream_name_suffix; $tvie_data['url'] = $output_url; $ret_tvie = $this->tvieLiveEdit($host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_output_id'] = $tvie_data['stream_name']; if ($status) { $tvie_data['api_token'] = $this->mApiToken; $ret_tvie = $this->mTvie->liveOperate($host, $input_dir . $tvie_data['stream_name'] . '/', 'restart', $tvie_data); } //直播 if ($live_host) { //输出层 $tvie_data = array('type' => $stream_type, 'code' => $code, 'save_time' => 0, 'is_audio' => $channel_stream['is_audio']); $tvie_data['stream_name'] = 'output_' . $stream_name_suffix; $tvie_data['url'] = $url; if (!$is_live) { $file = 'add'; } $ret_tvie = $this->tvieLiveEdit($live_host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_live_output_id'] = $tvie_data['stream_name']; } //录制 if ($record_host) { //输出层 $tvie_data = array('type' => $stream_type, 'code' => $code, 'save_time' => 0, 'is_audio' => $channel_stream['is_audio']); $tvie_data['stream_name'] = 'output_' . $stream_name_suffix; $tvie_data['url'] = $url; if (!$is_record) { $file = 'add'; } $ret_tvie = $this->tvieLiveEdit($record_host, $input_dir, $file, $tvie_data); if ($ret_tvie['result'] != 'ok') { return $return; } $return['ret_record_output_id'] = $tvie_data['stream_name']; } return $return; }