Commit 6e4a8cac04432f5a36d5c5e3c5eb3d28d2295a5c
Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
Showing
5 changed files
with
27 additions
and
40 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -290,12 +290,8 @@ public class SIPCommander implements ISIPCommander { | @@ -290,12 +290,8 @@ public class SIPCommander implements ISIPCommander { | ||
| 290 | @Override | 290 | @Override |
| 291 | public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { | 291 | public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { |
| 292 | try { | 292 | try { |
| 293 | - String ssrc = ""; | ||
| 294 | - if (rtpEnable) { | ||
| 295 | - ssrc = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); | ||
| 296 | - }else { | ||
| 297 | - ssrc = streamSession.createPlaySsrc(); | ||
| 298 | - } | 293 | + |
| 294 | + String ssrc = streamSession.createPlaySsrc(); | ||
| 299 | String streamId = null; | 295 | String streamId = null; |
| 300 | if (rtpEnable) { | 296 | if (rtpEnable) { |
| 301 | streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); | 297 | streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); |
| @@ -412,16 +408,13 @@ public class SIPCommander implements ISIPCommander { | @@ -412,16 +408,13 @@ public class SIPCommander implements ISIPCommander { | ||
| 412 | , SipSubscribe.Event errorEvent) { | 408 | , SipSubscribe.Event errorEvent) { |
| 413 | try { | 409 | try { |
| 414 | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 410 | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 415 | - String ssrc = null; | 411 | + String ssrc = streamSession.createPlayBackSsrc(); |
| 416 | String streamId = null; | 412 | String streamId = null; |
| 417 | if (rtpEnable) { | 413 | if (rtpEnable) { |
| 418 | - ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); | ||
| 419 | - streamId = ssrc; | 414 | + streamId = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); |
| 420 | }else { | 415 | }else { |
| 421 | - ssrc = streamSession.createPlayBackSsrc(); | ||
| 422 | streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | 416 | streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); |
| 423 | } | 417 | } |
| 424 | - | ||
| 425 | // 添加订阅 | 418 | // 添加订阅 |
| 426 | JSONObject subscribeKey = new JSONObject(); | 419 | JSONObject subscribeKey = new JSONObject(); |
| 427 | subscribeKey.put("app", "rtp"); | 420 | subscribeKey.put("app", "rtp"); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| @@ -342,6 +342,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -342,6 +342,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 342 | try { | 342 | try { |
| 343 | // 回复200 OK | 343 | // 回复200 OK |
| 344 | responseAck(evt); | 344 | responseAck(evt); |
| 345 | + String seqNo = String.valueOf(System.currentTimeMillis()); | ||
| 345 | RecordInfo recordInfo = new RecordInfo(); | 346 | RecordInfo recordInfo = new RecordInfo(); |
| 346 | Element rootElement = getRootElement(evt); | 347 | Element rootElement = getRootElement(evt); |
| 347 | Element deviceIdElement = rootElement.element("DeviceID"); | 348 | Element deviceIdElement = rootElement.element("DeviceID"); |
| @@ -396,32 +397,22 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -396,32 +397,22 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 396 | if (recordInfo.getSumNum() > 0 && recordList.size() > 0 && recordList.size() < recordInfo.getSumNum()) { | 397 | if (recordInfo.getSumNum() > 0 && recordList.size() > 0 && recordList.size() < recordInfo.getSumNum()) { |
| 397 | // 为防止连续请求该设备的录像数据,返回数据错乱,特增加sn进行区分 | 398 | // 为防止连续请求该设备的录像数据,返回数据错乱,特增加sn进行区分 |
| 398 | String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn; | 399 | String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn; |
| 399 | - // TODO 暂时直接操作redis存储,后续封装专用缓存接口,改为本地内存缓存 | ||
| 400 | - if (redis.hasKey(cacheKey)) { | ||
| 401 | - List<RecordItem> previousList = (List<RecordItem>) redis.get(cacheKey); | ||
| 402 | - if (previousList != null && previousList.size() > 0) { | ||
| 403 | - recordList.addAll(previousList); | ||
| 404 | - } | ||
| 405 | - // 本分支表示录像列表被拆包,且加上之前的数据还是不够,保存缓存返回,等待下个包再处理 | ||
| 406 | - if (recordList.size() < recordInfo.getSumNum()) { | ||
| 407 | - logger.info("已获取" + recordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); | ||
| 408 | - redis.set(cacheKey, recordList, 90); | ||
| 409 | - return; | ||
| 410 | - } else { | ||
| 411 | - // 本分支表示录像被拆包,但加上之前的数据够足够,返回响应 | ||
| 412 | - // 因设备心跳有监听redis过期机制,为提高性能,此处手动删除 | ||
| 413 | - logger.info("录像数据已全部获取"); | ||
| 414 | - redis.del(cacheKey); | ||
| 415 | - } | ||
| 416 | - } else { | ||
| 417 | - // 本分支有两种可能:1、录像列表被拆包,且是第一个包,直接保存缓存返回,等待下个包再处理 | ||
| 418 | - // 2、之前有包,但超时清空了,那么这次sn批次的响应数据已经不完整,等待过期时间后redis自动清空数据 | ||
| 419 | - logger.info("已获取" + recordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); | ||
| 420 | - logger.info("等待后续的包..."); | ||
| 421 | 400 | ||
| 422 | - redis.set(cacheKey, recordList, 90); | 401 | + redis.set(cacheKey + "_" + seqNo, recordList, 90); |
| 402 | + List<Object> cacheKeys = redis.scan(cacheKey + "_*"); | ||
| 403 | + List<RecordItem> totalRecordList = new ArrayList<RecordItem>(); | ||
| 404 | + for (int i = 0; i < cacheKeys.size(); i++) { | ||
| 405 | + totalRecordList.addAll((List<RecordItem>) redis.get(cacheKeys.get(i).toString())); | ||
| 406 | + } | ||
| 407 | + if (totalRecordList.size() < recordInfo.getSumNum()) { | ||
| 408 | + logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); | ||
| 423 | return; | 409 | return; |
| 424 | } | 410 | } |
| 411 | + logger.info("录像数据已全部获取,共" + recordInfo.getSumNum() + "项"); | ||
| 412 | + recordInfo.setRecordList(totalRecordList); | ||
| 413 | + for (int i = 0; i < cacheKeys.size(); i++) { | ||
| 414 | + redis.del(cacheKeys.get(i).toString()); | ||
| 415 | + } | ||
| 425 | } | 416 | } |
| 426 | // 自然顺序排序, 元素进行升序排列 | 417 | // 自然顺序排序, 元素进行升序排列 |
| 427 | recordInfo.getRecordList().sort(Comparator.naturalOrder()); | 418 | recordInfo.getRecordList().sort(Comparator.naturalOrder()); |
| @@ -460,7 +451,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -460,7 +451,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 460 | cmder.streamByeCmd(streamInfo.getStreamId()); | 451 | cmder.streamByeCmd(streamInfo.getStreamId()); |
| 461 | } | 452 | } |
| 462 | } | 453 | } |
| 463 | - | ||
| 464 | } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { | 454 | } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { |
| 465 | e.printStackTrace(); | 455 | e.printStackTrace(); |
| 466 | } | 456 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| @@ -144,10 +144,10 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -144,10 +144,10 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 144 | storager.updateDevice(device); | 144 | storager.updateDevice(device); |
| 145 | publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER); | 145 | publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER); |
| 146 | 146 | ||
| 147 | - // 只有第一次注册才更新通道 | ||
| 148 | - if (!exists) { | 147 | + // 重新注册更新设备和通道,以免设备替换或更新后信息无法更新 |
| 148 | + //if (!exists) { | ||
| 149 | handler.onRegister(device); | 149 | handler.onRegister(device); |
| 150 | - } | 150 | + //} |
| 151 | } else if (registerFlag == 2) { | 151 | } else if (registerFlag == 2) { |
| 152 | logger.info("注销成功! deviceId:" + device.getDeviceId()); | 152 | logger.info("注销成功! deviceId:" + device.getDeviceId()); |
| 153 | publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); | 153 | publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
web_src/src/components/platformEdit.vue
| @@ -74,7 +74,7 @@ | @@ -74,7 +74,7 @@ | ||
| 74 | </el-select> | 74 | </el-select> |
| 75 | </el-form-item> | 75 | </el-form-item> |
| 76 | <el-form-item label="其他选项"> | 76 | <el-form-item label="其他选项"> |
| 77 | - <el-checkbox label="启用" v-model="platform.enable"></el-checkbox> | 77 | + <el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox> |
| 78 | <el-checkbox label="云台控制" v-model="platform.PTZEnable"></el-checkbox> | 78 | <el-checkbox label="云台控制" v-model="platform.PTZEnable"></el-checkbox> |
| 79 | <el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox> | 79 | <el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox> |
| 80 | </el-form-item> | 80 | </el-form-item> |
| @@ -245,6 +245,11 @@ export default { | @@ -245,6 +245,11 @@ export default { | ||
| 245 | }); | 245 | }); |
| 246 | return result; | 246 | return result; |
| 247 | }, | 247 | }, |
| 248 | + checkExpires: function() { | ||
| 249 | + if (this.platform.enable && this.platform.expires == "0") { | ||
| 250 | + this.platform.expires = "300"; | ||
| 251 | + } | ||
| 252 | + } | ||
| 248 | }, | 253 | }, |
| 249 | }; | 254 | }; |
| 250 | </script> | 255 | </script> |