From 8f77d0c25cdd37d4cc96c923b46ae28607bae51d Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: 星期四, 18 八月 2022 16:17:23 +0800 Subject: [PATCH] 根据redis消息更新推流列表 --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 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 8350d29..cc6d416 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 @@ -33,13 +33,11 @@ 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 = "鍥芥爣璁惧鐐规挱") @CrossOrigin @@ -56,7 +54,7 @@ private VideoStreamSessionManager streamSession; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -88,7 +86,7 @@ // 鑾峰彇鍙敤鐨剒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(); } @@ -109,7 +107,6 @@ // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ String key = DeferredResultHolder.CALLBACK_CMD_STOP + deviceId + channelId; resultHolder.put(key, uuid, result); - Device device = storager.queryVideoDevice(deviceId); StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); if (streamInfo == null) { RequestMessage msg = new RequestMessage(); @@ -120,16 +117,14 @@ storager.stopPlay(deviceId, channelId); return result; } - cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), (event) -> { + cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), null, eventResult -> { 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.getStream()); + 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 +148,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); @@ -175,7 +172,7 @@ 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 +195,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 { -- Gitblit v1.8.0