增加对zlm使用docker容器的支持

This commit is contained in:
panlinlin
2021-04-28 15:10:35 +08:00
parent a3649ca243
commit 10ae1bba59
23 changed files with 367 additions and 175 deletions

View File

@@ -38,7 +38,7 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
logger.info(expiredKey);
logger.debug(expiredKey);
if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX)){
logger.debug("收到redis过期监听但开头不是"+VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX+",忽略");
return;

View File

@@ -1,8 +1,6 @@
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.sip.*;
import javax.sip.address.SipURI;
@@ -10,11 +8,11 @@ import javax.sip.header.CallIdHeader;
import javax.sip.header.ViaHeader;
import javax.sip.message.Request;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.conf.MediaConfig;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
@@ -82,13 +80,13 @@ public class SIPCommander implements ISIPCommander {
@Autowired
private ZLMRESTfulUtils zlmresTfulUtils;
@Value("${media.rtp.enable}")
private boolean rtpEnable;
@Autowired
private MediaConfig mediaConfig;
@Value("${media.seniorSdp}")
@Value("${userSettings.seniorSdp}")
private boolean seniorSdp;
@Value("${media.autoApplyPlay}")
@Value("${userSettings.autoApplyPlay}")
private boolean autoApplyPlay;
@Value("${userSettings.waitTrack}")
@@ -353,20 +351,20 @@ public class SIPCommander implements ISIPCommander {
try {
if (device == null) return;
String ssrc = streamSession.createPlaySsrc();
if (rtpEnable) {
if (mediaConfig.isRtpEnable()) {
streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId);
}else {
streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase();
}
String streamMode = device.getStreamMode().toUpperCase();
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
if (mediaInfo == null) {
logger.warn("点播时发现ZLM尚未连接...");
return;
}
String mediaPort = null;
// 使用动态udp端口
if (rtpEnable) {
if (mediaConfig.isRtpEnable()) {
mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
}else {
mediaPort = mediaInfo.getRtpProxyPort();
@@ -470,7 +468,7 @@ public class SIPCommander implements ISIPCommander {
public void playbackStreamCmd(Device device, String channelId, String startTime, String endTime, ZLMHttpHookSubscribe.Event event
, SipSubscribe.Event errorEvent) {
try {
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
String ssrc = streamSession.createPlayBackSsrc();
String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase();
// 添加订阅
@@ -495,7 +493,7 @@ public class SIPCommander implements ISIPCommander {
+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
String mediaPort = null;
// 使用动态udp端口
if (rtpEnable) {
if (mediaConfig.isRtpEnable()) {
mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
}else {
mediaPort = mediaInfo.getRtpProxyPort();
@@ -1445,7 +1443,7 @@ public class SIPCommander implements ISIPCommander {
@Override
public void closeRTPServer(Device device, String channelId) {
if (rtpEnable) {
if (mediaConfig.isRtpEnable()) {
String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId);
zlmrtpServerFactory.closeRTPServer(streamId);
}

View File

@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
import com.genersoft.iot.vmp.conf.MediaConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
@@ -63,9 +64,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
@Qualifier(value="udpSipProvider")
private SipProvider udpSipProvider;
@Value("${media.rtp.enable}")
private boolean rtpEnable;
@Override
public boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
return register(parentPlatform, null, null, errorEvent, okEvent);

View File

@@ -11,7 +11,7 @@ import javax.sip.header.*;
import javax.sip.message.Request;
import javax.sip.message.Response;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@@ -187,7 +187,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
sendRtpItem.setStatus(1);
redisCatchStorage.updateSendRTPSever(sendRtpItem);
// TODO 添加对tcp的支持
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
StringBuffer content = new StringBuffer(200);
content.append("v=0\r\n");
content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
@@ -246,7 +246,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
sendRtpItem.setStatus(1);
redisCatchStorage.updateSendRTPSever(sendRtpItem);
// TODO 添加对tcp的支持
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
StringBuffer content = new StringBuffer(200);
content.append("v=0\r\n");
content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");

View File

@@ -17,7 +17,9 @@ import javax.sip.message.Request;
import javax.sip.message.Response;
import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate;
import gov.nist.javax.sip.RequestEventExt;
import gov.nist.javax.sip.header.SIPDateHeader;
import gov.nist.javax.sip.message.SIPRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
@@ -59,7 +61,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
@Override
public void process(RequestEvent evt) {
try {
logger.info("收到注册请求,开始处理");
RequestEventExt evtExt = (RequestEventExt)evt;
String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort();
logger.info("[{}] 收到注册请求,开始处理", requestAddress);
Request request = evt.getRequest();
Response response = null;
@@ -78,9 +82,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
if (authorhead == null || !passwordCorrect) {
if (authorhead == null) {
logger.info("未携带授权头 回复401");
logger.info("[{}] 未携带授权头 回复401", requestAddress);
} else if (!passwordCorrect) {
logger.info("密码错误 回复401");
logger.info("[{}] 密码错误 回复401", requestAddress);
}
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain());
@@ -147,7 +151,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
// 保存到redis
// 下发catelog查询目录
if (registerFlag == 1 ) {
logger.info("注册成功! deviceId:" + device.getDeviceId());
logger.info("[{}] 注册成功! deviceId:" + device.getDeviceId(), requestAddress);
// boolean exists = storager.exists(device.getDeviceId());
device.setRegisterTimeMillis(System.currentTimeMillis());
storager.updateDevice(device);
@@ -158,7 +162,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
handler.onRegister(device);
//}
} else if (registerFlag == 2) {
logger.info("注销成功! deviceId:" + device.getDeviceId());
logger.info("[{}] 注销成功! deviceId:" + device.getDeviceId(), requestAddress);
publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER);
}
} catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) {