lawrencehj
2021-06-23 0acf13445a2e3120f3d3599238401c9f2885d711
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -12,6 +12,7 @@
import com.alibaba.fastjson.JSONObject;
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.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
@@ -24,7 +25,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@@ -83,14 +83,8 @@
   @Autowired
   private MediaConfig mediaConfig;
   @Value("${userSettings.seniorSdp}")
   private boolean seniorSdp;
   @Value("${userSettings.autoApplyPlay}")
   private boolean autoApplyPlay;
   @Value("${userSettings.waitTrack}")
   private boolean waitTrack;
   @Autowired
   private UserSetup userSetup;
   @Autowired
   private ZLMHttpHookSubscribe subscribe;
@@ -362,10 +356,10 @@
            logger.warn("点播时发现ZLM尚未连接...");
            return;
         }
         String mediaPort = null;
         Integer mediaPort = null;
         // 使用动态udp端口
         if (mediaConfig.isRtpEnable()) {
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId);
         }else {
            mediaPort = mediaInfo.getRtpProxyPort();
         }
@@ -377,7 +371,7 @@
         subscribeKey.put("regist", true);
         subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{
            if (waitTrack && json.getJSONArray("tracks") == null) return;
            if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
            event.response(json);
            subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
         });
@@ -385,12 +379,12 @@
         StringBuffer content = new StringBuffer(200);
         content.append("v=0\r\n");
//         content.append("o=" + sipConfig.getSipId() + " 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
         content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
         content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
         content.append("s=Play\r\n");
         content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
         content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
         content.append("t=0 0\r\n");
         if (seniorSdp) {
         if (userSetup.isSeniorSdp()) {
            if("TCP-PASSIVE".equals(streamMode)) {
               content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
            }else if ("TCP-ACTIVE".equals(streamMode)) {
@@ -476,9 +470,9 @@
         subscribeKey.put("app", "rtp");
         subscribeKey.put("stream", streamId);
         subscribeKey.put("regist", true);
         logger.debug("录像回放添加订阅,订阅内容:" + subscribeKey.toString());
         subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{
            if (json.getJSONArray("tracks") == null) return;
            if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
            event.response(json);
            subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
         });
@@ -488,19 +482,19 @@
           content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n");
           content.append("s=Playback\r\n");
           content.append("u="+channelId+":0\r\n");
           content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
           content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
           content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "
               +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
         String mediaPort = null;
         Integer mediaPort = null;
         // 使用动态udp端口
         if (mediaConfig.isRtpEnable()) {
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId);
         }else {
            mediaPort = mediaInfo.getRtpProxyPort();
         }
         String streamMode = device.getStreamMode().toUpperCase();
         if (seniorSdp) {
         if (userSetup.isSeniorSdp()) {
            if("TCP-PASSIVE".equals(streamMode)) {
               content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
            }else if ("TCP-ACTIVE".equals(streamMode)) {