LIVE_YE 22 hours ago
parent
commit
f2409726f1

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/camera/CameraController.java

@@ -97,6 +97,15 @@ public class CameraController extends BaseController {
         return cameraService.video(cameraIndexCode);
     }
 
+    /**
+     * 获取设备视频地址(放开,app)
+     */
+    @PreAuthorize("@ss.hasPermi('system:camera:app:video')")
+    @GetMapping("/app/video/{cameraIndexCode}")
+    public AjaxResult appVideo(@PathVariable String cameraIndexCode) {
+        return cameraService.appVideo(cameraIndexCode);
+    }
+
 
     /**
      * 查询安防设备列表(放开)

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/CameraService.java

@@ -10,4 +10,6 @@ public interface CameraService {
     AjaxResult video(String cameraIndexCode);
 
     void configureTasks();
+
+    AjaxResult appVideo(String cameraIndexCode);
 }

+ 27 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CameraServiceImpl.java

@@ -118,6 +118,7 @@ public class CameraServiceImpl implements CameraService {
         jsonBody.put("cameraIndexCode", cameraIndexCode);
         jsonBody.put("streamType", 0);
         jsonBody.put("protocol", "httpflv");
+        //jsonBody.put("protocol", "rtsp");
         jsonBody.put("transmode", 1);
         jsonBody.put("expand", "streamform=ps");
 
@@ -269,6 +270,32 @@ public class CameraServiceImpl implements CameraService {
 
     }
 
+    @Override
+    public AjaxResult appVideo(String cameraIndexCode) {
+        if(StringUtils.isEmpty(cameraIndexCode)){
+            throw new ServiceException("参数错误");
+        }
+        /**
+         * STEP3:设置接口的URI地址
+         */
+        String url = "/api/video/v2/cameras/previewURLs";
+
+        /**
+         * STEP5:组装请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("cameraIndexCode", cameraIndexCode);
+        jsonBody.put("streamType", 0);
+        //jsonBody.put("protocol", "httpflv");
+        jsonBody.put("protocol", "rtsp");
+        jsonBody.put("transmode", 1);
+        jsonBody.put("expand", "streamform=ps");
+
+        String result = GetCameraPreviewURL.GetCameraPreviewURL(url,jsonBody.toString());
+        JSONObject jsonObject = JSON.parseObject(result);
+        return AjaxResult.success(jsonObject);
+    }
+
     /*public static void main(String[] args) {
 
         // 获取当前时间