Kaynağa Gözat

流媒体的条数开发

gao.qiang 9 ay önce
ebeveyn
işleme
6a543ee11e

+ 36 - 0
business-service/src/main/java/com/ozs/utils/CameraUtil.java

@@ -1212,4 +1212,40 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
 
         return baseCameraManagementResponseList;
     }
+
+    /**
+     * 流媒体的条数
+     * @return
+     */
+    public int urlCount(){
+        int maxRetries = 5;
+        int retryCount = 0;
+        int count = 0;
+        boolean success = false;
+        JSONArray streamArray = null;
+        List<BaseCameraManagementResponse> baseCameraManagementResponseList = new ArrayList<>();
+        while (!success && retryCount < maxRetries) {
+            try {
+                String data = HttpClientUtil.gets(webUrl + "/api/summary");
+                log.info("data------------------>" + data);
+                if (StringUtils.isNotEmpty(data)) {
+                    JSONObject jsonObject = JSONObject.parseObject(data);
+                    streamArray = jsonObject.getJSONArray("Streams");
+                    success = true;
+                }
+            } catch (Exception e) {
+                log.info("Exception caught: " + e.getMessage());
+                // 增加重试计数
+                retryCount++;
+            }
+        }
+        for (int i = 0; i < streamArray.size(); i++) {
+            JSONObject subObj = streamArray.getJSONObject(i);
+            String PathValue = subObj.getString("Path");
+            if (PathValue.contains("/h264_720")){
+                count++;
+            }
+        }
+        return count;
+    }
 }

+ 2 - 2
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -1075,8 +1075,8 @@ public class BaseCameraManagementController extends BaseController {
      */
     @GetMapping("/getCameraManagementList")
     public AjaxResult getCameraManagementList() {
-        List<BaseCameraManagementResponse> baseCameraManagementResponses = cameraUtil.heartbeatGetPlayFlv();
-        return AjaxResult.success(baseCameraManagementResponses);
+        int count = cameraUtil.urlCount();
+        return AjaxResult.success(count);
     }
 }