Commit 3eb83ee9 by 冷斌

update

parent 0ec63146
...@@ -8,7 +8,7 @@ class Api_Livepk extends PhalApi_Api { ...@@ -8,7 +8,7 @@ class Api_Livepk extends PhalApi_Api {
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'), 'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'),
), ),
'search' => array( 'search' => 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'),
'key' => array('name' => 'key', 'type' => 'string', 'require' => true, 'desc' => '关键词'), 'key' => array('name' => 'key', 'type' => 'string', 'require' => true, 'desc' => '关键词'),
'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'), 'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'),
...@@ -17,7 +17,7 @@ class Api_Livepk extends PhalApi_Api { ...@@ -17,7 +17,7 @@ class Api_Livepk extends PhalApi_Api {
'stream' => array('name' => 'stream', 'type' => 'string', 'require' => true, 'desc' => '连麦主播流名'), 'stream' => array('name' => 'stream', 'type' => 'string', 'require' => true, 'desc' => '连麦主播流名'),
'uid_stream' => array('name' => 'uid_stream', 'type' => 'string', 'require' => true, 'desc' => '当前主播流名'), 'uid_stream' => array('name' => 'uid_stream', 'type' => 'string', 'require' => true, 'desc' => '当前主播流名'),
), ),
'changeLive' => array( 'changeLive' => 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'),
'pkuid' => array('name' => 'pkuid', 'type' => 'int', 'require' => true, 'desc' => '连麦主播ID'), 'pkuid' => array('name' => 'pkuid', 'type' => 'int', 'require' => true, 'desc' => '连麦主播ID'),
...@@ -31,25 +31,25 @@ class Api_Livepk extends PhalApi_Api { ...@@ -31,25 +31,25 @@ class Api_Livepk extends PhalApi_Api {
* 直播用户 * 直播用户
* @desc 用于 获取直播中的用户 * @desc 用于 获取直播中的用户
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].uid 主播ID * @return string info[].uid 主播ID
* @return string info[].pkuid PK对象ID,0表示未连麦 * @return string info[].pkuid PK对象ID,0表示未连麦
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function getLiveList() { public function getLiveList() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$p=checkNull($this->p); $p=checkNull($this->p);
if(!$p){ if(!$p){
$p=1; $p=1;
} }
$where="uid!={$uid}"; $where="uid!={$uid}";
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$list = $domain->getLiveList($uid,$where,$p); $list = $domain->getLiveList($uid,$where,$p);
foreach($list as $k=>$v){ foreach($list as $k=>$v){
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
...@@ -59,34 +59,34 @@ class Api_Livepk extends PhalApi_Api { ...@@ -59,34 +59,34 @@ class Api_Livepk extends PhalApi_Api {
} }
$rs['info']=$list; $rs['info']=$list;
return $rs; return $rs;
} }
/** /**
* 搜索直播用户 * 搜索直播用户
* @desc 用于搜索直播中用户 * @desc 用于搜索直播中用户
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].uid 主播ID * @return string info[].uid 主播ID
* @return string info[].pkuid PK对象ID,0表示未连麦 * @return string info[].pkuid PK对象ID,0表示未连麦
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function search() { public function search() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$key=checkNull($this->key); $key=checkNull($this->key);
$p=checkNull($this->p); $p=checkNull($this->p);
if(!$p){ if(!$p){
$p=1; $p=1;
} }
if($key==''){ if($key==''){
$rs['code']=1001; $rs['code']=1001;
$rs['msg']='请输入您要搜索的主播昵称或ID'; $rs['msg']='请输入您要搜索的主播昵称或ID';
return $rs; return $rs;
} }
$list=DI()->notorm->users $list=DI()->notorm->users
->select('id') ->select('id')
->where("id!={$uid} and (id='{$key}' or user_nicename like '%{$key}%')") ->where("id!={$uid} and (id='{$key}' or user_nicename like '%{$key}%')")
...@@ -96,14 +96,14 @@ class Api_Livepk extends PhalApi_Api { ...@@ -96,14 +96,14 @@ class Api_Livepk extends PhalApi_Api {
} }
$uids=array_column($list,'id'); $uids=array_column($list,'id');
$uids_s=implode(',',$uids); $uids_s=implode(',',$uids);
$where="uid!={$uid} and uid in ({$uids_s})"; $where="uid!={$uid} and uid in ({$uids_s})";
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$list = $domain->getLiveList($uid,$where,$p); $list = $domain->getLiveList($uid,$where,$p);
foreach($list as $k=>$v){ foreach($list as $k=>$v){
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
...@@ -113,22 +113,22 @@ class Api_Livepk extends PhalApi_Api { ...@@ -113,22 +113,22 @@ class Api_Livepk extends PhalApi_Api {
} }
$rs['info']=$list; $rs['info']=$list;
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 checkLive() { public function checkLive() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$stream=checkNull($this->stream); $stream=checkNull($this->stream);
$uid_stream=checkNull($this->uid_stream); $uid_stream=checkNull($this->uid_stream);
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$info = $domain->checkLive($stream); $info = $domain->checkLive($stream);
...@@ -138,7 +138,18 @@ class Api_Livepk extends PhalApi_Api { ...@@ -138,7 +138,18 @@ class Api_Livepk extends PhalApi_Api {
return $rs; return $rs;
} }
$configpri = getConfigPri(); $stream2=explode('_',$stream);
$liveuid=$stream2[0];
$pkuid=DI()->redis -> hGet('LiveConnect',$liveuid);
if ($pkuid) {
if(!$info){
$rs['code']=1001;
$rs['msg']='已连麦';
return $rs;
}
}
$configpri = getConfigPri();
$nowtime=time(); $nowtime=time();
$live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK $live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK
...@@ -150,32 +161,32 @@ class Api_Livepk extends PhalApi_Api { ...@@ -150,32 +161,32 @@ class Api_Livepk 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 = $uid_stream ; $live_code = $uid_stream ;
$txSecret = md5($push_url_key . $live_code . $txTime); $txSecret = md5($push_url_key . $live_code . $txTime);
$safe_url = "&txSecret=" . $txSecret."&txTime=" .$txTime; $safe_url = "&txSecret=" . $txSecret."&txTime=" .$txTime;
$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){
$liveinfo=DI()->notorm->users_live $liveinfo=DI()->notorm->users_live
->select('pull') ->select('pull')
->where('stream=?',$uid_stream) ->where('stream=?',$uid_stream)
->fetchOne(); ->fetchOne();
$play_url=$liveinfo['pull']; $play_url=$liveinfo['pull'];
}else{ }else{
$play_url=PrivateKeyA('rtmp',$uid_stream,0); $play_url=PrivateKeyA('rtmp',$uid_stream,0);
} }
$info=array( $info=array(
"pull" => $play_url "pull" => $play_url
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
...@@ -183,37 +194,37 @@ class Api_Livepk extends PhalApi_Api { ...@@ -183,37 +194,37 @@ class Api_Livepk extends PhalApi_Api {
* 修改直播信息 * 修改直播信息
* @desc 用于连麦成功后更新数据库信息 * @desc 用于连麦成功后更新数据库信息
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function changeLive() { public function changeLive() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid = $this->uid; $uid = $this->uid;
$pkuid=checkNull($this->pkuid); $pkuid=checkNull($this->pkuid);
$type=checkNull($this->type); $type=checkNull($this->type);
$sign=checkNull($this->sign); $sign=checkNull($this->sign);
$checkdata=array( $checkdata=array(
'uid'=>$uid, 'uid'=>$uid,
'pkuid'=>$pkuid, 'pkuid'=>$pkuid,
'type'=>$type, 'type'=>$type,
); );
$issign=checkSign($checkdata,$sign); $issign=checkSign($checkdata,$sign);
if(!$issign){ if(!$issign){
$rs['code']=1001; $rs['code']=1001;
$rs['msg']='签名错误'; $rs['msg']='签名错误';
return $rs; return $rs;
} }
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$info = $domain->changeLive($uid,$pkuid,$type); $info = $domain->changeLive($uid,$pkuid,$type);
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