Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0
commit
bb50a24314
19
README.md
19
README.md
|
@ -8,7 +8,7 @@
|
||||||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://github.com/xia-chu/ZLMediaKit/pulls)
|
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://github.com/xia-chu/ZLMediaKit/pulls)
|
||||||
|
|
||||||
|
|
||||||
WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康、大华、宇视等品牌的IPC、NVR、DVR接入。支持国标级联,支持rtsp/rtmp等视频流转发到国标平台,支持rtsp/rtmp等推流转发到国标平台。
|
WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康、大华、宇视等品牌的IPC、NVR接入。支持国标级联,支持将不带国标功能的摄像机/直播流/直播推流转发到其他国标平台。
|
||||||
|
|
||||||
流媒体服务基于ZLMediaKit-https://github.com/xiongziliang/ZLMediaKit
|
流媒体服务基于ZLMediaKit-https://github.com/xiongziliang/ZLMediaKit
|
||||||
|
|
||||||
|
@ -31,11 +31,13 @@ WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网
|
||||||
https://gitee.com/pan648540858/wvp-GB28181-pro.git
|
https://gitee.com/pan648540858/wvp-GB28181-pro.git
|
||||||
|
|
||||||
# 截图
|
# 截图
|
||||||
![build_1.png](https://github.com/648540858/wiki/blob/master/images/Screenshot_1.png)
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101513_79632720_1018729.png "2022-03-04_09-51.png")
|
||||||
![build_1.png](https://github.com/648540858/wiki/blob/master/images/Screenshot_2.png)
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/103025_5df016f9_1018729.png "2022-03-04_10-27.png")
|
||||||
![build_1.png](https://github.com/648540858/wiki/blob/master/images/Screenshot_20201012_151459.png)
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101706_088fbafa_1018729.png "2022-03-04_09-52_1.png")
|
||||||
![build_1.png](https://github.com/648540858/wiki/blob/master/images/Screenshot_20201012_152643.png)
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101756_3d662828_1018729.png "2022-03-04_10-00_1.png")
|
||||||
![build_1.png](https://github.com/648540858/wiki/blob/master/images/Screenshot_20201012_151606.png)
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101823_19050c66_1018729.png "2022-03-04_10-12_1.png")
|
||||||
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101848_e5a39557_1018729.png "2022-03-04_10-12_2.png")
|
||||||
|
![build_1.png](https://images.gitee.com/uploads/images/2022/0304/101919_ee5b8c79_1018729.png "2022-03-04_10-13.png")
|
||||||
|
|
||||||
# 1.0 基础特性
|
# 1.0 基础特性
|
||||||
1. 视频预览;
|
1. 视频预览;
|
||||||
|
@ -79,7 +81,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git
|
||||||
- [X] 移动位置通知处理
|
- [X] 移动位置通知处理
|
||||||
- [X] 报警事件订阅
|
- [X] 报警事件订阅
|
||||||
- [X] 报警事件通知处理
|
- [X] 报警事件通知处理
|
||||||
- [ ] 设备目录订阅
|
- [X] 设备目录订阅
|
||||||
- [X] 设备目录通知处理
|
- [X] 设备目录通知处理
|
||||||
16. 移动位置查询和显示,可通过配置文件设置移动位置历史是否存储
|
16. 移动位置查询和显示,可通过配置文件设置移动位置历史是否存储
|
||||||
|
|
||||||
|
@ -96,6 +98,9 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git
|
||||||
- [X] 平台信息查询
|
- [X] 平台信息查询
|
||||||
- [X] 平台远程启动
|
- [X] 平台远程启动
|
||||||
- [X] 每个级联平台可自定义的虚拟目录
|
- [X] 每个级联平台可自定义的虚拟目录
|
||||||
|
- [X] 目录订阅与通知
|
||||||
|
- [X] 录像查看与播放
|
||||||
|
- [X] GPS订阅与通知(直播推流)
|
||||||
- [X] 添加RTSP视频
|
- [X] 添加RTSP视频
|
||||||
- [X] 添加接口鉴权
|
- [X] 添加接口鉴权
|
||||||
- [X] 添加RTMP视频
|
- [X] 添加RTMP视频
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -253,10 +253,6 @@
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<!-- <scope>test</scope>-->
|
<!-- <scope>test</scope>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,6 @@ package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
|
|
||||||
public class Device {
|
public class Device {
|
||||||
|
|
||||||
/**
|
|
||||||
* Id
|
|
||||||
*/
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备Id
|
* 设备Id
|
||||||
*/
|
*/
|
||||||
|
@ -119,13 +114,7 @@ public class Device {
|
||||||
*/
|
*/
|
||||||
private int subscribeCycleForCatalog ;
|
private int subscribeCycleForCatalog ;
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
|
@ -294,6 +283,4 @@ public class Device {
|
||||||
public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) {
|
public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) {
|
||||||
this.subscribeCycleForCatalog = subscribeCycleForCatalog;
|
this.subscribeCycleForCatalog = subscribeCycleForCatalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,6 @@ package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MobilePosition {
|
public class MobilePosition {
|
||||||
/**
|
|
||||||
* Id
|
|
||||||
*/
|
|
||||||
private int id;
|
|
||||||
/**
|
/**
|
||||||
* 设备Id
|
* 设备Id
|
||||||
*/
|
*/
|
||||||
|
@ -76,13 +72,6 @@ public class MobilePosition {
|
||||||
*/
|
*/
|
||||||
private String cnLat;
|
private String cnLat;
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
|
|
|
@ -20,6 +20,8 @@ public class RecordItem implements Comparable<RecordItem>{
|
||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
|
private String fileSize;
|
||||||
|
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
private String startTime;
|
private String startTime;
|
||||||
|
@ -104,6 +106,14 @@ public class RecordItem implements Comparable<RecordItem>{
|
||||||
this.recorderId = recorderId;
|
this.recorderId = recorderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFileSize() {
|
||||||
|
return fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSize(String fileSize) {
|
||||||
|
this.fileSize = fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull RecordItem recordItem) {
|
public int compareTo(@NotNull RecordItem recordItem) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
|
|
||||||
|
import javax.sdp.SessionDescription;
|
||||||
|
|
||||||
|
public class SDPInfo {
|
||||||
|
private byte[] source;
|
||||||
|
private SessionDescription sdpSource;
|
||||||
|
private String sessionName;
|
||||||
|
private Long startTime;
|
||||||
|
private Long stopTime;
|
||||||
|
private String username;
|
||||||
|
private String address;
|
||||||
|
private String ssrc;
|
||||||
|
}
|
|
@ -71,6 +71,16 @@ public class SendRtpItem {
|
||||||
*/
|
*/
|
||||||
private String mediaServerId;
|
private String mediaServerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* invite的callId
|
||||||
|
*/
|
||||||
|
private String CallId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是play, false是playback
|
||||||
|
*/
|
||||||
|
private boolean isPlay;
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
@ -174,4 +184,20 @@ public class SendRtpItem {
|
||||||
public void setMediaServerId(String mediaServerId) {
|
public void setMediaServerId(String mediaServerId) {
|
||||||
this.mediaServerId = mediaServerId;
|
this.mediaServerId = mediaServerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCallId() {
|
||||||
|
return CallId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallId(String callId) {
|
||||||
|
CallId = callId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlay() {
|
||||||
|
return isPlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlay(boolean play) {
|
||||||
|
isPlay = play;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.event;
|
package com.genersoft.iot.vmp.gb28181.event;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
|
import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent;
|
import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent;
|
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
|
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
|
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
|
||||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
|
import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
|
||||||
|
@ -15,7 +14,6 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
|
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
|
import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
|
||||||
|
|
||||||
|
@ -145,4 +143,11 @@ public class EventPublisher {
|
||||||
gbStreamList.add(gbStream);
|
gbStreamList.add(gbStream);
|
||||||
catalogEventPublishForStream(platformId, gbStreamList, type);
|
catalogEventPublishForStream(platformId, gbStreamList, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void recordEndEventPush(RecordInfo recordInfo) {
|
||||||
|
RecordEndEvent outEvent = new RecordEndEvent(this);
|
||||||
|
outEvent.setRecordInfo(recordInfo);
|
||||||
|
applicationEventPublisher.publishEvent(outEvent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,8 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
|
||||||
eventResult.callId = callid;
|
eventResult.callId = callid;
|
||||||
eventResult.msg = "注册超时";
|
eventResult.msg = "注册超时";
|
||||||
eventResult.type = "register timeout";
|
eventResult.type = "register timeout";
|
||||||
if (sipSubscribe.getErrorSubscribe(callid) != null) {
|
|
||||||
sipSubscribe.getErrorSubscribe(callid).response(eventResult);
|
sipSubscribe.getErrorSubscribe(callid).response(eventResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ 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 com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -12,9 +13,11 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
@Component
|
||||||
public class PlatformCycleRegisterEventLister implements ApplicationListener<PlatformCycleRegisterEvent> {
|
public class PlatformCycleRegisterEventLister implements ApplicationListener<PlatformCycleRegisterEvent> {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(PlatformCycleRegisterEventLister.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVideoManagerStorager storager;
|
private IVideoManagerStorager storager;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -22,10 +25,10 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(PlatformCycleRegisterEvent event) {
|
public void onApplicationEvent(PlatformCycleRegisterEvent event) {
|
||||||
log.info("上级平台周期注册事件");
|
logger.info("上级平台周期注册事件");
|
||||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
|
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
|
||||||
if (parentPlatform == null) {
|
if (parentPlatform == null) {
|
||||||
log.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
logger.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
|
@ -36,7 +39,7 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
|
||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||||
}
|
}
|
||||||
}, 15*1000 ,Long.parseLong(parentPlatform.getExpires())* 1000);
|
}, 15*1000 ,Long.parseLong(parentPlatform.getExpires())* 1000);
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.genersoft.iot.vmp.gb28181.event.record;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 录像查询结束时间
|
||||||
|
* @author: pan
|
||||||
|
* @data: 2022-02-23
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RecordEndEvent extends ApplicationEvent {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public RecordEndEvent(Object source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RecordInfo recordInfo;
|
||||||
|
|
||||||
|
public RecordInfo getRecordInfo() {
|
||||||
|
return recordInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecordInfo(RecordInfo recordInfo) {
|
||||||
|
this.recordInfo = recordInfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.genersoft.iot.vmp.gb28181.event.record;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 录像查询结束时间
|
||||||
|
* @author: pan
|
||||||
|
* @data: 2022-02-23
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RecordEndEventListener implements ApplicationListener<RecordEndEvent> {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class);
|
||||||
|
|
||||||
|
private static Map<String, SseEmitter> sseEmitters = new Hashtable<>();
|
||||||
|
|
||||||
|
public interface RecordEndEventHandler{
|
||||||
|
void handler(RecordInfo recordInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>();
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(RecordEndEvent event) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(),
|
||||||
|
event.getRecordInfo().getChannelId(), event.getRecordInfo().getRecordList().size() );
|
||||||
|
}
|
||||||
|
if (handlerMap.size() > 0) {
|
||||||
|
for (RecordEndEventHandler recordEndEventHandler : handlerMap.values()) {
|
||||||
|
recordEndEventHandler.handler(event.getRecordInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) {
|
||||||
|
handlerMap.put(device + channelId, recordEndEventHandler);
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,7 +81,6 @@ public class SsrcConfig {
|
||||||
isUsed.remove(sn);
|
isUsed.remove(sn);
|
||||||
notUsed.add(sn);
|
notUsed.add(sn);
|
||||||
}catch (NullPointerException e){
|
}catch (NullPointerException e){
|
||||||
System.out.printf("11111");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ public class GPSSubscribeTask implements Runnable{
|
||||||
|
|
||||||
SubscribeInfo subscribe = redisCatchStorage.getSubscribe(key);
|
SubscribeInfo subscribe = redisCatchStorage.getSubscribe(key);
|
||||||
if (subscribe != null) {
|
if (subscribe != null) {
|
||||||
System.out.println("发送GPS消息");
|
|
||||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
|
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
|
||||||
if (parentPlatform == null || parentPlatform.isStatus()) {
|
if (parentPlatform == null || parentPlatform.isStatus()) {
|
||||||
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
||||||
|
|
|
@ -141,7 +141,6 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void processTimeout(TimeoutEvent timeoutEvent) {
|
public void processTimeout(TimeoutEvent timeoutEvent) {
|
||||||
System.out.println("processTimeout");
|
|
||||||
if(timeoutProcessor != null) {
|
if(timeoutProcessor != null) {
|
||||||
timeoutProcessor.process(timeoutEvent);
|
timeoutProcessor.process(timeoutEvent);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +172,6 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
|
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
|
||||||
System.out.println("processDialogTerminated");
|
|
||||||
CallIdHeader callId = dialogTerminatedEvent.getDialog().getCallId();
|
CallIdHeader callId = dialogTerminatedEvent.getDialog().getCallId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ public interface ISIPCommander {
|
||||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||||
* @param sn
|
* @param sn
|
||||||
*/
|
*/
|
||||||
boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, SipSubscribe.Event errorEvent);
|
boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询报警信息
|
* 查询报警信息
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||||
|
|
||||||
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.RecordInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
|
@ -87,4 +88,12 @@ public interface ISIPCommanderForPlatform {
|
||||||
*/
|
*/
|
||||||
boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index);
|
boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复recordInfo
|
||||||
|
* @param deviceChannel 通道信息
|
||||||
|
* @param parentPlatform 平台信息
|
||||||
|
* @param fromTag fromTag
|
||||||
|
* @param recordInfo 录像信息
|
||||||
|
*/
|
||||||
|
boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,8 +346,11 @@ public class SIPCommander implements ISIPCommander {
|
||||||
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
|
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
|
||||||
(MediaServerItem mediaServerItemInUse, JSONObject json)->{
|
(MediaServerItem mediaServerItemInUse, JSONObject json)->{
|
||||||
if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
|
if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
|
||||||
|
if (event != null) {
|
||||||
event.response(mediaServerItemInUse, json);
|
event.response(mediaServerItemInUse, json);
|
||||||
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
}
|
||||||
|
|
||||||
|
// subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
StringBuffer content = new StringBuffer(200);
|
StringBuffer content = new StringBuffer(200);
|
||||||
|
@ -450,13 +453,16 @@ public class SIPCommander implements ISIPCommander {
|
||||||
subscribeKey.put("app", "rtp");
|
subscribeKey.put("app", "rtp");
|
||||||
subscribeKey.put("stream", ssrcInfo.getStream());
|
subscribeKey.put("stream", ssrcInfo.getStream());
|
||||||
subscribeKey.put("regist", true);
|
subscribeKey.put("regist", true);
|
||||||
|
subscribeKey.put("schema", "rtmp");
|
||||||
subscribeKey.put("mediaServerId", mediaServerItem.getId());
|
subscribeKey.put("mediaServerId", mediaServerItem.getId());
|
||||||
logger.debug("录像回放添加订阅,订阅内容:" + subscribeKey.toString());
|
logger.debug("录像回放添加订阅,订阅内容:" + subscribeKey.toString());
|
||||||
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
|
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
|
||||||
(MediaServerItem mediaServerItemInUse, JSONObject json)->{
|
(MediaServerItem mediaServerItemInUse, JSONObject json)->{
|
||||||
|
System.out.println(344444);
|
||||||
if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
|
if (userSetup.isWaitTrack() && json.getJSONArray("tracks") == null) return;
|
||||||
|
if (event != null) {
|
||||||
event.response(mediaServerItemInUse, json);
|
event.response(mediaServerItemInUse, json);
|
||||||
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
StringBuffer content = new StringBuffer(200);
|
StringBuffer content = new StringBuffer(200);
|
||||||
|
@ -713,6 +719,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
if (ssrcTransaction != null) {
|
if (ssrcTransaction != null) {
|
||||||
MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
||||||
mediaServerService.releaseSsrc(mediaServerItem, ssrcTransaction.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem, ssrcTransaction.getSsrc());
|
||||||
|
mediaServerService.closeRTPServer(deviceId, channelId, ssrcTransaction.getStream());
|
||||||
streamSession.remove(deviceId, channelId, ssrcTransaction.getStream());
|
streamSession.remove(deviceId, channelId, ssrcTransaction.getStream());
|
||||||
}
|
}
|
||||||
} catch (SipException | ParseException e) {
|
} catch (SipException | ParseException e) {
|
||||||
|
@ -1196,9 +1203,13 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, SipSubscribe.Event errorEvent) {
|
public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
|
||||||
|
if (secrecy == null) {
|
||||||
|
secrecy = 0;
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
|
type = "all";
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
StringBuffer recordInfoXml = new StringBuffer(200);
|
StringBuffer recordInfoXml = new StringBuffer(200);
|
||||||
recordInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
|
recordInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
|
||||||
|
@ -1206,11 +1217,19 @@ public class SIPCommander implements ISIPCommander {
|
||||||
recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n");
|
recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n");
|
||||||
recordInfoXml.append("<SN>" + sn + "</SN>\r\n");
|
recordInfoXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||||
|
if (startTime != null) {
|
||||||
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
|
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
|
||||||
|
}
|
||||||
|
if (endTime != null) {
|
||||||
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
|
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
|
||||||
recordInfoXml.append("<Secrecy>0</Secrecy>\r\n");
|
}
|
||||||
|
if (secrecy != null) {
|
||||||
|
recordInfoXml.append("<Secrecy> "+ secrecy + " </Secrecy>\r\n");
|
||||||
|
}
|
||||||
|
if (type != null) {
|
||||||
// 大华NVR要求必须增加一个值为all的文本元素节点Type
|
// 大华NVR要求必须增加一个值为all的文本元素节点Type
|
||||||
recordInfoXml.append("<Type>all</Type>\r\n");
|
recordInfoXml.append("<Type>" + type+"</Type>\r\n");
|
||||||
|
}
|
||||||
recordInfoXml.append("</Query>\r\n");
|
recordInfoXml.append("</Query>\r\n");
|
||||||
|
|
||||||
String tm = Long.toString(System.currentTimeMillis());
|
String tm = Long.toString(System.currentTimeMillis());
|
||||||
|
@ -1221,7 +1240,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
||||||
"z9hG4bK-ViaRecordInfo-" + tm, "fromRec" + tm, null, callIdHeader);
|
"z9hG4bK-ViaRecordInfo-" + tm, "fromRec" + tm, null, callIdHeader);
|
||||||
|
|
||||||
transmitRequest(device, request, errorEvent);
|
transmitRequest(device, request, errorEvent, okEvent);
|
||||||
} catch (SipException | ParseException | InvalidArgumentException e) {
|
} catch (SipException | ParseException | InvalidArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
|
||||||
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;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.utils.DateUtil;
|
||||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -17,6 +15,7 @@ import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.sip.*;
|
import javax.sip.*;
|
||||||
import javax.sip.header.CallIdHeader;
|
import javax.sip.header.CallIdHeader;
|
||||||
|
@ -496,5 +495,52 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
catalogXml.append("</Notify>\r\n");
|
catalogXml.append("</Notify>\r\n");
|
||||||
return catalogXml.toString();
|
return catalogXml.toString();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) {
|
||||||
|
if ( parentPlatform ==null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StringBuffer recordXml = new StringBuffer(600);
|
||||||
|
recordXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
|
||||||
|
recordXml.append("<Response>\r\n");
|
||||||
|
recordXml.append("<CmdType>RecordInfo</CmdType>\r\n");
|
||||||
|
recordXml.append("<SN>" +recordInfo.getSn() + "</SN>\r\n");
|
||||||
|
recordXml.append("<DeviceID>" + recordInfo.getDeviceId() + "</DeviceID>\r\n");
|
||||||
|
recordXml.append("<SumNum>" + recordInfo.getSumNum() + "</SumNum>\r\n");
|
||||||
|
recordXml.append("<RecordList Num=\"" + recordInfo.getRecordList().size()+"\">\r\n");
|
||||||
|
for (RecordItem recordItem : recordInfo.getRecordList()) {
|
||||||
|
recordXml.append("<Item>\r\n");
|
||||||
|
if (deviceChannel != null) {
|
||||||
|
recordXml.append("<DeviceID>" + recordItem.getDeviceId() + "</DeviceID>\r\n");
|
||||||
|
recordXml.append("<Name>" + recordItem.getName() + "</Name>\r\n");
|
||||||
|
recordXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "</StartTime>\r\n");
|
||||||
|
recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n");
|
||||||
|
recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n");
|
||||||
|
recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n");
|
||||||
|
if (!StringUtils.isEmpty(recordItem.getFileSize())) {
|
||||||
|
recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n");
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(recordItem.getFilePath())) {
|
||||||
|
recordXml.append("<FilePath>" + recordItem.getFilePath() + "</FilePath>\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recordXml.append("</Item>\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
recordXml.append("</RecordList>\r\n");
|
||||||
|
recordXml.append("</Response>\r\n");
|
||||||
|
|
||||||
|
// callid
|
||||||
|
CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
|
||||||
|
: udpSipProvider.getNewCallId();
|
||||||
|
Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, callIdHeader);
|
||||||
|
transmitRequest(parentPlatform, request);
|
||||||
|
|
||||||
|
} catch (SipException | ParseException | InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
|
||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
|
@ -24,6 +27,8 @@ import javax.sip.header.HeaderAddress;
|
||||||
import javax.sip.header.ToHeader;
|
import javax.sip.header.ToHeader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SIP命令类型: ACK请求
|
* SIP命令类型: ACK请求
|
||||||
|
@ -52,6 +57,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMediaServerService mediaServerService;
|
private IMediaServerService mediaServerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZLMHttpHookSubscribe subscribe;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 ACK请求
|
* 处理 ACK请求
|
||||||
|
@ -60,6 +68,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void process(RequestEvent evt) {
|
public void process(RequestEvent evt) {
|
||||||
|
logger.info("ACK请求: {}", ((System.currentTimeMillis())));
|
||||||
Dialog dialog = evt.getDialog();
|
Dialog dialog = evt.getDialog();
|
||||||
if (dialog == null) return;
|
if (dialog == null) return;
|
||||||
if (dialog.getState()== DialogState.CONFIRMED) {
|
if (dialog.getState()== DialogState.CONFIRMED) {
|
||||||
|
@ -69,16 +78,17 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
|
String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
|
||||||
String deviceId = sendRtpItem.getDeviceId();
|
String deviceId = sendRtpItem.getDeviceId();
|
||||||
StreamInfo streamInfo = null;
|
StreamInfo streamInfo = null;
|
||||||
if (deviceId == null) {
|
if (sendRtpItem.isPlay()) {
|
||||||
|
streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
|
||||||
|
}else {
|
||||||
|
streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, channelId);
|
||||||
|
}
|
||||||
|
System.out.println(JSON.toJSON(streamInfo));
|
||||||
|
if (streamInfo == null) {
|
||||||
streamInfo = new StreamInfo();
|
streamInfo = new StreamInfo();
|
||||||
streamInfo.setApp(sendRtpItem.getApp());
|
streamInfo.setApp(sendRtpItem.getApp());
|
||||||
streamInfo.setStream(sendRtpItem.getStreamId());
|
streamInfo.setStream(sendRtpItem.getStreamId());
|
||||||
}else {
|
|
||||||
streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
|
|
||||||
sendRtpItem.setStreamId(streamInfo.getStream());
|
|
||||||
streamInfo.setApp("rtp");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
logger.info(platformGbId);
|
logger.info(platformGbId);
|
||||||
logger.info(channelId);
|
logger.info(channelId);
|
||||||
|
@ -90,34 +100,42 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
param.put("dst_url",sendRtpItem.getIp());
|
param.put("dst_url",sendRtpItem.getIp());
|
||||||
param.put("dst_port", sendRtpItem.getPort());
|
param.put("dst_port", sendRtpItem.getPort());
|
||||||
param.put("is_udp", is_Udp);
|
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) {
|
|
||||||
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
||||||
if (zlmrtpServerFactory.isStreamReady(mediaInfo, streamInfo.getApp(), streamInfo.getStream())) {
|
|
||||||
rtpPushed = true;
|
|
||||||
logger.info("已获取设备推流[{}/{}],开始向上级推流[{}:{}]",
|
|
||||||
streamInfo.getApp() ,streamInfo.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort());
|
|
||||||
zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
||||||
} else {
|
// if (zlmrtpServerFactory.isStreamReady(mediaInfo, streamInfo.getApp(), streamInfo.getStreamId())) {
|
||||||
logger.info("等待设备推流[{}/{}].......",
|
// logger.info("已获取设备推流[{}/{}],开始向上级推流[{}:{}]",
|
||||||
streamInfo.getApp() ,streamInfo.getStream());
|
// streamInfo.getApp() ,streamInfo.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort());
|
||||||
Thread.sleep(1000);
|
// zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
||||||
continue;
|
// } else {
|
||||||
}
|
// // 对hook进行订阅
|
||||||
} else {
|
// logger.info("等待设备推流[{}/{}].......",
|
||||||
rtpPushed = true;
|
// streamInfo.getApp(), streamInfo.getStreamId());
|
||||||
logger.info("设备推流[{}/{}]超时,终止向上级推流",
|
// Timer timer = new Timer();
|
||||||
streamInfo.getApp() ,streamInfo.getStream());
|
// timer.schedule(new TimerTask() {
|
||||||
}
|
// @Override
|
||||||
} catch (InterruptedException e) {
|
// public void run() {
|
||||||
e.printStackTrace();
|
// logger.info("设备推流[{}/{}]超时,终止向上级推流",
|
||||||
}
|
// finalStreamInfo.getApp() , finalStreamInfo.getStreamId());
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
|
// }, 30*1000L);
|
||||||
|
// // 添加订阅
|
||||||
|
// JSONObject subscribeKey = new JSONObject();
|
||||||
|
// subscribeKey.put("app", "rtp");
|
||||||
|
// subscribeKey.put("stream", streamInfo.getStreamId());
|
||||||
|
// subscribeKey.put("mediaServerId", streamInfo.getMediaServerId());
|
||||||
|
// subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey,
|
||||||
|
// (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
||||||
|
// logger.info("已获取设备推流[{}/{}],开始向上级推流[{}:{}]",
|
||||||
|
// finalStreamInfo.getApp(), finalStreamInfo.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort());
|
||||||
|
// timer.cancel();
|
||||||
|
// zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
|
||||||
|
// subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
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.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||||
|
@ -87,23 +88,35 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
||||||
zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
|
zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
|
||||||
redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
|
redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
|
||||||
if (zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId) == 0) {
|
int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
|
||||||
|
if (totalReaderCount == 0) {
|
||||||
logger.info(streamId + "无其它观看者,通知设备停止推流");
|
logger.info(streamId + "无其它观看者,通知设备停止推流");
|
||||||
cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId, streamId);
|
cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId, streamId);
|
||||||
|
}else if (totalReaderCount == -1){
|
||||||
|
logger.warn(streamId + " 查找其它观看者失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 可能是设备主动停止
|
// 可能是设备主动停止
|
||||||
Device device = storager.queryVideoDeviceByChannelId(platformGbId);
|
Device device = storager.queryVideoDeviceByChannelId(platformGbId);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
|
||||||
|
if (sendRtpItem != null) {
|
||||||
|
if (sendRtpItem.isPlay()) {
|
||||||
if (streamInfo != null) {
|
if (streamInfo != null) {
|
||||||
redisCatchStorage.stopPlay(streamInfo);
|
redisCatchStorage.stopPlay(streamInfo);
|
||||||
}
|
}
|
||||||
storager.stopPlay(device.getDeviceId(), channelId);
|
}else {
|
||||||
mediaServerService.closeRTPServer(device, channelId, streamInfo.getStream());
|
if (streamInfo != null) {
|
||||||
|
redisCatchStorage.stopPlayback(streamInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storager.stopPlay(device.getDeviceId(), channelId);
|
||||||
|
mediaServerService.closeRTPServer(device.getDeviceId(), channelId, streamInfo.getStream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (SipException e) {
|
} catch (SipException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InvalidArgumentException e) {
|
} catch (InvalidArgumentException e) {
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||||
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.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
|
||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.service.IPlayService;
|
import com.genersoft.iot.vmp.service.IPlayService;
|
||||||
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||||
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.gb28181.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
||||||
|
import gov.nist.javax.sdp.TimeDescriptionImpl;
|
||||||
|
import gov.nist.javax.sdp.fields.TimeField;
|
||||||
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;
|
||||||
|
@ -27,10 +38,13 @@ import javax.sip.RequestEvent;
|
||||||
import javax.sip.ServerTransaction;
|
import javax.sip.ServerTransaction;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
import javax.sip.address.SipURI;
|
import javax.sip.address.SipURI;
|
||||||
|
import javax.sip.header.CallIdHeader;
|
||||||
import javax.sip.header.FromHeader;
|
import javax.sip.header.FromHeader;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -60,6 +74,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPlayService playService;
|
private IPlayService playService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISIPCommander commander;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZLMRTPServerFactory zlmrtpServerFactory;
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
|
@ -69,6 +86,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPProcessorObserver sipProcessorObserver;
|
private SIPProcessorObserver sipProcessorObserver;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
// 添加消息处理的订阅
|
// 添加消息处理的订阅
|
||||||
|
@ -88,22 +106,19 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
Request request = evt.getRequest();
|
Request request = evt.getRequest();
|
||||||
SipURI sipURI = (SipURI) request.getRequestURI();
|
SipURI sipURI = (SipURI) request.getRequestURI();
|
||||||
String channelId = sipURI.getUser();
|
String channelId = sipURI.getUser();
|
||||||
String requesterId = null;
|
String requesterId = SipUtils.getUserIdFromFromHeader(request);
|
||||||
|
CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
|
||||||
FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME);
|
|
||||||
AddressImpl address = (AddressImpl) fromHeader.getAddress();
|
|
||||||
SipUri uri = (SipUri) address.getURI();
|
|
||||||
requesterId = uri.getUser();
|
|
||||||
|
|
||||||
if (requesterId == null || channelId == null) {
|
if (requesterId == null || channelId == null) {
|
||||||
logger.info("无法从FromHeader的Address中获取到平台id,返回400");
|
logger.info("无法从FromHeader的Address中获取到平台id,返回400");
|
||||||
responseAck(evt, Response.BAD_REQUEST); // 参数不全, 发400,请求错误
|
responseAck(evt, Response.BAD_REQUEST); // 参数不全, 发400,请求错误
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询请求方是否上级平台
|
// 查询请求是否来自上级平台\设备
|
||||||
ParentPlatform platform = storager.queryParentPlatByServerGBId(requesterId);
|
ParentPlatform platform = storager.queryParentPlatByServerGBId(requesterId);
|
||||||
if (platform != null) {
|
if (platform == null) {
|
||||||
|
inviteFromDeviceHandle(evt, requesterId);
|
||||||
|
}else {
|
||||||
// 查询平台下是否有该通道
|
// 查询平台下是否有该通道
|
||||||
DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
|
DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
|
||||||
GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
|
GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
|
||||||
|
@ -122,7 +137,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
mediaServerItem = mediaServerService.getOne(mediaServerId);
|
mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||||
if (mediaServerItem == null) {
|
if (mediaServerItem == null) {
|
||||||
logger.info("[ app={}, stream={} ]找不到zlm {},返回410",gbStream.getApp(), gbStream.getStream(), mediaServerId);
|
logger.info("[ app={}, stream={} ]找不到zlm {},返回410",gbStream.getApp(), gbStream.getStream(), mediaServerId);
|
||||||
responseAck(evt, Response.GONE, "media server not found");
|
responseAck(evt, Response.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream());
|
Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream());
|
||||||
|
@ -158,13 +173,26 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
ssrc = ssrcDefault;
|
ssrc = ssrcDefault;
|
||||||
sdp = SdpFactory.getInstance().createSessionDescription(contentString);
|
sdp = SdpFactory.getInstance().createSessionDescription(contentString);
|
||||||
}
|
}
|
||||||
|
String sessionName = sdp.getSessionName().getValue();
|
||||||
|
|
||||||
|
Long startTime = null;
|
||||||
|
Long stopTime = null;
|
||||||
|
Date start = null;
|
||||||
|
Date end = null;
|
||||||
|
if (sdp.getTimeDescriptions(false) != null && sdp.getTimeDescriptions(false).size() > 0) {
|
||||||
|
TimeDescriptionImpl timeDescription = (TimeDescriptionImpl)(sdp.getTimeDescriptions(false).get(0));
|
||||||
|
TimeField startTimeFiled = (TimeField)timeDescription.getTime();
|
||||||
|
startTime = startTimeFiled.getStartTime();
|
||||||
|
stopTime = startTimeFiled.getStopTime();
|
||||||
|
|
||||||
|
start = new Date(startTime*1000);
|
||||||
|
end = new Date(stopTime*1000);
|
||||||
|
}
|
||||||
// 获取支持的格式
|
// 获取支持的格式
|
||||||
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 mediaTransmissionTCP = false;
|
boolean mediaTransmissionTCP = false;
|
||||||
Boolean tcpActive = null;
|
Boolean tcpActive = null;
|
||||||
for (Object description : mediaDescriptions) {
|
for (Object description : mediaDescriptions) {
|
||||||
|
@ -200,7 +228,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
}
|
}
|
||||||
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();
|
|
||||||
logger.info("[上级点播]用户:{}, 地址:{}:{}, ssrc:{}", username, addressStr, port, ssrc);
|
logger.info("[上级点播]用户:{}, 地址:{}:{}, ssrc:{}", username, addressStr, port, ssrc);
|
||||||
Device device = null;
|
Device device = null;
|
||||||
// 通过 channel 和 gbStream 是否为null 值判断来源是直播流合适国标
|
// 通过 channel 和 gbStream 是否为null 值判断来源是直播流合适国标
|
||||||
|
@ -228,23 +255,33 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
responseAck(evt, Response.BUSY_HERE);
|
responseAck(evt, Response.BUSY_HERE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sendRtpItem.setCallId(callIdHeader.getCallId());
|
||||||
|
sendRtpItem.setPlay("Play".equals(sessionName));
|
||||||
// 写入redis, 超时时回复
|
// 写入redis, 超时时回复
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
// 通知下级推流,
|
|
||||||
PlayResult playResult = playService.play(mediaServerItem,device.getDeviceId(), channelId, (mediaServerItemInUSe, responseJSON)->{
|
Device finalDevice = device;
|
||||||
// 收到推流, 回复200OK, 等待ack
|
MediaServerItem finalMediaServerItem = mediaServerItem;
|
||||||
// if (sendRtpItem == null) return;
|
Long finalStartTime = startTime;
|
||||||
|
Long finalStopTime = stopTime;
|
||||||
|
ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON)->{
|
||||||
|
logger.info("[上级点播]下级已经开始推流。 回复200OK(SDP), {}/{}", sendRtpItem.getApp(), sendRtpItem.getStreamId());
|
||||||
|
// * 0 等待设备推流上来
|
||||||
|
// * 1 下级已经推流,等待上级平台回复ack
|
||||||
|
// * 2 推流中
|
||||||
sendRtpItem.setStatus(1);
|
sendRtpItem.setStatus(1);
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
// TODO 添加对tcp的支持
|
|
||||||
|
|
||||||
StringBuffer content = new StringBuffer(200);
|
StringBuffer content = new StringBuffer(200);
|
||||||
content.append("v=0\r\n");
|
content.append("v=0\r\n");
|
||||||
content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItemInUSe.getSdpIp()+"\r\n");
|
content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItemInUSe.getSdpIp()+"\r\n");
|
||||||
content.append("s=Play\r\n");
|
content.append("s=" + sessionName+"\r\n");
|
||||||
content.append("c=IN IP4 "+mediaServerItemInUSe.getSdpIp()+"\r\n");
|
content.append("c=IN IP4 "+mediaServerItemInUSe.getSdpIp()+"\r\n");
|
||||||
|
if ("Playback".equals(sessionName)) {
|
||||||
|
content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n");
|
||||||
|
}else {
|
||||||
content.append("t=0 0\r\n");
|
content.append("t=0 0\r\n");
|
||||||
|
}
|
||||||
content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
|
content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
|
||||||
content.append("a=sendonly\r\n");
|
content.append("a=sendonly\r\n");
|
||||||
content.append("a=rtpmap:96 PS/90000\r\n");
|
content.append("a=rtpmap:96 PS/90000\r\n");
|
||||||
|
@ -260,7 +297,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} ,((event) -> {
|
};
|
||||||
|
SipSubscribe.Event errorEvent = ((event) -> {
|
||||||
// 未知错误。直接转发设备点播的错误
|
// 未知错误。直接转发设备点播的错误
|
||||||
Response response = null;
|
Response response = null;
|
||||||
try {
|
try {
|
||||||
|
@ -271,11 +309,46 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
} catch (ParseException | SipException | InvalidArgumentException e) {
|
} catch (ParseException | SipException | InvalidArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
if (logger.isDebugEnabled()) {
|
if ("Playback".equals(sessionName)) {
|
||||||
logger.debug(playResult.getResult().toString());
|
sendRtpItem.setPlay(false);
|
||||||
|
sendRtpItem.setStreamId(ssrc);
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
playService.playBack(device.getDeviceId(), channelId, format.format(start), format.format(end),result -> {
|
||||||
|
if (result.getCode() != 0){
|
||||||
|
logger.warn("录像回放失败");
|
||||||
|
if (result.getEvent() != null) {
|
||||||
|
errorEvent.response(result.getEvent());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
responseAck(evt, Response.REQUEST_TIMEOUT);
|
||||||
|
} catch (SipException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (result.getMediaServerItem() != null) {
|
||||||
|
hookEvent.response(result.getMediaServerItem(), result.getResponse());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
sendRtpItem.setPlay(true);
|
||||||
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
|
||||||
|
if (streamInfo == null) {
|
||||||
|
if (mediaServerItem.isRtpEnable()) {
|
||||||
|
sendRtpItem.setStreamId(String.format("%s_%s", device.getDeviceId(), channelId));
|
||||||
|
}
|
||||||
|
sendRtpItem.setPlay(false);
|
||||||
|
playService.play(mediaServerItem,device.getDeviceId(), channelId, hookEvent,errorEvent);
|
||||||
|
}else {
|
||||||
|
sendRtpItem.setStreamId(streamInfo.getStream());
|
||||||
|
hookEvent.response(mediaServerItem, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if (gbStream != null) {
|
}else if (gbStream != null) {
|
||||||
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
|
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
|
||||||
gbStream.getApp(), gbStream.getStream(), channelId,
|
gbStream.getApp(), gbStream.getStream(), channelId,
|
||||||
|
@ -291,11 +364,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入redis, 超时时回复
|
// 写入redis, 超时时回复
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
|
||||||
|
|
||||||
sendRtpItem.setStatus(1);
|
sendRtpItem.setStatus(1);
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
// TODO 添加对tcp的支持
|
|
||||||
StringBuffer content = new StringBuffer(200);
|
StringBuffer content = new StringBuffer(200);
|
||||||
content.append("v=0\r\n");
|
content.append("v=0\r\n");
|
||||||
content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
|
content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
|
||||||
|
@ -319,9 +389,24 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.warn("sdp解析错误");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SdpParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SdpException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inviteFromDeviceHandle(RequestEvent evt, String requesterId) throws InvalidArgumentException, ParseException, SipException, SdpException {
|
||||||
|
|
||||||
// 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备)
|
// 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备)
|
||||||
Device device = redisCatchStorage.getDevice(requesterId);
|
Device device = redisCatchStorage.getDevice(requesterId);
|
||||||
|
Request request = evt.getRequest();
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
logger.info("收到设备" + requesterId + "的语音广播Invite请求");
|
logger.info("收到设备" + requesterId + "的语音广播Invite请求");
|
||||||
responseAck(evt, Response.TRYING);
|
responseAck(evt, Response.TRYING);
|
||||||
|
@ -386,15 +471,4 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
responseAck(evt, Response.BAD_REQUEST);
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.warn("sdp解析错误");
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SdpParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SdpException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.utils.DateUtil;
|
||||||
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.sip.InvalidArgumentException;
|
||||||
|
import javax.sip.RequestEvent;
|
||||||
|
import javax.sip.SipException;
|
||||||
|
import javax.sip.header.FromHeader;
|
||||||
|
import javax.sip.message.Response;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
|
||||||
|
|
||||||
|
private Logger logger = LoggerFactory.getLogger(RecordInfoQueryMessageHandler.class);
|
||||||
|
private final String cmdType = "RecordInfo";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private QueryMessageHandler queryMessageHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IVideoManagerStorager storager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SIPCommanderFroPlatform cmderFroPlatform;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SIPCommander commander;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RecordEndEventListener recordEndEventListener;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SipConfig config;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventPublisher publisher;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
queryMessageHandler.addHandler(cmdType, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handForDevice(RequestEvent evt, Device device, Element element) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) {
|
||||||
|
|
||||||
|
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
|
||||||
|
|
||||||
|
Element snElement = rootElement.element("SN");
|
||||||
|
int sn = Integer.parseInt(snElement.getText());
|
||||||
|
Element deviceIDElement = rootElement.element("DeviceID");
|
||||||
|
String channelId = deviceIDElement.getText();
|
||||||
|
Element startTimeElement = rootElement.element("StartTime");
|
||||||
|
String startTime = null;
|
||||||
|
if (startTimeElement != null) {
|
||||||
|
startTime = startTimeElement.getText();
|
||||||
|
}
|
||||||
|
Element endTimeElement = rootElement.element("EndTime");
|
||||||
|
String endTime = null;
|
||||||
|
if (endTimeElement != null) {
|
||||||
|
endTime = endTimeElement.getText();
|
||||||
|
}
|
||||||
|
Element secrecyElement = rootElement.element("Secrecy");
|
||||||
|
int secrecy = 0;
|
||||||
|
if (secrecyElement != null) {
|
||||||
|
secrecy = Integer.parseInt(secrecyElement.getText());
|
||||||
|
}
|
||||||
|
String type = "all";
|
||||||
|
Element typeElement = rootElement.element("Type");
|
||||||
|
if (typeElement != null) {
|
||||||
|
type = typeElement.getText();
|
||||||
|
}
|
||||||
|
// 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务
|
||||||
|
List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId);
|
||||||
|
|
||||||
|
if (channelSources.get(0).getCount() > 0) { // 国标
|
||||||
|
// 向国标设备请求录像数据
|
||||||
|
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
|
||||||
|
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId);
|
||||||
|
// 接收录像数据
|
||||||
|
recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{
|
||||||
|
cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, fromHeader.getTag(), recordInfo);
|
||||||
|
});
|
||||||
|
commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime),
|
||||||
|
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> {
|
||||||
|
// 回复200 OK
|
||||||
|
try {
|
||||||
|
responseAck(evt, Response.OK);
|
||||||
|
} catch (SipException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}),(eventResult -> {
|
||||||
|
// 查询失败
|
||||||
|
try {
|
||||||
|
responseAck(evt, eventResult.statusCode, eventResult.msg);
|
||||||
|
} catch (SipException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
}else if (channelSources.get(1).getCount() > 0) { // 直播流
|
||||||
|
// TODO
|
||||||
|
try {
|
||||||
|
responseAck(evt, Response.NOT_IMPLEMENTED); // 回复未实现
|
||||||
|
} catch (SipException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}else { // 错误的请求
|
||||||
|
try {
|
||||||
|
responseAck(evt, Response.BAD_REQUEST);
|
||||||
|
} catch (SipException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
|
import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||||
|
@ -49,6 +50,9 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeferredResultHolder deferredResultHolder;
|
private DeferredResultHolder deferredResultHolder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventPublisher eventPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
responseMessageHandler.addHandler(cmdType, this);
|
responseMessageHandler.addHandler(cmdType, this);
|
||||||
|
@ -77,6 +81,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||||
Element recordListElement = rootElement.element("RecordList");
|
Element recordListElement = rootElement.element("RecordList");
|
||||||
if (recordListElement == null || recordInfo.getSumNum() == 0) {
|
if (recordListElement == null || recordInfo.getSumNum() == 0) {
|
||||||
logger.info("无录像数据");
|
logger.info("无录像数据");
|
||||||
|
eventPublisher.recordEndEventPush(recordInfo);
|
||||||
RequestMessage msg = new RequestMessage();
|
RequestMessage msg = new RequestMessage();
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
msg.setData(recordInfo);
|
msg.setData(recordInfo);
|
||||||
|
@ -99,6 +104,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||||
record.setDeviceId(getText(itemRecord, "DeviceID"));
|
record.setDeviceId(getText(itemRecord, "DeviceID"));
|
||||||
record.setName(getText(itemRecord, "Name"));
|
record.setName(getText(itemRecord, "Name"));
|
||||||
record.setFilePath(getText(itemRecord, "FilePath"));
|
record.setFilePath(getText(itemRecord, "FilePath"));
|
||||||
|
record.setFileSize(getText(itemRecord, "FileSize"));
|
||||||
record.setAddress(getText(itemRecord, "Address"));
|
record.setAddress(getText(itemRecord, "Address"));
|
||||||
record.setStartTime(
|
record.setStartTime(
|
||||||
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(getText(itemRecord, "StartTime")));
|
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(getText(itemRecord, "StartTime")));
|
||||||
|
@ -112,7 +118,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
recordInfo.setRecordList(recordList);
|
recordInfo.setRecordList(recordList);
|
||||||
}
|
}
|
||||||
|
eventPublisher.recordEndEventPush(recordInfo);
|
||||||
// 改用单独线程统计已获取录像文件数量,避免多包并行分别统计不完整的问题
|
// 改用单独线程统计已获取录像文件数量,避免多包并行分别统计不完整的问题
|
||||||
String cacheKey = CACHE_RECORDINFO_KEY + device.getDeviceId() + sn;
|
String cacheKey = CACHE_RECORDINFO_KEY + device.getDeviceId() + sn;
|
||||||
redis.set(cacheKey + "_" + uuid, recordList, 90);
|
redis.set(cacheKey + "_" + uuid, recordList, 90);
|
||||||
|
|
|
@ -82,9 +82,6 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract {
|
||||||
requestURI.setPort(event.getRemotePort());
|
requestURI.setPort(event.getRemotePort());
|
||||||
reqAck.setRequestURI(requestURI);
|
reqAck.setRequestURI(requestURI);
|
||||||
logger.info("向 " + event.getRemoteIpAddress() + ":" + event.getRemotePort() + "回复ack");
|
logger.info("向 " + event.getRemoteIpAddress() + ":" + event.getRemotePort() + "回复ack");
|
||||||
SipURI sipURI = (SipURI)dialog.getRemoteParty().getURI();
|
|
||||||
String deviceId = requestURI.getUser();
|
|
||||||
String channelId = sipURI.getUser();
|
|
||||||
|
|
||||||
dialog.sendAck(reqAck);
|
dialog.sendAck(reqAck);
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class ZLMHttpHookListener {
|
||||||
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
|
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
|
||||||
public ResponseEntity<String> onPublish(@RequestBody JSONObject json) {
|
public ResponseEntity<String> onPublish(@RequestBody JSONObject json) {
|
||||||
|
|
||||||
logger.debug("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString());
|
logger.info("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString());
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
ret.put("code", 0);
|
ret.put("code", 0);
|
||||||
ret.put("msg", "success");
|
ret.put("msg", "success");
|
||||||
|
|
|
@ -77,10 +77,11 @@ public class ZLMHttpHookSubscribe {
|
||||||
if (eventMap == null) {
|
if (eventMap == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<Map.Entry<JSONObject, Event>> iterator = eventMap.entrySet().iterator();
|
|
||||||
while (iterator.hasNext()){
|
Set<Map.Entry<JSONObject, Event>> entries = eventMap.entrySet();
|
||||||
Map.Entry<JSONObject, Event> next = iterator.next();
|
if (entries.size() > 0) {
|
||||||
JSONObject key = next.getKey();
|
for (Map.Entry<JSONObject, Event> entry : entries) {
|
||||||
|
JSONObject key = entry.getKey();
|
||||||
Boolean result = null;
|
Boolean result = null;
|
||||||
for (String s : key.keySet()) {
|
for (String s : key.keySet()) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
@ -91,8 +92,8 @@ public class ZLMHttpHookSubscribe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != result && result){
|
if (null != result && result){
|
||||||
// TODO 报错未处理
|
entries.remove(entry);
|
||||||
iterator.remove();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,9 +242,18 @@ public class ZLMRTPServerFactory {
|
||||||
*/
|
*/
|
||||||
public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) {
|
public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) {
|
||||||
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId);
|
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId);
|
||||||
|
Integer code = mediaInfo.getInteger("code");
|
||||||
if (mediaInfo == null) {
|
if (mediaInfo == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ( code < 0) {
|
||||||
|
logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( code == 0 && ! mediaInfo.getBoolean("online")) {
|
||||||
|
logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return mediaInfo.getInteger("totalReaderCount");
|
return mediaInfo.getInteger("totalReaderCount");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface IMediaServerService {
|
||||||
|
|
||||||
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback);
|
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback);
|
||||||
|
|
||||||
void closeRTPServer(Device device, String channelId, String ssrc);
|
void closeRTPServer(String deviceId, String channelId, String ssrc);
|
||||||
|
|
||||||
void clearRTPServer(MediaServerItem mediaServerItem);
|
void clearRTPServer(MediaServerItem mediaServerItem);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package com.genersoft.iot.vmp.service.bean;
|
package com.genersoft.iot.vmp.service.bean;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
|
|
||||||
public interface PlayBackCallback {
|
public interface PlayBackCallback {
|
||||||
|
|
||||||
void call(RequestMessage msg);
|
void call(PlayBackResult<RequestMessage> msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.genersoft.iot.vmp.service.bean;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
|
|
||||||
|
import javax.sip.RequestEvent;
|
||||||
|
|
||||||
|
public class PlayBackResult<T> {
|
||||||
|
private int code;
|
||||||
|
private T data;
|
||||||
|
private MediaServerItem mediaServerItem;
|
||||||
|
private JSONObject response;
|
||||||
|
private SipSubscribe.EventResult event;
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MediaServerItem getMediaServerItem() {
|
||||||
|
return mediaServerItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMediaServerItem(MediaServerItem mediaServerItem) {
|
||||||
|
this.mediaServerItem = mediaServerItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(JSONObject response) {
|
||||||
|
this.response = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SipSubscribe.EventResult getEvent() {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEvent(SipSubscribe.EventResult event) {
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
}
|
|
@ -160,16 +160,16 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeRTPServer(Device device, String channelId, String stream) {
|
public void closeRTPServer(String deviceId, String channelId, String stream) {
|
||||||
String mediaServerId = streamSession.getMediaServerId(device.getDeviceId(), channelId, stream);
|
String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream);
|
||||||
String ssrc = streamSession.getSSRC(device.getDeviceId(), channelId, stream);
|
String ssrc = streamSession.getSSRC(deviceId, channelId, stream);
|
||||||
MediaServerItem mediaServerItem = this.getOne(mediaServerId);
|
MediaServerItem mediaServerItem = this.getOne(mediaServerId);
|
||||||
if (mediaServerItem != null) {
|
if (mediaServerItem != null) {
|
||||||
String streamId = String.format("%s_%s", device.getDeviceId(), channelId);
|
String streamId = String.format("%s_%s", deviceId, channelId);
|
||||||
zlmrtpServerFactory.closeRTPServer(mediaServerItem, streamId);
|
zlmrtpServerFactory.closeRTPServer(mediaServerItem, streamId);
|
||||||
releaseSsrc(mediaServerItem, ssrc);
|
releaseSsrc(mediaServerItem, ssrc);
|
||||||
}
|
}
|
||||||
streamSession.remove(device.getDeviceId(), channelId, stream);
|
streamSession.remove(deviceId, channelId, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,9 +17,11 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
|
import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
|
||||||
|
import com.genersoft.iot.vmp.service.bean.PlayBackResult;
|
||||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||||
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.redis.RedisUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
||||||
import com.genersoft.iot.vmp.service.IMediaService;
|
import com.genersoft.iot.vmp.service.IMediaService;
|
||||||
|
@ -53,6 +55,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redis;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeferredResultHolder resultHolder;
|
private DeferredResultHolder resultHolder;
|
||||||
|
|
||||||
|
@ -112,7 +117,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// 点播超时回复BYE
|
// 点播超时回复BYE
|
||||||
cmder.streamByeCmd(device.getDeviceId(), channelId, streamInfo.getStream());
|
cmder.streamByeCmd(device.getDeviceId(), channelId, streamInfo.getStream());
|
||||||
// 释放rtpserver
|
// 释放rtpserver
|
||||||
mediaServerService.closeRTPServer(playResult.getDevice(), channelId, streamInfo.getStream());
|
mediaServerService.closeRTPServer(playResult.getDevice().getDeviceId(), channelId, streamInfo.getStream());
|
||||||
// 回复之前所有的点播请求
|
// 回复之前所有的点播请求
|
||||||
resultHolder.invokeAllResult(msg);
|
resultHolder.invokeAllResult(msg);
|
||||||
// TODO 释放ssrc
|
// TODO 释放ssrc
|
||||||
|
@ -121,7 +126,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// 点播结束时调用截图接口
|
// 点播结束时调用截图接口
|
||||||
try {
|
try {
|
||||||
String classPath = ResourceUtils.getURL("classpath:").getPath();
|
String classPath = ResourceUtils.getURL("classpath:").getPath();
|
||||||
// System.out.println(classPath);
|
|
||||||
// 兼容打包为jar的class路径
|
// 兼容打包为jar的class路径
|
||||||
if(classPath.contains("jar")) {
|
if(classPath.contains("jar")) {
|
||||||
classPath = classPath.substring(0, classPath.lastIndexOf("."));
|
classPath = classPath.substring(0, classPath.lastIndexOf("."));
|
||||||
|
@ -170,7 +174,10 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
WVPResult wvpResult = new WVPResult();
|
WVPResult wvpResult = new WVPResult();
|
||||||
wvpResult.setCode(-1);
|
wvpResult.setCode(-1);
|
||||||
// 点播返回sip错误
|
// 点播返回sip错误
|
||||||
mediaServerService.closeRTPServer(playResult.getDevice(), channelId, ssrcInfo.getStream());
|
mediaServerService.closeRTPServer(playResult.getDevice().getDeviceId(), channelId, ssrcInfo.getStream());
|
||||||
|
// 释放ssrc
|
||||||
|
mediaServerService.releaseSsrc(mediaServerItem, ssrcInfo.getSsrc());
|
||||||
|
streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
|
||||||
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
|
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
|
||||||
msg.setData(wvpResult);
|
msg.setData(wvpResult);
|
||||||
resultHolder.invokeAllResult(msg);
|
resultHolder.invokeAllResult(msg);
|
||||||
|
@ -219,7 +226,10 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
logger.info("收到订阅消息: " + response.toJSONString());
|
logger.info("收到订阅消息: " + response.toJSONString());
|
||||||
onPublishHandlerForPlay(mediaServerItemInuse, response, deviceId, channelId, uuid);
|
onPublishHandlerForPlay(mediaServerItemInuse, response, deviceId, channelId, uuid);
|
||||||
}, (event) -> {
|
}, (event) -> {
|
||||||
mediaServerService.closeRTPServer(playResult.getDevice(), channelId, ssrcInfo.getStream());
|
mediaServerService.closeRTPServer(playResult.getDevice().getDeviceId(), channelId, ssrcInfo.getStream());
|
||||||
|
// 释放ssrc
|
||||||
|
mediaServerService.releaseSsrc(mediaServerItem, ssrcInfo.getSsrc());
|
||||||
|
streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
|
||||||
WVPResult wvpResult = new WVPResult();
|
WVPResult wvpResult = new WVPResult();
|
||||||
wvpResult.setCode(-1);
|
wvpResult.setCode(-1);
|
||||||
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
|
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
|
||||||
|
@ -233,11 +243,11 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid) {
|
public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) {
|
||||||
RequestMessage msg = new RequestMessage();
|
RequestMessage msg = new RequestMessage();
|
||||||
msg.setId(uuid);
|
msg.setId(uuid);
|
||||||
msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId);
|
msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId);
|
||||||
StreamInfo streamInfo = onPublishHandler(mediaServerItem, resonse, deviceId, channelId);
|
StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId);
|
||||||
if (streamInfo != null) {
|
if (streamInfo != null) {
|
||||||
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
||||||
if (deviceChannel != null) {
|
if (deviceChannel != null) {
|
||||||
|
@ -295,9 +305,12 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
RequestMessage msg = new RequestMessage();
|
RequestMessage msg = new RequestMessage();
|
||||||
msg.setId(uuid);
|
msg.setId(uuid);
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
|
PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>();
|
||||||
result.onTimeout(()->{
|
result.onTimeout(()->{
|
||||||
msg.setData("回放超时");
|
msg.setData("回放超时");
|
||||||
callback.call(msg);
|
playBackResult.setCode(-1);
|
||||||
|
playBackResult.setData(msg);
|
||||||
|
callback.call(playBackResult);
|
||||||
});
|
});
|
||||||
cmder.playbackStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, (MediaServerItem mediaServerItem, JSONObject response) -> {
|
cmder.playbackStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, (MediaServerItem mediaServerItem, JSONObject response) -> {
|
||||||
logger.info("收到订阅消息: " + response.toJSONString());
|
logger.info("收到订阅消息: " + response.toJSONString());
|
||||||
|
@ -305,15 +318,25 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
if (streamInfo == null) {
|
if (streamInfo == null) {
|
||||||
logger.warn("设备回放API调用失败!");
|
logger.warn("设备回放API调用失败!");
|
||||||
msg.setData("设备回放API调用失败!");
|
msg.setData("设备回放API调用失败!");
|
||||||
callback.call(msg);
|
playBackResult.setCode(-1);
|
||||||
|
playBackResult.setData(msg);
|
||||||
|
callback.call(playBackResult);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
redisCatchStorage.startPlayback(streamInfo);
|
redisCatchStorage.startPlayback(streamInfo);
|
||||||
msg.setData(JSON.toJSONString(streamInfo));
|
msg.setData(JSON.toJSONString(streamInfo));
|
||||||
callback.call(msg);
|
playBackResult.setCode(0);
|
||||||
|
playBackResult.setData(msg);
|
||||||
|
playBackResult.setMediaServerItem(mediaServerItem);
|
||||||
|
playBackResult.setResponse(response);
|
||||||
|
callback.call(playBackResult);
|
||||||
}, event -> {
|
}, event -> {
|
||||||
msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg));
|
msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg));
|
||||||
callback.call(msg);
|
playBackResult.setCode(-1);
|
||||||
|
playBackResult.setData(msg);
|
||||||
|
playBackResult.setEvent(event);
|
||||||
|
callback.call(playBackResult);
|
||||||
|
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
||||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
|
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
|
||||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
@ -475,4 +476,6 @@ public interface IVideoManagerStorager {
|
||||||
void delRelationByPlatformId(String serverGBId);
|
void delRelationByPlatformId(String serverGBId);
|
||||||
|
|
||||||
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
|
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
|
||||||
|
|
||||||
|
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.storager.dao;
|
package com.genersoft.iot.vmp.storager.dao;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -86,4 +87,9 @@ public interface ParentPlatformMapper {
|
||||||
"WHERE serverGBId=#{platformId}"+
|
"WHERE serverGBId=#{platformId}"+
|
||||||
"</script>"})
|
"</script>"})
|
||||||
int setDefaultCatalog(String platformId, String catalogId);
|
int setDefaultCatalog(String platformId, String catalogId);
|
||||||
|
|
||||||
|
@Select("select 'channel' as name, count(pgc.platformId) count from platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId where pgc.platformId=#{platformId} and dc.channelId =#{gbId} " +
|
||||||
|
"union " +
|
||||||
|
"select 'stream' as name, count(pgs.platformId) count from platform_gb_stream pgs left join gb_stream gs on pgs.gbStreamId = gs.gbStreamId where pgs.platformId=#{platformId} and gs.gbId = #{gbId}")
|
||||||
|
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.genersoft.iot.vmp.storager.dao.dto;
|
||||||
|
|
||||||
|
public class ChannelSourceInfo {
|
||||||
|
private String name;
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,7 +141,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo queryPlayByDevice(String deviceId, String channelId) {
|
public StreamInfo queryPlayByDevice(String deviceId, String channelId) {
|
||||||
// List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
|
||||||
List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
||||||
userSetup.getServerId(),
|
userSetup.getServerId(),
|
||||||
deviceId,
|
deviceId,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
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.storager.dao.*;
|
import com.genersoft.iot.vmp.storager.dao.*;
|
||||||
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
||||||
import com.genersoft.iot.vmp.utils.node.ForestNodeMerger;
|
import com.genersoft.iot.vmp.utils.node.ForestNodeMerger;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
|
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
|
||||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||||
|
@ -1104,4 +1105,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||||
public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
|
public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
|
||||||
return catalogMapper.selectDefaultByPlatFormId(platformId);
|
return catalogMapper.selectDefaultByPlatFormId(platformId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) {
|
||||||
|
return platformMapper.getChannelSource(platformId, gbId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.utils.node;
|
package com.genersoft.iot.vmp.utils.node;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,7 +9,6 @@ import java.util.List;
|
||||||
* 节点基类
|
* 节点基类
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
public class BaseNode<T> implements INode<T> {
|
public class BaseNode<T> implements INode<T> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -51,4 +49,34 @@ public class BaseNode<T> implements INode<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentId(String parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<T> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasChildren(Boolean hasChildren) {
|
||||||
|
this.hasChildren = hasChildren;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package com.genersoft.iot.vmp.utils.node;
|
package com.genersoft.iot.vmp.utils.node;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 森林节点类
|
* 森林节点类
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ForestNode extends BaseNode<ForestNode> {
|
public class ForestNode extends BaseNode<ForestNode> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -25,4 +21,11 @@ public class ForestNode extends BaseNode<ForestNode> {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(Object content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
package com.genersoft.iot.vmp.utils.node;
|
package com.genersoft.iot.vmp.utils.node;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 树型节点类
|
* 树型节点类
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class TreeNode extends BaseNode<TreeNode> {
|
public class TreeNode extends BaseNode<TreeNode> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -18,4 +15,28 @@ public class TreeNode extends BaseNode<TreeNode> {
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.utils.node.INode;
|
import com.genersoft.iot.vmp.utils.node.INode;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ApiModel(value = "DeviceChannelTree对象", description = "DeviceChannelTree对象")
|
@ApiModel(value = "DeviceChannelTree对象", description = "DeviceChannelTree对象")
|
||||||
public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChannelTree> {
|
public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChannelTree> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -62,4 +58,64 @@ public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChan
|
||||||
return this.hasChildren;
|
return this.hasChildren;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParentId(String parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentName() {
|
||||||
|
return parentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentName(String parentName) {
|
||||||
|
this.parentName = parentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<DeviceChannelTree> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasChildren(Boolean hasChildren) {
|
||||||
|
this.hasChildren = hasChildren;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.vmanager.bean;
|
package com.genersoft.iot.vmp.vmanager.bean;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.utils.node.TreeNode;
|
import com.genersoft.iot.vmp.utils.node.TreeNode;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class DeviceChannelTreeNode extends TreeNode {
|
public class DeviceChannelTreeNode extends TreeNode {
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
@ -17,4 +13,44 @@ public class DeviceChannelTreeNode extends TreeNode {
|
||||||
private Double lng;
|
private Double lng;
|
||||||
|
|
||||||
private Double lat;
|
private Double lat;
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChannelId() {
|
||||||
|
return channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelId(String channelId) {
|
||||||
|
this.channelId = channelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLng() {
|
||||||
|
return lng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLng(Double lng) {
|
||||||
|
this.lng = lng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLat() {
|
||||||
|
return lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLat(Double lat) {
|
||||||
|
this.lat = lat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package com.genersoft.iot.vmp.vmanager.bean;
|
package com.genersoft.iot.vmp.vmanager.bean;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class WVPResult<T> {
|
public class WVPResult<T> {
|
||||||
|
|
||||||
|
public WVPResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WVPResult(int code, String msg, T data) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
private String msg;
|
private String msg;
|
||||||
private T data;
|
private T data;
|
||||||
|
@ -32,4 +35,27 @@ public class WVPResult<T> {
|
||||||
return fail(FAILED, msg);
|
return fail(FAILED, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,11 @@ public class PlatformController {
|
||||||
wvpResult.setMsg("missing parameters");
|
wvpResult.setMsg("missing parameters");
|
||||||
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
if (parentPlatform.getServerPort()< 0 || parentPlatform.getServerPort() > 65535){
|
||||||
|
wvpResult.setCode(-1);
|
||||||
|
wvpResult.setMsg("error severPort");
|
||||||
|
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
|
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
|
||||||
if (parentPlatformOld != null) {
|
if (parentPlatformOld != null) {
|
||||||
|
|
|
@ -129,7 +129,6 @@ public class PlayController {
|
||||||
//Response response = event.getResponse();
|
//Response response = event.getResponse();
|
||||||
msg.setData(String.format("success"));
|
msg.setData(String.format("success"));
|
||||||
resultHolder.invokeAllResult(msg);
|
resultHolder.invokeAllResult(msg);
|
||||||
mediaServerService.closeRTPServer(device, channelId, streamInfo.getStream());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deviceId != null || channelId != null) {
|
if (deviceId != null || channelId != null) {
|
||||||
|
|
|
@ -77,8 +77,8 @@ public class PlaybackController {
|
||||||
logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId));
|
logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<ResponseEntity<String>> result = playService.playBack(deviceId, channelId, startTime, endTime, msg->{
|
DeferredResult<ResponseEntity<String>> result = playService.playBack(deviceId, channelId, startTime, endTime, wvpResult->{
|
||||||
resultHolder.invokeResult(msg);
|
resultHolder.invokeResult(wvpResult.getData());
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class GBRecordController {
|
||||||
RequestMessage msg = new RequestMessage();
|
RequestMessage msg = new RequestMessage();
|
||||||
msg.setId(uuid);
|
msg.setId(uuid);
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, (eventResult -> {
|
cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, null, null, null, (eventResult -> {
|
||||||
msg.setData("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg );
|
msg.setData("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg );
|
||||||
resultHolder.invokeResult(msg);
|
resultHolder.invokeResult(msg);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 此配置文件只是用作展示所有配置项, 不可不直接使用
|
# 此配置文件只是用作展示所有配置项, 不可直接使用
|
||||||
|
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -50,14 +50,7 @@ class DeviceAlarmServiceImplTest {
|
||||||
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, "1", null,
|
// System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, "1", null,
|
||||||
// null, null).getSize());
|
// null, null).getSize());
|
||||||
|
|
||||||
System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, null, null,
|
|
||||||
"2021-01-01 00:00:00", null).getSize());
|
|
||||||
|
|
||||||
System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, null, null,
|
|
||||||
null, "2021-04-01 09:00:00").getSize());
|
|
||||||
|
|
||||||
System.out.println(deviceAlarmService.getAllAlarm(0, 10000, "11111111111111111111", null, null, null,
|
|
||||||
"2021-02-01 01:00:00", "2021-04-01 04:00:00").getSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,19 @@
|
||||||
</el-popover>
|
</el-popover>
|
||||||
<el-popover placement="bottom" width="900" height="300" trigger="click">
|
<el-popover placement="bottom" width="900" height="300" trigger="click">
|
||||||
<div style="height: 600px;overflow:auto; padding: 20px">
|
<div style="height: 600px;overflow:auto; padding: 20px">
|
||||||
|
<el-descriptions title="国标配置" border column="1">
|
||||||
|
<template slot="extra">
|
||||||
|
<el-button style="float: right;" type="primary" size="mini" icon="el-icon-document-copy" title="点击拷贝" v-clipboard="JSON.stringify(wvpServerConfig.sip)" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
|
||||||
|
</template>
|
||||||
|
<el-descriptions-item v-for="(value, key, index) in wvpServerConfig.sip">
|
||||||
|
<template slot="label">
|
||||||
|
{{ getNameFromKey(key) }}
|
||||||
|
</template>
|
||||||
|
{{ value }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<div style="margin-top: 1rem">
|
||||||
<el-descriptions title="基础配置" border column="1">
|
<el-descriptions title="基础配置" border column="1">
|
||||||
<template slot="extra">
|
<template slot="extra">
|
||||||
<el-button style="float: right;" type="primary" size="mini" icon="el-icon-document-copy" title="点击拷贝" v-clipboard="JSON.stringify(wvpServerConfig.base)" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
|
<el-button style="float: right;" type="primary" size="mini" icon="el-icon-document-copy" title="点击拷贝" v-clipboard="JSON.stringify(wvpServerConfig.base)" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
|
||||||
|
@ -70,18 +82,6 @@
|
||||||
|
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<div style="margin-top: 1rem">
|
|
||||||
<el-descriptions title="国标配置" border column="1">
|
|
||||||
<template slot="extra">
|
|
||||||
<el-button style="float: right;" type="primary" size="mini" icon="el-icon-document-copy" title="点击拷贝" v-clipboard="JSON.stringify(wvpServerConfig.sip)" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
|
|
||||||
</template>
|
|
||||||
<el-descriptions-item v-for="(value, key, index) in wvpServerConfig.sip" :key="key">
|
|
||||||
<template slot="label">
|
|
||||||
{{ getNameFromKey(key) }}
|
|
||||||
</template>
|
|
||||||
{{ value }}
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 1rem">
|
<div style="margin-top: 1rem">
|
||||||
<el-descriptions title="版本信息" border column="1">
|
<el-descriptions title="版本信息" border column="1">
|
||||||
|
|
Loading…
Reference in New Issue