Quellcode durchsuchen

洗选执法记录仪

任敬轩 vor 7 Monaten
Ursprung
Commit
529f4122b3

+ 1 - 1
Modules/Camera/Http/Controllers/Api/CameraApiController.php

@@ -681,7 +681,7 @@ class CameraApiController extends BaseController
 //
 //            }
             elseif($parent_id == '6561'){//洗选执法记录仪hls
-                $result = CameraServices::getCameraHlsUrl($parent_id, $camera_id);
+                $result = CameraServices::getCameraWsUrl($parent_id, $camera_id);
             }
             //海康切片逻辑
             else{

+ 32 - 0
Modules/Camera/Http/Controllers/Api/HaiKangController.php

@@ -260,6 +260,38 @@ class HaiKangController extends BaseController
         }
     }
 
+    //洗选执法记录仪
+    public function getWsCameraUrl(){
+        if (!Input::has('cameraIndexCode')) {
+            return $this->error(1, '缺少必要参数');
+        }
+        $parent_id  = Input::get('parent_id');
+        $protocol   = Input::get('protocol', 'hls');
+        $streamType = Input::get('streamType', 1);
+        $url        = $this->artemis . '/api/video/v1/cameras/previewURLs';
+//        $cameras_info = json_decode($this->getCamerasInfo(Input::all()), true);
+        //请求参数
+        $params = [];
+//        $params['regionIndexCode'] = $request->input('regionIndexCode');
+        $params['cameraIndexCode'] = Input::get('cameraIndexCode');
+        $params['streamType']      = $streamType;  //0主码流 1子码流 2第三码流
+        $params['protocol']        = 'ws';
+        $params['transmode']       = 1;  //0:UDP 1:TCP
+        $params['expand'] = 'streamform=rtp';
+
+        $this->sign = $this->get_sign($url);
+
+        $result = $this->curlPost($this->pre_url . $url, json_encode($params));
+        $result = json_decode($result, true);
+        if (isset($result['code']) && $result['code'] == 0 && $parent_id != 353) {  // 将内网地址替换为外网地址,除了羊二
+            $video_url = $result['data']['url'];
+            preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i', $video_url, $res);  // 提取内网ip
+            preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i', $this->pre_url, $res_n);  // 提取外网ip
+            $result['data']['url'] = str_replace($res, $res_n, $video_url);
+        }
+        return $result;
+    }
+
     /**
      * 获取摄像头码流url
      * @return array|mixed

+ 3 - 3
Modules/Camera/Services/CameraServices.php

@@ -1868,7 +1868,7 @@ class CameraServices
     }
 
     //洗选执法记录仪hls
-    public static function getCameraHlsUrl($parent_id, $camera_id){
+    public static function getCameraWsUrl($parent_id, $camera_id){
         $result['status'] = true;
         $result['msg']    = ApiEnum::RETURN_SUCCESS;
 
@@ -1883,12 +1883,12 @@ class CameraServices
                 'secret'          => $query->secret,
                 'cameraIndexCode' => $camera->index_code,
                 'streamType'      => CameraEnum::CODE_STREAM_HAK[$camera->code_stream],
-                'protocol'        => 'hls',
+                'protocol'        => 'ws',
                 'parent_id'       => $parent_id
             ]
         );
         $haikang   = new HaiKangController();
-        $result_hk = $haikang->getCamerasUrl();
+        $result_hk = $haikang->getWsCameraUrl();
 
         if ($result_hk['data']['url']) {
             $result['data']['camera_id'] = $camera_id;