浏览代码

【同步】 老项目代码同步

linfutong 3 年之前
父节点
当前提交
6b7c99361e

+ 1 - 1
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/conf/UserSetup.java

@@ -17,7 +17,7 @@ public class UserSetup {
 
     private Boolean seniorSdp = Boolean.FALSE;
 
-    private Long playTimeout = 60000L;
+    private Long playTimeout = 3000L;
 
     private Boolean waitTrack = Boolean.FALSE;
 

+ 32 - 36
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/media/zlm/ZLMHttpHookListener.java

@@ -318,7 +318,7 @@ public class ZLMHttpHookListener {
 	@ResponseBody
 	@PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
 	public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){
-
+		logger.info("on_stream_none_reader调用:"+json.toString());
 		if (logger.isDebugEnabled()) {
 			logger.debug("ZLM HOOK on_stream_none_reader API调用,参数:" + json.toString());
 		}
@@ -326,41 +326,37 @@ public class ZLMHttpHookListener {
 		String streamId = json.getString("stream");
 		String app = json.getString("app");
 
-//		if ("rtp".equals(app)){
-//			JSONObject ret = new JSONObject();
-//			ret.put("code", 0);
-//			ret.put("close", true);
-//			StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(streamId);
-//			if (streamInfoForPlayCatch != null) {
-//				if (redisCatchStorage.isChannelSendingRTP(streamInfoForPlayCatch.getChannelId())) {
-//					ret.put("close", false);
-//				} else {
-//					cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
-//					redisCatchStorage.stopPlay(streamInfoForPlayCatch);
-//					storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
-//				}
-//			}else{
-//				StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlaybackByStreamId(streamId);
-//				if (streamInfoForPlayBackCatch != null) {
-//					cmder.streamByeCmd(streamInfoForPlayBackCatch.getDeviceID(), streamInfoForPlayBackCatch.getChannelId());
-//					redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch);
-//				}
-//			}
-//			MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
-//			if (mediaServerItem != null && "-1".equals(mediaServerItem.getStreamNoneReaderDelayMS())) {
-//				ret.put("close", false);
-//			}
-//			return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
-//		}else {
-//			JSONObject ret = new JSONObject();
-//			ret.put("code", 0);
-//			ret.put("close", false);
-//			return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
-//		}
-		JSONObject ret = new JSONObject();
-		ret.put("code", 0);
-		ret.put("close", false);
-		return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
+		if ("rtp".equals(app)){
+			JSONObject ret = new JSONObject();
+			ret.put("code", 0);
+			ret.put("close", true);
+			StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(streamId);
+			if (streamInfoForPlayCatch != null) {
+				if (redisCatchStorage.isChannelSendingRTP(streamInfoForPlayCatch.getChannelId())) {
+					ret.put("close", false);
+				} else {
+					cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
+					redisCatchStorage.stopPlay(streamInfoForPlayCatch);
+					storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
+				}
+			}else{
+				StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlaybackByStreamId(streamId);
+				if (streamInfoForPlayBackCatch != null) {
+					cmder.streamByeCmd(streamInfoForPlayBackCatch.getDeviceID(), streamInfoForPlayBackCatch.getChannelId());
+					redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch);
+				}
+			}
+			MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
+			if (mediaServerItem != null && "-1".equals(mediaServerItem.getStreamNoneReaderDelayMS())) {
+				ret.put("close", false);
+			}
+			return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
+		}else {
+			JSONObject ret = new JSONObject();
+			ret.put("code", 0);
+			ret.put("close", false);
+			return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
+		}
 	}
 
 	/**

+ 51 - 49
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/vmanager/gb28181/play/PlayController.java

@@ -74,14 +74,12 @@ public class PlayController {
 	@Autowired
 	private DeviceChannelMapper deviceChannelMapper;
 
-	@ApiOperation("开始点播")
-	@ApiImplicitParams({
-			@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
-			@ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
-	})
-	@GetMapping("/start/{deviceId}/{channelId}")
-	public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId,
-													   @PathVariable String channelId) {
+    @ApiOperation("开始点播")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
+            @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class)})
+    @GetMapping("/start/{deviceId}/{channelId}")
+    public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, @PathVariable String channelId) {
 
 		// 获取可用的zlm
 		Device device = storager.queryVideoDevice(deviceId);
@@ -91,47 +89,51 @@ public class PlayController {
 		return playResult.getResult();
 	}
 
-	@ApiOperation("带分页批量点播")
-	@ApiImplicitParams({
-			@ApiImplicitParam(name = "deviceIds", value = "设备ID", dataTypeClass = String.class,allowMultiple = true),
-			@ApiImplicitParam(name = "page", value = "当前页", required = true, dataTypeClass = Integer.class),
-			@ApiImplicitParam(name = "count", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
-	})
-	@GetMapping("/startList")
-	public Map<String,Object> play(String deviceIds, int page, int count) {
-		if(StringUtils.isEmpty(deviceIds)){
-			Map<String,Object> map=new HashMap<>();
-			map.put("code","500");
-			map.put("msg","设备编号不能为空!");
-			map.put("data",null);
-			return map;
-		}
-		List<DeferredResult<ResponseEntity<String>>> list=new ArrayList<DeferredResult<ResponseEntity<String>>>();
-		String deviceStr[]=deviceIds.split(",");
-		List<String> deviceList= Arrays.asList(deviceStr);
-		List<DeviceChannel> deviceChannelList= playService.queryChannelByDeviceId(deviceList,page,count);
-		for(DeviceChannel deviceChannel:deviceChannelList){
-			// 获取可用的zlm
-			Device device = storager.queryVideoDevice(deviceChannel.getDeviceId());
-			MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
-			PlayResult playResult = playService.play(newMediaServerItem, deviceChannel.getDeviceId(), deviceChannel.getChannelId(), null, null);
-			list.add(playResult.getResult());
-		}
-		Map<String,Object> map=new HashMap<>();
-		map.put("code","200");
-		map.put("msg","成功!");
-		map.put("data",list);
-		return map;
-	}
-
-
-	@ApiOperation("停止点播")
-	@ApiImplicitParams({
-			@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
-			@ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
-	})
-	@GetMapping("/stop/{deviceId}/{channelId}")
-	public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String deviceId, @PathVariable String channelId) {
+    @ApiOperation("带分页批量点播")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "deviceIds", value = "设备ID", dataTypeClass = String.class, allowMultiple = true),
+            @ApiImplicitParam(name = "page", value = "当前页", required = true, dataTypeClass = Integer.class),
+            @ApiImplicitParam(name = "count", value = "每页查询数量", required = true, dataTypeClass = Integer.class)})
+    @GetMapping("/startList")
+    public Map<String, Object> play(String deviceIds, int page, int count) {
+        if (deviceIds==null || ("").equals(deviceIds)) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("code", "500");
+            map.put("msg", "设备编号不能为空!");
+            map.put("data", null);
+            return map;
+        }
+        List<StreamInfo> list = new ArrayList<>();
+        String deviceStr[] = deviceIds.split(",");
+        List<String> deviceList = Arrays.asList(deviceStr);
+        List<DeviceChannel> deviceChannelList = playService.queryChannelByDeviceId(deviceList, page, count);
+        for (DeviceChannel deviceChannel : deviceChannelList) {
+            // 获取可用的zlm
+            Device device = storager.queryVideoDevice(deviceChannel.getDeviceId());
+            MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
+            PlayResult playResult = playService.play(newMediaServerItem, deviceChannel.getDeviceId(), deviceChannel.getChannelId(), null, null);
+            DeferredResult<ResponseEntity<String>> result=playResult.getResult();
+            ResponseEntity responseEntity =  (ResponseEntity)result.getResult();
+            if(responseEntity != null && responseEntity.getStatusCode()==HttpStatus.OK){
+                WVPResult wvpResult = (WVPResult)responseEntity.getBody();
+                if (wvpResult.getCode() == 0) {
+                    StreamInfo streamInfo = (StreamInfo)wvpResult.getData();
+                    list.add(streamInfo);
+                }
+            }
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", "200");
+        map.put("msg", "成功!");
+        map.put("data", list);
+        return map;
+    }
+
+
+    @ApiOperation("停止点播")
+    @ApiImplicitParams({@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class), @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class)})
+    @GetMapping("/stop/{deviceId}/{channelId}")
+    public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String deviceId, @PathVariable String channelId) {
 
 		logger.debug(String.format("设备预览/回放停止API调用,streamId:%s_%s", deviceId, channelId ));
 

+ 19 - 20
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/vmanager/log/LogController.java

@@ -37,6 +37,23 @@ public class LogController {
     private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     /**
+     *  清空日志
+     *
+     */
+    @ApiOperation("清空日志")
+    @DeleteMapping("/clear")
+    public ResponseEntity<WVPResult<String>> clear() {
+
+        int count = logService.clear();
+        WVPResult wvpResult = new WVPResult();
+        wvpResult.setCode(0);
+        wvpResult.setMsg("success");
+        wvpResult.setData(count);
+        return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
+    }
+
+
+    /**
      *  分页查询日志
      *
      * @param query 查询内容
@@ -50,12 +67,12 @@ public class LogController {
     @ApiOperation("分页查询报警")
     @GetMapping("/all")
     @ApiImplicitParams({
-            @ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
             @ApiImplicitParam(name="page", value = "当前页", required = true ,dataTypeClass = Integer.class),
             @ApiImplicitParam(name="count", value = "每页查询数量", required = true ,dataTypeClass = Integer.class),
+            @ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
             @ApiImplicitParam(name="type", value = "类型" ,dataTypeClass = String.class),
             @ApiImplicitParam(name="startTime", value = "查询内容" ,dataTypeClass = String.class),
-            @ApiImplicitParam(name="endTime", value = "查询内容" ,dataTypeClass = String.class),
+            @ApiImplicitParam(name="endTime", value = "查询内容" ,dataTypeClass = String.class)
     })
     public ResponseEntity<PageInfo<LogDto>> getAll(
             @RequestParam int page,
@@ -82,22 +99,4 @@ public class LogController {
         PageInfo<LogDto> allLog = logService.getAll(page, count, query, type, startTime, endTime);
         return new ResponseEntity<>(allLog, HttpStatus.OK);
     }
-
-    /**
-     *  清空日志
-     *
-     */
-    @ApiOperation("清空日志")
-    @DeleteMapping("/clear")
-    @ApiImplicitParams({})
-    public ResponseEntity<WVPResult<String>> clear() {
-
-        int count = logService.clear();
-        WVPResult wvpResult = new WVPResult();
-        wvpResult.setCode(0);
-        wvpResult.setMsg("success");
-        wvpResult.setData(count);
-        return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
-    }
-
 }

+ 1 - 3
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/vmanager/onvif/ONVIFController.java

@@ -46,9 +46,7 @@ public class ONVIFController {
 
 
     @ApiOperation("搜索")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "timeout", value = "超时时间", required = true, dataTypeClass = Integer.class),
-    })
+    @ApiImplicitParam(name = "timeout", value = "超时时间", required = true, dataTypeClass = Integer.class)
     @GetMapping(value = "/search")
     public DeferredResult<ResponseEntity<WVPResult>> search(@RequestParam(required = false) Integer timeout) {
         DeferredResult<ResponseEntity<WVPResult>> result = new DeferredResult<>(timeout + 10L);

+ 1 - 3
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/vmanager/server/ServerController.java

@@ -133,9 +133,7 @@ public class ServerController {
 
     @ApiOperation("配置信息")
     @GetMapping(value = "/config")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="type", value = "配置类型(sip, base)", dataTypeClass = String.class),
-    })
+    @ApiImplicitParam(name = "type", value = "配置类型(sip, base)", dataTypeClass = String.class)
     @ResponseBody
     public WVPResult<JSONObject> getVersion(String type){
         WVPResult<JSONObject> result = new WVPResult<>();

+ 1 - 6
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/vmanager/streamProxy/StreamProxyController.java

@@ -60,9 +60,6 @@ public class StreamProxyController {
     }
 
     @ApiOperation("保存代理")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "param", value = "代理参数", dataTypeClass = StreamProxyItem.class),
-    })
     @PostMapping(value = "/save")
     @ResponseBody
     public WVPResult save(@RequestBody StreamProxyItem param){
@@ -77,9 +74,7 @@ public class StreamProxyController {
 
     @ApiOperation("获取ffmpeg.cmd模板")
     @GetMapping(value = "/ffmpeg_cmd/list")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "mediaServerId", value = "流媒体ID", dataTypeClass = String.class),
-    })
+    @ApiImplicitParam(name = "mediaServerId", value = "流媒体ID", dataTypeClass = String.class)
     @ResponseBody
     public WVPResult getFFmpegCMDs(@RequestParam String mediaServerId){
         logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId );

+ 0 - 2
zd-modules/zd-algorithm/src/main/java/com/zd/alg/iot/vmp/web/ApiCompatibleController.java

@@ -14,8 +14,6 @@ import javax.servlet.http.HttpServletRequest;
 @RestController
 public class ApiCompatibleController {
 
-    private final static Logger logger = LoggerFactory.getLogger(ApiCompatibleController.class);
-
     @Autowired
     private IMediaService mediaService;