修复重复调用open rtp server 的bug

增加对rtp server开启释放的统一管理
This commit is contained in:
648540858
2020-12-21 15:29:17 +08:00
parent 1ec6c4506a
commit bfd1628d5b
6 changed files with 38 additions and 71 deletions

View File

@@ -213,4 +213,11 @@ public interface ISIPCommander {
* @param device 视频设备
*/
boolean mobilePostitionQuery(Device device);
/**
* 释放rtpserver
* @param device
* @param channelId
*/
void closeRTPServer(Device device, String channelId);
}

View File

@@ -8,7 +8,6 @@ import javax.sip.ClientTransaction;
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.header.ViaHeader;
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 @@ public class SIPCommander implements ISIPCommander {
private SipProvider udpSipProvider;
@Autowired
private ZLMUtils zlmUtils;
private ZLMRTPServerFactory zlmrtpServerFactory;
@Value("${media.rtp.enable}")
private boolean rtpEnable;
@@ -288,7 +286,7 @@ public class SIPCommander implements ISIPCommander {
String mediaPort = null;
// 使用动态udp端口
if (rtpEnable) {
mediaPort = zlmUtils.getNewRTPPort(streamId) + "";
mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
}else {
mediaPort = mediaInfo.getRtpProxyPort();
}
@@ -383,7 +381,7 @@ public class SIPCommander implements ISIPCommander {
String mediaPort = null;
// 使用动态udp端口
if (rtpEnable) {
mediaPort = zlmUtils.getNewRTPPort(streamId) + "";
mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
}else {
mediaPort = mediaInfo.getRtpProxyPort();
}
@@ -459,6 +457,7 @@ public class SIPCommander implements ISIPCommander {
}
dialog.sendRequest(clientTransaction);
streamSession.remove(streamId);
zlmrtpServerFactory.closeRTPServer(streamId);
} catch (TransactionDoesNotExistException e) {
e.printStackTrace();
} catch (SipException e) {
@@ -701,4 +700,11 @@ public class SIPCommander implements ISIPCommander {
}
@Override
public void closeRTPServer(Device device, String channelId) {
if (rtpEnable) {
String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId);
zlmrtpServerFactory.closeRTPServer(streamId);
}
}
}