Commit 26076f43 by 冷斌

update

parent 272ae615
...@@ -9,31 +9,31 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -9,31 +9,31 @@ class Api_Linkmic extends PhalApi_Api {
'token' => array('name' => 'token', 'type' => 'string','require' => true, 'desc' => '用户Token'), 'token' => array('name' => 'token', 'type' => 'string','require' => true, 'desc' => '用户Token'),
'ismic' => array('name' => 'ismic', 'type' => 'int', 'require' => true, 'desc' => '连麦开关,0关1开'), 'ismic' => array('name' => 'ismic', 'type' => 'int', 'require' => true, 'desc' => '连麦开关,0关1开'),
), ),
'isMic' => array( 'isMic' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'liveuid' => array('name' => 'liveuid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '主播ID'), 'liveuid' => array('name' => 'liveuid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '主播ID'),
), ),
'RequestLVBAddrForLinkMic' => array( 'RequestLVBAddrForLinkMic' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
), ),
'RequestPlayUrlWithSignForLinkMic' => array( 'RequestPlayUrlWithSignForLinkMic' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'originStreamUrl' => array('name' => 'originStreamUrl', 'type' => 'string', 'require' => true, 'desc' => '流地址'), 'originStreamUrl' => array('name' => 'originStreamUrl', 'type' => 'string', 'require' => true, 'desc' => '流地址'),
), ),
'MergeVideoStream' => array( 'MergeVideoStream' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'mergeparams' => array('name' => 'mergeparams', 'type' => 'string', 'require' => true, 'desc' => '混流参数'), 'mergeparams' => array('name' => 'mergeparams', 'type' => 'string', 'require' => true, 'desc' => '混流参数'),
), ),
); );
} }
/** /**
* 设置连麦开关 * 设置连麦开关
* @desc 用于 用户设置当前直播的连麦开关 * @desc 用于 用户设置当前直播的连麦开关
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].pushurl 推流地址 * @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址 * @return string info[].playurl 播流地址
...@@ -42,7 +42,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -42,7 +42,7 @@ class Api_Linkmic extends PhalApi_Api {
public function setMic() { public function setMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$token=checkNull($this->token); $token=checkNull($this->token);
$ismic=checkNull($this->ismic); $ismic=checkNull($this->ismic);
...@@ -52,40 +52,40 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -52,40 +52,40 @@ class Api_Linkmic extends PhalApi_Api {
$rs['msg'] = '您的登陆状态失效,请重新登陆!'; $rs['msg'] = '您的登陆状态失效,请重新登陆!';
return $rs; return $rs;
} }
$domain = new Domain_Linkmic(); $domain = new Domain_Linkmic();
$result = $domain->setMic($uid,$ismic); $result = $domain->setMic($uid,$ismic);
$rs['msg']='设置成功'; $rs['msg']='设置成功';
return $rs; return $rs;
} }
/** /**
* 判断主播是否开启连麦 * 判断主播是否开启连麦
* @desc 用于 判断主播是否开启连麦 * @desc 用于 判断主播是否开启连麦
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function isMic() { public function isMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$liveuid=checkNull($this->liveuid); $liveuid=checkNull($this->liveuid);
$configpri=getConfigPri(); $configpri=getConfigPri();
$mic_limit=$configpri['mic_limit']; $mic_limit=$configpri['mic_limit'];
$userinfo=getUserinfo($uid); $userinfo=getUserinfo($uid);
if($mic_limit && $userinfo['level']<$mic_limit){ if($mic_limit && $userinfo['level']<$mic_limit){
$rs['code'] = 1002; $rs['code'] = 1002;
$rs['msg'] = "用户等级达到{$mic_limit}级才可与主播连麦哦~"; $rs['msg'] = "用户等级达到{$mic_limit}级才可与主播连麦哦~";
return $rs; return $rs;
} }
$domain = new Domain_Linkmic(); $domain = new Domain_Linkmic();
$result = $domain->isMic($liveuid); $result = $domain->isMic($liveuid);
...@@ -95,14 +95,14 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -95,14 +95,14 @@ class Api_Linkmic extends PhalApi_Api {
return $rs; return $rs;
} }
return $rs; return $rs;
} }
/** /**
* 获取连麦推拉流地址 * 获取连麦推拉流地址
* @desc 用于 获取连麦推拉流地址 * @desc 用于 获取连麦推拉流地址
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].pushurl 推流地址 * @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址 * @return string info[].playurl 播流地址
...@@ -112,7 +112,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -112,7 +112,7 @@ class Api_Linkmic extends PhalApi_Api {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$configpri = getConfigPri(); $configpri = getConfigPri();
$nowtime=time(); $nowtime=time();
$stream=$uid.'_'.$nowtime; $stream=$uid.'_'.$nowtime;
$live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK $live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK
...@@ -124,7 +124,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -124,7 +124,7 @@ class Api_Linkmic extends PhalApi_Api {
$now_time2 = $nowtime + 3*60*60; $now_time2 = $nowtime + 3*60*60;
$txTime = dechex($now_time2); $txTime = dechex($now_time2);
$live_code = $stream ; $live_code = $stream ;
$txSecret = md5($push_url_key . $live_code . $txTime); $txSecret = md5($push_url_key . $live_code . $txTime);
...@@ -133,7 +133,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -133,7 +133,7 @@ class Api_Linkmic extends PhalApi_Api {
$push_url = "rtmp://" . $push . "/live/" . $live_code . "?bizid=" . $bizid .$safe_url; $push_url = "rtmp://" . $push . "/live/" . $live_code . "?bizid=" . $bizid .$safe_url;
$play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url; $play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url;
}else if($configpri['cdn_switch']==5) }else if($configpri['cdn_switch']==5)
{ {
$wyinfo=PrivateKeyA('rtmp',$stream,1); $wyinfo=PrivateKeyA('rtmp',$stream,1);
...@@ -144,49 +144,49 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -144,49 +144,49 @@ class Api_Linkmic extends PhalApi_Api {
$push_url=PrivateKeyA('rtmp',$stream,1); $push_url=PrivateKeyA('rtmp',$stream,1);
$play_url=PrivateKeyA('rtmp',$stream,0); $play_url=PrivateKeyA('rtmp',$stream,0);
} }
$info=array( $info=array(
"pushurl" => $push_url, "pushurl" => $push_url,
"timestamp" => $nowtime, "timestamp" => $nowtime,
"playurl" => $play_url "playurl" => $play_url
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
/** /**
* 获取鉴权流地址 * 获取鉴权流地址
* @desc 用于鉴权流地址 * @desc 用于鉴权流地址
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].streamUrlWithSignature 鉴权地址 * @return string info[].streamUrlWithSignature 鉴权地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function RequestPlayUrlWithSignForLinkMic() { public function RequestPlayUrlWithSignForLinkMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$originalUrl=checkNull($this->originStreamUrl); $originalUrl=checkNull($this->originStreamUrl);
$configpri = getConfigPri(); $configpri = getConfigPri();
$bizid = $configpri['tx_bizid']; $bizid = $configpri['tx_bizid'];
$push_url_key = $configpri['tx_push_key']; $push_url_key = $configpri['tx_push_key'];
$list1 = preg_split ('/\?/', $originalUrl); $list1 = preg_split ('/\?/', $originalUrl);
$originalUrl=$list1[0]; $originalUrl=$list1[0];
$list = preg_split ('/\//', $originalUrl); $list = preg_split ('/\//', $originalUrl);
$url = preg_split ('/\./', end($list)); $url = preg_split ('/\./', end($list));
$now_time = time(); $now_time = time();
$now_time = $now_time + 3*60*60; $now_time = $now_time + 3*60*60;
$txTime = dechex($now_time); $txTime = dechex($now_time);
$txSecret = md5($push_url_key . $url[0] . $txTime); $txSecret = md5($push_url_key . $url[0] . $txTime);
$safe_url = $originalUrl."?txSecret=" . $txSecret ."&txTime=" .$txTime ."&bizid=".$bizid; $safe_url = $originalUrl."?txSecret=" . $txSecret ."&txTime=" .$txTime ."&bizid=".$bizid;
$safe_url=str_replace(".flv",'',$safe_url); $safe_url=str_replace(".flv",'',$safe_url);
...@@ -194,34 +194,34 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -194,34 +194,34 @@ class Api_Linkmic extends PhalApi_Api {
$info=array( $info=array(
"streamUrlWithSignature" => $safe_url, "streamUrlWithSignature" => $safe_url,
"timestamp" => $now_time, "timestamp" => $now_time,
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
/** /**
* 连麦混流 * 连麦混流
* @desc 用于连麦混流 * @desc 用于连麦混流
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function MergeVideoStream() { public function MergeVideoStream() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$mergeparams=html_entity_decode($this->mergeparams); $mergeparams=html_entity_decode($this->mergeparams);
$configpri = getConfigPri(); $configpri = getConfigPri();
$appid = $configpri['tx_appid']; $appid = $configpri['tx_appid'];
$bizid = $configpri['tx_bizid']; $bizid = $configpri['tx_bizid'];
$push_url_key = $configpri['tx_push_key']; $push_url_key = $configpri['tx_push_key'];
$call_back_key = $configpri['tx_api_key']; $call_back_key = $configpri['tx_api_key'];
$t=time()+60; $t=time()+60;
$sign=$md5_val = md5($call_back_key . strval($t));; $sign=$md5_val = md5($call_back_key . strval($t));;
...@@ -231,8 +231,8 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -231,8 +231,8 @@ class Api_Linkmic extends PhalApi_Api {
$url='http://fcgi.video.qcloud.com/common_access?appid='.$appid.'&interface=Mix_StreamV2&t='.$t.'&sign='.$sign; $url='http://fcgi.video.qcloud.com/common_access?appid='.$appid.'&interface=Mix_StreamV2&t='.$t.'&sign='.$sign;
$ch = curl_init (); $ch = curl_init ();
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
@curl_setopt($ch, CURLOPT_URL, $url); @curl_setopt($ch, CURLOPT_URL, $url);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_POST, 1); @curl_setopt($ch, CURLOPT_POST, 1);
...@@ -244,6 +244,8 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -244,6 +244,8 @@ class Api_Linkmic extends PhalApi_Api {
); );
@$result = curl_exec($ch); @$result = curl_exec($ch);
var_dump($result);
die;
if(curl_errno($ch)){ if(curl_errno($ch)){
//print curl_error($ch); //print curl_error($ch);
file_put_contents('./MergeVideoStream.txt',date('y-m-d H:i:s').' 提交参数信息 ch:'.json_encode(curl_error($ch))."\r\n",FILE_APPEND); file_put_contents('./MergeVideoStream.txt',date('y-m-d H:i:s').' 提交参数信息 ch:'.json_encode(curl_error($ch))."\r\n",FILE_APPEND);
...@@ -258,7 +260,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -258,7 +260,7 @@ class Api_Linkmic extends PhalApi_Api {
return $rs; return $rs;
} }
return $rs; return $rs;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment