commit
1100255ec9
@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.conf;
|
|||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -22,7 +22,12 @@ public class SendRtpItem {
|
|||||||
*/
|
*/
|
||||||
private String platformId;
|
private String platformId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 对应设备id
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
* 通道id
|
* 通道id
|
||||||
*/
|
*/
|
||||||
private String channelId;
|
private String channelId;
|
||||||
@ -92,6 +97,14 @@ public class SendRtpItem {
|
|||||||
this.platformId = platformId;
|
this.platformId = platformId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getChannelId() {
|
public String getChannelId() {
|
||||||
return channelId;
|
return channelId;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.event.offline;
|
package com.genersoft.iot.vmp.gb28181.event.offline;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.data.redis.connection.Message;
|
import org.springframework.data.redis.connection.Message;
|
||||||
import org.springframework.data.redis.connection.MessageListener;
|
|
||||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -13,8 +9,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:设备心跳超时监听,借助redis过期特性,进行监听,监听到说明设备心跳超时,发送离线事件
|
* @Description:设备心跳超时监听,借助redis过期特性,进行监听,监听到说明设备心跳超时,发送离线事件
|
||||||
* @author: swwheihei
|
* @author: swwheihei
|
||||||
|
@ -7,6 +7,11 @@ import org.springframework.context.ApplicationEvent;
|
|||||||
*/
|
*/
|
||||||
public class PlatformKeepaliveExpireEvent extends ApplicationEvent {
|
public class PlatformKeepaliveExpireEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add default serial version ID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String platformGbID;
|
private String platformGbID;
|
||||||
|
|
||||||
public PlatformKeepaliveExpireEvent(Object source) {
|
public PlatformKeepaliveExpireEvent(Object source) {
|
||||||
|
@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
@ -52,14 +51,14 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener<P
|
|||||||
}
|
}
|
||||||
ParentPlatform parentPlatform = storager.queryParentPlatById(event.getPlatformGbID());
|
ParentPlatform parentPlatform = storager.queryParentPlatById(event.getPlatformGbID());
|
||||||
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(event.getPlatformGbID());
|
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(event.getPlatformGbID());
|
||||||
parentPlatformCatch.setParentPlatform(parentPlatform);
|
if (parentPlatformCatch == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (parentPlatform == null) {
|
if (parentPlatform == null) {
|
||||||
logger.debug("平台心跳到期事件事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
logger.debug("平台心跳到期事件事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parentPlatformCatch == null) {
|
parentPlatformCatch.setParentPlatform(parentPlatform);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 发送心跳
|
// 发送心跳
|
||||||
if (parentPlatformCatch.getKeepAliveReply() >= 3) {
|
if (parentPlatformCatch.getKeepAliveReply() >= 3) {
|
||||||
// 有3次未收到心跳回复, 设置平台状态为离线, 开始重新注册
|
// 有3次未收到心跳回复, 设置平台状态为离线, 开始重新注册
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
public class PlatformNotRegisterEvent extends ApplicationEvent {
|
public class PlatformNotRegisterEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add default serial version ID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String platformGbID;
|
private String platformGbID;
|
||||||
|
|
||||||
public PlatformNotRegisterEvent(Object source) {
|
public PlatformNotRegisterEvent(Object source) {
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.online.OnlineEventListener;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -27,11 +23,12 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVideoManagerStorager storager;
|
private IVideoManagerStorager storager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPCommanderFroPlatform sipCommanderFroPlatform;
|
private SIPCommanderFroPlatform sipCommanderFroPlatform;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisUtil redis;
|
// private RedisUtil redis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(PlatformNotRegisterEvent event) {
|
public void onApplicationEvent(PlatformNotRegisterEvent event) {
|
||||||
|
@ -4,25 +4,17 @@ import javax.sip.RequestEvent;
|
|||||||
import javax.sip.ResponseEvent;
|
import javax.sip.ResponseEvent;
|
||||||
import javax.sip.SipProvider;
|
import javax.sip.SipProvider;
|
||||||
import javax.sip.header.CSeqHeader;
|
import javax.sip.header.CSeqHeader;
|
||||||
import javax.sip.header.CallIdHeader;
|
|
||||||
import javax.sip.header.Header;
|
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
|
||||||
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
// import org.slf4j.Logger;
|
// import org.slf4j.Logger;
|
||||||
// import org.slf4j.LoggerFactory;
|
// import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -59,7 +51,7 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|||||||
@Component
|
@Component
|
||||||
public class SIPProcessorFactory {
|
public class SIPProcessorFactory {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class);
|
// private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipConfig sipConfig;
|
private SipConfig sipConfig;
|
||||||
@ -156,6 +148,8 @@ public class SIPProcessorFactory {
|
|||||||
} else if (Request.ACK.equals(method)) {
|
} else if (Request.ACK.equals(method)) {
|
||||||
AckRequestProcessor processor = new AckRequestProcessor();
|
AckRequestProcessor processor = new AckRequestProcessor();
|
||||||
processor.setRequestEvent(evt);
|
processor.setRequestEvent(evt);
|
||||||
|
processor.setRedisCatchStorage(redisCatchStorage);
|
||||||
|
processor.setZlmrtpServerFactory(zlmrtpServerFactory);
|
||||||
return processor;
|
return processor;
|
||||||
} else if (Request.BYE.equals(method)) {
|
} else if (Request.BYE.equals(method)) {
|
||||||
ByeRequestProcessor processor = new ByeRequestProcessor();
|
ByeRequestProcessor processor = new ByeRequestProcessor();
|
||||||
|
@ -5,8 +5,6 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
|
|
||||||
import javax.sip.header.WWWAuthenticateHeader;
|
import javax.sip.header.WWWAuthenticateHeader;
|
||||||
import java.nio.channels.Channel;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ISIPCommanderForPlatform {
|
public interface ISIPCommanderForPlatform {
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Host;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -16,10 +13,8 @@ import javax.sip.address.SipURI;
|
|||||||
import javax.sip.header.*;
|
import javax.sip.header.*;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.nio.channels.Channel;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.sip.InvalidArgumentException;
|
import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.PeerUnavailableException;
|
import javax.sip.PeerUnavailableException;
|
||||||
@ -12,17 +11,13 @@ import javax.sip.address.Address;
|
|||||||
import javax.sip.address.SipURI;
|
import javax.sip.address.SipURI;
|
||||||
import javax.sip.header.*;
|
import javax.sip.header.*;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Host;
|
|
||||||
import org.springframework.util.DigestUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:摄像头命令request创造器 TODO 冗余代码太多待优化
|
* @Description:摄像头命令request创造器 TODO 冗余代码太多待优化
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
//import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
//import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
//import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider;
|
//import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
//import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -22,28 +22,26 @@ import javax.sip.*;
|
|||||||
import javax.sip.header.CallIdHeader;
|
import javax.sip.header.CallIdHeader;
|
||||||
import javax.sip.header.WWWAuthenticateHeader;
|
import javax.sip.header.WWWAuthenticateHeader;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import java.nio.channels.Channel;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SipConfig sipConfig;
|
// private SipConfig sipConfig;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SIPRequestHeaderProvider headerProvider;
|
// private SIPRequestHeaderProvider headerProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPRequestHeaderPlarformProvider headerProviderPlarformProvider;
|
private SIPRequestHeaderPlarformProvider headerProviderPlarformProvider;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private VideoStreamSessionManager streamSession;
|
// private VideoStreamSessionManager streamSession;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IVideoManagerStorager storager;
|
// private IVideoManagerStorager storager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
@ -1,19 +1,34 @@
|
|||||||
package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.sip.*;
|
import javax.sip.*;
|
||||||
import javax.sip.message.Request;
|
//import javax.sip.message.Request;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
|
|
||||||
import gov.nist.javax.sip.header.CSeq;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:ACK请求处理器
|
* @Description:ACK请求处理器
|
||||||
* @author: swwheihei
|
* @author: swwheihei
|
||||||
* @date: 2020年5月3日 下午5:31:45
|
* @date: 2020年5月3日 下午5:31:45
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class AckRequestProcessor extends SIPRequestAbstractProcessor {
|
public class AckRequestProcessor extends SIPRequestAbstractProcessor {
|
||||||
|
|
||||||
|
//@Autowired
|
||||||
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
|
//@Autowired
|
||||||
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 ACK请求
|
* 处理 ACK请求
|
||||||
*
|
*
|
||||||
@ -21,25 +36,77 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void process(RequestEvent evt) {
|
public void process(RequestEvent evt) {
|
||||||
Request request = evt.getRequest();
|
//Request request = evt.getRequest();
|
||||||
Dialog dialog = evt.getDialog();
|
Dialog dialog = evt.getDialog();
|
||||||
DialogState state = dialog.getState();
|
|
||||||
if (dialog == null) return;
|
if (dialog == null) return;
|
||||||
if (request.getMethod().equals(Request.INVITE) && dialog.getState()== DialogState.CONFIRMED) {
|
//DialogState state = dialog.getState();
|
||||||
// TODO 查询并开始推流
|
if (/*request.getMethod().equals(Request.INVITE) &&*/ dialog.getState()== DialogState.CONFIRMED) {
|
||||||
}
|
String remoteUri = dialog.getRemoteParty().getURI().toString();
|
||||||
try {
|
String localUri = dialog.getLocalParty().getURI().toString();
|
||||||
Request ackRequest = null;
|
String platformGbId = remoteUri.substring(remoteUri.indexOf(":") + 1, remoteUri.indexOf("@"));
|
||||||
CSeq csReq = (CSeq) request.getHeader(CSeq.NAME);
|
String channelId = localUri.substring(remoteUri.indexOf(":") + 1, remoteUri.indexOf("@"));
|
||||||
ackRequest = dialog.createAck(csReq.getSeqNumber());
|
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(platformGbId, channelId);
|
||||||
dialog.sendAck(ackRequest);
|
String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
|
||||||
System.out.println("send ack to callee:" + ackRequest.toString());
|
String deviceId = sendRtpItem.getDeviceId();
|
||||||
} catch (SipException e) {
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
|
||||||
e.printStackTrace();
|
System.out.println(platformGbId);
|
||||||
} catch (InvalidArgumentException e) {
|
System.out.println(channelId);
|
||||||
e.printStackTrace();
|
Map<String, Object> param = new HashMap<>();
|
||||||
|
param.put("vhost","__defaultVhost__");
|
||||||
|
param.put("app","rtp");
|
||||||
|
param.put("stream",streamInfo.getStreamId());
|
||||||
|
param.put("ssrc", sendRtpItem.getSsrc());
|
||||||
|
param.put("dst_url",sendRtpItem.getIp());
|
||||||
|
param.put("dst_port", sendRtpItem.getPort());
|
||||||
|
param.put("is_udp", is_Udp);
|
||||||
|
//param.put ("src_port", sendRtpItem.getLocalPort());
|
||||||
|
// 设备推流查询,成功后才能转推
|
||||||
|
boolean rtpPushed = false;
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
while (!rtpPushed) {
|
||||||
|
try {
|
||||||
|
if (System.currentTimeMillis() - startTime < 30 * 1000) {
|
||||||
|
if (zlmrtpServerFactory.isRtpReady(streamInfo.getStreamId())) {
|
||||||
|
rtpPushed = true;
|
||||||
|
zlmrtpServerFactory.startSendRtpStream(param);
|
||||||
|
} else {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// try {
|
||||||
|
// Request ackRequest = null;
|
||||||
|
// CSeq csReq = (CSeq) request.getHeader(CSeq.NAME);
|
||||||
|
// ackRequest = dialog.createAck(csReq.getSeqNumber());
|
||||||
|
// dialog.sendAck(ackRequest);
|
||||||
|
// System.out.println("send ack to callee:" + ackRequest.toString());
|
||||||
|
// } catch (SipException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// } catch (InvalidArgumentException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IRedisCatchStorage getRedisCatchStorage() {
|
||||||
|
return redisCatchStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) {
|
||||||
|
this.redisCatchStorage = redisCatchStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLMRTPServerFactory getZlmrtpServerFactory() {
|
||||||
|
return zlmrtpServerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZlmrtpServerFactory(ZLMRTPServerFactory zlmrtpServerFactory) {
|
||||||
|
this.zlmrtpServerFactory = zlmrtpServerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,10 @@ import javax.sip.SipException;
|
|||||||
import javax.sip.SipFactory;
|
import javax.sip.SipFactory;
|
||||||
import javax.sip.address.Address;
|
import javax.sip.address.Address;
|
||||||
import javax.sip.address.SipURI;
|
import javax.sip.address.SipURI;
|
||||||
import javax.sip.header.ContentTypeHeader;
|
import javax.sip.header.*;
|
||||||
import javax.sip.header.FromHeader;
|
|
||||||
import javax.sip.header.HeaderFactory;
|
|
||||||
import javax.sip.header.SubjectHeader;
|
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
@ -27,17 +23,12 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
||||||
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
||||||
import gov.nist.javax.sdp.fields.SDPFormat;
|
|
||||||
import gov.nist.javax.sip.address.AddressImpl;
|
import gov.nist.javax.sip.address.AddressImpl;
|
||||||
import gov.nist.javax.sip.address.SipUri;
|
import gov.nist.javax.sip.address.SipUri;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,6 +36,7 @@ import java.util.Vector;
|
|||||||
* @author: panll
|
* @author: panll
|
||||||
* @date: 2021年1月14日
|
* @date: 2021年1月14日
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class);
|
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class);
|
||||||
@ -122,8 +114,10 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
|
|
||||||
// jainSip不支持y=字段, 移除移除以解析。
|
// jainSip不支持y=字段, 移除移除以解析。
|
||||||
int ssrcIndex = contentString.indexOf("y=");
|
int ssrcIndex = contentString.indexOf("y=");
|
||||||
String ssrc = contentString.substring(ssrcIndex + 2, contentString.length())
|
String ssrc = contentString.substring(ssrcIndex + 2, ssrcIndex + 12);
|
||||||
.replace("\r\n", "").replace("\n", "");
|
//ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段
|
||||||
|
// String ssrc = contentString.substring(ssrcIndex + 2, contentString.length())
|
||||||
|
// .replace("\r\n", "").replace("\n", "");
|
||||||
|
|
||||||
String substring = contentString.substring(0, contentString.indexOf("y="));
|
String substring = contentString.substring(0, contentString.indexOf("y="));
|
||||||
SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring);
|
SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring);
|
||||||
@ -131,9 +125,9 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
// 获取支持的格式
|
// 获取支持的格式
|
||||||
Vector mediaDescriptions = sdp.getMediaDescriptions(true);
|
Vector mediaDescriptions = sdp.getMediaDescriptions(true);
|
||||||
// 查看是否支持PS 负载96
|
// 查看是否支持PS 负载96
|
||||||
String ip = null;
|
//String ip = null;
|
||||||
int port = -1;
|
int port = -1;
|
||||||
boolean recvonly = false;
|
//boolean recvonly = false;
|
||||||
boolean mediaTransmissionTCP = false;
|
boolean mediaTransmissionTCP = false;
|
||||||
Boolean tcpActive = null;
|
Boolean tcpActive = null;
|
||||||
for (int i = 0; i < mediaDescriptions.size(); i++) {
|
for (int i = 0; i < mediaDescriptions.size(); i++) {
|
||||||
@ -143,7 +137,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
Vector mediaFormats = media.getMediaFormats(false);
|
Vector mediaFormats = media.getMediaFormats(false);
|
||||||
if (mediaFormats.contains("96")) {
|
if (mediaFormats.contains("96")) {
|
||||||
port = media.getMediaPort();
|
port = media.getMediaPort();
|
||||||
String mediaType = media.getMediaType();
|
//String mediaType = media.getMediaType();
|
||||||
String protocol = media.getProtocol();
|
String protocol = media.getProtocol();
|
||||||
|
|
||||||
// 区分TCP发流还是udp, 当前默认udp
|
// 区分TCP发流还是udp, 当前默认udp
|
||||||
@ -169,7 +163,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
}
|
}
|
||||||
String username = sdp.getOrigin().getUsername();
|
String username = sdp.getOrigin().getUsername();
|
||||||
String addressStr = sdp.getOrigin().getAddress();
|
String addressStr = sdp.getOrigin().getAddress();
|
||||||
String sessionName = sdp.getSessionName().getValue();
|
//String sessionName = sdp.getSessionName().getValue();
|
||||||
logger.info("[上级点播]用户:{}, 地址:{}:{}, ssrc:{}", username, addressStr, port, ssrc);
|
logger.info("[上级点播]用户:{}, 地址:{}:{}, ssrc:{}", username, addressStr, port, ssrc);
|
||||||
|
|
||||||
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||||
@ -178,7 +172,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
responseAck(evt, Response.SERVER_INTERNAL_ERROR);
|
responseAck(evt, Response.SERVER_INTERNAL_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(ip, port, platformId, ssrc, channelId,
|
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(addressStr, port, ssrc, platformId, device.getDeviceId(), channelId,
|
||||||
mediaTransmissionTCP);
|
mediaTransmissionTCP);
|
||||||
if (tcpActive != null) {
|
if (tcpActive != null) {
|
||||||
sendRtpItem.setTcpActive(tcpActive);
|
sendRtpItem.setTcpActive(tcpActive);
|
||||||
|
@ -370,31 +370,36 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
|
|||||||
private void processMessageDeviceInfo(RequestEvent evt) {
|
private void processMessageDeviceInfo(RequestEvent evt) {
|
||||||
try {
|
try {
|
||||||
Element rootElement = getRootElement(evt);
|
Element rootElement = getRootElement(evt);
|
||||||
|
String requestName = rootElement.getName();
|
||||||
Element deviceIdElement = rootElement.element("DeviceID");
|
Element deviceIdElement = rootElement.element("DeviceID");
|
||||||
String deviceId = deviceIdElement.getTextTrim().toString();
|
String deviceId = deviceIdElement.getTextTrim().toString();
|
||||||
|
if (requestName.equals("Query")) {
|
||||||
Device device = storager.queryVideoDevice(deviceId);
|
// 回复200 OK
|
||||||
if (device == null) {
|
responseAck(evt);
|
||||||
return;
|
} else {
|
||||||
}
|
Device device = storager.queryVideoDevice(deviceId);
|
||||||
device.setName(XmlUtil.getText(rootElement, "DeviceName"));
|
if (device == null) {
|
||||||
device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer"));
|
return;
|
||||||
device.setModel(XmlUtil.getText(rootElement, "Model"));
|
}
|
||||||
device.setFirmware(XmlUtil.getText(rootElement, "Firmware"));
|
device.setName(XmlUtil.getText(rootElement, "DeviceName"));
|
||||||
if (StringUtils.isEmpty(device.getStreamMode())) {
|
device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer"));
|
||||||
device.setStreamMode("UDP");
|
device.setModel(XmlUtil.getText(rootElement, "Model"));
|
||||||
}
|
device.setFirmware(XmlUtil.getText(rootElement, "Firmware"));
|
||||||
storager.updateDevice(device);
|
if (StringUtils.isEmpty(device.getStreamMode())) {
|
||||||
|
device.setStreamMode("UDP");
|
||||||
RequestMessage msg = new RequestMessage();
|
}
|
||||||
msg.setDeviceId(deviceId);
|
storager.updateDevice(device);
|
||||||
msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICEINFO);
|
|
||||||
msg.setData(device);
|
RequestMessage msg = new RequestMessage();
|
||||||
deferredResultHolder.invokeResult(msg);
|
msg.setDeviceId(deviceId);
|
||||||
// 回复200 OK
|
msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICEINFO);
|
||||||
responseAck(evt);
|
msg.setData(device);
|
||||||
if (offLineDetector.isOnline(deviceId)) {
|
deferredResultHolder.invokeResult(msg);
|
||||||
publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
|
// 回复200 OK
|
||||||
|
responseAck(evt);
|
||||||
|
if (offLineDetector.isOnline(deviceId)) {
|
||||||
|
publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
|
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -9,24 +9,15 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.impl.RegisterRequestProces
|
|||||||
import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import gov.nist.core.Host;
|
|
||||||
import gov.nist.javax.sip.address.AddressImpl;
|
|
||||||
import gov.nist.javax.sip.address.SipUri;
|
|
||||||
import gov.nist.javax.sip.header.To;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.sip.ResponseEvent;
|
import javax.sip.ResponseEvent;
|
||||||
import javax.sip.address.Address;
|
|
||||||
import javax.sip.address.URI;
|
|
||||||
import javax.sip.header.CallIdHeader;
|
import javax.sip.header.CallIdHeader;
|
||||||
import javax.sip.header.ExpiresHeader;
|
|
||||||
import javax.sip.header.ToHeader;
|
|
||||||
import javax.sip.header.WWWAuthenticateHeader;
|
import javax.sip.header.WWWAuthenticateHeader;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:Register响应处理器
|
* @Description:Register响应处理器
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
package com.genersoft.iot.vmp.media.zlm;
|
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 java.util.UUID;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.utils.IpUtil;
|
|
||||||
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -57,8 +51,8 @@ public class ZLMHttpHookListener {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ZLMRESTfulUtils zlmresTfulUtils;
|
// private ZLMRESTfulUtils zlmresTfulUtils;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZLMHttpHookSubscribe subscribe;
|
private ZLMHttpHookSubscribe subscribe;
|
||||||
@ -217,8 +211,8 @@ public class ZLMHttpHookListener {
|
|||||||
logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString());
|
logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString());
|
||||||
}
|
}
|
||||||
// TODO 如果是带有rtpstream则开启按需拉流
|
// TODO 如果是带有rtpstream则开启按需拉流
|
||||||
String app = json.getString("app");
|
// String app = json.getString("app");
|
||||||
String stream = json.getString("stream");
|
// String stream = json.getString("stream");
|
||||||
|
|
||||||
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
||||||
if (subscribe != null) subscribe.response(json);
|
if (subscribe != null) subscribe.response(json);
|
||||||
|
@ -119,4 +119,8 @@ public class ZLMRESTfulUtils {
|
|||||||
public JSONObject closeRtpServer(Map<String, Object> param) {
|
public JSONObject closeRtpServer(Map<String, Object> param) {
|
||||||
return sendPost("closeRtpServer",param);
|
return sendPost("closeRtpServer",param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONObject startSendRtp(Map<String, Object> param) {
|
||||||
|
return sendPost("startSendRtp",param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class ZLMRTPServerFactory {
|
|||||||
* @param tcp 是否为tcp
|
* @param tcp 是否为tcp
|
||||||
* @return SendRtpItem
|
* @return SendRtpItem
|
||||||
*/
|
*/
|
||||||
public SendRtpItem createSendRtpItem(String ip, int port, String ssrc, String platformId, String channelId, boolean tcp){
|
public SendRtpItem createSendRtpItem(String ip, int port, String ssrc, String platformId, String deviceId, String channelId, boolean tcp){
|
||||||
String playSsrc = SsrcUtil.getPlaySsrc();
|
String playSsrc = SsrcUtil.getPlaySsrc();
|
||||||
int localPort = createRTPServer(SsrcUtil.getPlaySsrc());
|
int localPort = createRTPServer(SsrcUtil.getPlaySsrc());
|
||||||
if (localPort != -1) {
|
if (localPort != -1) {
|
||||||
@ -119,9 +119,54 @@ public class ZLMRTPServerFactory {
|
|||||||
sendRtpItem.setPort(port);
|
sendRtpItem.setPort(port);
|
||||||
sendRtpItem.setSsrc(ssrc);
|
sendRtpItem.setSsrc(ssrc);
|
||||||
sendRtpItem.setPlatformId(platformId);
|
sendRtpItem.setPlatformId(platformId);
|
||||||
|
sendRtpItem.setDeviceId(deviceId);
|
||||||
sendRtpItem.setChannelId(channelId);
|
sendRtpItem.setChannelId(channelId);
|
||||||
sendRtpItem.setTcp(tcp);
|
sendRtpItem.setTcp(tcp);
|
||||||
sendRtpItem.setLocalPort(localPort);
|
sendRtpItem.setLocalPort(localPort);
|
||||||
return sendRtpItem;
|
return sendRtpItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Boolean startSendRtpStream(Map<String, Object>param) {
|
||||||
|
Boolean result = false;
|
||||||
|
JSONObject jsonObject = zlmresTfulUtils.startSendRtp(param);
|
||||||
|
System.out.println(jsonObject);
|
||||||
|
if (jsonObject != null) {
|
||||||
|
switch (jsonObject.getInteger("code")){
|
||||||
|
case 0:
|
||||||
|
result= true;
|
||||||
|
logger.error("RTP推流请求成功,本地推流端口:" + jsonObject.getString("local_port"));
|
||||||
|
break;
|
||||||
|
// case -300: // id已经存在
|
||||||
|
// result = false;
|
||||||
|
// break;
|
||||||
|
// case -400: // 端口占用
|
||||||
|
// result= false;
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
logger.error("RTP推流失败: " + jsonObject.getString("msg"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// 检查ZLM状态
|
||||||
|
logger.error("RTP推流失败: 请检查ZLM服务");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Boolean isRtpReady(String streamId) {
|
||||||
|
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId);
|
||||||
|
if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
|
||||||
|
logger.info("设备RTP推流成功");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
logger.info("设备RTP推流未完成");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
|||||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -81,4 +80,13 @@ public interface IRedisCatchStorage {
|
|||||||
void delPlatformRegisterInfo(String callId);
|
void delPlatformRegisterInfo(String callId);
|
||||||
|
|
||||||
void updateSendRTPSever(SendRtpItem sendRtpItem);
|
void updateSendRTPSever(SendRtpItem sendRtpItem);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询RTP推送信息缓存
|
||||||
|
* @param platformGbId
|
||||||
|
* @param channelId
|
||||||
|
* @return sendRtpItem
|
||||||
|
*/
|
||||||
|
SendRtpItem querySendRTPServer(String platformGbId, String channelId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
package com.genersoft.iot.vmp.storager;
|
package com.genersoft.iot.vmp.storager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import gov.nist.javax.sip.stack.NioTcpMessageProcessor;
|
|
||||||
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:视频设备数据存储接口
|
* @Description:视频设备数据存储接口
|
||||||
* @author: swwheihei
|
* @author: swwheihei
|
||||||
* @date: 2020年5月6日 下午2:14:31
|
* @date: 2020年5月6日 下午2:14:31
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public interface IVideoManagerStorager {
|
public interface IVideoManagerStorager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.genersoft.iot.vmp.storager.dao;
|
package com.genersoft.iot.vmp.storager.dao;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.genersoft.iot.vmp.storager.dao;
|
package com.genersoft.iot.vmp.storager.dao;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -218,4 +218,11 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
|||||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId();
|
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId();
|
||||||
redis.set(key, sendRtpItem);
|
redis.set(key, sendRtpItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendRtpItem querySendRTPServer(String platformGbId, String channelId) {
|
||||||
|
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_" + channelId;
|
||||||
|
return (SendRtpItem)redis.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
* @author: swwheihei
|
* @author: swwheihei
|
||||||
* @date: 2020年5月6日 下午2:31:42
|
* @date: 2020年5月6日 下午2:31:42
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Component
|
@Component
|
||||||
public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.genersoft.iot.vmp.vmanager.platform;
|
package com.genersoft.iot.vmp.vmanager.platform;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
@ -18,10 +17,6 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api")
|
@RequestMapping("/api")
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.genersoft.iot.vmp.vmanager.play;
|
package com.genersoft.iot.vmp.vmanager.play;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||||
@ -22,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import javax.sip.message.Response;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
|
@ -14,7 +14,6 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
|
|||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.vmanager.play.PlayController;
|
|
||||||
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
||||||
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -25,7 +24,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
Loading…
Reference in New Issue
Block a user