Commit 98e6cf5bae84ec7860c3da3a6e3228353ae9b385
1 parent
d571e440
优化海康录像下载
Showing
5 changed files
with
18 additions
and
9 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
| @@ -66,7 +66,6 @@ public class SubscribeHolder { | @@ -66,7 +66,6 @@ public class SubscribeHolder { | ||
| 66 | dynamicTask.stop(taskOverdueKey); | 66 | dynamicTask.stop(taskOverdueKey); |
| 67 | // 添加任务处理订阅过期 | 67 | // 添加任务处理订阅过期 |
| 68 | dynamicTask.startDelay(taskOverdueKey, () -> { | 68 | dynamicTask.startDelay(taskOverdueKey, () -> { |
| 69 | - System.out.println("订阅过期"); | ||
| 70 | removeMobilePositionSubscribe(subscribeInfo.getId()); | 69 | removeMobilePositionSubscribe(subscribeInfo.getId()); |
| 71 | }, | 70 | }, |
| 72 | subscribeInfo.getExpires() * 1000); | 71 | subscribeInfo.getExpires() * 1000); |
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
| @@ -76,8 +76,8 @@ public class VideoStreamSessionManager { | @@ -76,8 +76,8 @@ public class VideoStreamSessionManager { | ||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | - public ClientTransaction getTransactionByStream(String deviceId, String channelId, String stream){ | ||
| 80 | - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 79 | + public ClientTransaction getTransaction(String deviceId, String channelId, String stream, String callId){ |
| 80 | + SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, stream); | ||
| 81 | if (ssrcTransaction == null) { | 81 | if (ssrcTransaction == null) { |
| 82 | return null; | 82 | return null; |
| 83 | } | 83 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -652,6 +652,14 @@ public class SIPCommander implements ISIPCommander { | @@ -652,6 +652,14 @@ public class SIPCommander implements ISIPCommander { | ||
| 652 | (MediaServerItem mediaServerItemInUse, JSONObject json)->{ | 652 | (MediaServerItem mediaServerItemInUse, JSONObject json)->{ |
| 653 | hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); | 653 | hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); |
| 654 | subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); | 654 | subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); |
| 655 | + subscribeKey.put("regist", false); | ||
| 656 | + subscribeKey.put("schema", "rtmp"); | ||
| 657 | + // 添加流注销的订阅,注销了后向设备发送bye | ||
| 658 | + subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, | ||
| 659 | + (MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd)->{ | ||
| 660 | + logger.info("[录像]下载结束, 发送BYE"); | ||
| 661 | + streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), callIdHeader.getCallId()); | ||
| 662 | + }); | ||
| 655 | }); | 663 | }); |
| 656 | 664 | ||
| 657 | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc()); | 665 | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc()); |
| @@ -684,10 +692,10 @@ public class SIPCommander implements ISIPCommander { | @@ -684,10 +692,10 @@ public class SIPCommander implements ISIPCommander { | ||
| 684 | @Override | 692 | @Override |
| 685 | public void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent) { | 693 | public void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent) { |
| 686 | try { | 694 | try { |
| 687 | - SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(deviceId, channelId, null, stream); | ||
| 688 | - ClientTransaction transaction = streamSession.getTransactionByStream(deviceId, channelId, stream); | 695 | + SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(deviceId, channelId, callId, stream); |
| 696 | + ClientTransaction transaction = streamSession.getTransaction(deviceId, channelId, stream, callId); | ||
| 689 | 697 | ||
| 690 | - if (transaction == null) { | 698 | + if (transaction == null ) { |
| 691 | logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId); | 699 | logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId); |
| 692 | SipSubscribe.EventResult<Object> eventResult = new SipSubscribe.EventResult<>(); | 700 | SipSubscribe.EventResult<Object> eventResult = new SipSubscribe.EventResult<>(); |
| 693 | if (okEvent != null) { | 701 | if (okEvent != null) { |
| @@ -1664,6 +1672,7 @@ public class SIPCommander implements ISIPCommander { | @@ -1664,6 +1672,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 1664 | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { | 1672 | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { |
| 1665 | errorEvent.response(eventResult); | 1673 | errorEvent.response(eventResult); |
| 1666 | sipSubscribe.removeErrorSubscribe(eventResult.callId); | 1674 | sipSubscribe.removeErrorSubscribe(eventResult.callId); |
| 1675 | + sipSubscribe.removeOkSubscribe(eventResult.callId); | ||
| 1667 | })); | 1676 | })); |
| 1668 | } | 1677 | } |
| 1669 | // 添加订阅 | 1678 | // 添加订阅 |
| @@ -1671,6 +1680,7 @@ public class SIPCommander implements ISIPCommander { | @@ -1671,6 +1680,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 1671 | sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{ | 1680 | sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{ |
| 1672 | okEvent.response(eventResult); | 1681 | okEvent.response(eventResult); |
| 1673 | sipSubscribe.removeOkSubscribe(eventResult.callId); | 1682 | sipSubscribe.removeOkSubscribe(eventResult.callId); |
| 1683 | + sipSubscribe.removeErrorSubscribe(eventResult.callId); | ||
| 1674 | }); | 1684 | }); |
| 1675 | } | 1685 | } |
| 1676 | 1686 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
| @@ -60,10 +60,9 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i | @@ -60,10 +60,9 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i | ||
| 60 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); | 60 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); |
| 61 | String NotifyType =getText(rootElement, "NotifyType"); | 61 | String NotifyType =getText(rootElement, "NotifyType"); |
| 62 | if (NotifyType.equals("121")){ | 62 | if (NotifyType.equals("121")){ |
| 63 | - logger.info("媒体播放完毕,通知关流"); | 63 | + logger.info("[录像流]推送完毕,收到关流通知"); |
| 64 | String channelId =getText(rootElement, "DeviceID"); | 64 | String channelId =getText(rootElement, "DeviceID"); |
| 65 | -// redisCatchStorage.stopPlayback(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); | ||
| 66 | -// redisCatchStorage.stopDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); | 65 | + // 查询是设备 |
| 67 | StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); | 66 | StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); |
| 68 | // 设置进度100% | 67 | // 设置进度100% |
| 69 | streamInfo.setProgress(1); | 68 | streamInfo.setProgress(1); |
web_src/src/components/dialog/recordDownload.vue
| @@ -172,6 +172,7 @@ export default { | @@ -172,6 +172,7 @@ export default { | ||
| 172 | isEnd: true, | 172 | isEnd: true, |
| 173 | } | 173 | } |
| 174 | }).then((res) => { | 174 | }).then((res) => { |
| 175 | + console.log(res) | ||
| 175 | if (res.data.code == 0) { | 176 | if (res.data.code == 0) { |
| 176 | this.percentage = parseFloat(res.data.data.percentage)*100 | 177 | this.percentage = parseFloat(res.data.data.percentage)*100 |
| 177 | if (res.data.data[0].percentage === '1') { | 178 | if (res.data.data[0].percentage === '1') { |