From ae4d33013136dfdceb129e96ae52bdf375d91dbe Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 20:51:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=9B=9E=E6=94=BEssrc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/cmd/impl/SIPCommander.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 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 d3aceb10..b3447f95 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 @@ -290,12 +290,8 @@ public class SIPCommander implements ISIPCommander { @Override public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { try { - String ssrc = ""; - if (rtpEnable) { - ssrc = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); - }else { - ssrc = streamSession.createPlaySsrc(); - } + + String ssrc = streamSession.createPlaySsrc(); String streamId = null; if (rtpEnable) { streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); @@ -412,16 +408,13 @@ public class SIPCommander implements ISIPCommander { , SipSubscribe.Event errorEvent) { try { MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); - String ssrc = null; + String ssrc = streamSession.createPlayBackSsrc(); String streamId = null; if (rtpEnable) { - ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); - streamId = ssrc; + streamId = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); }else { - ssrc = streamSession.createPlayBackSsrc(); streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); } - // 添加订阅 JSONObject subscribeKey = new JSONObject(); subscribeKey.put("app", "rtp"); From 6735b017755aaba54b7e2951d7eff0fe47fb493a Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 20:52:58 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0=E8=AE=BE=E5=A4=87=E4=B8=8E=E9=80=9A?= =?UTF-8?q?=E9=81=93=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transmit/request/impl/RegisterRequestProcessor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java index 4faab0ef..26764697 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java @@ -144,10 +144,10 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { storager.updateDevice(device); publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER); - // 只有第一次注册才更新通道 - if (!exists) { + // 重新注册更新设备和通道,以免设备替换或更新后信息无法更新 + //if (!exists) { handler.onRegister(device); - } + //} } else if (registerFlag == 2) { logger.info("注销成功! deviceId:" + device.getDeviceId()); publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); From df321f27af64d61c7553aa17c660824522f00a3f Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 20:54:29 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=90=91=E4=B8=8A?= =?UTF-8?q?=E7=BA=A7=E8=81=94=EF=BC=8C=E9=87=8D=E6=96=B0=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E9=87=8D=E8=AE=BEExpires=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/platformEdit.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web_src/src/components/platformEdit.vue b/web_src/src/components/platformEdit.vue index 76697d29..2eafb332 100644 --- a/web_src/src/components/platformEdit.vue +++ b/web_src/src/components/platformEdit.vue @@ -74,7 +74,7 @@ - + @@ -245,6 +245,11 @@ export default { }); return result; }, + checkExpires: function() { + if (this.platform.enable && this.platform.expires == "0") { + this.platform.expires = "300"; + } + } }, }; From dc1d9646a97ac07d20a911c0daf5bae361964717 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 20:56:25 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- .../request/impl/MessageRequestProcessor.java | 38 +++++++------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 0c96aafd..54054a0f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # Mobile Tools for Java (J2ME) .mtj.tmp/ - +src/main/resources/application-*.yml # Package Files # #*.jar *.war @@ -18,7 +18,7 @@ *.zip *.tar.gz *.rar - +*.iml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* /.idea/* diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java index 3ed22b28..c5ae4f5d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java @@ -342,6 +342,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { try { // 回复200 OK responseAck(evt); + String seqNo = String.valueOf(System.currentTimeMillis()); RecordInfo recordInfo = new RecordInfo(); Element rootElement = getRootElement(evt); Element deviceIdElement = rootElement.element("DeviceID"); @@ -396,32 +397,22 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { if (recordInfo.getSumNum() > 0 && recordList.size() > 0 && recordList.size() < recordInfo.getSumNum()) { // 为防止连续请求该设备的录像数据,返回数据错乱,特增加sn进行区分 String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn; - // TODO 暂时直接操作redis存储,后续封装专用缓存接口,改为本地内存缓存 - if (redis.hasKey(cacheKey)) { - List previousList = (List) redis.get(cacheKey); - if (previousList != null && previousList.size() > 0) { - recordList.addAll(previousList); - } - // 本分支表示录像列表被拆包,且加上之前的数据还是不够,保存缓存返回,等待下个包再处理 - if (recordList.size() < recordInfo.getSumNum()) { - logger.info("已获取" + recordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); - redis.set(cacheKey, recordList, 90); - return; - } else { - // 本分支表示录像被拆包,但加上之前的数据够足够,返回响应 - // 因设备心跳有监听redis过期机制,为提高性能,此处手动删除 - logger.info("录像数据已全部获取"); - redis.del(cacheKey); - } - } else { - // 本分支有两种可能:1、录像列表被拆包,且是第一个包,直接保存缓存返回,等待下个包再处理 - // 2、之前有包,但超时清空了,那么这次sn批次的响应数据已经不完整,等待过期时间后redis自动清空数据 - logger.info("已获取" + recordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); - logger.info("等待后续的包..."); - redis.set(cacheKey, recordList, 90); + redis.set(cacheKey + "_" + seqNo, recordList, 90); + List cacheKeys = redis.scan(cacheKey + "_*"); + List totalRecordList = new ArrayList(); + for (int i = 0; i < cacheKeys.size(); i++) { + totalRecordList.addAll((List) redis.get(cacheKeys.get(i).toString())); + } + if (totalRecordList.size() < recordInfo.getSumNum()) { + logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); return; } + logger.info("录像数据已全部获取,共" + recordInfo.getSumNum() + "项"); + recordInfo.setRecordList(totalRecordList); + for (int i = 0; i < cacheKeys.size(); i++) { + redis.del(cacheKeys.get(i).toString()); + } } // 自然顺序排序, 元素进行升序排列 recordInfo.getRecordList().sort(Comparator.naturalOrder()); @@ -460,7 +451,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { cmder.streamByeCmd(streamInfo.getStreamId()); } } - } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { e.printStackTrace(); } From d568a18e0a3e9cfc54175961db66ee659c8f057d Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 21:01:59 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=B8=8Emaster=E5=88=86=E6=94=AF=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java | 4 +++- .../java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java index 0b4ecbb4..c564eddb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java @@ -121,7 +121,9 @@ public class SipLayer implements SipListener { logger.debug(evt.getRequest().toString()); // 由于jainsip是单线程程序,为提高性能并发处理 processThreadPool.execute(() -> { - processorFactory.createRequestProcessor(evt).process(); + if (processorFactory != null) { + processorFactory.createRequestProcessor(evt).process(); + } }); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index ce3d6584..e6a6066f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -66,5 +66,4 @@ public interface DeviceMapper { @Delete("DELETE FROM device WHERE deviceId=#{deviceId}") int del(String deviceId); - } From 80b5dc0068f86a633fca363656d827a70b0bfd61 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Mon, 11 Jan 2021 21:03:23 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=A1=B5=E7=A0=81?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/channelList.vue | 5 ++--- web_src/src/components/videoList.vue | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index 4f663fa2..928ee1f5 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -153,11 +153,10 @@ export default { }, getDeviceChannelList: function () { let that = this; - console.log(this.currentPage - 1) this.$axios.get(`/api/devices/${this.$route.params.deviceId}/channels`, { params: { - page: that.currentPage - 1, + page: that.currentPage, count: that.count, query: that.searchSrt, online: that.online, @@ -254,7 +253,7 @@ export default { this.$axios.get(`/api/subChannels/${this.deviceId}/${this.parentChannelId}/channels`, { params: { - page: that.currentPage - 1, + page: that.currentPage, count: that.count, query: that.searchSrt, online: that.online, diff --git a/web_src/src/components/videoList.vue b/web_src/src/components/videoList.vue index 002a5813..01dae2c3 100644 --- a/web_src/src/components/videoList.vue +++ b/web_src/src/components/videoList.vue @@ -134,7 +134,7 @@ this.getDeviceListLoading = true; this.$axios.get(`/api/devices`,{ params: { - page: that.currentPage - 1, + page: that.currentPage, count: that.count } } )