Forráskód Böngészése

添加消除主码流逻辑

gao.qiang 1 éve
szülő
commit
d64451e6f1

+ 21 - 1
business-service/src/main/java/com/ozs/utils/CameraUtil.java

@@ -1077,6 +1077,19 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
         return null;
     }
 
+    public String hostStopStream(String straem) {
+        try {
+            //http://10.48.36.47:9080/api/gateway/stop?stream=0235538f5ec241abad7c29cb423f16bb/1
+            log.info("code-----1111----->" + httpUrl + "/api/gateway/stop?stream=" + straem);
+            String code = HttpClientUtil.getURL(httpUrl + "/api/gateway/stop?stream=" + straem);
+            log.info("code---111111------->" + code);
+            return code;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     /**
      * web页面实时流调用的远程天网接口
      *
@@ -1235,7 +1248,9 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
                     log.info("subValue------------------>" + subValue);
                     log.info("pathValue------------------>" + pathValue);
                     log.info("heartbeat------------------>" + heartbeat);
-                    if (subValue.equals("0") && pathValue.contains("h264_720")) {
+                    //判断压缩流是否订阅者是0
+                    if (subValue.equals("0") && pathValue.contains("h264_720") && !pathValue.contains("live")) {
+                        log.info("----------流程1--判断压缩流是否订阅者是0-------------");
                         if (!ObjectUtils.isEmpty(heartbeat)) {
                             if (!heartbeat.contains(pathValue)) {
                                 log.info("执行stopStream---111--------------->");
@@ -1248,6 +1263,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
                             stopStream(parts[0], parts[1]);
                         }
                     }
+                    //判断主码流是否订阅者是2
+                    if (subValue.equals("2") && !pathValue.contains("h264_720")) {
+                        log.info("----------流程2--判断主码流是否订阅者是2-------------");
+                        hostStopStream(pathValue);
+                    }
                 }
             }
         }

+ 2 - 2
vehicle-sdk/src/main/java/com/ozs/config/ShotExecutors.java

@@ -36,7 +36,7 @@ public class ShotExecutors {
     @Async
     @Scheduled(fixedRate = 3000)
     public void handleAlarmPicture() {
-        log.info("-------定时清除流媒体压缩视频--------------");
-        cameraUtil.heartbeatGetPlayFlv();
+//        log.info("-------定时清除流媒体压缩视频--------------");
+//        cameraUtil.heartbeatGetPlayFlv();
     }
 }

+ 40 - 8
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -979,14 +979,14 @@ public class GeoHazardMonitorTokenController {
                         //            String[] parts = str.split("/");
                         //            log.info("--------------parts--------------:" + parts);
                         //            if (parts.length == 2) {
-                        //                CompletableFuture.runAsync(() -> {
-                        //                    try {
-                        //                        TimeUnit.SECONDS.sleep(3);
-                        //                    } catch (InterruptedException e) {
-                        //                        e.printStackTrace();
-                        //                    }
-                        //                    cameraUtil.stopStream(parts[0], parts[1]);
-                        //                });
+                                        CompletableFuture.runAsync(() -> {
+                                            try {
+                                                TimeUnit.SECONDS.sleep(3);
+                                            } catch (InterruptedException e) {
+                                                e.printStackTrace();
+                                            }
+                                            cameraUtil.heartbeatGetPlayFlv();
+                                        });
                         //            }
                         //        }
                         //    }
@@ -1067,6 +1067,14 @@ public class GeoHazardMonitorTokenController {
                             //        }
                             //    }
                             //}
+                            CompletableFuture.runAsync(() -> {
+                                try {
+                                    TimeUnit.SECONDS.sleep(3);
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                                cameraUtil.heartbeatGetPlayFlv();
+                            });
                         } else {
                             log.info("-------------->>已进入拉一路视频");
                             log.info("list1-------------->>" + list1.size());
@@ -1118,6 +1126,14 @@ public class GeoHazardMonitorTokenController {
                             //        }
                             //    }
                             //}
+                            CompletableFuture.runAsync(() -> {
+                                try {
+                                    TimeUnit.SECONDS.sleep(3);
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                                cameraUtil.heartbeatGetPlayFlv();
+                            });
                         }
                         twoMap.put("currentStream", playFlv);
                         twoMap.put("cameraCode", list1.get(0).getCameraCode());
@@ -1211,6 +1227,14 @@ public class GeoHazardMonitorTokenController {
 //                                }
 //                            }
 //                        }
+                        CompletableFuture.runAsync(() -> {
+                            try {
+                                TimeUnit.SECONDS.sleep(3);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                            cameraUtil.heartbeatGetPlayFlv();
+                        });
 //                        List<String> finalCodeList2 = codeList;
 //                        CompletableFuture.runAsync(() -> {
 //                            log.info("-------------->>finalCodeList2-------" + finalCodeList2);
@@ -1277,6 +1301,14 @@ public class GeoHazardMonitorTokenController {
 //                                }
 //                            }
 //                        }
+                        CompletableFuture.runAsync(() -> {
+                            try {
+                                TimeUnit.SECONDS.sleep(3);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                            cameraUtil.heartbeatGetPlayFlv();
+                        });
                     }
                     twoMap.put("currentStream", playFlv);
                     twoMap.put("cameraCode", list1.get(0).getCameraCode());