Commit cbd2bc8e99a20d1ff65fb1171961e86c790ab024
Committed by
GitHub
Merge pull request #63 from lawrencehj/wvp-28181-2.0
实现级联点播的RTP推送
Showing
28 changed files
with
243 additions
and
152 deletions
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
| ... | ... | @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.conf; |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 6 | -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | |
| 7 | 6 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 8 | 7 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 9 | 8 | import org.springframework.beans.factory.annotation.Autowired; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
| ... | ... | @@ -22,7 +22,12 @@ public class SendRtpItem { |
| 22 | 22 | */ |
| 23 | 23 | private String platformId; |
| 24 | 24 | |
| 25 | - /** | |
| 25 | + /** | |
| 26 | + * 对应设备id | |
| 27 | + */ | |
| 28 | + private String deviceId; | |
| 29 | + | |
| 30 | + /** | |
| 26 | 31 | * 通道id |
| 27 | 32 | */ |
| 28 | 33 | private String channelId; |
| ... | ... | @@ -92,6 +97,14 @@ public class SendRtpItem { |
| 92 | 97 | this.platformId = platformId; |
| 93 | 98 | } |
| 94 | 99 | |
| 100 | + public String getDeviceId() { | |
| 101 | + return deviceId; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setDeviceId(String deviceId) { | |
| 105 | + this.deviceId = deviceId; | |
| 106 | + } | |
| 107 | + | |
| 95 | 108 | public String getChannelId() { |
| 96 | 109 | return channelId; |
| 97 | 110 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.event.offline; |
| 2 | 2 | |
| 3 | -import org.slf4j.Logger; | |
| 4 | -import org.slf4j.LoggerFactory; | |
| 5 | 3 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | -import org.springframework.beans.factory.annotation.Value; | |
| 7 | 4 | import org.springframework.data.redis.connection.Message; |
| 8 | -import org.springframework.data.redis.connection.MessageListener; | |
| 9 | 5 | import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; |
| 10 | 6 | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| 11 | 7 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -13,8 +9,6 @@ import org.springframework.stereotype.Component; |
| 13 | 9 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 14 | 10 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 15 | 11 | |
| 16 | -import java.nio.charset.StandardCharsets; | |
| 17 | - | |
| 18 | 12 | /** |
| 19 | 13 | * @Description:设备心跳超时监听,借助redis过期特性,进行监听,监听到说明设备心跳超时,发送离线事件 |
| 20 | 14 | * @author: swwheihei | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEvent.java
| ... | ... | @@ -7,6 +7,11 @@ import org.springframework.context.ApplicationEvent; |
| 7 | 7 | */ |
| 8 | 8 | public class PlatformKeepaliveExpireEvent extends ApplicationEvent { |
| 9 | 9 | |
| 10 | + /** | |
| 11 | + * Add default serial version ID | |
| 12 | + */ | |
| 13 | + private static final long serialVersionUID = 1L; | |
| 14 | + | |
| 10 | 15 | private String platformGbID; |
| 11 | 16 | |
| 12 | 17 | public PlatformKeepaliveExpireEvent(Object source) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
| ... | ... | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister; | |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 7 | 6 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 8 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| ... | ... | @@ -52,14 +51,14 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener<P |
| 52 | 51 | } |
| 53 | 52 | ParentPlatform parentPlatform = storager.queryParentPlatById(event.getPlatformGbID()); |
| 54 | 53 | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(event.getPlatformGbID()); |
| 55 | - parentPlatformCatch.setParentPlatform(parentPlatform); | |
| 56 | - if (parentPlatform == null) { | |
| 57 | - logger.debug("平台心跳到期事件事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID()); | |
| 54 | + if (parentPlatformCatch == null) { | |
| 58 | 55 | return; |
| 59 | 56 | } |
| 60 | - if (parentPlatformCatch == null) { | |
| 57 | + if (parentPlatform == null) { | |
| 58 | + logger.debug("平台心跳到期事件事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID()); | |
| 61 | 59 | return; |
| 62 | 60 | } |
| 61 | + parentPlatformCatch.setParentPlatform(parentPlatform); | |
| 63 | 62 | // 发送心跳 |
| 64 | 63 | if (parentPlatformCatch.getKeepAliveReply() >= 3) { |
| 65 | 64 | // 有3次未收到心跳回复, 设置平台状态为离线, 开始重新注册 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEvent.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 4 | 3 | import org.springframework.context.ApplicationEvent; |
| 5 | 4 | |
| 6 | 5 | public class PlatformNotRegisterEvent extends ApplicationEvent { |
| 7 | 6 | |
| 7 | + /** | |
| 8 | + * Add default serial version ID | |
| 9 | + */ | |
| 10 | + private static final long serialVersionUID = 1L; | |
| 11 | + | |
| 8 | 12 | private String platformGbID; |
| 9 | 13 | |
| 10 | 14 | public PlatformNotRegisterEvent(Object source) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | -import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent; | |
| 5 | -import com.genersoft.iot.vmp.gb28181.event.online.OnlineEventListener; | |
| 6 | 4 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| 7 | 5 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 8 | -import com.genersoft.iot.vmp.utils.redis.RedisUtil; | |
| 9 | 6 | import org.slf4j.Logger; |
| 10 | 7 | import org.slf4j.LoggerFactory; |
| 11 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | -import org.springframework.context.ApplicationEvent; | |
| 13 | 9 | import org.springframework.context.ApplicationListener; |
| 14 | 10 | import org.springframework.stereotype.Component; |
| 15 | 11 | |
| ... | ... | @@ -27,11 +23,12 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf |
| 27 | 23 | |
| 28 | 24 | @Autowired |
| 29 | 25 | private IVideoManagerStorager storager; |
| 26 | + | |
| 30 | 27 | @Autowired |
| 31 | 28 | private SIPCommanderFroPlatform sipCommanderFroPlatform; |
| 32 | 29 | |
| 33 | - @Autowired | |
| 34 | - private RedisUtil redis; | |
| 30 | + // @Autowired | |
| 31 | + // private RedisUtil redis; | |
| 35 | 32 | |
| 36 | 33 | @Override |
| 37 | 34 | public void onApplicationEvent(PlatformNotRegisterEvent event) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
| ... | ... | @@ -4,25 +4,17 @@ import javax.sip.RequestEvent; |
| 4 | 4 | import javax.sip.ResponseEvent; |
| 5 | 5 | import javax.sip.SipProvider; |
| 6 | 6 | import javax.sip.header.CSeqHeader; |
| 7 | -import javax.sip.header.CallIdHeader; | |
| 8 | -import javax.sip.header.Header; | |
| 9 | 7 | import javax.sip.message.Request; |
| 10 | 8 | import javax.sip.message.Response; |
| 11 | 9 | |
| 12 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| 13 | 11 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 14 | 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 15 | -import com.alibaba.fastjson.JSON; | |
| 16 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*; |
| 17 | -import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*; | |
| 18 | -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | |
| 19 | 14 | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| 20 | -import org.slf4j.Logger; | |
| 21 | -import org.slf4j.LoggerFactory; | |
| 22 | 15 | // import org.slf4j.Logger; |
| 23 | 16 | // import org.slf4j.LoggerFactory; |
| 24 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 26 | 18 | import org.springframework.context.annotation.Lazy; |
| 27 | 19 | import org.springframework.stereotype.Component; |
| 28 | 20 | |
| ... | ... | @@ -59,7 +51,7 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 59 | 51 | @Component |
| 60 | 52 | public class SIPProcessorFactory { |
| 61 | 53 | |
| 62 | - private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class); | |
| 54 | + // private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class); | |
| 63 | 55 | |
| 64 | 56 | @Autowired |
| 65 | 57 | private SipConfig sipConfig; |
| ... | ... | @@ -156,6 +148,8 @@ public class SIPProcessorFactory { |
| 156 | 148 | } else if (Request.ACK.equals(method)) { |
| 157 | 149 | AckRequestProcessor processor = new AckRequestProcessor(); |
| 158 | 150 | processor.setRequestEvent(evt); |
| 151 | + processor.setRedisCatchStorage(redisCatchStorage); | |
| 152 | + processor.setZlmrtpServerFactory(zlmrtpServerFactory); | |
| 159 | 153 | return processor; |
| 160 | 154 | } else if (Request.BYE.equals(method)) { |
| 161 | 155 | ByeRequestProcessor processor = new ByeRequestProcessor(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| ... | ... | @@ -5,8 +5,6 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 6 | 6 | |
| 7 | 7 | import javax.sip.header.WWWAuthenticateHeader; |
| 8 | -import java.nio.channels.Channel; | |
| 9 | -import java.util.List; | |
| 10 | 8 | |
| 11 | 9 | public interface ISIPCommanderForPlatform { |
| 12 | 10 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.Host; | |
| 6 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | |
| 8 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 6 | import org.springframework.beans.factory.annotation.Qualifier; |
| 10 | 7 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -16,10 +13,8 @@ import javax.sip.address.SipURI; |
| 16 | 13 | import javax.sip.header.*; |
| 17 | 14 | import javax.sip.message.Request; |
| 18 | 15 | import javax.validation.constraints.NotNull; |
| 19 | -import java.nio.channels.Channel; | |
| 20 | 16 | import java.text.ParseException; |
| 21 | 17 | import java.util.ArrayList; |
| 22 | -import java.util.List; | |
| 23 | 18 | import java.util.UUID; |
| 24 | 19 | |
| 25 | 20 | /** | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| ... | ... | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | 3 | import java.text.ParseException; |
| 4 | 4 | import java.util.ArrayList; |
| 5 | -import java.util.UUID; | |
| 6 | 5 | |
| 7 | 6 | import javax.sip.InvalidArgumentException; |
| 8 | 7 | import javax.sip.PeerUnavailableException; |
| ... | ... | @@ -12,17 +11,13 @@ import javax.sip.address.Address; |
| 12 | 11 | import javax.sip.address.SipURI; |
| 13 | 12 | import javax.sip.header.*; |
| 14 | 13 | import javax.sip.message.Request; |
| 15 | -import javax.validation.constraints.NotNull; | |
| 16 | 14 | |
| 17 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 18 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | 16 | import org.springframework.beans.factory.annotation.Qualifier; |
| 20 | 17 | import org.springframework.stereotype.Component; |
| 21 | 18 | |
| 22 | 19 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 23 | 20 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 24 | -import com.genersoft.iot.vmp.gb28181.bean.Host; | |
| 25 | -import org.springframework.util.DigestUtils; | |
| 26 | 21 | |
| 27 | 22 | /** |
| 28 | 23 | * @Description:摄像头命令request创造器 TODO 冗余代码太多待优化 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.conf.SipConfig; | |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 3 | +//import com.genersoft.iot.vmp.conf.SipConfig; | |
| 4 | +//import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 9 | -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | |
| 9 | +//import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | |
| 10 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
| 12 | -import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; | |
| 12 | +//import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; | |
| 13 | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 14 | -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | |
| 14 | +//import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | |
| 15 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 16 | import org.springframework.beans.factory.annotation.Qualifier; |
| 17 | 17 | import org.springframework.beans.factory.annotation.Value; |
| ... | ... | @@ -22,28 +22,26 @@ import javax.sip.*; |
| 22 | 22 | import javax.sip.header.CallIdHeader; |
| 23 | 23 | import javax.sip.header.WWWAuthenticateHeader; |
| 24 | 24 | import javax.sip.message.Request; |
| 25 | -import java.nio.channels.Channel; | |
| 26 | 25 | import java.text.ParseException; |
| 27 | -import java.util.List; | |
| 28 | 26 | import java.util.UUID; |
| 29 | 27 | |
| 30 | 28 | @Component |
| 31 | 29 | public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 32 | 30 | |
| 33 | - @Autowired | |
| 34 | - private SipConfig sipConfig; | |
| 31 | + // @Autowired | |
| 32 | + // private SipConfig sipConfig; | |
| 35 | 33 | |
| 36 | - @Autowired | |
| 37 | - private SIPRequestHeaderProvider headerProvider; | |
| 34 | + // @Autowired | |
| 35 | + // private SIPRequestHeaderProvider headerProvider; | |
| 38 | 36 | |
| 39 | 37 | @Autowired |
| 40 | 38 | private SIPRequestHeaderPlarformProvider headerProviderPlarformProvider; |
| 41 | 39 | |
| 42 | - @Autowired | |
| 43 | - private VideoStreamSessionManager streamSession; | |
| 40 | + // @Autowired | |
| 41 | + // private VideoStreamSessionManager streamSession; | |
| 44 | 42 | |
| 45 | - @Autowired | |
| 46 | - private IVideoManagerStorager storager; | |
| 43 | + // @Autowired | |
| 44 | + // private IVideoManagerStorager storager; | |
| 47 | 45 | |
| 48 | 46 | @Autowired |
| 49 | 47 | private IRedisCatchStorage redisCatchStorage; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 2 | 2 | |
| 3 | +import java.util.HashMap; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 3 | 6 | import javax.sip.*; |
| 4 | -import javax.sip.message.Request; | |
| 7 | +//import javax.sip.message.Request; | |
| 5 | 8 | |
| 9 | +import com.genersoft.iot.vmp.common.StreamInfo; | |
| 10 | +import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | |
| 6 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; |
| 12 | +import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | |
| 13 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 7 | 14 | |
| 8 | -import gov.nist.javax.sip.header.CSeq; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 9 | 16 | |
| 10 | 17 | /** |
| 11 | 18 | * @Description:ACK请求处理器 |
| 12 | 19 | * @author: swwheihei |
| 13 | 20 | * @date: 2020年5月3日 下午5:31:45 |
| 14 | 21 | */ |
| 22 | +@Component | |
| 15 | 23 | public class AckRequestProcessor extends SIPRequestAbstractProcessor { |
| 16 | - | |
| 24 | + | |
| 25 | + //@Autowired | |
| 26 | + private IRedisCatchStorage redisCatchStorage; | |
| 27 | + | |
| 28 | + //@Autowired | |
| 29 | + private ZLMRTPServerFactory zlmrtpServerFactory; | |
| 30 | + | |
| 31 | + | |
| 17 | 32 | /** |
| 18 | 33 | * 处理 ACK请求 |
| 19 | 34 | * |
| ... | ... | @@ -21,25 +36,77 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor { |
| 21 | 36 | */ |
| 22 | 37 | @Override |
| 23 | 38 | public void process(RequestEvent evt) { |
| 24 | - Request request = evt.getRequest(); | |
| 39 | + //Request request = evt.getRequest(); | |
| 25 | 40 | Dialog dialog = evt.getDialog(); |
| 26 | - DialogState state = dialog.getState(); | |
| 27 | 41 | if (dialog == null) return; |
| 28 | - if (request.getMethod().equals(Request.INVITE) && dialog.getState()== DialogState.CONFIRMED) { | |
| 29 | - // TODO 查询并开始推流 | |
| 30 | - } | |
| 31 | - try { | |
| 32 | - Request ackRequest = null; | |
| 33 | - CSeq csReq = (CSeq) request.getHeader(CSeq.NAME); | |
| 34 | - ackRequest = dialog.createAck(csReq.getSeqNumber()); | |
| 35 | - dialog.sendAck(ackRequest); | |
| 36 | - System.out.println("send ack to callee:" + ackRequest.toString()); | |
| 37 | - } catch (SipException e) { | |
| 38 | - e.printStackTrace(); | |
| 39 | - } catch (InvalidArgumentException e) { | |
| 40 | - e.printStackTrace(); | |
| 42 | + //DialogState state = dialog.getState(); | |
| 43 | + if (/*request.getMethod().equals(Request.INVITE) &&*/ dialog.getState()== DialogState.CONFIRMED) { | |
| 44 | + String remoteUri = dialog.getRemoteParty().getURI().toString(); | |
| 45 | + String localUri = dialog.getLocalParty().getURI().toString(); | |
| 46 | + String platformGbId = remoteUri.substring(remoteUri.indexOf(":") + 1, remoteUri.indexOf("@")); | |
| 47 | + String channelId = localUri.substring(remoteUri.indexOf(":") + 1, remoteUri.indexOf("@")); | |
| 48 | + SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(platformGbId, channelId); | |
| 49 | + String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; | |
| 50 | + String deviceId = sendRtpItem.getDeviceId(); | |
| 51 | + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); | |
| 52 | + System.out.println(platformGbId); | |
| 53 | + System.out.println(channelId); | |
| 54 | + Map<String, Object> param = new HashMap<>(); | |
| 55 | + param.put("vhost","__defaultVhost__"); | |
| 56 | + param.put("app","rtp"); | |
| 57 | + param.put("stream",streamInfo.getStreamId()); | |
| 58 | + param.put("ssrc", sendRtpItem.getSsrc()); | |
| 59 | + param.put("dst_url",sendRtpItem.getIp()); | |
| 60 | + param.put("dst_port", sendRtpItem.getPort()); | |
| 61 | + param.put("is_udp", is_Udp); | |
| 62 | + //param.put ("src_port", sendRtpItem.getLocalPort()); | |
| 63 | + // 设备推流查询,成功后才能转推 | |
| 64 | + boolean rtpPushed = false; | |
| 65 | + long startTime = System.currentTimeMillis(); | |
| 66 | + while (!rtpPushed) { | |
| 67 | + try { | |
| 68 | + if (System.currentTimeMillis() - startTime < 30 * 1000) { | |
| 69 | + if (zlmrtpServerFactory.isRtpReady(streamInfo.getStreamId())) { | |
| 70 | + rtpPushed = true; | |
| 71 | + zlmrtpServerFactory.startSendRtpStream(param); | |
| 72 | + } else { | |
| 73 | + Thread.sleep(2000); | |
| 74 | + continue; | |
| 75 | + } | |
| 76 | + } | |
| 77 | + } catch (InterruptedException e) { | |
| 78 | + e.printStackTrace(); | |
| 79 | + } | |
| 80 | + } | |
| 41 | 81 | } |
| 82 | + // try { | |
| 83 | + // Request ackRequest = null; | |
| 84 | + // CSeq csReq = (CSeq) request.getHeader(CSeq.NAME); | |
| 85 | + // ackRequest = dialog.createAck(csReq.getSeqNumber()); | |
| 86 | + // dialog.sendAck(ackRequest); | |
| 87 | + // System.out.println("send ack to callee:" + ackRequest.toString()); | |
| 88 | + // } catch (SipException e) { | |
| 89 | + // e.printStackTrace(); | |
| 90 | + // } catch (InvalidArgumentException e) { | |
| 91 | + // e.printStackTrace(); | |
| 92 | + // } | |
| 42 | 93 | |
| 43 | 94 | } |
| 44 | 95 | |
| 96 | + public IRedisCatchStorage getRedisCatchStorage() { | |
| 97 | + return redisCatchStorage; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) { | |
| 101 | + this.redisCatchStorage = redisCatchStorage; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public ZLMRTPServerFactory getZlmrtpServerFactory() { | |
| 105 | + return zlmrtpServerFactory; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setZlmrtpServerFactory(ZLMRTPServerFactory zlmrtpServerFactory) { | |
| 109 | + this.zlmrtpServerFactory = zlmrtpServerFactory; | |
| 110 | + } | |
| 111 | + | |
| 45 | 112 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -7,14 +7,10 @@ import javax.sip.SipException; |
| 7 | 7 | import javax.sip.SipFactory; |
| 8 | 8 | import javax.sip.address.Address; |
| 9 | 9 | import javax.sip.address.SipURI; |
| 10 | -import javax.sip.header.ContentTypeHeader; | |
| 11 | -import javax.sip.header.FromHeader; | |
| 12 | -import javax.sip.header.HeaderFactory; | |
| 13 | -import javax.sip.header.SubjectHeader; | |
| 10 | +import javax.sip.header.*; | |
| 14 | 11 | import javax.sip.message.Request; |
| 15 | 12 | import javax.sip.message.Response; |
| 16 | 13 | |
| 17 | -import com.alibaba.fastjson.JSONObject; | |
| 18 | 14 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 19 | 15 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 20 | 16 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| ... | ... | @@ -27,17 +23,12 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 27 | 23 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 28 | 24 | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult; |
| 29 | 25 | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| 30 | -import gov.nist.javax.sdp.fields.SDPFormat; | |
| 31 | 26 | import gov.nist.javax.sip.address.AddressImpl; |
| 32 | 27 | import gov.nist.javax.sip.address.SipUri; |
| 33 | 28 | import org.slf4j.Logger; |
| 34 | 29 | import org.slf4j.LoggerFactory; |
| 35 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 36 | 30 | |
| 37 | -import java.io.IOException; | |
| 38 | 31 | import java.text.ParseException; |
| 39 | -import java.util.List; | |
| 40 | -import java.util.UUID; | |
| 41 | 32 | import java.util.Vector; |
| 42 | 33 | |
| 43 | 34 | /** |
| ... | ... | @@ -45,6 +36,7 @@ import java.util.Vector; |
| 45 | 36 | * @author: panll |
| 46 | 37 | * @date: 2021年1月14日 |
| 47 | 38 | */ |
| 39 | +@SuppressWarnings("rawtypes") | |
| 48 | 40 | public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 49 | 41 | |
| 50 | 42 | private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); |
| ... | ... | @@ -122,8 +114,10 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 122 | 114 | |
| 123 | 115 | // jainSip不支持y=字段, 移除移除以解析。 |
| 124 | 116 | int ssrcIndex = contentString.indexOf("y="); |
| 125 | - String ssrc = contentString.substring(ssrcIndex + 2, contentString.length()) | |
| 126 | - .replace("\r\n", "").replace("\n", ""); | |
| 117 | + String ssrc = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); | |
| 118 | + //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 | |
| 119 | + // String ssrc = contentString.substring(ssrcIndex + 2, contentString.length()) | |
| 120 | + // .replace("\r\n", "").replace("\n", ""); | |
| 127 | 121 | |
| 128 | 122 | String substring = contentString.substring(0, contentString.indexOf("y=")); |
| 129 | 123 | SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); |
| ... | ... | @@ -131,9 +125,9 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 131 | 125 | // 获取支持的格式 |
| 132 | 126 | Vector mediaDescriptions = sdp.getMediaDescriptions(true); |
| 133 | 127 | // 查看是否支持PS 负载96 |
| 134 | - String ip = null; | |
| 128 | + //String ip = null; | |
| 135 | 129 | int port = -1; |
| 136 | - boolean recvonly = false; | |
| 130 | + //boolean recvonly = false; | |
| 137 | 131 | boolean mediaTransmissionTCP = false; |
| 138 | 132 | Boolean tcpActive = null; |
| 139 | 133 | for (int i = 0; i < mediaDescriptions.size(); i++) { |
| ... | ... | @@ -143,7 +137,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 143 | 137 | Vector mediaFormats = media.getMediaFormats(false); |
| 144 | 138 | if (mediaFormats.contains("96")) { |
| 145 | 139 | port = media.getMediaPort(); |
| 146 | - String mediaType = media.getMediaType(); | |
| 140 | + //String mediaType = media.getMediaType(); | |
| 147 | 141 | String protocol = media.getProtocol(); |
| 148 | 142 | |
| 149 | 143 | // 区分TCP发流还是udp, 当前默认udp |
| ... | ... | @@ -169,7 +163,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 169 | 163 | } |
| 170 | 164 | String username = sdp.getOrigin().getUsername(); |
| 171 | 165 | String addressStr = sdp.getOrigin().getAddress(); |
| 172 | - String sessionName = sdp.getSessionName().getValue(); | |
| 166 | + //String sessionName = sdp.getSessionName().getValue(); | |
| 173 | 167 | logger.info("[上级点播]用户:{}, 地址:{}:{}, ssrc:{}", username, addressStr, port, ssrc); |
| 174 | 168 | |
| 175 | 169 | Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); |
| ... | ... | @@ -178,7 +172,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { |
| 178 | 172 | responseAck(evt, Response.SERVER_INTERNAL_ERROR); |
| 179 | 173 | return; |
| 180 | 174 | } |
| 181 | - SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(ip, port, platformId, ssrc, channelId, | |
| 175 | + SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(addressStr, port, ssrc, platformId, device.getDeviceId(), channelId, | |
| 182 | 176 | mediaTransmissionTCP); |
| 183 | 177 | if (tcpActive != null) { |
| 184 | 178 | sendRtpItem.setTcpActive(tcpActive); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| ... | ... | @@ -370,31 +370,36 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 370 | 370 | private void processMessageDeviceInfo(RequestEvent evt) { |
| 371 | 371 | try { |
| 372 | 372 | Element rootElement = getRootElement(evt); |
| 373 | + String requestName = rootElement.getName(); | |
| 373 | 374 | Element deviceIdElement = rootElement.element("DeviceID"); |
| 374 | 375 | String deviceId = deviceIdElement.getTextTrim().toString(); |
| 375 | - | |
| 376 | - Device device = storager.queryVideoDevice(deviceId); | |
| 377 | - if (device == null) { | |
| 378 | - return; | |
| 379 | - } | |
| 380 | - device.setName(XmlUtil.getText(rootElement, "DeviceName")); | |
| 381 | - device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer")); | |
| 382 | - device.setModel(XmlUtil.getText(rootElement, "Model")); | |
| 383 | - device.setFirmware(XmlUtil.getText(rootElement, "Firmware")); | |
| 384 | - if (StringUtils.isEmpty(device.getStreamMode())) { | |
| 385 | - device.setStreamMode("UDP"); | |
| 386 | - } | |
| 387 | - storager.updateDevice(device); | |
| 388 | - | |
| 389 | - RequestMessage msg = new RequestMessage(); | |
| 390 | - msg.setDeviceId(deviceId); | |
| 391 | - msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICEINFO); | |
| 392 | - msg.setData(device); | |
| 393 | - deferredResultHolder.invokeResult(msg); | |
| 394 | - // 回复200 OK | |
| 395 | - responseAck(evt); | |
| 396 | - if (offLineDetector.isOnline(deviceId)) { | |
| 397 | - publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 376 | + if (requestName.equals("Query")) { | |
| 377 | + // 回复200 OK | |
| 378 | + responseAck(evt); | |
| 379 | + } else { | |
| 380 | + Device device = storager.queryVideoDevice(deviceId); | |
| 381 | + if (device == null) { | |
| 382 | + return; | |
| 383 | + } | |
| 384 | + device.setName(XmlUtil.getText(rootElement, "DeviceName")); | |
| 385 | + device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer")); | |
| 386 | + device.setModel(XmlUtil.getText(rootElement, "Model")); | |
| 387 | + device.setFirmware(XmlUtil.getText(rootElement, "Firmware")); | |
| 388 | + if (StringUtils.isEmpty(device.getStreamMode())) { | |
| 389 | + device.setStreamMode("UDP"); | |
| 390 | + } | |
| 391 | + storager.updateDevice(device); | |
| 392 | + | |
| 393 | + RequestMessage msg = new RequestMessage(); | |
| 394 | + msg.setDeviceId(deviceId); | |
| 395 | + msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICEINFO); | |
| 396 | + msg.setData(device); | |
| 397 | + deferredResultHolder.invokeResult(msg); | |
| 398 | + // 回复200 OK | |
| 399 | + responseAck(evt); | |
| 400 | + if (offLineDetector.isOnline(deviceId)) { | |
| 401 | + publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 402 | + } | |
| 398 | 403 | } |
| 399 | 404 | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
| 400 | 405 | e.printStackTrace(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java
| ... | ... | @@ -9,24 +9,15 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.impl.RegisterRequestProces |
| 9 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor; |
| 10 | 10 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 11 | 11 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 12 | -import gov.nist.core.Host; | |
| 13 | -import gov.nist.javax.sip.address.AddressImpl; | |
| 14 | -import gov.nist.javax.sip.address.SipUri; | |
| 15 | -import gov.nist.javax.sip.header.To; | |
| 16 | 12 | import org.slf4j.Logger; |
| 17 | 13 | import org.slf4j.LoggerFactory; |
| 18 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | 15 | import org.springframework.stereotype.Component; |
| 20 | 16 | |
| 21 | 17 | import javax.sip.ResponseEvent; |
| 22 | -import javax.sip.address.Address; | |
| 23 | -import javax.sip.address.URI; | |
| 24 | 18 | import javax.sip.header.CallIdHeader; |
| 25 | -import javax.sip.header.ExpiresHeader; | |
| 26 | -import javax.sip.header.ToHeader; | |
| 27 | 19 | import javax.sip.header.WWWAuthenticateHeader; |
| 28 | 20 | import javax.sip.message.Response; |
| 29 | -import java.util.UUID; | |
| 30 | 21 | |
| 31 | 22 | /** |
| 32 | 23 | * @Description:Register响应处理器 | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import java.math.BigInteger; | |
| 4 | -import java.text.DecimalFormat; | |
| 5 | -import java.util.ArrayList; | |
| 6 | -import java.util.List; | |
| 7 | 3 | import java.util.UUID; |
| 8 | 4 | |
| 9 | 5 | import com.alibaba.fastjson.JSON; |
| 10 | -import com.alibaba.fastjson.JSONArray; | |
| 11 | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 12 | 7 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 13 | 8 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 14 | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 15 | 10 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 16 | -import com.genersoft.iot.vmp.utils.IpUtil; | |
| 17 | 11 | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| 18 | 12 | import org.slf4j.Logger; |
| 19 | 13 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -57,8 +51,8 @@ public class ZLMHttpHookListener { |
| 57 | 51 | @Autowired |
| 58 | 52 | private IRedisCatchStorage redisCatchStorage; |
| 59 | 53 | |
| 60 | - @Autowired | |
| 61 | - private ZLMRESTfulUtils zlmresTfulUtils; | |
| 54 | + // @Autowired | |
| 55 | + // private ZLMRESTfulUtils zlmresTfulUtils; | |
| 62 | 56 | |
| 63 | 57 | @Autowired |
| 64 | 58 | private ZLMHttpHookSubscribe subscribe; |
| ... | ... | @@ -217,8 +211,8 @@ public class ZLMHttpHookListener { |
| 217 | 211 | logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString()); |
| 218 | 212 | } |
| 219 | 213 | // TODO 如果是带有rtpstream则开启按需拉流 |
| 220 | - String app = json.getString("app"); | |
| 221 | - String stream = json.getString("stream"); | |
| 214 | + // String app = json.getString("app"); | |
| 215 | + // String stream = json.getString("stream"); | |
| 222 | 216 | |
| 223 | 217 | ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json); |
| 224 | 218 | if (subscribe != null) subscribe.response(json); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -119,4 +119,8 @@ public class ZLMRESTfulUtils { |
| 119 | 119 | public JSONObject closeRtpServer(Map<String, Object> param) { |
| 120 | 120 | return sendPost("closeRtpServer",param); |
| 121 | 121 | } |
| 122 | + | |
| 123 | + public JSONObject startSendRtp(Map<String, Object> param) { | |
| 124 | + return sendPost("startSendRtp",param); | |
| 125 | + } | |
| 122 | 126 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| ... | ... | @@ -105,7 +105,7 @@ public class ZLMRTPServerFactory { |
| 105 | 105 | * @param tcp 是否为tcp |
| 106 | 106 | * @return SendRtpItem |
| 107 | 107 | */ |
| 108 | - public SendRtpItem createSendRtpItem(String ip, int port, String ssrc, String platformId, String channelId, boolean tcp){ | |
| 108 | + public SendRtpItem createSendRtpItem(String ip, int port, String ssrc, String platformId, String deviceId, String channelId, boolean tcp){ | |
| 109 | 109 | String playSsrc = SsrcUtil.getPlaySsrc(); |
| 110 | 110 | int localPort = createRTPServer(SsrcUtil.getPlaySsrc()); |
| 111 | 111 | if (localPort != -1) { |
| ... | ... | @@ -119,9 +119,54 @@ public class ZLMRTPServerFactory { |
| 119 | 119 | sendRtpItem.setPort(port); |
| 120 | 120 | sendRtpItem.setSsrc(ssrc); |
| 121 | 121 | sendRtpItem.setPlatformId(platformId); |
| 122 | + sendRtpItem.setDeviceId(deviceId); | |
| 122 | 123 | sendRtpItem.setChannelId(channelId); |
| 123 | 124 | sendRtpItem.setTcp(tcp); |
| 124 | 125 | sendRtpItem.setLocalPort(localPort); |
| 125 | 126 | return sendRtpItem; |
| 126 | 127 | } |
| 128 | + | |
| 129 | + /** | |
| 130 | + * | |
| 131 | + */ | |
| 132 | + public Boolean startSendRtpStream(Map<String, Object>param) { | |
| 133 | + Boolean result = false; | |
| 134 | + JSONObject jsonObject = zlmresTfulUtils.startSendRtp(param); | |
| 135 | + System.out.println(jsonObject); | |
| 136 | + if (jsonObject != null) { | |
| 137 | + switch (jsonObject.getInteger("code")){ | |
| 138 | + case 0: | |
| 139 | + result= true; | |
| 140 | + logger.error("RTP推流请求成功,本地推流端口:" + jsonObject.getString("local_port")); | |
| 141 | + break; | |
| 142 | + // case -300: // id已经存在 | |
| 143 | + // result = false; | |
| 144 | + // break; | |
| 145 | + // case -400: // 端口占用 | |
| 146 | + // result= false; | |
| 147 | + // break; | |
| 148 | + default: | |
| 149 | + logger.error("RTP推流失败: " + jsonObject.getString("msg")); | |
| 150 | + break; | |
| 151 | + } | |
| 152 | + }else { | |
| 153 | + // 检查ZLM状态 | |
| 154 | + logger.error("RTP推流失败: 请检查ZLM服务"); | |
| 155 | + } | |
| 156 | + return result; | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * | |
| 161 | + */ | |
| 162 | + public Boolean isRtpReady(String streamId) { | |
| 163 | + JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId); | |
| 164 | + if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { | |
| 165 | + logger.info("设备RTP推流成功"); | |
| 166 | + return true; | |
| 167 | + } else { | |
| 168 | + logger.info("设备RTP推流未完成"); | |
| 169 | + return false; | |
| 170 | + } | |
| 171 | + } | |
| 127 | 172 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| ... | ... | @@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | 4 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 7 | -import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister; | |
| 8 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 9 | 8 | |
| 10 | 9 | import java.util.Map; |
| ... | ... | @@ -81,4 +80,13 @@ public interface IRedisCatchStorage { |
| 81 | 80 | void delPlatformRegisterInfo(String callId); |
| 82 | 81 | |
| 83 | 82 | void updateSendRTPSever(SendRtpItem sendRtpItem); |
| 83 | + | |
| 84 | + /** | |
| 85 | + * 查询RTP推送信息缓存 | |
| 86 | + * @param platformGbId | |
| 87 | + * @param channelId | |
| 88 | + * @return sendRtpItem | |
| 89 | + */ | |
| 90 | + SendRtpItem querySendRTPServer(String platformGbId, String channelId); | |
| 91 | + | |
| 84 | 92 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| 1 | 1 | package com.genersoft.iot.vmp.storager; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | -import java.util.Map; | |
| 5 | 4 | |
| 6 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 7 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 8 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 9 | 7 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 10 | 8 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 11 | 9 | import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; |
| 12 | 10 | import com.github.pagehelper.PageInfo; |
| 13 | -import gov.nist.javax.sip.stack.NioTcpMessageProcessor; | |
| 14 | - | |
| 15 | -import javax.swing.event.ChangeEvent; | |
| 16 | 11 | |
| 17 | 12 | /** |
| 18 | 13 | * @Description:视频设备数据存储接口 |
| 19 | 14 | * @author: swwheihei |
| 20 | 15 | * @date: 2020年5月6日 下午2:14:31 |
| 21 | 16 | */ |
| 17 | +@SuppressWarnings("rawtypes") | |
| 22 | 18 | public interface IVideoManagerStorager { |
| 23 | 19 | |
| 24 | 20 | /** | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 5 | 4 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 6 | 5 | import org.apache.ibatis.annotations.*; |
| 7 | 6 | import org.springframework.stereotype.Repository; | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| ... | ... | @@ -218,4 +218,11 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 218 | 218 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId(); |
| 219 | 219 | redis.set(key, sendRtpItem); |
| 220 | 220 | } |
| 221 | + | |
| 222 | + @Override | |
| 223 | + public SendRtpItem querySendRTPServer(String platformGbId, String channelId) { | |
| 224 | + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_" + channelId; | |
| 225 | + return (SendRtpItem)redis.get(key); | |
| 226 | + } | |
| 227 | + | |
| 221 | 228 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 27 | 27 | * @author: swwheihei |
| 28 | 28 | * @date: 2020年5月6日 下午2:31:42 |
| 29 | 29 | */ |
| 30 | +@SuppressWarnings("rawtypes") | |
| 30 | 31 | @Component |
| 31 | 32 | public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 32 | 33 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.platform; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.alibaba.fastjson.JSONObject; |
| 5 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| ... | ... | @@ -18,10 +17,6 @@ import org.springframework.util.StringUtils; |
| 18 | 17 | import org.springframework.web.bind.annotation.*; |
| 19 | 18 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 20 | 19 | |
| 21 | -import java.util.List; | |
| 22 | -import java.util.Map; | |
| 23 | - | |
| 24 | - | |
| 25 | 20 | @CrossOrigin |
| 26 | 21 | @RestController |
| 27 | 22 | @RequestMapping("/api") | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.play; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 4 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| ... | ... | @@ -22,12 +21,10 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 22 | 21 | import org.springframework.web.bind.annotation.RestController; |
| 23 | 22 | |
| 24 | 23 | import com.alibaba.fastjson.JSONObject; |
| 25 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 26 | 24 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 27 | 25 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 28 | 26 | import org.springframework.web.context.request.async.DeferredResult; |
| 29 | 27 | |
| 30 | -import javax.sip.message.Response; | |
| 31 | 28 | import java.util.UUID; |
| 32 | 29 | |
| 33 | 30 | @CrossOrigin | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
| ... | ... | @@ -14,7 +14,6 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; |
| 14 | 14 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 15 | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | 16 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 17 | -import com.genersoft.iot.vmp.vmanager.play.PlayController; | |
| 18 | 17 | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult; |
| 19 | 18 | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| 20 | 19 | import org.slf4j.Logger; |
| ... | ... | @@ -25,7 +24,6 @@ import org.springframework.stereotype.Service; |
| 25 | 24 | import org.springframework.web.context.request.async.DeferredResult; |
| 26 | 25 | |
| 27 | 26 | import javax.sip.message.Response; |
| 28 | -import java.text.DecimalFormat; | |
| 29 | 27 | import java.util.UUID; |
| 30 | 28 | |
| 31 | 29 | @Service | ... | ... |