lawrencehj
2021-03-10 b01ec1d72738de24777aee67313539b50f98a15a
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -1,19 +1,13 @@
package com.genersoft.iot.vmp.media.zlm;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.IpUtil;
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,8 +51,8 @@
   @Autowired
   private IRedisCatchStorage redisCatchStorage;
   @Autowired
   private ZLMRESTfulUtils zlmresTfulUtils;
   // @Autowired
   // private ZLMRESTfulUtils zlmresTfulUtils;
   @Autowired
   private ZLMHttpHookSubscribe subscribe;
@@ -82,10 +76,10 @@
   @ResponseBody
   @PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8")
   public ResponseEntity<String> onFlowReport(@RequestBody JSONObject json){
      logger.debug("ZLM HOOK on_flow_report API调用,参数:" + json.toString());
      // TODO Auto-generated method stub
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_flow_report API调用,参数:" + json.toString());
      }
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");
@@ -103,8 +97,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_http_access API 调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("err", "");
@@ -124,8 +116,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");
@@ -143,15 +133,10 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString());
      }
      String app = json.getString("app");
      String streamId = json.getString("id");
      ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
      if (subscribe != null) subscribe.response(json);
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");
@@ -172,8 +157,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_record_mp4 API调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");
@@ -191,8 +174,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_rtsp_realm API调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("realm", "");
@@ -211,8 +192,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_rtsp_auth API调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("encrypted", false);
@@ -232,8 +211,8 @@
         logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString());
      }
      // TODO 如果是带有rtpstream则开启按需拉流
      String app = json.getString("app");
      String stream = json.getString("stream");
      // String app = json.getString("app");
      // String stream = json.getString("stream");
      ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
      if (subscribe != null) subscribe.response(json);
@@ -269,8 +248,6 @@
            redisCatchStorage.stopPlayback(streamInfo);
         }
      }
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");
@@ -318,8 +295,6 @@
      if (logger.isDebugEnabled()) {
         logger.debug("ZLM HOOK on_stream_not_found API调用,参数:" + json.toString());
      }
      // TODO Auto-generated method stub
      if (autoApplyPlay) {
         String app = json.getString("app");
         String streamId = json.getString("stream");
@@ -369,8 +344,6 @@
      mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp);
      mediaServerConfig.setLocalIP(mediaIp);
      redisCatchStorage.updateMediaInfo(mediaServerConfig);
      // TODO Auto-generated method stub
      JSONObject ret = new JSONObject();
      ret.put("code", 0);
      ret.put("msg", "success");