648540858
2022-05-26 2a5404c68f387523a833b8e9f17cda5b0c9ad727
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
@@ -3,6 +3,8 @@
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
@@ -18,6 +20,7 @@
import javax.sip.InvalidArgumentException;
import javax.sip.RequestEvent;
import javax.sip.SipException;
import javax.sip.header.CallIdHeader;
import javax.sip.message.Response;
import java.text.ParseException;
@@ -38,6 +41,9 @@
    @Autowired
    private IRedisCatchStorage redisCatchStorage;
    @Autowired
    private VideoStreamSessionManager sessionManager;
    @Override
    public void afterPropertiesSet() throws Exception {
        notifyMessageHandler.addHandler(cmdType, this);
@@ -56,14 +62,25 @@
        } catch (ParseException e) {
            e.printStackTrace();
        }
        CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
        String NotifyType =getText(rootElement, "NotifyType");
        if (NotifyType.equals("121")){
            logger.info("媒体播放完毕,通知关流");
            StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(device.getDeviceId(), "*");
            logger.info("[录像流]推送完毕,收到关流通知");
            // 查询是设备
            StreamInfo streamInfo = redisCatchStorage.queryDownload(null, null, null, callIdHeader.getCallId());
            if (streamInfo != null) {
                redisCatchStorage.stopPlayback(streamInfo);
                cmder.streamByeCmd(streamInfo.getDeviceID(), streamInfo.getChannelId());
                // 设置进度100%
                streamInfo.setProgress(1);
                redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId());
            }
            // 先从会话内查找
            SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
            if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题
                cmder.streamByeCmd(device.getDeviceId(), ssrcTransaction.getChannelId(), null, callIdHeader.getCallId());
            }
            // TODO 如果级联播放,需要给上级发送此通知
        }
    }