old mode 100644
new mode 100755
|  |  |  | 
|---|
|  |  |  | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.StreamInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.InviteInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.InviteSessionType; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.bean.Device; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.media.event.hook.Hook; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.media.event.hook.HookType; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.service.IInviteStreamService; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 
|---|
|  |  |  | import gov.nist.javax.sip.message.SIPRequest; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private VideoStreamSessionManager sessionManager; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private HookSubscribe subscribe; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private IInviteStreamService inviteStreamService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private VideoStreamSessionManager streamSession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void afterPropertiesSet() throws Exception { | 
|---|
|  |  |  | notifyMessageHandler.addHandler(cmdType, this); | 
|---|
|  |  |  | 
|---|
|  |  |  | String NotifyType =getText(rootElement, "NotifyType"); | 
|---|
|  |  |  | if ("121".equals(NotifyType)){ | 
|---|
|  |  |  | logger.info("[录像流]推送完毕,收到关流通知"); | 
|---|
|  |  |  | // 查询是设备 | 
|---|
|  |  |  | StreamInfo streamInfo = redisCatchStorage.queryDownload(null, null, null, callIdHeader.getCallId()); | 
|---|
|  |  |  | if (streamInfo != null) { | 
|---|
|  |  |  | // 设置进度100% | 
|---|
|  |  |  | streamInfo.setProgress(1); | 
|---|
|  |  |  | redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 先从会话内查找 | 
|---|
|  |  |  | SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); | 
|---|
|  |  |  | if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题 | 
|---|
|  |  |  | SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); | 
|---|
|  |  |  | if (ssrcTransaction != null) { | 
|---|
|  |  |  | logger.info("[录像流]推送完毕,关流通知, device: {}, channelId: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); | 
|---|
|  |  |  | InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); | 
|---|
|  |  |  | if (inviteInfo.getStreamInfo() != null) { | 
|---|
|  |  |  | inviteInfo.getStreamInfo().setProgress(1); | 
|---|
|  |  |  | inviteStreamService.updateInviteInfo(inviteInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), null, callIdHeader.getCallId()); | 
|---|
|  |  |  | } catch (InvalidArgumentException | ParseException | SsrcTransactionNotFoundException | SipException e) { | 
|---|
|  |  |  | } catch (InvalidArgumentException | ParseException  | SipException | SsrcTransactionNotFoundException e) { | 
|---|
|  |  |  | logger.error("[录像流]推送完毕,收到关流通知, 发送BYE失败 {}", e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 去除监听流注销自动停止下载的监听 | 
|---|
|  |  |  | Hook hook = Hook.getInstance(HookType.on_media_arrival, "rtp", ssrcTransaction.getStream(), ssrcTransaction.getMediaServerId()); | 
|---|
|  |  |  | subscribe.removeSubscribe(hook); | 
|---|
|  |  |  | // 如果级联播放,需要给上级发送此通知 TODO 多个上级同时观看一个下级 可能存在停错的问题,需要将点播CallId进行上下级绑定 | 
|---|
|  |  |  | SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, ssrcTransaction.getChannelId(), null, null); | 
|---|
|  |  |  | if (sendRtpItem != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | logger.error("[命令发送失败] 国标级联 录像播放完毕: {}", e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | logger.info("[录像流]推送完毕,关流通知, 但是未找到对应的下载信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|