648540858
2020-12-21 bfd1628d5b6e753091b0aa702a520b08cc64cc76
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -8,7 +8,6 @@
import javax.sip.Dialog;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import javax.sip.SipFactory;
import javax.sip.SipProvider;
import javax.sip.TransactionDoesNotExistException;
import javax.sip.address.SipURI;
@@ -16,11 +15,10 @@
import javax.sip.message.Request;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -63,7 +61,7 @@
   private SipProvider udpSipProvider;
   @Autowired
   private ZLMUtils zlmUtils;
   private ZLMRTPServerFactory zlmrtpServerFactory;
   @Value("${media.rtp.enable}")
   private boolean rtpEnable;
@@ -288,7 +286,7 @@
         String mediaPort = null;
         // 使用动态udp端口
         if (rtpEnable) {
            mediaPort = zlmUtils.getNewRTPPort(streamId) + "";
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
         }else {
            mediaPort = mediaInfo.getRtpProxyPort();
         }
@@ -383,7 +381,7 @@
         String mediaPort = null;
         // 使用动态udp端口
         if (rtpEnable) {
            mediaPort = zlmUtils.getNewRTPPort(streamId) + "";
            mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
         }else {
            mediaPort = mediaInfo.getRtpProxyPort();
         }
@@ -459,6 +457,7 @@
         }
         dialog.sendRequest(clientTransaction);
         streamSession.remove(streamId);
         zlmrtpServerFactory.closeRTPServer(streamId);
      } catch (TransactionDoesNotExistException e) {
         e.printStackTrace();
      } catch (SipException e) {
@@ -701,4 +700,11 @@
   }
   @Override
   public void closeRTPServer(Device device, String channelId) {
      if (rtpEnable) {
         String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId);
         zlmrtpServerFactory.closeRTPServer(streamId);
      }
   }
}