|
@@ -19,7 +19,6 @@ use Modules\Mine\Entities\MineList;
|
|
use Modules\Mine\Enum\MineEnum;
|
|
use Modules\Mine\Enum\MineEnum;
|
|
use Modules\Mine\Services\MineServices;
|
|
use Modules\Mine\Services\MineServices;
|
|
|
|
|
|
-
|
|
|
|
class TdwyController extends BaseController
|
|
class TdwyController extends BaseController
|
|
{
|
|
{
|
|
protected $pre_url; // 请求地址
|
|
protected $pre_url; // 请求地址
|
|
@@ -366,6 +365,126 @@ class TdwyController extends BaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //大华停止语音对讲
|
|
|
|
+ public function talkStop($camera_id,$parent_id,$device_code,$session){
|
|
|
|
+ $dahua_ext = DB::table('mine_list_ext')
|
|
|
|
+ ->where('mine_id',$parent_id)
|
|
|
|
+ ->where('deleted_at',null)->get();
|
|
|
|
+
|
|
|
|
+ if(count($dahua_ext) > 0){
|
|
|
|
+ $ip = $dahua_ext[0]->ip.':'.$dahua_ext[0]->port;
|
|
|
|
+
|
|
|
|
+ //获取public_key
|
|
|
|
+ $url = '/evo-apigw/evo-oauth/1.0.0/oauth/public-key';
|
|
|
|
+ $result1 = $this->httpRequest($ip.$url);
|
|
|
|
+ if($result1['data']['publicKey']){
|
|
|
|
+ $public_key = $result1['data']['publicKey'];
|
|
|
|
+ }else{
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取access_token
|
|
|
|
+ $url2 = '/evo-apigw/evo-oauth/1.0.0/oauth/extend/token';
|
|
|
|
+ $username_password = explode('|',$dahua_ext[0]->sOrgId);
|
|
|
|
+ if(count($username_password) != 2){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ $password = $this->rsaEncode($username_password[1],$public_key);
|
|
|
|
+ $params = [
|
|
|
|
+ 'grant_type'=>'password',
|
|
|
|
+ 'username'=>$username_password[0],
|
|
|
|
+ 'password'=>$password,
|
|
|
|
+ 'client_id'=>$dahua_ext[0]->key,
|
|
|
|
+ 'client_secret'=>$dahua_ext[0]->secret,
|
|
|
|
+ 'public_key'=>$public_key
|
|
|
|
+ ];
|
|
|
|
+ $result2 = $this->httpRequest($ip.$url2,'post',$params);
|
|
|
|
+ if($result2['data']['access_token']){
|
|
|
|
+ $access_token = $result2['data']['access_token'];
|
|
|
|
+ }else{
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //语音对讲
|
|
|
|
+ $url5 = '/evo-apigw/admin/API/MTS/Audio/StopTalk';
|
|
|
|
+ $params4['data'] = [
|
|
|
|
+ "deviceCode"=>$device_code,
|
|
|
|
+ "talkType"=>"1",
|
|
|
|
+ "session"=>$session,
|
|
|
|
+ "channelSeq"=>""
|
|
|
|
+ ];
|
|
|
|
+ $result = $this->httpRequest($ip.$url5,'post',$params4,$access_token);
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //大华语音对讲
|
|
|
|
+ public function talkUrl($camera_id,$parent_id){
|
|
|
|
+ $dahua_ext = DB::table('mine_list_ext')
|
|
|
|
+ ->where('mine_id',$parent_id)
|
|
|
|
+ ->where('deleted_at',null)->get();
|
|
|
|
+
|
|
|
|
+ if(count($dahua_ext) > 0){
|
|
|
|
+ $ip = $dahua_ext[0]->ip.':'.$dahua_ext[0]->port;
|
|
|
|
+
|
|
|
|
+ //获取public_key
|
|
|
|
+ $url = '/evo-apigw/evo-oauth/1.0.0/oauth/public-key';
|
|
|
|
+ $result1 = $this->httpRequest($ip.$url);
|
|
|
|
+ if($result1['data']['publicKey']){
|
|
|
|
+ $public_key = $result1['data']['publicKey'];
|
|
|
|
+ }else{
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取access_token
|
|
|
|
+ $url2 = '/evo-apigw/evo-oauth/1.0.0/oauth/extend/token';
|
|
|
|
+ $username_password = explode('|',$dahua_ext[0]->sOrgId);
|
|
|
|
+ if(count($username_password) != 2){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ $password = $this->rsaEncode($username_password[1],$public_key);
|
|
|
|
+ $params = [
|
|
|
|
+ 'grant_type'=>'password',
|
|
|
|
+ 'username'=>$username_password[0],
|
|
|
|
+ 'password'=>$password,
|
|
|
|
+ 'client_id'=>$dahua_ext[0]->key,
|
|
|
|
+ 'client_secret'=>$dahua_ext[0]->secret,
|
|
|
|
+ 'public_key'=>$public_key
|
|
|
|
+ ];
|
|
|
|
+ $result2 = $this->httpRequest($ip.$url2,'post',$params);
|
|
|
|
+ if($result2['data']['access_token']){
|
|
|
|
+ $access_token = $result2['data']['access_token'];
|
|
|
|
+ }else{
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $camera = DB::table('camera_list')->where('id',$camera_id)->get();
|
|
|
|
+
|
|
|
|
+ $result['data']['camera_id'] = $camera_id;
|
|
|
|
+ $result['data']['deviceCode'] = explode('$',$camera[0]->index_code)[0];
|
|
|
|
+
|
|
|
|
+ //语音对讲
|
|
|
|
+ $url5 = '/evo-apigw/admin/API/MTS/Audio/StartTalk';
|
|
|
|
+ $params4['data'] = [
|
|
|
|
+ "deviceCode"=>explode('$',$camera[0]->index_code)[0],
|
|
|
|
+ "talkType"=>"1",
|
|
|
|
+ "audioBit"=>"16",
|
|
|
|
+ "audioType"=>"2",
|
|
|
|
+ "broadcastChannels"=>"",
|
|
|
|
+ "sampleRate"=>"8000",
|
|
|
|
+ "talkmode"=>"",
|
|
|
|
+ "channelSeq"=>"0"
|
|
|
|
+ ];
|
|
|
|
+ $result5 = $this->httpRequest($ip.$url5,'post',$params4,$access_token);
|
|
|
|
+ if(explode('|',$result5['data']['url'])[1]){
|
|
|
|
+ $result['data']['url'] = explode('|',$result5['data']['url'])[1];
|
|
|
|
+ $result['data']['session'] = $result5['data']['session'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//接口第三方调用
|
|
//接口第三方调用
|
|
public function httpRequest($url, $format = 'get', $data = null, $token = null){
|
|
public function httpRequest($url, $format = 'get', $data = null, $token = null){
|
|
//设置头信息
|
|
//设置头信息
|