panlinlin
2021-01-04 dcd78a1cfa0c929403d51a347e43414f6aa5f0d8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -10,6 +10,7 @@
import javax.sip.message.Request;
import javax.sip.message.Response;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -47,6 +48,8 @@
   private SIPCommander cmder;
   private IVideoManagerStorager storager;
   private IRedisCatchStorage redisCatchStorage;
   private EventPublisher publisher;
@@ -184,10 +187,11 @@
               DeviceChannel deviceChannel = new DeviceChannel();
               deviceChannel.setName(channelName);
               deviceChannel.setChannelId(channelDeviceId);
               if (status.equals("ON") || status.equals("On")) {
               // ONLINE OFFLINE  HIKVISION DS-7716N-E4 NVR的兼容性处理
               if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) {
                  deviceChannel.setStatus(1);
               }
               if (status.equals("OFF") || status.equals("Off")) {
               if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
                  deviceChannel.setStatus(0);
               }
@@ -293,7 +297,7 @@
            device.setStreamMode("UDP");
         }
         storager.updateDevice(device);
         cmder.catalogQuery(device);
         cmder.catalogQuery(device, null);
         // 回复200 OK
         responseAck(evt);
         if (offLineDetector.isOnline(deviceId)) {
@@ -314,12 +318,16 @@
      try {
         Element rootElement = getRootElement(evt);
         String deviceId = XmlUtil.getText(rootElement, "DeviceID");
         // 回复200 OK
         responseAck(evt);
         if (offLineDetector.isOnline(deviceId)) {
            publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
         } else {
         // 检查设备是否存在, 不存在则不回复
         if (storager.exists(deviceId)) {
            // 回复200 OK
            responseAck(evt);
            if (offLineDetector.isOnline(deviceId)) {
               publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
            } else {
            }
         }
      } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
         e.printStackTrace();
      }
@@ -446,10 +454,10 @@
         String NotifyType =XmlUtil.getText(rootElement, "NotifyType");
         if (NotifyType.equals("121")){
            logger.info("媒体播放完毕,通知关流");
            StreamInfo streamInfo = storager.queryPlaybackByDevice(deviceId, "*");
            StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, "*");
            if (streamInfo != null) {
               storager.stopPlayback(streamInfo);
               cmder.streamByeCmd(streamInfo.getSsrc());
               redisCatchStorage.stopPlayback(streamInfo);
               cmder.streamByeCmd(streamInfo.getStreamId());
            }
         }
      } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
@@ -502,4 +510,11 @@
      this.offLineDetector = offLineDetector;
   }
   public IRedisCatchStorage getRedisCatchStorage() {
      return redisCatchStorage;
   }
   public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) {
      this.redisCatchStorage = redisCatchStorage;
   }
}