From ef742e715b8c0a983d661aa5b5f8980dade8c790 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期四, 22 四月 2021 15:28:40 +0800 Subject: [PATCH] 优化宕机后点播中设备发送bye --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 36 ++++++++++++++++++++++++++++++++++-- 1 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 188676f..5f31d87 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -10,11 +10,14 @@ import javax.sip.header.ViaHeader; import javax.sip.message.Request; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; @@ -74,6 +77,9 @@ @Autowired private ZLMRTPServerFactory zlmrtpServerFactory; + + @Autowired + private ZLMRESTfulUtils zlmresTfulUtils; @Value("${media.rtp.enable}") private boolean rtpEnable; @@ -577,13 +583,39 @@ try { ClientTransaction transaction = streamSession.getTransaction(deviceId, channelId); - // 鏈嶅姟閲嶅惎鍚� + // 鏈嶅姟閲嶅惎鍚�, 鏃犳硶鐩存帴鍙戦�乥ye锛� 閫氳繃鎵嬪姩鏋勫缓鍙戦�� if (transaction == null) { + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); if (streamInfo != null) { + JSONObject mediaList = zlmresTfulUtils.getMediaList(streamInfo.getApp(), streamInfo.getStreamId()); + if (mediaList != null) { // 浠嶅湪鎺ㄦ祦鎵嶅彂閫� + if (mediaList.getInteger("code") == 0) { + JSONArray data = mediaList.getJSONArray("data"); + if (data != null && data.size() > 0) { + Device device = storager.queryVideoDevice(deviceId); + if (device != null) { + StreamInfo.TransactionInfo transactionInfo = streamInfo.getTransactionInfo(); + try { + Request byteRequest = headerProvider.createByteRequest(device, channelId, + transactionInfo.branch, + transactionInfo.localTag, + transactionInfo.remoteTag, + transactionInfo.callId); + transmitRequest(device, byteRequest); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } + } + } + } + } redisCatchStorage.stopPlay(streamInfo); } - okEvent.response(null); + + if (okEvent != null) { + okEvent.response(null); + } return; } -- Gitblit v1.8.0