From 4ee8924bd9dbd36046d922d9480de310ee16b6ac Mon Sep 17 00:00:00 2001 From: zx <zuoxue@qq.com> Date: 星期五, 19 八月 2022 21:55:59 +0800 Subject: [PATCH] fix PlatformKeepaliveExpireEvent typo --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java | 103 +++++++++++++++++++++++---------------------------- 1 files changed, 46 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index c22a558..233e1de 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -15,10 +15,10 @@ import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IPlayService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -33,15 +33,13 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.web.context.request.async.DeferredResult; import java.util.List; import java.util.UUID; -import javax.sip.message.Response; - -@Api(tags = "鍥芥爣璁惧鐐规挱") +@Tag(name = "鍥芥爣璁惧鐐规挱") @CrossOrigin @RestController @RequestMapping("/api/play") @@ -56,7 +54,7 @@ private VideoStreamSessionManager streamSession; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -76,11 +74,9 @@ @Autowired private IMediaServerService mediaServerService; - @ApiOperation("寮�濮嬬偣鎾�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "璁惧ID", dataTypeClass = String.class), - @ApiImplicitParam(name = "channelId", value = "閫氶亾ID", dataTypeClass = String.class), - }) + @Operation(summary = "寮�濮嬬偣鎾�") + @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true) + @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true) @GetMapping("/start/{deviceId}/{channelId}") public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, @PathVariable String channelId) { @@ -88,16 +84,15 @@ // 鑾峰彇鍙敤鐨剒lm Device device = storager.queryVideoDevice(deviceId); MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); - PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null); + PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); return playResult.getResult(); } - @ApiOperation("鍋滄鐐规挱") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "璁惧ID", dataTypeClass = String.class), - @ApiImplicitParam(name = "channelId", value = "閫氶亾ID", dataTypeClass = String.class), - }) + + @Operation(summary = "鍋滄鐐规挱") + @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true) + @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true) @GetMapping("/stop/{deviceId}/{channelId}") public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String deviceId, @PathVariable String channelId) { @@ -109,27 +104,24 @@ // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ String key = DeferredResultHolder.CALLBACK_CMD_STOP + deviceId + channelId; resultHolder.put(key, uuid, result); - Device device = storager.queryVideoDevice(deviceId); - cmder.streamByeCmd(deviceId, channelId, (event) -> { - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); - if (streamInfo == null) { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("鐐规挱鏈壘鍒�"); - resultHolder.invokeAllResult(msg); - storager.stopPlay(deviceId, channelId); - }else { - redisCatchStorage.stopPlay(streamInfo); - storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - //Response response = event.getResponse(); - msg.setData(String.format("success")); - resultHolder.invokeAllResult(msg); - } - mediaServerService.closeRTPServer(device, channelId); + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); + if (streamInfo == null) { + RequestMessage msg = new RequestMessage(); + msg.setId(uuid); + msg.setKey(key); + msg.setData("鐐规挱鏈壘鍒�"); + resultHolder.invokeAllResult(msg); + storager.stopPlay(deviceId, channelId); + return result; + } + cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), null, eventResult -> { + redisCatchStorage.stopPlay(streamInfo); + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); + RequestMessage msgForSuccess = new RequestMessage(); + msgForSuccess.setId(uuid); + msgForSuccess.setKey(key); + msgForSuccess.setData(String.format("success")); + resultHolder.invokeAllResult(msgForSuccess); }); if (deviceId != null || channelId != null) { @@ -153,6 +145,8 @@ // 瓒呮椂澶勭悊 result.onTimeout(()->{ logger.warn(String.format("璁惧棰勮/鍥炴斁鍋滄瓒呮椂锛宒eviceId/channelId锛�%s_%s ", deviceId, channelId)); + redisCatchStorage.stopPlay(streamInfo); + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); RequestMessage msg = new RequestMessage(); msg.setId(uuid); msg.setKey(key); @@ -167,15 +161,13 @@ * @param streamId 娴両D * @return */ - @ApiOperation("灏嗕笉鏄痟264鐨勮棰戦�氳繃ffmpeg 杞爜涓篽264 + aac") - @ApiImplicitParams({ - @ApiImplicitParam(name = "streamId", value = "瑙嗛娴両D", dataTypeClass = String.class), - }) + @Operation(summary = "灏嗕笉鏄痟264鐨勮棰戦�氳繃ffmpeg 杞爜涓篽264 + aac") + @Parameter(name = "streamId", description = "瑙嗛娴両D", required = true) @PostMapping("/convert/{streamId}") public ResponseEntity<String> playConvert(@PathVariable String streamId) { StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); if (streamInfo == null) { - streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); + streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); } if (streamInfo == null) { logger.warn("瑙嗛杞爜API璋冪敤澶辫触锛�, 瑙嗛娴佸凡缁忓仠姝�!"); @@ -198,7 +190,7 @@ JSONObject data = jsonObject.getJSONObject("data"); if (data != null) { result.put("key", data.getString("key")); - StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId()); + StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false); result.put("data", streamInfoResult); } }else { @@ -214,10 +206,9 @@ * @param key * @return */ - @ApiOperation("缁撴潫杞爜") - @ApiImplicitParams({ - @ApiImplicitParam(name = "key", value = "瑙嗛娴乲ey", dataTypeClass = String.class), - }) + @Operation(summary = "缁撴潫杞爜") + @Parameter(name = "key", description = "瑙嗛娴乲ey", required = true) + @Parameter(name = "mediaServerId", description = "娴佸獟浣撴湇鍔D", required = true) @PostMapping("/convertStop/{key}") public ResponseEntity<String> playConvertStop(@PathVariable String key, String mediaServerId) { JSONObject result = new JSONObject(); @@ -253,10 +244,8 @@ } - @ApiOperation("璇煶骞挎挱鍛戒护") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "璁惧Id", dataTypeClass = String.class), - }) + @Operation(summary = "璇煶骞挎挱鍛戒护") + @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true) @GetMapping("/broadcast/{deviceId}") @PostMapping("/broadcast/{deviceId}") public DeferredResult<ResponseEntity<String>> broadcastApi(@PathVariable String deviceId) { @@ -316,7 +305,7 @@ return result; } - @ApiOperation("鑾峰彇鎵�鏈夌殑ssrc") + @Operation(summary = "鑾峰彇鎵�鏈夌殑ssrc") @GetMapping("/ssrc") public WVPResult<JSONObject> getSSRC() { if (logger.isDebugEnabled()) { @@ -329,7 +318,7 @@ jsonObject.put("deviceId", transaction.getDeviceId()); jsonObject.put("channelId", transaction.getChannelId()); jsonObject.put("ssrc", transaction.getSsrc()); - jsonObject.put("streamId", transaction.getStreamId()); + jsonObject.put("streamId", transaction.getStream()); objects.add(jsonObject); } -- Gitblit v1.8.0