Browse Source

优化海康录像下载

pull/473/head
648540858 3 years ago
parent
commit
98e6cf5bae
  1. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
  2. 4
      src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
  3. 14
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  4. 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
  5. 1
      web_src/src/components/dialog/recordDownload.vue

1
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java

@ -66,7 +66,6 @@ public class SubscribeHolder {
dynamicTask.stop(taskOverdueKey); dynamicTask.stop(taskOverdueKey);
// 添加任务处理订阅过期 // 添加任务处理订阅过期
dynamicTask.startDelay(taskOverdueKey, () -> { dynamicTask.startDelay(taskOverdueKey, () -> {
System.out.println("订阅过期");
removeMobilePositionSubscribe(subscribeInfo.getId()); removeMobilePositionSubscribe(subscribeInfo.getId());
}, },
subscribeInfo.getExpires() * 1000); subscribeInfo.getExpires() * 1000);

4
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java

@ -76,8 +76,8 @@ public class VideoStreamSessionManager {
} }
public ClientTransaction getTransactionByStream(String deviceId, String channelId, String stream){ public ClientTransaction getTransaction(String deviceId, String channelId, String stream, String callId){
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, stream);
if (ssrcTransaction == null) { if (ssrcTransaction == null) {
return null; return null;
} }

14
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -652,6 +652,14 @@ public class SIPCommander implements ISIPCommander {
(MediaServerItem mediaServerItemInUse, JSONObject json)->{ (MediaServerItem mediaServerItemInUse, JSONObject json)->{
hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream()));
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
subscribeKey.put("regist", false);
subscribeKey.put("schema", "rtmp");
// 添加流注销的订阅,注销了后向设备发送bye
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
(MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd)->{
logger.info("[录像]下载结束, 发送BYE");
streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), callIdHeader.getCallId());
});
}); });
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc()); Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc());
@ -684,8 +692,8 @@ public class SIPCommander implements ISIPCommander {
@Override @Override
public void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent) { public void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent) {
try { try {
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(deviceId, channelId, null, stream); SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(deviceId, channelId, callId, stream);
ClientTransaction transaction = streamSession.getTransactionByStream(deviceId, channelId, stream); ClientTransaction transaction = streamSession.getTransaction(deviceId, channelId, stream, callId);
if (transaction == null ) { if (transaction == null ) {
logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId); logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId);
@ -1664,6 +1672,7 @@ public class SIPCommander implements ISIPCommander {
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> {
errorEvent.response(eventResult); errorEvent.response(eventResult);
sipSubscribe.removeErrorSubscribe(eventResult.callId); sipSubscribe.removeErrorSubscribe(eventResult.callId);
sipSubscribe.removeOkSubscribe(eventResult.callId);
})); }));
} }
// 添加订阅 // 添加订阅
@ -1671,6 +1680,7 @@ public class SIPCommander implements ISIPCommander {
sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{ sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{
okEvent.response(eventResult); okEvent.response(eventResult);
sipSubscribe.removeOkSubscribe(eventResult.callId); sipSubscribe.removeOkSubscribe(eventResult.callId);
sipSubscribe.removeErrorSubscribe(eventResult.callId);
}); });
} }

5
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
CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
String NotifyType =getText(rootElement, "NotifyType"); String NotifyType =getText(rootElement, "NotifyType");
if (NotifyType.equals("121")){ if (NotifyType.equals("121")){
logger.info("媒体播放完毕,通知关流"); logger.info("[录像流]推送完毕,收到关流通知");
String channelId =getText(rootElement, "DeviceID"); String channelId =getText(rootElement, "DeviceID");
// redisCatchStorage.stopPlayback(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); // 查询是设备
// redisCatchStorage.stopDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId());
StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId());
// 设置进度100% // 设置进度100%
streamInfo.setProgress(1); streamInfo.setProgress(1);

1
web_src/src/components/dialog/recordDownload.vue

@ -172,6 +172,7 @@ export default {
isEnd: true, isEnd: true,
} }
}).then((res) => { }).then((res) => {
console.log(res)
if (res.data.code == 0) { if (res.data.code == 0) {
this.percentage = parseFloat(res.data.data.percentage)*100 this.percentage = parseFloat(res.data.data.percentage)*100
if (res.data.data[0].percentage === '1') { if (res.data.data[0].percentage === '1') {

Loading…
Cancel
Save