Lawrence
2020-11-13 c009637e0979741475e78c01551e7dcdcf99ecbf
增加录像回放结束后对设备发出的MediaStatus的回应并关流
1个文件已修改
37 ■■■■■ 已修改文件
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -34,7 +34,7 @@
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.springframework.util.StringUtils;
import com.genersoft.iot.vmp.common.StreamInfo;
/**
 * @Description:MESSAGE请求处理器
 * @author: swwheihei
@@ -64,6 +64,7 @@
    private static final String MESSAGE_DEVICE_INFO = "DeviceInfo";
    private static final String MESSAGE_ALARM = "Alarm";
    private static final String MESSAGE_RECORD_INFO = "RecordInfo";
    private static final String MESSAGE_MEDIA_STATUS = "MediaStatus";
    // private static final String MESSAGE_BROADCAST = "Broadcast";
    // private static final String MESSAGE_DEVICE_STATUS = "DeviceStatus";
    // private static final String MESSAGE_MOBILE_POSITION = "MobilePosition";
@@ -98,6 +99,11 @@
            } else if (MESSAGE_RECORD_INFO.equals(cmd)) {
                logger.info("接收到RecordInfo消息");
                processMessageRecordInfo(evt);
            }else if (MESSAGE_MEDIA_STATUS.equals(cmd)) {
                logger.info("接收到MediaStatus消息");
                processMessageMediaStatus(evt);
            } else {
                logger.info("接收到消息:" + cmd);
            }
        } catch (DocumentException e) {
            e.printStackTrace();
@@ -399,6 +405,35 @@
        }
    }
    private void processMessageMediaStatus(RequestEvent evt){
        try {
            // 回复200 OK
            responseAck(evt);
            Element rootElement = getRootElement(evt);
            String deviceId = XmlUtil.getText(rootElement, "DeviceID");
            String NotifyType =XmlUtil.getText(rootElement, "NotifyType");
            if (NotifyType.equals("121")){
                logger.info("媒体播放完毕,通知关流");
                StreamInfo streamInfo = storager.queryPlaybackByDevice(deviceId, "*");
                if (streamInfo != null) {
                    storager.stopPlayback(streamInfo);
                    cmder.streamByeCmd(streamInfo.getSsrc());
                }
            }
        } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
            e.printStackTrace();
        }
    }
    /***
     * 回复200 OK
     * @param evt
     * @throws SipException
     * @throws InvalidArgumentException
     * @throws ParseException
     */
    private void responseAck(RequestEvent evt) throws SipException, InvalidArgumentException, ParseException {
        Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest());
        getServerTransaction(evt).sendResponse(response);