648540858
2021-06-22 11e8fad2e981b3dca22dad4048246d012ce326b7
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -7,6 +7,7 @@
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaConfig;
import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
@@ -14,10 +15,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -54,6 +53,9 @@
   private IRedisCatchStorage redisCatchStorage;
   @Autowired
   private ZLMRESTfulUtils zlmresTfulUtils;
   @Autowired
   private ZLMServerManger zlmServerManger;
    @Autowired
@@ -62,8 +64,8 @@
   @Autowired
   private ZLMHttpHookSubscribe subscribe;
   @Value("${userSettings.autoApplyPlay}")
   private boolean autoApplyPlay;
   @Autowired
   private UserSetup userSetup;
   @Autowired
   private MediaConfig mediaConfig;
@@ -132,10 +134,8 @@
   @ResponseBody
   @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
   public ResponseEntity<String> onPublish(@RequestBody JSONObject json){
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString());
      }
      logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString());
      ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
      if (subscribe != null) subscribe.response(json);
@@ -144,7 +144,7 @@
      ret.put("code", 0);
      ret.put("msg", "success");
      ret.put("enableHls", true);
      ret.put("enableMP4", false);
      ret.put("enableMP4", userSetup.isRecordPushLive());
      ret.put("enableRtxp", true);
      return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
   }
@@ -333,11 +333,10 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_stream_not_found API调用,参数:" + json.toString());
      }
      if (autoApplyPlay) {
      if (userSetup.isAutoApplyPlay()) {
         String app = json.getString("app");
         String streamId = json.getString("stream");
            StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
         if ("rtp".equals(app) && streamId.contains("gb_play") && streamInfo == null) {
         if ("rtp".equals(app) && streamId.contains("gb_play") ) {
            String[] s = streamId.split("_");
            if (s.length == 4) {
               String deviceId = s[2];
@@ -352,7 +351,6 @@
               }
            }
         }
      }