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 | 66 | dynamicTask.stop(taskOverdueKey); |
| 67 | 67 | // 添加任务处理订阅过期 |
| 68 | 68 | dynamicTask.startDelay(taskOverdueKey, () -> { |
| 69 | - System.out.println("订阅过期"); | |
| 70 | 69 | removeMobilePositionSubscribe(subscribeInfo.getId()); |
| 71 | 70 | }, |
| 72 | 71 | subscribeInfo.getExpires() * 1000); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
| ... | ... | @@ -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 | 81 | if (ssrcTransaction == null) { |
| 82 | 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 | 652 | (MediaServerItem mediaServerItemInUse, JSONObject json)->{ |
| 653 | 653 | hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); |
| 654 | 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 | 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 | 692 | @Override |
| 685 | 693 | public void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent) { |
| 686 | 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 | 699 | logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId); |
| 692 | 700 | SipSubscribe.EventResult<Object> eventResult = new SipSubscribe.EventResult<>(); |
| 693 | 701 | if (okEvent != null) { |
| ... | ... | @@ -1664,6 +1672,7 @@ public class SIPCommander implements ISIPCommander { |
| 1664 | 1672 | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { |
| 1665 | 1673 | errorEvent.response(eventResult); |
| 1666 | 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 | 1680 | sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{ |
| 1672 | 1681 | okEvent.response(eventResult); |
| 1673 | 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 | 60 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); |
| 61 | 61 | String NotifyType =getText(rootElement, "NotifyType"); |
| 62 | 62 | if (NotifyType.equals("121")){ |
| 63 | - logger.info("媒体播放完毕,通知关流"); | |
| 63 | + logger.info("[录像流]推送完毕,收到关流通知"); | |
| 64 | 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 | 66 | StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); |
| 68 | 67 | // 设置进度100% |
| 69 | 68 | streamInfo.setProgress(1); | ... | ... |
web_src/src/components/dialog/recordDownload.vue