Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
egg.eemo.co.kr
/
public_html
/
super5
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/egg.eemo.co.kr/public_html/super5/farm_wowza_set_do.php
<? session_cache_limiter('no-cache, must-revalidate'); session_start(); header("Pragma: no-cache"); header("Cache-Control: no-cache,must-revalidate"); header("Content-Type: text/html; charset=utf-8"); include_once("dbconn.php"); include_once("lib.php"); foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } $arr_rst=array(); $rs=RS("select * from farm_nvr where no='$nvr_no' "); $vv_mac=strtolower(str_replace(":","",$rs[nvr_sn])); $ddns = $vv_mac; $type = $rs[nvr_chan_su] + 1; function addWOWZA() { global $type, $ddns; if($type==17) { $pass="1234"; } else { $pass="11qqaa.."; } for ($i=1; $i < $type; $i++) { $chNo = "ch".$i; // $paramRtspUrl = "rtsp://172.16.0.5:554/waS89rjts=PA5V8wtb8="; $paramRtspUrl = "rtsp://admin:".$pass."@$ddns.dynlink.net/main/$chNo"; $year = "2019"; $month= "07"; $day = "29"; $hour = "01"; $minute = "00"; // $paramRtspUrl = $paramRtspUrl."&".$year."&".$month."&".$day."&".$hour."&".$minute."&00"; $paramStreamID = $ddns."ch".$i; // $streaming_url = "http://172.16.0.111:1935/live/$paramStreamID.stream/playlist.m3u8"; $streaming_url = "http://110.93.133.72:1935/live/$paramStreamID.stream/playlist.m3u8"; $rtnData = setWowza($paramStreamID, $paramRtspUrl,1); $rtnJson = json_decode($rtnData); } } // 와우자 API 요청 function callAPI($method, $url, $data="", $headers=array()) { $curl = curl_init(); switch ($method){ case "POST": curl_setopt($curl, CURLOPT_POST, 1); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; case "PUT": curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; default: if ($data) $url = sprintf("%s?%s", $url, http_build_query($data)); } // OPTIONS: curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // EXECUTE: $result = curl_exec($curl); if(!$result){die("Connection Failure");} curl_close($curl); return $result; } // 와우자 세팅 function setWowza($streamID, $rtspUri, $wowzaType = 1) { // $wowzaAddr = ["172.16.0.102", "172.16.0.111"]; $wowzaAddr = ["110.93.133.72", "110.93.133.72"]; $headers = array( "Accept:application/json", "Content-Type:application/json", "charset=utf-8" ); $ret = callAPI("PUT", "http://{$wowzaAddr[$wowzaType]}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/{$streamID}.stream/actions/disconnectStream", false, $headers); $params = [ "sourceControlDriver" => "", "advancedSettings" => [[ "sectionName" => "Common", "canRemove" => true, "defaultValue" => "null", "documented" => true, "name" => "uri", "section" => "null", "type" => "integer", "value" => $rtspUri, "enabled" => true ]], "serverName" => "_defaultServer_", "saveFieldList" => [""], "version" => "" ]; $json = json_encode($params, JSON_UNESCAPED_SLASHES); $ret = callAPI("PUT", "http://{$wowzaAddr[$wowzaType]}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/{$streamID}/adv", $json, $headers); $ret = callAPI("PUT", "http://{$wowzaAddr[$wowzaType]}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/{$streamID}/actions/connect?connectAppName=live&appInstance=_definst_&mediaCasterType=rtp", false, $headers); return $ret; } mysql_query("update farm_nvr set is_wowza='1' where no='$nvr_no' ") or die(); $arr_rst['rst']='1'; echo json_encode($arr_rst); ?>