Merge branch 'main' into main2

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
#	src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
#	src/main/resources/all-application.yml
#	web_src/src/components/dialog/devicePlayer.vue
This commit is contained in:
648540858
2023-02-10 15:54:42 +08:00
85 changed files with 2638 additions and 1856 deletions

View File

@@ -71,6 +71,8 @@ public class VideoManagerConstants {
public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
public static final String BROADCAST_WAITE_INVITE = "task_broadcast_waite_invite_";
public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";

View File

@@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.*;
@@ -51,6 +52,9 @@ public class ApiAccessFilter extends OncePerRequestFilter {
LogDto logDto = new LogDto();
logDto.setName(uriName);
if (ObjectUtils.isEmpty(username)) {
username = "";
}
logDto.setUsername(username);
logDto.setAddress(servletRequest.getRemoteAddr());
logDto.setResult(HttpStatus.valueOf(servletResponse.getStatus()).toString());

View File

@@ -35,6 +35,8 @@ public class UserSetting {
private Boolean useSourceIpAsStreamIp = Boolean.FALSE;
private Boolean sipUseSourceIpAsRemoteAddress = Boolean.FALSE;
private Boolean streamOnDemand = Boolean.TRUE;
private Boolean pushAuthority = Boolean.TRUE;
@@ -45,6 +47,8 @@ public class UserSetting {
private Boolean pushStreamAfterAck = Boolean.FALSE;
private Boolean sipLog = Boolean.FALSE;
private String serverId = "000000";
private String thirdPartyGBIdReg = "[\\s\\S]*";
@@ -216,4 +220,20 @@ public class UserSetting {
public void setPushStreamAfterAck(Boolean pushStreamAfterAck) {
this.pushStreamAfterAck = pushStreamAfterAck;
}
public Boolean getSipUseSourceIpAsRemoteAddress() {
return sipUseSourceIpAsRemoteAddress;
}
public void setSipUseSourceIpAsRemoteAddress(Boolean sipUseSourceIpAsRemoteAddress) {
this.sipUseSourceIpAsRemoteAddress = sipUseSourceIpAsRemoteAddress;
}
public Boolean getSipLog() {
return sipLog;
}
public void setSipLog(Boolean sipLog) {
this.sipLog = sipLog;
}
}

View File

@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;
import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;
import gov.nist.javax.sip.SipProviderImpl;
@@ -29,6 +30,9 @@ public class SipLayer implements CommandLineRunner {
@Autowired
private ISIPProcessorObserver sipProcessorObserver;
@Autowired
private UserSetting userSetting;
private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
@@ -61,7 +65,7 @@ public class SipLayer implements CommandLineRunner {
private void addListeningPoint(String monitorIp, int port){
SipStackImpl sipStack;
try {
sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false));
sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false, userSetting.getSipLog()));
} catch (PeerUnavailableException e) {
logger.error("[Sip Server] SIP服务启动失败 监听地址{}失败,请检查ip是否正确", monitorIp);
return;

View File

@@ -94,6 +94,13 @@ public class Device {
@Schema(description = "心跳时间")
private String keepaliveTime;
/**
* 心跳间隔
*/
@Schema(description = "心跳间隔")
private int keepaliveIntervalTime;
/**
* 通道个数
*/
@@ -414,4 +421,12 @@ public class Device {
public void setLocalIp(String localIp) {
this.localIp = localIp;
}
public int getKeepaliveIntervalTime() {
return keepaliveIntervalTime;
}
public void setKeepaliveIntervalTime(int keepaliveIntervalTime) {
this.keepaliveIntervalTime = keepaliveIntervalTime;
}
}

View File

@@ -0,0 +1,27 @@
package com.genersoft.iot.vmp.gb28181.bean;
public class RemoteAddressInfo {
private String ip;
private int port;
public RemoteAddressInfo(String ip, int port) {
this.ip = ip;
this.port = port;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}

View File

@@ -9,14 +9,15 @@ public class SipTransactionInfo {
private String toTag;
private String viaBranch;
private boolean fromServer;
// 自己是否媒体流发送者
private boolean asSender;
public SipTransactionInfo(SIPResponse response, boolean fromServer) {
public SipTransactionInfo(SIPResponse response, boolean asSender) {
this.callId = response.getCallIdHeader().getCallId();
this.fromTag = response.getFromTag();
this.toTag = response.getToTag();
this.viaBranch = response.getTopmostViaHeader().getBranch();
this.fromServer = fromServer;
this.asSender = asSender;
}
public SipTransactionInfo(SIPResponse response) {
@@ -24,7 +25,7 @@ public class SipTransactionInfo {
this.fromTag = response.getFromTag();
this.toTag = response.getToTag();
this.viaBranch = response.getTopmostViaHeader().getBranch();
this.fromServer = true;
this.asSender = false;
}
public SipTransactionInfo() {
@@ -62,11 +63,11 @@ public class SipTransactionInfo {
this.viaBranch = viaBranch;
}
public boolean isFromServer() {
return fromServer;
public boolean isAsSender() {
return asSender;
}
public void setFromServer(boolean fromServer) {
this.fromServer = fromServer;
public void setAsSender(boolean asSender) {
this.asSender = asSender;
}
}

View File

@@ -1,5 +1,9 @@
package com.genersoft.iot.vmp.gb28181.conf;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd.AlarmNotifyMessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties;
/**
@@ -8,10 +12,11 @@ import java.util.Properties;
*/
public class DefaultProperties {
public static Properties getProperties(String ip, boolean isDebug) {
public static Properties getProperties(String ip, boolean isDebug, boolean sipLog) {
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP");
properties.setProperty("javax.sip.IP_ADDRESS", ip);
// 关闭自动会话
properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
/**
* 完整配置参考 gov.nist.javax.sip.SipStackImpl需要下载源码
@@ -26,7 +31,7 @@ public class DefaultProperties {
// 接收所有notify请求即使没有订阅
properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true");
properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false");
properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "false");
properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "true");
// 为_NULL _对话框传递_终止的_事件
properties.setProperty("gov.nist.javax.sip.DELIVER_TERMINATED_EVENT_FOR_NULL_DIALOG", "true");
// 会话清理策略
@@ -35,11 +40,38 @@ public class DefaultProperties {
properties.setProperty("gov.nist.javax.sip.RELIABLE_CONNECTION_KEEP_ALIVE_TIMEOUT", "60");
// 获取实际内容长度不使用header中的长度信息
properties.setProperty("gov.nist.javax.sip.COMPUTE_CONTENT_LENGTH_FROM_MESSAGE_BODY", "true");
// 线程可重入
properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "true");
// 定义应用程序打算多久审计一次 SIP 堆栈,了解其内部线程的健康状况(该属性指定连续审计之间的时间(以毫秒为单位))
properties.setProperty("gov.nist.javax.sip.THREAD_AUDIT_INTERVAL_IN_MILLISECS", "30000");
/**
* sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE
*/
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR");
Logger logger = LoggerFactory.getLogger(AlarmNotifyMessageHandler.class);
if (sipLog) {
if (logger.isDebugEnabled()) {
System.out.println("DEBUG");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG");
}else if (logger.isInfoEnabled()) {
System.out.println("INFO1");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "INFO");
}else if (logger.isWarnEnabled()) {
System.out.println("WARNING");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "WARNING");
}else if (logger.isErrorEnabled()) {
System.out.println("ERROR");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR");
}else {
System.out.println("INFO2");
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "INFO");
}
logger.info("[SIP日志]级别为: {}", properties.getProperty("gov.nist.javax.sip.TRACE_LEVEL"));
}else {
logger.info("[SIP日志]已关闭");
}
return properties;
}

View File

@@ -1,107 +0,0 @@
package com.genersoft.iot.vmp.gb28181.conf;
import gov.nist.core.StackLogger;
import java.util.Properties;
/**
* sip日志格式化
* 暂不使用
*/
public class SipLoggerPass implements StackLogger {
@Override
public void logStackTrace() {
}
@Override
public void logStackTrace(int traceLevel) {
}
@Override
public int getLineCount() {
return 0;
}
@Override
public void logException(Throwable ex) {
}
@Override
public void logDebug(String message) {
}
@Override
public void logDebug(String message, Exception ex) {
}
@Override
public void logTrace(String message) {
}
@Override
public void logFatalError(String message) {
}
@Override
public void logError(String message) {
}
@Override
public boolean isLoggingEnabled() {
return false;
}
@Override
public boolean isLoggingEnabled(int logLevel) {
return false;
}
@Override
public void logError(String message, Exception ex) {
}
@Override
public void logWarning(String string) {
}
@Override
public void logInfo(String string) {
}
@Override
public void disableLogging() {
}
@Override
public void enableLogging() {
}
@Override
public void setBuildTimeStamp(String buildTimeStamp) {
}
@Override
public void setStackProperties(Properties stackProperties) {
}
@Override
public String getLoggerName() {
return null;
}
}

View File

@@ -13,7 +13,7 @@ import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
/**
/**
* @description:视频流session管理器管理视频预览、预览回放的通信句柄
* @author: swwheihei
* @date: 2020年5月13日 下午4:03:02
@@ -51,6 +51,7 @@ public class VideoStreamSessionManager {
ssrcTransaction.setSsrc(ssrc);
ssrcTransaction.setMediaServerId(mediaServerId);
ssrcTransaction.setType(type);
RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
+ "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
}

View File

@@ -170,11 +170,11 @@ public class SIPRequestHeaderProvider {
//from
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.isFromServer()?transactionInfo.getFromTag():transactionInfo.getToTag());
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
//to
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,transactionInfo.isFromServer()?transactionInfo.getToTag():transactionInfo.getFromTag());
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
//Forwards
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
@@ -186,11 +186,6 @@ public class SIPRequestHeaderProvider {
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
return request;
}

View File

@@ -574,10 +574,11 @@ public class SIPCommander implements ISIPCommander {
if (inviteStreamCallback != null) {
inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
}
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent -> {
ResponseEvent responseEvent = (ResponseEvent) okEvent.event;
SIPResponse response = (SIPResponse) responseEvent.getResponse();
streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
});
}
@@ -655,7 +656,12 @@ public class SIPCommander implements ISIPCommander {
*/
@Override
public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream);
SsrcTransaction ssrcTransaction;
if (callId != null) {
ssrcTransaction = streamSession.getSsrcTransaction(null, null, callId, null);
}else {
ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, null, stream);
}
if (ssrcTransaction == null) {
throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream);
}
@@ -769,7 +775,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<GuardCmd>" + guardCmdStr + "</GuardCmd>\r\n");
cmdXml.append("</Control>\r\n");
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);

View File

@@ -307,19 +307,20 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
* @return
*/
@Override
public void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException {
public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException {
if (parentPlatform == null) {
return ;
}
String statusStr = (status==1)?"ONLINE":"OFFLINE";
String characterSet = parentPlatform.getCharacterSet();
StringBuffer deviceStatusXml = new StringBuffer(600);
deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
deviceStatusXml.append("<Response>\r\n");
deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n");
deviceStatusXml.append("<SN>" +sn + "</SN>\r\n");
deviceStatusXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
deviceStatusXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
deviceStatusXml.append("<Result>OK</Result>\r\n");
deviceStatusXml.append("<Online>ONLINE</Online>\r\n");
deviceStatusXml.append("<Online>"+statusStr+"</Online>\r\n");
deviceStatusXml.append("<Status>OK</Status>\r\n");
deviceStatusXml.append("</Response>\r\n");
@@ -327,7 +328,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
}
@Override

View File

@@ -1,13 +1,16 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
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.utils.SipUtils;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.RequestEventExt;
@@ -59,6 +62,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
@Autowired
private SIPSender sipSender;
@Autowired
private UserSetting userSetting;
@Override
public void afterPropertiesSet() throws Exception {
// 添加消息处理的订阅
@@ -128,15 +134,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
// 添加Expires头
response.addHeader(request.getExpires());
// 获取到通信地址等信息
ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
String received = viaHeader.getReceived();
int rPort = viaHeader.getRPort();
// 解析本地地址替代
if (ObjectUtils.isEmpty(received) || rPort == -1) {
received = viaHeader.getHost();
rPort = viaHeader.getPort();
}
RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request,
userSetting.getSipUseSourceIpAsRemoteAddress());
if (device == null) {
device = new Device();
device.setStreamMode("UDP");
@@ -146,9 +146,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
device.setDeviceId(deviceId);
device.setOnline(0);
}
device.setIp(received);
device.setPort(rPort);
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
device.setIp(remoteAddressInfo.getIp());
device.setPort(remoteAddressInfo.getPort());
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));
device.setLocalIp(request.getLocalAddress().getHostAddress());
if (request.getExpires().getExpires() == 0) {
// 注销成功

View File

@@ -67,6 +67,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
@Override
public void process(RequestEvent evt) {
SIPRequest sipRequest = (SIPRequest)evt.getRequest();
logger.info("接收到消息:" + evt.getRequest());
logger.debug("接收到消息:" + evt.getRequest());
String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
CallIdHeader callIdHeader = sipRequest.getCallIdHeader();
@@ -94,7 +95,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
if (device == null && parentPlatform == null) {
// 不存在则回复404
responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found");
logger.warn("[设备未找到 ] {}", deviceId);
logger.warn("[设备未找到 ]deviceId: {}, callId: {}", deviceId, callIdHeader.getCallId());
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
deviceNotFoundEvent.setCallId(callIdHeader.getCallId());

View File

@@ -1,14 +1,16 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
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.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.message.SIPRequest;
import org.dom4j.Element;
@@ -17,13 +19,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException;
import javax.sip.RequestEvent;
import javax.sip.SipException;
import javax.sip.header.ViaHeader;
import javax.sip.message.Response;
import java.text.ParseException;
@@ -33,6 +32,7 @@ import java.text.ParseException;
@Component
public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
private Logger logger = LoggerFactory.getLogger(KeepaliveNotifyMessageHandler.class);
private final static String cmdType = "Keepalive";
@@ -42,6 +42,12 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
@Autowired
private IDeviceService deviceService;
@Autowired
private UserSetting userSetting;
@Autowired
private DynamicTask dynamicTask;
@Override
public void afterPropertiesSet() throws Exception {
notifyMessageHandler.addHandler(cmdType, this);
@@ -53,26 +59,27 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
// 未注册的设备不做处理
return;
}
SIPRequest request = (SIPRequest) evt.getRequest();
// 回复200 OK
try {
responseAck((SIPRequest) evt.getRequest(), Response.OK);
responseAck(request, Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 心跳回复: {}", e.getMessage());
logger.error("[命令发送失败] 心跳回复: {}", e.getMessage());
}
// 判断RPort是否改变改变则说明路由nat信息变化修改设备信息
// 获取到通信地址等信息
ViaHeader viaHeader = (ViaHeader) evt.getRequest().getHeader(ViaHeader.NAME);
String received = viaHeader.getReceived();
int rPort = viaHeader.getRPort();
// 解析本地地址替代
if (ObjectUtils.isEmpty(received) || rPort == -1) {
received = viaHeader.getHost();
rPort = viaHeader.getPort();
RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, userSetting.getSipUseSourceIpAsRemoteAddress());
if (!device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort()) {
device.setPort(remoteAddressInfo.getPort());
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));
device.setIp(remoteAddressInfo.getIp());
}
if (device.getPort() != rPort) {
device.setPort(rPort);
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
if (device.getKeepaliveTime() == null) {
device.setKeepaliveIntervalTime(60);
}else {
long lastTime = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(device.getKeepaliveTime());
device.setKeepaliveIntervalTime(new Long(System.currentTimeMillis()/1000-lastTime).intValue());
}
device.setKeepaliveTime(DateUtil.getNow());
if (device.getOnline() == 1) {
@@ -80,9 +87,15 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
}else {
// 对于已经离线的设备判断他的注册是否已经过期
if (!deviceService.expire(device)){
device.setOnline(0);
deviceService.online(device);
}
}
// 刷新过期任务
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
// 如果三次心跳失败,则设置设备离线
dynamicTask.startDelay(registerExpireTaskKey, ()-> deviceService.offline(device.getDeviceId()), device.getKeepaliveIntervalTime()*1000*3);
}
@Override

View File

@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@@ -24,6 +25,8 @@ import javax.sip.header.FromHeader;
import javax.sip.message.Response;
import java.text.ParseException;
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
@Component
public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
@@ -62,13 +65,19 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
// 回复200 OK
try {
responseAck((SIPRequest) evt.getRequest(), Response.OK);
responseAck((SIPRequest) evt.getRequest(), Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage());
}
String sn = rootElement.element("SN").getText();
String channelId = getText(rootElement, "DeviceID");
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId);
if (deviceChannel ==null){
logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId);
return;
}
try {
cmderFroPlatform.deviceStatusResponse(parentPlatform, sn, fromHeader.getTag());
cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.getStatus());
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage());
}

View File

@@ -63,7 +63,12 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i
return;
}
String result = getText(rootElement, "Result");
logger.info("[语音广播]回复:{}, {}/{}", result, device.getDeviceId(), channelId );
Element infoElement = rootElement.element("Info");
String reason = null;
if (infoElement != null) {
reason = getText(infoElement, "Reason");
}
logger.info("[语音广播]回复:{}, {}/{}", reason == null? result : result + ": " + reason, device.getDeviceId(), channelId );
// 回复200 OK
responseAck(request, Response.OK);

View File

@@ -1,9 +1,11 @@
package com.genersoft.iot.vmp.gb28181.utils;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.utils.GitUtil;
import gov.nist.javax.sip.address.AddressImpl;
import gov.nist.javax.sip.address.SipUri;
import gov.nist.javax.sip.header.Subject;
import gov.nist.javax.sip.message.SIPRequest;
import org.springframework.util.ObjectUtils;
import javax.sip.PeerUnavailableException;
@@ -139,4 +141,31 @@ public class SipUtils {
int typeCodeFromGbCode = getTypeCodeFromGbCode(deviceId);
return typeCodeFromGbCode > 130 && typeCodeFromGbCode < 199;
}
/**
* 从请求中获取设备ip地址和端口号
* @param request 请求
* @param sipUseSourceIpAsRemoteAddress false 从via中获取地址 true 直接获取远程地址
* @return 地址信息
*/
public static RemoteAddressInfo getRemoteAddressFromRequest(SIPRequest request, boolean sipUseSourceIpAsRemoteAddress) {
String remoteAddress;
int remotePort;
if (sipUseSourceIpAsRemoteAddress) {
remoteAddress = request.getRemoteAddress().getHostAddress();
remotePort = request.getRemotePort();
}else {
// 判断RPort是否改变改变则说明路由nat信息变化修改设备信息
// 获取到通信地址等信息
remoteAddress = request.getTopmostViaHeader().getReceived();
remotePort = request.getTopmostViaHeader().getRPort();
// 解析本地地址替代
if (ObjectUtils.isEmpty(remoteAddress) || remotePort == -1) {
remoteAddress = request.getTopmostViaHeader().getHost();
remotePort = request.getTopmostViaHeader().getPort();
}
}
return new RemoteAddressInfo(remoteAddress, remotePort);
}
}

View File

@@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -347,7 +348,7 @@ public class ZLMHttpHookListener {
}
}
}else if ("broadcast".equals(param.getApp())){
// 语音喊话推流 stream需要满足格式deviceId_channelId
// 语音对讲推流 stream需要满足格式deviceId_channelId
if (param.isRegist() && param.getStream().indexOf("_") > 0) {
String[] streamArray = param.getStream().split("_");
if (streamArray.length == 2) {
@@ -355,8 +356,7 @@ public class ZLMHttpHookListener {
String channelId = streamArray[1];
Device device = deviceService.getDevice(deviceId);
if (device != null) {
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel != null) {
if (param.isRegist()) {
if (audioBroadcastManager.exit(deviceId, channelId)) {
// 直接推流
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, param.getStream(), null);
@@ -381,18 +381,17 @@ public class ZLMHttpHookListener {
logger.error("[命令发送失败] 语音喊话: {}", e.getMessage());
}
}
}else {
logger.info("[语音对讲] 未找到通道:{}", channelId);
// 流注销
playService.stopAudioBroadcast(deviceId, channelId);
}
}else{
} else{
logger.info("[语音对讲] 未找到设备:{}", deviceId);
}
}else {
logger.info("[语音喊话] 推流格式有误, 格式为: broadcast/设备编号_通道编号 ");
}
}
}else if ("talk".equals(param.getApp())){
// 语音喊话推流 stream需要满足格式deviceId_channelId
if (param.isRegist() && param.getStream().indexOf("_") > 0) {
@@ -444,7 +443,7 @@ public class ZLMHttpHookListener {
}
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem,
param.getApp(), param.getStream(), param.getTracks(), callId);
param.setStreamInfo(streamInfoByAppAndStream);
param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param);
if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|| param.getOriginType() == OriginType.RTMP_PUSH.ordinal()
@@ -462,7 +461,7 @@ public class ZLMHttpHookListener {
}
GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream());
if (gbStream != null) {
// eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF);
// eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF);
}
zlmMediaListManager.removeMedia(param.getApp(), param.getStream());
}
@@ -531,7 +530,7 @@ public class ZLMHttpHookListener {
logger.info("[ZLM HOOK]流无人观看:{]->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
JSONObject ret = new JSONObject();
ret.put("code", 0);
// 录像下载
// 国标类型的流
if ("rtp".equals(param.getApp())){
ret.put("close", userSetting.getStreamOnDemand());
// 国标流, 点播/录像回放/录像下载
@@ -638,7 +637,7 @@ public class ZLMHttpHookListener {
@ResponseBody
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
public JSONObject onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param){
logger.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
logger.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
taskExecutor.execute(()->{
MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId());
if (userSetting.isAutoApplyPlay() && mediaInfo != null) {
@@ -706,7 +705,7 @@ public class ZLMHttpHookListener {
@PostMapping(value = "/on_send_rtp_stopped", produces = "application/json;charset=UTF-8")
public JSONObject onSendRtpStopped(HttpServletRequest request, @RequestBody OnSendRtpStoppedHookParam param){
logger.info("[ZLM HOOK] 发送rtp被动关闭:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream());
logger.info("[ZLM HOOK] rtp发送关闭:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream());
JSONObject ret = new JSONObject();
ret.put("code", 0);

View File

@@ -1,6 +1,6 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import java.util.List;
@@ -291,7 +291,7 @@ public class OnStreamChangedHookParam extends HookParam{
}
}
private StreamInfo streamInfo;
private StreamContent streamInfo;
public String getApp() {
return app;
@@ -407,11 +407,11 @@ public class OnStreamChangedHookParam extends HookParam{
this.docker = docker;
}
public StreamInfo getStreamInfo() {
public StreamContent getStreamInfo() {
return streamInfo;
}
public void setStreamInfo(StreamInfo streamInfo) {
public void setStreamInfo(StreamContent streamInfo) {
this.streamInfo = streamInfo;
}

View File

@@ -37,7 +37,7 @@ public interface IMediaServerService {
*/
void zlmServerOffline(String mediaServerId);
MediaServerItem getMediaServerForMinimumLoad();
MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist);
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);

View File

@@ -40,15 +40,20 @@ public interface IPlayService {
MediaServerItem getNewMediaServerItem(Device device);
/**
* 获取包含assist服务的节点
*/
MediaServerItem getNewMediaServerItemHasAssist(Device device);
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
void playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);
void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
void zlmServerOffline(String mediaServerId);
DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);
void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);

View File

@@ -1,10 +1,7 @@
package com.genersoft.iot.vmp.service.bean;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
public interface PlayBackCallback<T> {
public interface PlayBackCallback {
void call(PlayBackResult<RequestMessage> msg);
void call(PlayBackResult<T> msg);
}

View File

@@ -99,7 +99,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (channels != null && channels.size() > 0) {
List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null);
List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null);
if (channelList.size() == 0) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);

View File

@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -46,8 +47,6 @@ public class DeviceServiceImpl implements IDeviceService {
private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class);
private final String registerExpireTaskKeyPrefix = "device-register-expire-";
@Autowired
private DynamicTask dynamicTask;
@@ -108,7 +107,10 @@ public class DeviceServiceImpl implements IDeviceService {
redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
}
device.setUpdateTime(now);
if (device.getKeepaliveIntervalTime() == 0) {
// 默认心跳间隔60
device.setKeepaliveIntervalTime(60);
}
// 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询
if (device.getCreateTime() == null) {
device.setOnline(1);
@@ -123,7 +125,6 @@ public class DeviceServiceImpl implements IDeviceService {
}
sync(device);
}else {
if(device.getOnline() == 0){
device.setOnline(1);
device.setCreateTime(now);
@@ -160,18 +161,19 @@ public class DeviceServiceImpl implements IDeviceService {
addMobilePositionSubscribe(device);
}
// 刷新过期任务
String registerExpireTaskKey = registerExpireTaskKeyPrefix + device.getDeviceId();
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getExpires() * 1000);
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
// 如果第一次注册那么必须在60 * 3时间内收到一个心跳否则设备离线
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getKeepaliveIntervalTime() * 1000 * 3);
}
@Override
public void offline(String deviceId) {
logger.info("[设备离线] device{}", deviceId);
logger.error("[设备离线] device{}", deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return;
}
String registerExpireTaskKey = registerExpireTaskKeyPrefix + deviceId;
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
dynamicTask.stop(registerExpireTaskKey);
device.setOnline(0);
redisCatchStorage.updateDevice(device);
@@ -356,7 +358,6 @@ public class DeviceServiceImpl implements IDeviceService {
device.setUpdateTime(DateUtil.getNow());
if (deviceMapper.update(device) > 0) {
redisCatchStorage.updateDevice(device);
}
}
@@ -432,7 +433,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (parentId.length() < 14 ) {
return null;
}
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId);
return trees;
}
@@ -477,7 +478,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (parentId.length() < 14 ) {
return null;
}
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
return deviceChannels;
}
@@ -541,7 +542,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
}else {
if (haveChannel) {
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null);
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null,null);
if (deviceChannels != null && deviceChannels.size() > 0) {
result.addAll(deviceChannels);
}

View File

@@ -501,7 +501,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
* @return MediaServerItem
*/
@Override
public MediaServerItem getMediaServerForMinimumLoad() {
public MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist) {
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
if (RedisUtil.zSize(key) == null || RedisUtil.zSize(key) == 0) {
@@ -514,9 +514,31 @@ public class MediaServerServiceImpl implements IMediaServerService {
// 获取分数最低的,及并发最低的
Set<Object> objects = RedisUtil.zRange(key, 0, -1);
ArrayList<Object> mediaServerObjectS = new ArrayList<>(objects);
MediaServerItem mediaServerItem = null;
if (hasAssist == null) {
String mediaServerId = (String)mediaServerObjectS.get(0);
mediaServerItem = getOne(mediaServerId);
}else if (hasAssist) {
for (Object mediaServerObject : mediaServerObjectS) {
String mediaServerId = (String)mediaServerObject;
MediaServerItem serverItem = getOne(mediaServerId);
if (serverItem.getRecordAssistPort() > 0) {
mediaServerItem = serverItem;
break;
}
}
}else if (!hasAssist) {
for (Object mediaServerObject : mediaServerObjectS) {
String mediaServerId = (String)mediaServerObject;
MediaServerItem serverItem = getOne(mediaServerId);
if (serverItem.getRecordAssistPort() == 0) {
mediaServerItem = serverItem;
break;
}
}
}
String mediaServerId = (String)mediaServerObjectS.get(0);
return getOne(mediaServerId);
return mediaServerItem;
}
/**

View File

@@ -157,14 +157,7 @@ public class PlatformServiceImpl implements IPlatformService {
dynamicTask.startCron(registerTaskKey,
// 注册失败注册成功时由程序直接调用了online方法
()-> {
try {
logger.info("[国标级联] 平台:{}注册即将到期,重新注册", parentPlatform.getServerGBId());
commanderForPlatform.register(parentPlatform, eventResult -> {
offline(parentPlatform, false);
},null);
} catch (InvalidArgumentException | ParseException | SipException e) {
logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage());
}
registerTask(parentPlatform);
},
(parentPlatform.getExpires() - 10) *1000);
}
@@ -216,6 +209,28 @@ public class PlatformServiceImpl implements IPlatformService {
}
}
private void registerTask(ParentPlatform parentPlatform){
try {
// 设置超时重发, 后续从底层支持消息重发
String key = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId() + "_timeout";
if (dynamicTask.isAlive(key)) {
return;
}
dynamicTask.startDelay(key, ()->{
registerTask(parentPlatform);
}, 1000);
logger.info("[国标级联] 平台:{}注册即将到期,重新注册", parentPlatform.getServerGBId());
commanderForPlatform.register(parentPlatform, eventResult -> {
dynamicTask.stop(key);
offline(parentPlatform, false);
},eventResult -> {
dynamicTask.stop(key);
});
} catch (InvalidArgumentException | ParseException | SipException e) {
logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage());
}
}
@Override
public void offline(ParentPlatform parentPlatform, boolean stopRegister) {
logger.info("[平台离线]{}", parentPlatform.getServerGBId());

View File

@@ -39,6 +39,7 @@ import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent;
import gov.nist.javax.sip.message.SIPResponse;
@@ -49,7 +50,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.InvalidArgumentException;
import javax.sip.ResponseEvent;
@@ -454,6 +454,9 @@ public class PlayServiceImpl implements IPlayService {
mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream());
// 取消订阅消息监听
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
subscribe.removeSubscribe(hookSubscribe);
}
}
}, userSetting.getPlayTimeout());
@@ -463,7 +466,6 @@ public class PlayServiceImpl implements IPlayService {
dynamicTask.stop(timeOutTaskKey);
// 释放ssrc
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
RequestMessage msg = new RequestMessage();
@@ -481,7 +483,7 @@ public class PlayServiceImpl implements IPlayService {
onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId);
hookEvent.response(mediaServerItemInuse, response);
logger.info("[点播成功] deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
String streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", ssrcInfo.getStream());
String streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.flv", mediaServerItemInuse.getHttpPort(), "rtp", ssrcInfo.getStream());
String path = "snap";
String fileName = device.getDeviceId() + "_" + channelId + ".jpg";
// 请求截图
@@ -589,14 +591,10 @@ public class PlayServiceImpl implements IPlayService {
}
}
private void onPublishHandlerForPlayback(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) {
RequestMessage msg = new RequestMessage();
msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId);
if (!ObjectUtils.isEmpty(uuid)) {
msg.setId(uuid);
}
StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId);
private void onPublishHandlerForPlayback(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, PlayBackCallback playBackCallback) {
StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId);
PlayBackResult<StreamInfo> playBackResult = new PlayBackResult<>();
if (streamInfo != null) {
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel != null) {
@@ -605,17 +603,16 @@ public class PlayServiceImpl implements IPlayService {
}
redisCatchStorage.startPlay(streamInfo);
WVPResult wvpResult = new WVPResult();
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo);
msg.setData(wvpResult);
resultHolder.invokeAllResult(msg);
playBackResult.setCode(ErrorCode.SUCCESS.getCode());
playBackResult.setMsg(ErrorCode.SUCCESS.getMsg());
playBackResult.setData(streamInfo);
playBackCallback.call(playBackResult);
} else {
logger.warn("录像回放调用失败!");
msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "录像回放调用失败!"));
resultHolder.invokeAllResult(msg);
playBackResult.setCode(ErrorCode.ERROR100.getCode());
playBackResult.setMsg("录像回放调用失败!");
playBackCallback.call(playBackResult);
}
}
@@ -626,7 +623,7 @@ public class PlayServiceImpl implements IPlayService {
}
MediaServerItem mediaServerItem;
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
} else {
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
@@ -637,45 +634,56 @@ public class PlayServiceImpl implements IPlayService {
}
@Override
public DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime,
public MediaServerItem getNewMediaServerItemHasAssist(Device device) {
if (device == null) {
return null;
}
MediaServerItem mediaServerItem;
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(true);
} else {
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
if (mediaServerItem == null) {
logger.warn("[获取可用的ZLM节点]未找到可使用的ZLM...");
}
return mediaServerItem;
}
@Override
public void playBack(String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback inviteStreamCallback,
PlayBackCallback callback) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return null;
return;
}
MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, device.isSsrcCheck(), true);
return playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, inviteStreamCallback, callback);
playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, inviteStreamCallback, callback);
}
@Override
public DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
public void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback infoCallBack,
PlayBackCallback playBackCallback) {
if (mediaServerItem == null || ssrcInfo == null) {
return null;
return;
}
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在");
}
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L);
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result);
RequestMessage requestMessage = new RequestMessage();
requestMessage.setId(uuid);
requestMessage.setKey(key);
PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>();
PlayBackResult<StreamInfo> playBackResult = new PlayBackResult<>();
String playBackTimeOutTaskKey = UUID.randomUUID().toString();
dynamicTask.startDelay(playBackTimeOutTaskKey, () -> {
logger.warn(String.format("设备回放超时deviceId%s channelId%s", deviceId, channelId));
playBackResult.setCode(ErrorCode.ERROR100.getCode());
playBackResult.setMsg("回放超时");
playBackResult.setData(requestMessage);
try {
cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null);
@@ -687,19 +695,14 @@ public class PlayServiceImpl implements IPlayService {
mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream());
streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
}
// 回复之前所有的点播请求
playBackCallback.call(playBackResult);
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "回放超时"));
resultHolder.exist(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid);
}, userSetting.getPlayTimeout());
SipSubscribe.Event errorEvent = event -> {
dynamicTask.stop(playBackTimeOutTaskKey);
requestMessage.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)));
playBackResult.setCode(ErrorCode.ERROR100.getCode());
playBackResult.setMsg(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg));
playBackResult.setData(requestMessage);
playBackResult.setEvent(event);
playBackCallback.call(playBackResult);
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
@@ -717,11 +720,9 @@ public class PlayServiceImpl implements IPlayService {
return;
}
redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId());
WVPResult<StreamInfo> success = WVPResult.success(streamInfo);
requestMessage.setData(success);
playBackResult.setCode(ErrorCode.SUCCESS.getCode());
playBackResult.setMsg(ErrorCode.SUCCESS.getMsg());
playBackResult.setData(requestMessage);
playBackResult.setData(streamInfo);
playBackResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem());
playBackResult.setResponse(inviteStreamInfo.getResponse());
playBackCallback.call(playBackResult);
@@ -768,7 +769,7 @@ public class PlayServiceImpl implements IPlayService {
logger.info("[ZLM HOOK] ssrc修正后收到订阅消息 " + response.toJSONString());
dynamicTask.stop(playBackTimeOutTaskKey);
// hook响应
onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid);
onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, playBackCallback);
hookEvent.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream()));
});
}
@@ -788,50 +789,45 @@ public class PlayServiceImpl implements IPlayService {
eventResult.msg = "命令发送失败";
errorEvent.response(eventResult);
}
return result;
}
@Override
public DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return null;
return;
}
MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device);
if (newMediaServerItem == null) {
PlayBackResult<StreamInfo> downloadResult = new PlayBackResult<>();
downloadResult.setCode(ErrorCode.ERROR100.getCode());
downloadResult.setMsg("未找到assist服务");
playBackCallback.call(downloadResult);
return;
}
MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, device.isSsrcCheck(), true);
return download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, hookCallBack);
download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, playBackCallback);
}
@Override
public DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
public void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
if (mediaServerItem == null || ssrcInfo == null) {
return null;
return;
}
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L);
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在");
}
resultHolder.put(key, uuid, result);
RequestMessage requestMessage = new RequestMessage();
requestMessage.setId(uuid);
requestMessage.setKey(key);
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
requestMessage.setData(wvpResult);
PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>();
downloadResult.setData(requestMessage);
PlayBackResult<StreamInfo> downloadResult = new PlayBackResult<>();
String downLoadTimeOutTaskKey = UUID.randomUUID().toString();
dynamicTask.startDelay(downLoadTimeOutTaskKey, () -> {
logger.warn(String.format("录像下载请求超时deviceId%s channelId%s", deviceId, channelId));
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("录像下载请求超时");
downloadResult.setCode(ErrorCode.ERROR100.getCode());
downloadResult.setMsg("录像下载请求超时");
hookCallBack.call(downloadResult);
@@ -846,16 +842,12 @@ public class PlayServiceImpl implements IPlayService {
mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream());
streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
}
// 回复之前所有的点播请求
hookCallBack.call(downloadResult);
}, userSetting.getPlayTimeout());
SipSubscribe.Event errorEvent = event -> {
dynamicTask.stop(downLoadTimeOutTaskKey);
downloadResult.setCode(ErrorCode.ERROR100.getCode());
downloadResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg));
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg));
downloadResult.setEvent(event);
hookCallBack.call(downloadResult);
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
@@ -870,11 +862,9 @@ public class PlayServiceImpl implements IPlayService {
streamInfo.setStartTime(startTime);
streamInfo.setEndTime(endTime);
redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId());
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo);
downloadResult.setCode(ErrorCode.SUCCESS.getCode());
downloadResult.setMsg(ErrorCode.SUCCESS.getMsg());
downloadResult.setData(streamInfo);
downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem());
downloadResult.setResponse(inviteStreamInfo.getResponse());
hookCallBack.call(downloadResult);
@@ -886,7 +876,6 @@ public class PlayServiceImpl implements IPlayService {
eventResult.msg = "命令发送失败";
errorEvent.response(eventResult);
}
return result;
}
@Override
@@ -906,7 +895,10 @@ public class PlayServiceImpl implements IPlayService {
}
if (mediaServerItem.getRecordAssistPort() > 0) {
JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, streamInfo.getApp(), streamInfo.getStream(), null);
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
if (jsonObject == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接Assist服务失败");
}
if (jsonObject.getInteger("code") == 0) {
long duration = jsonObject.getLong("data");
if (duration == 0) {
@@ -1004,7 +996,7 @@ public class PlayServiceImpl implements IPlayService {
logger.warn("开启语音广播的时候未找到通道: {}", channelId);
return null;
}
MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
String app = "broadcast";
// TODO 从sip user agent中判断是什么品牌设备大华默认使用talk模式其他使用broadcast模式
// String app = "talk";
@@ -1013,7 +1005,7 @@ public class PlayServiceImpl implements IPlayService {
AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
audioBroadcastResult.setApp(app);
audioBroadcastResult.setStream(stream);
audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, null,false));
audioBroadcastResult.setStreamInfo(new StreamContent(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, null,false)));
audioBroadcastResult.setCodec("G.711");
return audioBroadcastResult;
}
@@ -1103,6 +1095,12 @@ public class PlayServiceImpl implements IPlayService {
param.put("app", sendRtpItem.getApp());
param.put("stream", sendRtpItem.getStreamId());
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
try {
cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null);
} catch (InvalidArgumentException | ParseException | SipException |
SsrcTransactionNotFoundException e) {
logger.error("[消息发送失败] 发送语音喊话BYE失败");
}
}
audioBroadcastManager.del(deviceId, channelId);

View File

@@ -90,7 +90,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo;
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null);
}else {
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
}

View File

@@ -117,7 +117,7 @@ public class RedisGbPlayMsgListener implements MessageListener {
Message msg = taskQueue.poll();
try {
JSONObject msgJSON = JSON.parseObject(msg.getBody(), JSONObject.class);
WvpRedisMsg wvpRedisMsg = JSON.toJavaObject(msgJSON, WvpRedisMsg.class);
WvpRedisMsg wvpRedisMsg = JSON.to(WvpRedisMsg.class, msgJSON);
if (!userSetting.getServerId().equals(wvpRedisMsg.getToId())) {
continue;
}
@@ -126,11 +126,11 @@ public class RedisGbPlayMsgListener implements MessageListener {
switch (wvpRedisMsg.getCmd()){
case WvpRedisMsgCmd.GET_SEND_ITEM:
RequestSendItemMsg content = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), RequestSendItemMsg.class);
RequestSendItemMsg content = JSON.to(RequestSendItemMsg.class, wvpRedisMsg.getContent());
requestSendItemMsgHand(content, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial());
break;
case WvpRedisMsgCmd.REQUEST_PUSH_STREAM:
RequestPushStreamMsg param = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), RequestPushStreamMsg.class);;
RequestPushStreamMsg param = JSON.to(RequestPushStreamMsg.class, wvpRedisMsg.getContent());
requestPushStreamMsgHand(param, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial());
break;
default:
@@ -142,12 +142,12 @@ public class RedisGbPlayMsgListener implements MessageListener {
switch (wvpRedisMsg.getCmd()){
case WvpRedisMsgCmd.GET_SEND_ITEM:
WVPResult content = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), WVPResult.class);
WVPResult content = JSON.to(WVPResult.class, wvpRedisMsg.getContent());
String key = wvpRedisMsg.getSerial();
switch (content.getCode()) {
case 0:
ResponseSendItemMsg responseSendItemMsg =JSON.toJavaObject((JSONObject)content.getData(), ResponseSendItemMsg.class);
ResponseSendItemMsg responseSendItemMsg =JSON.to(ResponseSendItemMsg.class, content.getData());
PlayMsgCallback playMsgCallback = callbacks.get(key);
if (playMsgCallback != null) {
callbacksForError.remove(key);
@@ -172,7 +172,7 @@ public class RedisGbPlayMsgListener implements MessageListener {
}
break;
case WvpRedisMsgCmd.REQUEST_PUSH_STREAM:
WVPResult wvpResult = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), WVPResult.class);
WVPResult wvpResult = JSON.to(WVPResult.class, wvpRedisMsg.getContent());
String serial = wvpRedisMsg.getSerial();
switch (wvpResult.getCode()) {
case 0:
@@ -199,6 +199,7 @@ public class RedisGbPlayMsgListener implements MessageListener {
default:
break;
}
}
}catch (Exception e) {
logger.warn("[RedisGbPlayMsg] 发现未处理的异常, {}",e.getMessage());

View File

@@ -59,7 +59,7 @@ public interface IVideoManagerStorage {
*/
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
/**
@@ -68,7 +68,7 @@ public interface IVideoManagerStorage {
* @param deviceId 设备ID
* @return
*/
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds);
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
/**
@@ -91,14 +91,14 @@ public interface IVideoManagerStorage {
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
public PageInfo<Device> queryVideoDeviceList(int page, int count);
public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online);
/**
* 获取多个设备
*
* @return List<Device> 设备对象数组
*/
public List<Device> queryVideoDeviceList();
public List<Device> queryVideoDeviceList(Boolean online);

View File

@@ -16,19 +16,19 @@ import java.util.List;
public interface DeviceAlarmMapper {
@Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType , createTime ) " +
"VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}', '${createTime}')")
"VALUES (#{deviceId}, #{channelId}, #{alarmPriority}, #{alarmMethod}, #{alarmTime}, #{alarmDescription}, #{longitude}, #{latitude}, #{alarmType}, #{createTime})")
int add(DeviceAlarm alarm);
@Select(value = {" <script>" +
" SELECT * FROM device_alarm " +
" WHERE 1=1 " +
" <if test=\"deviceId != null\" > AND deviceId = '${deviceId}'</if>" +
" <if test=\"alarmPriority != null\" > AND alarmPriority = '${alarmPriority}' </if>" +
" <if test=\"alarmMethod != null\" > AND alarmMethod = '${alarmMethod}' </if>" +
" <if test=\"alarmType != null\" > AND alarmType = '${alarmType}' </if>" +
" <if test=\"startTime != null\" > AND alarmTime &gt;= '${startTime}' </if>" +
" <if test=\"endTime != null\" > AND alarmTime &lt;= '${endTime}' </if>" +
" <if test=\"deviceId != null\" > AND deviceId = #{deviceId}</if>" +
" <if test=\"alarmPriority != null\" > AND alarmPriority = #{alarmPriority} </if>" +
" <if test=\"alarmMethod != null\" > AND alarmMethod = #{alarmMethod} </if>" +
" <if test=\"alarmType != null\" > AND alarmType = #{alarmType} </if>" +
" <if test=\"startTime != null\" > AND alarmTime &gt;= #{startTime} </if>" +
" <if test=\"endTime != null\" > AND alarmTime &lt;= #{endTime} </if>" +
" ORDER BY alarmTime ASC " +
" </script>"})
List<DeviceAlarm> query(String deviceId, String alarmPriority, String alarmMethod,
@@ -38,10 +38,10 @@ public interface DeviceAlarmMapper {
@Delete(" <script>" +
"DELETE FROM device_alarm WHERE 1=1 " +
" <if test=\"deviceIdList != null and id == null \" > AND deviceId in " +
"<foreach collection='deviceIdList' item='item' open='(' separator=',' close=')' > '${item}'</foreach>" +
"<foreach collection='deviceIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</if>" +
" <if test=\"time != null and id == null \" > AND alarmTime &lt;= '${time}'</if>" +
" <if test=\"id != null\" > AND id = ${id}</if>" +
" <if test=\"time != null and id == null \" > AND alarmTime &lt;= #{time}</if>" +
" <if test=\"id != null\" > AND id = #{id}</if>" +
" </script>"
)
int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time);

View File

@@ -20,46 +20,46 @@ public interface DeviceChannelMapper {
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
"longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, " +
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, ${hasAudio}, '${createTime}', '${updateTime}', '${businessGroupId}', '${gpsTime}')")
"VALUES (#{channelId}, #{deviceId}, #{name}, #{manufacture}, #{model}, #{owner}, #{civilCode}, #{block}," +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{PTZType}, #{status}, #{streamId}, #{longitude}, #{latitude}, #{longitudeGcj02}, " +
"#{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{hasAudio}, #{createTime}, #{updateTime}, #{businessGroupId}, #{gpsTime})")
int add(DeviceChannel channel);
@Update(value = {" <script>" +
"UPDATE device_channel " +
"SET updateTime='${updateTime}'" +
"<if test='name != null'>, name='${name}'</if>" +
"<if test='manufacture != null'>, manufacture='${manufacture}'</if>" +
"<if test='model != null'>, model='${model}'</if>" +
"<if test='owner != null'>, owner='${owner}'</if>" +
"<if test='civilCode != null'>, civilCode='${civilCode}'</if>" +
"<if test='block != null'>, block='${block}'</if>" +
"<if test='address != null'>, address='${address}'</if>" +
"<if test='parental != null'>, parental=${parental}</if>" +
"<if test='parentId != null'>, parentId='${parentId}'</if>" +
"<if test='safetyWay != null'>, safetyWay=${safetyWay}</if>" +
"<if test='registerWay != null'>, registerWay=${registerWay}</if>" +
"<if test='certNum != null'>, certNum='${certNum}'</if>" +
"<if test='certifiable != null'>, certifiable=${certifiable}</if>" +
"<if test='errCode != null'>, errCode=${errCode}</if>" +
"<if test='secrecy != null'>, secrecy='${secrecy}'</if>" +
"<if test='ipAddress != null'>, ipAddress='${ipAddress}'</if>" +
"<if test='port != null'>, port=${port}</if>" +
"<if test='password != null'>, password='${password}'</if>" +
"<if test='PTZType != null'>, PTZType=${PTZType}</if>" +
"<if test='status != null'>, status='${status}'</if>" +
"<if test='streamId != null'>, streamId='${streamId}'</if>" +
"<if test='hasAudio != null'>, hasAudio=${hasAudio}</if>" +
"<if test='longitude != null'>, longitude=${longitude}</if>" +
"<if test='latitude != null'>, latitude=${latitude}</if>" +
"<if test='longitudeGcj02 != null'>, longitudeGcj02=${longitudeGcj02}</if>" +
"<if test='latitudeGcj02 != null'>, latitudeGcj02=${latitudeGcj02}</if>" +
"<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
"SET updateTime=#{updateTime}" +
"<if test='name != null'>, name=#{name}</if>" +
"<if test='manufacture != null'>, manufacture=#{manufacture}</if>" +
"<if test='model != null'>, model=#{model}</if>" +
"<if test='owner != null'>, owner=#{owner}</if>" +
"<if test='civilCode != null'>, civilCode=#{civilCode}</if>" +
"<if test='block != null'>, block=#{block}</if>" +
"<if test='address != null'>, address=#{address}</if>" +
"<if test='parental != null'>, parental=#{parental}</if>" +
"<if test='parentId != null'>, parentId=#{parentId}</if>" +
"<if test='safetyWay != null'>, safetyWay=#{safetyWay}</if>" +
"<if test='registerWay != null'>, registerWay=#{registerWay}</if>" +
"<if test='certNum != null'>, certNum=#{certNum}</if>" +
"<if test='certifiable != null'>, certifiable=#{certifiable}</if>" +
"<if test='errCode != null'>, errCode=#{errCode}</if>" +
"<if test='secrecy != null'>, secrecy=#{secrecy}</if>" +
"<if test='ipAddress != null'>, ipAddress=#{ipAddress}</if>" +
"<if test='port != null'>, port=#{port}</if>" +
"<if test='password != null'>, password=#{password}</if>" +
"<if test='PTZType != null'>, PTZType=#{PTZType}</if>" +
"<if test='status != null'>, status=#{status}</if>" +
"<if test='streamId != null'>, streamId=#{streamId}</if>" +
"<if test='hasAudio != null'>, hasAudio=#{hasAudio}</if>" +
"<if test='longitude != null'>, longitude=#{longitude}</if>" +
"<if test='latitude != null'>, latitude=#{latitude}</if>" +
"<if test='longitudeGcj02 != null'>, longitudeGcj02=#{longitudeGcj02}</if>" +
"<if test='latitudeGcj02 != null'>, latitudeGcj02=#{latitudeGcj02}</if>" +
"<if test='longitudeWgs84 != null'>, longitudeWgs84=#{longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitudeWgs84=#{latitudeWgs84}</if>" +
"<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
"<if test='gpsTime != null'>, gpsTime=#{gpsTime}</if>" +
"WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
"WHERE deviceId=#{deviceId} AND channelId=#{channelId}"+
" </script>"})
int update(DeviceChannel channel);
@@ -70,15 +70,18 @@ public interface DeviceChannelMapper {
"device_channel dc " +
"WHERE " +
"dc.deviceId = #{deviceId} " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='query != null'> AND (dc.channelId LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
" <if test='online == true' > AND dc.status=1</if>" +
" <if test='online == false' > AND dc.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc.subCount > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.subCount = 0 </if>" +
"<if test='channelIds != null'> AND dc.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channelId " +
" </script>"})
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List<String> channelIds);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
DeviceChannel queryChannel(String deviceId, String channelId);
@@ -110,7 +113,7 @@ public interface DeviceChannelMapper {
" LEFT JOIN device de ON dc.deviceId = de.deviceId " +
" LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
" WHERE 1=1 " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='query != null'> AND (dc.channelId LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='online == true' > AND dc.status=1</if> " +
" <if test='online == false' > AND dc.status=0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " +
@@ -151,14 +154,14 @@ public interface DeviceChannelMapper {
" longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"('${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
"'${item.owner}', '${item.civilCode}', '${item.block}',${item.subCount}," +
"'${item.address}', ${item.parental}, '${item.parentId}', ${item.safetyWay}, ${item.registerWay}, " +
"'${item.certNum}', ${item.certifiable}, ${item.errCode}, '${item.secrecy}', " +
"'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
"'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
"${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84}, ${item.hasAudio},'${item.createTime}', '${item.updateTime}', " +
"'${item.businessGroupId}', '${item.gpsTime}') " +
"(#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, " +
"#{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}," +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, " +
"#{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.PTZType}, #{item.status}, " +
"#{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, " +
"#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " +
"#{item.businessGroupId}, #{item.gpsTime}) " +
"</foreach> " +
"ON DUPLICATE KEY UPDATE " +
"updateTime=VALUES(updateTime), " +
@@ -203,39 +206,39 @@ public interface DeviceChannelMapper {
"<foreach collection='updateChannels' item='item' separator=';'>" +
" UPDATE" +
" device_channel" +
" SET updateTime='${item.updateTime}'" +
"<if test='item.name != null'>, name='${item.name}'</if>" +
"<if test='item.manufacture != null'>, manufacture='${item.manufacture}'</if>" +
"<if test='item.model != null'>, model='${item.model}'</if>" +
"<if test='item.owner != null'>, owner='${item.owner}'</if>" +
"<if test='item.civilCode != null'>, civilCode='${item.civilCode}'</if>" +
"<if test='item.block != null'>, block='${item.block}'</if>" +
"<if test='item.subCount != null'>, block=${item.subCount}</if>" +
"<if test='item.address != null'>, address='${item.address}'</if>" +
"<if test='item.parental != null'>, parental=${item.parental}</if>" +
"<if test='item.parentId != null'>, parentId='${item.parentId}'</if>" +
"<if test='item.safetyWay != null'>, safetyWay=${item.safetyWay}</if>" +
"<if test='item.registerWay != null'>, registerWay=${item.registerWay}</if>" +
"<if test='item.certNum != null'>, certNum='${item.certNum}'</if>" +
"<if test='item.certifiable != null'>, certifiable=${item.certifiable}</if>" +
"<if test='item.errCode != null'>, errCode=${item.errCode}</if>" +
"<if test='item.secrecy != null'>, secrecy='${item.secrecy}'</if>" +
"<if test='item.ipAddress != null'>, ipAddress='${item.ipAddress}'</if>" +
"<if test='item.port != null'>, port=${item.port}</if>" +
"<if test='item.password != null'>, password='${item.password}'</if>" +
"<if test='item.PTZType != null'>, PTZType=${item.PTZType}</if>" +
"<if test='item.status != null'>, status='${item.status}'</if>" +
"<if test='item.streamId != null'>, streamId='${item.streamId}'</if>" +
"<if test='item.hasAudio != null'>, hasAudio=${item.hasAudio}</if>" +
"<if test='item.longitude != null'>, longitude=${item.longitude}</if>" +
"<if test='item.latitude != null'>, latitude=${item.latitude}</if>" +
"<if test='item.longitudeGcj02 != null'>, longitudeGcj02=${item.longitudeGcj02}</if>" +
"<if test='item.latitudeGcj02 != null'>, latitudeGcj02=${item.latitudeGcj02}</if>" +
"<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
" SET updateTime=#{item.updateTime}" +
"<if test='item.name != null'>, name=#{item.name}</if>" +
"<if test='item.manufacture != null'>, manufacture=#{item.manufacture}</if>" +
"<if test='item.model != null'>, model=#{item.model}</if>" +
"<if test='item.owner != null'>, owner=#{item.owner}</if>" +
"<if test='item.civilCode != null'>, civilCode=#{item.civilCode}</if>" +
"<if test='item.block != null'>, block=#{item.block}</if>" +
"<if test='item.subCount != null'>, block=#{item.subCount}</if>" +
"<if test='item.address != null'>, address=#{item.address}</if>" +
"<if test='item.parental != null'>, parental=#{item.parental}</if>" +
"<if test='item.parentId != null'>, parentId=#{item.parentId}</if>" +
"<if test='item.safetyWay != null'>, safetyWay=#{item.safetyWay}</if>" +
"<if test='item.registerWay != null'>, registerWay=#{item.registerWay}</if>" +
"<if test='item.certNum != null'>, certNum=#{item.certNum}</if>" +
"<if test='item.certifiable != null'>, certifiable=#{item.certifiable}</if>" +
"<if test='item.errCode != null'>, errCode=#{item.errCode}</if>" +
"<if test='item.secrecy != null'>, secrecy=#{item.secrecy}</if>" +
"<if test='item.ipAddress != null'>, ipAddress=#{item.ipAddress}</if>" +
"<if test='item.port != null'>, port=#{item.port}</if>" +
"<if test='item.password != null'>, password=#{item.password}</if>" +
"<if test='item.PTZType != null'>, PTZType=#{item.PTZType}</if>" +
"<if test='item.status != null'>, status=#{item.status}</if>" +
"<if test='item.streamId != null'>, streamId=#{item.streamId}</if>" +
"<if test='item.hasAudio != null'>, hasAudio=#{item.hasAudio}</if>" +
"<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
"<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
"<if test='item.longitudeGcj02 != null'>, longitudeGcj02=#{item.longitudeGcj02}</if>" +
"<if test='item.latitudeGcj02 != null'>, latitudeGcj02=#{item.latitudeGcj02}</if>" +
"<if test='item.longitudeWgs84 != null'>, longitudeWgs84=#{item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitudeWgs84=#{item.latitudeWgs84}</if>" +
"<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" +
"<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" +
"WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
"WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}"+
"</foreach>" +
"</script>"})
int batchUpdate(List<DeviceChannel> updateChannels);
@@ -248,17 +251,20 @@ public interface DeviceChannelMapper {
"device_channel dc1 " +
"WHERE " +
"dc1.deviceId = #{deviceId} " +
" <if test='query != null'> AND (dc1.channelId LIKE '%${query}%' OR dc1.name LIKE '%${query}%' OR dc1.name LIKE '%${query}%')</if> " +
" <if test='query != null'> AND (dc1.channelId LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%') OR dc1.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc1.status=1</if>" +
" <if test='online == false' > AND dc1.status=0</if>" +
" <if test='hasSubChannel == true' > AND dc1.subCount >0</if>" +
" <if test='hasSubChannel == false' > AND dc1.subCount=0</if>" +
"<if test='channelIds != null'> AND dc1.channelId in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc1.channelId ASC " +
"Limit #{limit} OFFSET #{start}" +
" </script>"})
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
Boolean hasSubChannel, Boolean online, int start, int limit);
Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds);
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
@@ -286,13 +292,13 @@ public interface DeviceChannelMapper {
@Update(value = {" <script>" +
"UPDATE device_channel " +
"SET " +
"latitude=${latitude}, " +
"longitude=${longitude}, " +
"longitudeGcj02=${longitudeGcj02}, " +
"latitudeGcj02=${latitudeGcj02}, " +
"longitudeWgs84=${longitudeWgs84}, " +
"latitudeWgs84=${latitudeWgs84}, " +
"gpsTime='${gpsTime}' " +
"latitude=#{latitude}, " +
"longitude=#{longitude}, " +
"longitudeGcj02=#{longitudeGcj02}, " +
"latitudeGcj02=#{latitudeGcj02}, " +
"longitudeWgs84=#{longitudeWgs84}, " +
"latitudeWgs84=#{latitudeWgs84}, " +
"gpsTime=#{gpsTime} " +
"WHERE deviceId=#{deviceId} " +
" <if test='channelId != null' > AND channelId=#{channelId}</if>" +
" </script>"})
@@ -309,10 +315,10 @@ public interface DeviceChannelMapper {
"select * " +
"from device_channel " +
"where deviceId=#{deviceId}" +
" <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} </if>" +
" <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=${length} </if>" +
" <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} and length(channelId)=#{length} </if>" +
" <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=#{length} </if>" +
" <if test='parentId == null and length == null' > and parentId = #{parentId} </if>" +
" <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} </if>" +
" <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} </if>" +
" </script>"})
List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);

View File

@@ -61,6 +61,7 @@ public interface DeviceMapper {
"expires," +
"registerTime," +
"keepaliveTime," +
"keepaliveIntervalTime," +
"createTime," +
"updateTime," +
"charset," +
@@ -88,6 +89,7 @@ public interface DeviceMapper {
"#{expires}," +
"#{registerTime}," +
"#{keepaliveTime}," +
"#{keepaliveIntervalTime}," +
"#{createTime}," +
"#{updateTime}," +
"#{charset}," +
@@ -104,25 +106,28 @@ public interface DeviceMapper {
@Update(value = {" <script>" +
"UPDATE device " +
"SET updateTime='${updateTime}'" +
"<if test=\"name != null\">, name='${name}'</if>" +
"<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" +
"<if test=\"model != null\">, model='${model}'</if>" +
"<if test=\"firmware != null\">, firmware='${firmware}'</if>" +
"<if test=\"transport != null\">, transport='${transport}'</if>" +
"<if test=\"ip != null\">, ip='${ip}'</if>" +
"<if test=\"localIp != null\">, localIp='${localIp}'</if>" +
"<if test=\"port != null\">, port=${port}</if>" +
"<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
"<if test=\"online != null\">, online=${online}</if>" +
"<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" +
"<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" +
"<if test=\"expires != null\">, expires=${expires}</if>" +
"WHERE deviceId='${deviceId}'"+
"SET updateTime=#{updateTime}" +
"<if test=\"name != null\">, name=#{name}</if>" +
"<if test=\"manufacturer != null\">, manufacturer=#{manufacturer}</if>" +
"<if test=\"model != null\">, model=#{model}</if>" +
"<if test=\"firmware != null\">, firmware=#{firmware}</if>" +
"<if test=\"transport != null\">, transport=#{transport}</if>" +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"localIp != null\">, localIp=#{localIp}</if>" +
"<if test=\"port != null\">, port=#{port}</if>" +
"<if test=\"hostAddress != null\">, hostAddress=#{hostAddress}</if>" +
"<if test=\"online != null\">, online=#{online}</if>" +
"<if test=\"registerTime != null\">, registerTime=#{registerTime}</if>" +
"<if test=\"keepaliveTime != null\">, keepaliveTime=#{keepaliveTime}</if>" +
"<if test=\"keepaliveIntervalTime != null\">, keepaliveIntervalTime=#{keepaliveIntervalTime}</if>" +
"<if test=\"expires != null\">, expires=#{expires}</if>" +
"WHERE deviceId=#{deviceId}"+
" </script>"})
int update(Device device);
@Select("SELECT " +
@Select(
" <script>" +
"SELECT " +
"deviceId, " +
"coalesce(custom_name, name) as name, " +
"password, " +
@@ -150,8 +155,11 @@ public interface DeviceMapper {
"geoCoordSys," +
"treeType," +
"online," +
"(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de")
List<Device> getDevices();
"(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount FROM device de" +
"<if test=\"online != null\"> where online=${online}</if>"+
" </script>"
)
List<Device> getDevices(Boolean online);
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
int del(String deviceId);
@@ -217,28 +225,28 @@ public interface DeviceMapper {
"geoCoordSys," +
"treeType," +
"online" +
" FROM device WHERE ip = #{host} AND port=${port}")
" FROM device WHERE ip = #{host} AND port=#{port}")
Device getDeviceByHostAndPort(String host, int port);
@Update(value = {" <script>" +
"UPDATE device " +
"SET updateTime='${updateTime}'" +
"<if test=\"name != null\">, custom_name='${name}'</if>" +
"<if test=\"password != null\">, password='${password}'</if>" +
"<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
"<if test=\"ip != null\">, ip='${ip}'</if>" +
"<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
"<if test=\"port != null\">, port=${port}</if>" +
"<if test=\"charset != null\">, charset='${charset}'</if>" +
"<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
"<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
"<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" +
"<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
"<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
"SET updateTime=#{updateTime}" +
"<if test=\"name != null\">, custom_name=#{name}</if>" +
"<if test=\"password != null\">, password=#{password}</if>" +
"<if test=\"streamMode != null\">, streamMode=#{streamMode}</if>" +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
"<if test=\"port != null\">, port=#{port}</if>" +
"<if test=\"charset != null\">, charset=#{charset}</if>" +
"<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=#{subscribeCycleForCatalog}</if>" +
"<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=#{subscribeCycleForMobilePosition}</if>" +
"<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=#{mobilePositionSubmissionInterval}</if>" +
"<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=#{subscribeCycleForAlarm}</if>" +
"<if test=\"ssrcCheck != null\">, ssrcCheck=#{ssrcCheck}</if>" +
"<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
"<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
"<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
"WHERE deviceId='${deviceId}'"+
"WHERE deviceId=#{deviceId}"+
" </script>"})
int updateCustom(Device device);

View File

@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.*;
public interface DeviceMobilePositionMapper {
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime) " +
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, '${createTime}')")
"VALUES (#{deviceId},#{channelId}, #{deviceName}, #{time}, #{longitude}, #{latitude}, #{altitude}, #{speed}, #{direction}, #{reportSource}, #{longitudeGcj02}, #{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{createTime})")
int insertNewPosition(MobilePosition mobilePosition);
@Select(value = {" <script>" +

View File

@@ -16,9 +16,9 @@ public interface GbStreamMapper {
@Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, createTime) VALUES" +
"('${app}', '${stream}', '${gbId}', '${name}', " +
"'${longitude}', '${latitude}', '${streamType}', " +
"'${mediaServerId}', '${createTime}')")
"(#{app}, #{stream}, #{gbId}, #{name}, " +
"#{longitude}, #{latitude}, #{streamType}, " +
"#{mediaServerId}, #{createTime})")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
int add(GbStream gbStream);
@@ -57,7 +57,7 @@ public interface GbStreamMapper {
"(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId})</if> " +
" <if test='catalogId == null'> AND gs.gbStreamId not in" +
"(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " +
" <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='query != null'> AND (gs.app LIKE concat('%',#{query},'%') OR gs.stream LIKE concat('%',#{query},'%') OR gs.gbId LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
" order by gs.gbStreamId asc " +
"</script>")
@@ -71,7 +71,7 @@ public interface GbStreamMapper {
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
"LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " +
"WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
"WHERE gs.gbId = #{gbId} AND pgs.platformId = #{platformId}")
GbStream queryStreamInPlatform(String platformId, String gbId);
@Select("<script> "+
@@ -122,9 +122,9 @@ public interface GbStreamMapper {
"longitude, latitude, streamType, mediaServerId, createTime)" +
"values " +
"<foreach collection='subList' index='index' item='item' separator=','> " +
"('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
"'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
"'${item.mediaServerId}', '${item.createTime}') "+
"(#{item.app}, #{item.stream}, #{item.gbId}, #{item.name}, " +
"#{item.longitude}, #{item.latitude}, #{item.streamType}, " +
"#{item.mediaServerId}, #{item.createTime}) "+
"</foreach> " +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
@@ -134,7 +134,7 @@ public interface GbStreamMapper {
"<foreach collection='gpsMsgInfos' item='item' separator=';'>" +
" UPDATE" +
" gb_stream" +
" SET longitude=${item.lng}, latitude=${item.lat} " +
" SET longitude=#{item.lng}, latitude=#{item.lat} " +
"WHERE gbId=#{item.id}"+
"</foreach>" +
"</script>"})

View File

@@ -18,16 +18,16 @@ import java.util.List;
public interface LogMapper {
@Insert("insert into log ( name, type, uri, address, result, timing, username, createTime) " +
"values ('${name}', '${type}', '${uri}', '${address}', '${result}', ${timing}, '${username}', '${createTime}')")
"values (#{name}, #{type}, #{uri}, #{address}, #{result}, #{timing}, #{username}, #{createTime})")
int add(LogDto logDto);
@Select(value = {"<script>" +
" SELECT * FROM log " +
" WHERE 1=1 " +
" <if test=\"query != null\"> AND (name LIKE '%${query}%')</if> " +
" <if test=\"type != null\" > AND type = '${type}'</if>" +
" <if test=\"startTime != null\" > AND createTime &gt;= '${startTime}' </if>" +
" <if test=\"endTime != null\" > AND createTime &lt;= '${endTime}' </if>" +
" <if test=\"query != null\"> AND (name LIKE concat('%',#{query},'%'))</if> " +
" <if test=\"type != null\" > AND type = #{type}</if>" +
" <if test=\"startTime != null\" > AND createTime &gt;= #{startTime} </if>" +
" <if test=\"endTime != null\" > AND createTime &lt;= #{endTime} </if>" +
" ORDER BY createTime DESC " +
" </script>"})
List<LogDto> query(String query, String type, String startTime, String endTime);

View File

@@ -35,92 +35,92 @@ public interface MediaServerMapper {
"hookAliveInterval" +
") VALUES " +
"(" +
"'${id}', " +
"'${ip}', " +
"'${hookIp}', " +
"'${sdpIp}', " +
"'${streamIp}', " +
"${httpPort}, " +
"${httpSSlPort}, " +
"${rtmpPort}, " +
"${rtmpSSlPort}, " +
"${rtpProxyPort}, " +
"${rtspPort}, " +
"${rtspSSLPort}, " +
"${autoConfig}, " +
"'${secret}', " +
"${rtpEnable}, " +
"'${rtpPortRange}', " +
"${recordAssistPort}, " +
"${defaultServer}, " +
"'${createTime}', " +
"'${updateTime}', " +
"${hookAliveInterval})")
"#{id}, " +
"#{ip}, " +
"#{hookIp}, " +
"#{sdpIp}, " +
"#{streamIp}, " +
"#{httpPort}, " +
"#{httpSSlPort}, " +
"#{rtmpPort}, " +
"#{rtmpSSlPort}, " +
"#{rtpProxyPort}, " +
"#{rtspPort}, " +
"#{rtspSSLPort}, " +
"#{autoConfig}, " +
"#{secret}, " +
"#{rtpEnable}, " +
"#{rtpPortRange}, " +
"#{recordAssistPort}, " +
"#{defaultServer}, " +
"#{createTime}, " +
"#{updateTime}, " +
"#{hookAliveInterval})")
int add(MediaServerItem mediaServerItem);
@Update(value = {" <script>" +
"UPDATE media_server " +
"SET updateTime='${updateTime}'" +
"<if test=\"ip != null\">, ip='${ip}'</if>" +
"<if test=\"hookIp != null\">, hookIp='${hookIp}'</if>" +
"<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
"<if test=\"streamIp != null\">, streamIp='${streamIp}'</if>" +
"<if test=\"httpPort != null\">, httpPort=${httpPort}</if>" +
"<if test=\"httpSSlPort != null\">, httpSSlPort=${httpSSlPort}</if>" +
"<if test=\"rtmpPort != null\">, rtmpPort=${rtmpPort}</if>" +
"<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=${rtmpSSlPort}</if>" +
"<if test=\"rtpProxyPort != null\">, rtpProxyPort=${rtpProxyPort}</if>" +
"<if test=\"rtspPort != null\">, rtspPort=${rtspPort}</if>" +
"<if test=\"rtspSSLPort != null\">, rtspSSLPort=${rtspSSLPort}</if>" +
"<if test=\"autoConfig != null\">, autoConfig=${autoConfig}</if>" +
"<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" +
"<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" +
"<if test=\"secret != null\">, secret='${secret}'</if>" +
"<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" +
"<if test=\"hookAliveInterval != null\">, hookAliveInterval=${hookAliveInterval}</if>" +
"WHERE id='${id}'"+
"SET updateTime=#{updateTime}" +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"hookIp != null\">, hookIp=#{hookIp}</if>" +
"<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
"<if test=\"streamIp != null\">, streamIp=#{streamIp}</if>" +
"<if test=\"httpPort != null\">, httpPort=#{httpPort}</if>" +
"<if test=\"httpSSlPort != null\">, httpSSlPort=#{httpSSlPort}</if>" +
"<if test=\"rtmpPort != null\">, rtmpPort=#{rtmpPort}</if>" +
"<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=#{rtmpSSlPort}</if>" +
"<if test=\"rtpProxyPort != null\">, rtpProxyPort=#{rtpProxyPort}</if>" +
"<if test=\"rtspPort != null\">, rtspPort=#{rtspPort}</if>" +
"<if test=\"rtspSSLPort != null\">, rtspSSLPort=#{rtspSSLPort}</if>" +
"<if test=\"autoConfig != null\">, autoConfig=#{autoConfig}</if>" +
"<if test=\"rtpEnable != null\">, rtpEnable=#{rtpEnable}</if>" +
"<if test=\"rtpPortRange != null\">, rtpPortRange=#{rtpPortRange}</if>" +
"<if test=\"secret != null\">, secret=#{secret}</if>" +
"<if test=\"recordAssistPort != null\">, recordAssistPort=#{recordAssistPort}</if>" +
"<if test=\"hookAliveInterval != null\">, hookAliveInterval=#{hookAliveInterval}</if>" +
"WHERE id=#{id}"+
" </script>"})
int update(MediaServerItem mediaServerItem);
@Update(value = {" <script>" +
"UPDATE media_server " +
"SET updateTime='${updateTime}'" +
"<if test=\"id != null\">, id='${id}'</if>" +
"<if test=\"hookIp != null\">, hookIp='${hookIp}'</if>" +
"<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
"<if test=\"streamIp != null\">, streamIp='${streamIp}'</if>" +
"<if test=\"httpSSlPort != null\">, httpSSlPort=${httpSSlPort}</if>" +
"<if test=\"rtmpPort != null\">, rtmpPort=${rtmpPort}</if>" +
"<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=${rtmpSSlPort}</if>" +
"<if test=\"rtpProxyPort != null\">, rtpProxyPort=${rtpProxyPort}</if>" +
"<if test=\"rtspPort != null\">, rtspPort=${rtspPort}</if>" +
"<if test=\"rtspSSLPort != null\">, rtspSSLPort=${rtspSSLPort}</if>" +
"<if test=\"autoConfig != null\">, autoConfig=${autoConfig}</if>" +
"<if test=\"rtpEnable != null\">, rtpEnable=${rtpEnable}</if>" +
"<if test=\"rtpPortRange != null\">, rtpPortRange='${rtpPortRange}'</if>" +
"<if test=\"secret != null\">, secret='${secret}'</if>" +
"<if test=\"recordAssistPort != null\">, recordAssistPort=${recordAssistPort}</if>" +
"<if test=\"hookAliveInterval != null\">, hookAliveInterval=${hookAliveInterval}</if>" +
"WHERE ip='${ip}' and httpPort=${httpPort}"+
"SET updateTime=#{updateTime}" +
"<if test=\"id != null\">, id=#{id}</if>" +
"<if test=\"hookIp != null\">, hookIp=#{hookIp}</if>" +
"<if test=\"sdpIp != null\">, sdpIp=#{sdpIp}</if>" +
"<if test=\"streamIp != null\">, streamIp=#{streamIp}</if>" +
"<if test=\"httpSSlPort != null\">, httpSSlPort=#{httpSSlPort}</if>" +
"<if test=\"rtmpPort != null\">, rtmpPort=#{rtmpPort}</if>" +
"<if test=\"rtmpSSlPort != null\">, rtmpSSlPort=#{rtmpSSlPort}</if>" +
"<if test=\"rtpProxyPort != null\">, rtpProxyPort=#{rtpProxyPort}</if>" +
"<if test=\"rtspPort != null\">, rtspPort=#{rtspPort}</if>" +
"<if test=\"rtspSSLPort != null\">, rtspSSLPort=#{rtspSSLPort}</if>" +
"<if test=\"autoConfig != null\">, autoConfig=#{autoConfig}</if>" +
"<if test=\"rtpEnable != null\">, rtpEnable=#{rtpEnable}</if>" +
"<if test=\"rtpPortRange != null\">, rtpPortRange=#{rtpPortRange}</if>" +
"<if test=\"secret != null\">, secret=#{secret}</if>" +
"<if test=\"recordAssistPort != null\">, recordAssistPort=#{recordAssistPort}</if>" +
"<if test=\"hookAliveInterval != null\">, hookAliveInterval=#{hookAliveInterval}</if>" +
"WHERE ip=#{ip} and httpPort=#{httpPort}"+
" </script>"})
int updateByHostAndPort(MediaServerItem mediaServerItem);
@Select("SELECT * FROM media_server WHERE id='${id}'")
@Select("SELECT * FROM media_server WHERE id=#{id}")
MediaServerItem queryOne(String id);
@Select("SELECT * FROM media_server")
List<MediaServerItem> queryAll();
@Delete("DELETE FROM media_server WHERE id='${id}'")
@Delete("DELETE FROM media_server WHERE id=#{id}")
void delOne(String id);
@Select("DELETE FROM media_server WHERE ip='${host}' and httpPort=${port}")
@Select("DELETE FROM media_server WHERE ip=#{host} and httpPort=#{port}")
void delOneByIPAndPort(String host, int port);
@Delete("DELETE FROM media_server WHERE defaultServer=1")
int delDefault();
@Select("SELECT * FROM media_server WHERE ip='${host}' and httpPort=${port}")
@Select("SELECT * FROM media_server WHERE ip=#{host} and httpPort=#{port}")
MediaServerItem queryOneByHostAndPort(String host, int port);
@Select("SELECT * FROM media_server WHERE defaultServer=1")

View File

@@ -17,9 +17,9 @@ public interface ParentPlatformMapper {
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
" status, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " +
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
" ${status}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
" VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
" #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, " +
" #{status}, #{startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE parent_platform " +
@@ -41,7 +41,7 @@ public interface ParentPlatformMapper {
"ptz=#{ptz}, " +
"rtcp=#{rtcp}, " +
"status=#{status}, " +
"startOfflinePush=${startOfflinePush}, " +
"startOfflinePush=#{startOfflinePush}, " +
"catalogGroup=#{catalogGroup}, " +
"administrativeDivision=#{administrativeDivision}, " +
"createTime=#{createTime}, " +

View File

@@ -21,22 +21,22 @@ public interface PlatformChannelMapper {
* 查询列表里已经关联的
*/
@Select("<script> "+
"SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
"<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" +
"SELECT deviceChannelId FROM platform_gb_channel WHERE platformId=#{platformId} AND deviceChannelId in" +
"<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> #{item.id}</foreach>" +
"</script>")
List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces);
@Insert("<script> "+
"INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" +
"<foreach collection='channelReducesToAdd' item='item' separator=','>" +
" ('${platformId}', '${item.id}' , '${item.catalogId}' )" +
" (#{platformId}, #{item.id} , #{item.catalogId} )" +
"</foreach>" +
"</script>")
int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd);
@Delete("<script> "+
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" +
"DELETE FROM platform_gb_channel WHERE platformId=#{platformId} AND deviceChannelId in" +
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
"</script>")
int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
@@ -50,14 +50,14 @@ public interface PlatformChannelMapper {
int delChannelForDeviceId(String deviceId);
@Delete("<script> "+
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}'" +
"DELETE FROM platform_gb_channel WHERE platformId=#{platformId}" +
"</script>")
int cleanChannelForGB(String platformId);
@Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'")
@Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId=#{channelId} and pgc.platformId=#{platformId}")
List<DeviceChannel> queryChannelInParentPlatform(String platformId, String channelId);
@Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE pgc.platformId='${platformId}' and pgc.catalogId=#{catalogId}")
@Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}")
List<DeviceChannel> queryAllChannelInCatalog(String platformId, String catalogId);
@Select(" select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " +

View File

@@ -26,7 +26,7 @@ public interface PlatformGbStreamMapper {
"(gbStreamId, platformId, catalogId) " +
"values " +
"<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
"(${item.gbStreamId}, '${item.platformId}', '${item.catalogId}')" +
"(#{item.gbStreamId}, #{item.platformId}, #{item.catalogId})" +
"</foreach> " +
"</script>")
int batchAdd(List<StreamPushItem> streamPushItems);

View File

@@ -14,10 +14,10 @@ import java.util.List;
public interface RecordInfoDao {
@Insert("INSERT INTO recordInfo (app, stream, mediaServerId, createTime, type, deviceId, channelId, name) VALUES" +
"('${app}', '${stream}', '${mediaServerId}', datetime('now','localtime')), '${type}', '${deviceId}', '${channelId}', '${name}'")
"(#{app}, #{stream}, #{mediaServerId}, datetime('now','localtime')), #{type}, #{deviceId}, #{channelId}, #{name}")
int add(RecordInfo recordInfo);
@Delete("DELETE FROM user WHERE createTime < '${beforeTime}'")
@Delete("DELETE FROM user WHERE createTime < #{beforeTime}")
int deleteBefore(String beforeTime);
@Select("select * FROM recordInfo")

View File

@@ -12,14 +12,14 @@ import java.util.List;
public interface RoleMapper {
@Insert("INSERT INTO user_role (name, authority, createTime, updateTime) VALUES" +
"('${name}', '${authority}', '${createTime}', '${updateTime}')")
"(#{name}, #{authority}, #{createTime}, #{updateTime})")
int add(Role role);
@Update(value = {" <script>" +
"UPDATE user_role " +
"SET updateTime='${updateTime}' " +
"<if test=\"name != null\">, name='${name}'</if>" +
"<if test=\"authority != null\">, authority='${authority}'</if>" +
"SET updateTime=#{updateTime} " +
"<if test=\"name != null\">, name=#{name}</if>" +
"<if test=\"authority != null\">, authority=#{authority}</if>" +
"WHERE id != 1 and id=#{id}" +
" </script>"})
int update(Role role);

View File

@@ -13,9 +13,9 @@ public interface StreamProxyMapper {
@Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " +
"timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" +
"('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " +
"'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_audio}, ${enable_mp4}, ${enable}, ${status}, " +
"${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )")
"(#{type}, #{name}, #{app}, #{stream}, #{mediaServerId}, #{url}, #{src_url}, #{dst_url}, " +
"#{timeout_ms}, #{ffmpeg_cmd_key}, #{rtp_type}, #{enable_audio}, #{enable_mp4}, #{enable}, #{status}, " +
"#{enable_remove_none_reader}, #{enable_disable_none_reader}, #{createTime} )")
int add(StreamProxyItem streamProxyDto);
@Update("UPDATE stream_proxy " +
@@ -45,7 +45,7 @@ public interface StreamProxyMapper {
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.createTime desc")
List<StreamProxyItem> selectAll();
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable} order by st.createTime desc")
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=#{enable} order by st.createTime desc")
List<StreamProxyItem> selectForEnable(boolean enable);
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream} order by st.createTime desc")
@@ -53,12 +53,12 @@ public interface StreamProxyMapper {
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st " +
"LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
"WHERE st.enable=${enable} and st.mediaServerId = #{id} order by st.createTime desc")
"WHERE st.enable=#{enable} and st.mediaServerId = #{id} order by st.createTime desc")
List<StreamProxyItem> selectForEnableInMediaServer(String id, boolean enable);
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st " +
"LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
"WHERE st.mediaServerId = '${id}' order by st.createTime desc")
"WHERE st.mediaServerId = #{id} order by st.createTime desc")
List<StreamProxyItem> selectInMediaServer(String id);
@Update("UPDATE stream_proxy " +
@@ -67,7 +67,7 @@ public interface StreamProxyMapper {
void updateStatusByMediaServerId(String mediaServerId, boolean status);
@Update("UPDATE stream_proxy " +
"SET status=${status} " +
"SET status=#{status} " +
"WHERE app=#{app} AND stream=#{stream}")
int updateStatus(String app, String stream, boolean status);

View File

@@ -17,23 +17,23 @@ public interface StreamPushMapper {
@Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"pushTime, aliveSecond, mediaServerId, serverId, updateTime, createTime, pushIng, self) VALUES" +
"('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
"'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}', " +
"${pushIng}, ${self} )")
"(#{app}, #{stream}, #{totalReaderCount}, #{originType}, #{originTypeStr}, " +
"#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{serverId} , #{updateTime} , #{createTime}, " +
"#{pushIng}, #{self} )")
int add(StreamPushItem streamPushItem);
@Update(value = {" <script>" +
"UPDATE stream_push " +
"SET updateTime='${updateTime}'" +
"<if test=\"mediaServerId != null\">, mediaServerId='${mediaServerId}'</if>" +
"<if test=\"totalReaderCount != null\">, totalReaderCount='${totalReaderCount}'</if>" +
"<if test=\"originType != null\">, originType=${originType}</if>" +
"<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" +
"<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" +
"<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" +
"<if test=\"pushIng != null\">, pushIng=${pushIng}</if>" +
"<if test=\"self != null\">, self=${self}</if>" +
"SET updateTime=#{updateTime}" +
"<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
"<if test=\"totalReaderCount != null\">, totalReaderCount=#{totalReaderCount}</if>" +
"<if test=\"originType != null\">, originType=#{originType}</if>" +
"<if test=\"originTypeStr != null\">, originTypeStr=#{originTypeStr}</if>" +
"<if test=\"pushTime != null\">, pushTime=#{pushTime}</if>" +
"<if test=\"aliveSecond != null\">, aliveSecond=#{aliveSecond}</if>" +
"<if test=\"pushIng != null\">, pushIng=#{pushIng}</if>" +
"<if test=\"self != null\">, self=#{self}</if>" +
"WHERE app=#{app} AND stream=#{stream}"+
" </script>"})
int update(StreamPushItem streamPushItem);
@@ -76,7 +76,7 @@ public interface StreamPushMapper {
"on st.app = gs.app AND st.stream = gs.stream " +
"WHERE " +
"1=1 " +
" <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') OR st.stream LIKE concat('%',#{query},'%') OR gs.gbId LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='pushing == true' > AND (gs.gbId is null OR st.pushIng=1)</if>" +
" <if test='pushing == false' > AND (st.pushIng is null OR st.pushIng=0) </if>" +
" <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" +
@@ -94,9 +94,9 @@ public interface StreamPushMapper {
"Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createTime, aliveSecond, mediaServerId, status, pushIng) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
"'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} ," +
" ${item.pushIng} )" +
"( #{item.app}, #{item.stream}, #{item.totalReaderCount}, #{item.originType}, " +
"#{item.originTypeStr},#{item.createTime}, #{item.aliveSecond}, #{item.mediaServerId}, #{item.status} ," +
" #{item.pushIng} )" +
" </foreach>" +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@@ -115,12 +115,12 @@ public interface StreamPushMapper {
List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
@Update("UPDATE stream_push " +
"SET status=${status} " +
"SET status=#{status} " +
"WHERE app=#{app} AND stream=#{stream}")
int updateStatus(String app, String stream, boolean status);
@Update("UPDATE stream_push " +
"SET pushIng=${pushIng} " +
"SET pushIng=#{pushIng} " +
"WHERE app=#{app} AND stream=#{stream}")
int updatePushStatus(String app, String stream, boolean pushIng);

View File

@@ -11,16 +11,16 @@ import java.util.List;
public interface UserMapper {
@Insert("INSERT INTO user (username, password, roleId, pushKey, createTime, updateTime) VALUES" +
"('${username}', '${password}', '${role.id}', '${pushKey}', '${createTime}', '${updateTime}')")
"(#{username}, #{password}, #{role.id}, #{pushKey}, #{createTime}, #{updateTime})")
int add(User user);
@Update(value = {" <script>" +
"UPDATE user " +
"SET updateTime='${updateTime}' " +
"<if test=\"pushKey != null\">, pushKey='${pushKey}'</if>" +
"<if test=\"role != null\">, roleId='${role.id}'</if>" +
"<if test=\"password != null\">, password='${password}'</if>" +
"<if test=\"username != null\">, username='${username}'</if>" +
"SET updateTime=#{updateTime} " +
"<if test=\"pushKey != null\">, pushKey=#{pushKey}</if>" +
"<if test=\"role != null\">, roleId=#{role.id}</if>" +
"<if test=\"password != null\">, password=#{password}</if>" +
"<if test=\"username != null\">, username=#{username}</if>" +
"WHERE id=#{id}" +
" </script>"})
int update(User user);
@@ -50,10 +50,10 @@ public interface UserMapper {
@ResultMap(value="roleMap")
List<User> selectAll();
@Select("select * from (select user.*, concat('${callId}_', pushKey) as str1 from user) as u where md5(u.str1) = '${sign}'")
@Select("select * from (select user.*, concat(concat(#{callId}, '_'), pushKey) as str1 from user) as u where md5(u.str1) = #{sign}")
List<User> checkPushAuthorityByCallIdAndSign(String callId, String sign);
@Select("select * from user where md5(pushKey) = '${sign}'")
@Select("select * from user where md5(pushKey) = #{sign}")
List<User> checkPushAuthorityByCallId(String sign);
@Select("select u.id, u.username,u.pushKey,u.roleId, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u join user_role r on u.roleId=r.id")

View File

@@ -224,31 +224,31 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
PageHelper.startPage(page, count);
List<DeviceChannel> all;
if (catalogUnderDevice != null && catalogUnderDevice) {
all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online);
all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null);
// 海康设备的parentId是SIP id
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online);
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null);
all.addAll(deviceChannels);
}else {
all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online);
all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online,null);
}
return new PageInfo<>(all);
}
@Override
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit);
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds);
}
@Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
return deviceChannelMapper.queryChannels(deviceId, null,null, null, null);
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds) {
return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds);
}
@Override
public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online);
List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null);
return new PageInfo<>(all);
}
@@ -271,9 +271,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @return PageInfo<Device> 分页设备对象数组
*/
@Override
public PageInfo<Device> queryVideoDeviceList(int page, int count) {
public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online) {
PageHelper.startPage(page, count);
List<Device> all = deviceMapper.getDevices();
List<Device> all = deviceMapper.getDevices(online);
return new PageInfo<>(all);
}
@@ -283,9 +283,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @return List<Device> 设备对象数组
*/
@Override
public List<Device> queryVideoDeviceList() {
public List<Device> queryVideoDeviceList(Boolean online) {
List<Device> deviceList = deviceMapper.getDevices();
List<Device> deviceList = deviceMapper.getDevices(online);
return deviceList;
}

View File

@@ -1,14 +1,13 @@
package com.genersoft.iot.vmp.utils.redis;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
import gov.nist.javax.sip.stack.UDPMessageChannel;
import org.springframework.data.redis.core.*;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Redis工具类
* @author swwheihei

View File

@@ -1,9 +1,5 @@
package com.genersoft.iot.vmp.vmanager.bean;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
/**
* @author lin
*/
@@ -11,7 +7,7 @@ public class AudioBroadcastResult {
/**
* 推流的各个方式流地址
*/
private StreamInfo streamInfo;
private StreamContent streamInfo;
/**
* 编码格式
@@ -29,11 +25,11 @@ public class AudioBroadcastResult {
private String stream;
public StreamInfo getStreamInfo() {
public StreamContent getStreamInfo() {
return streamInfo;
}
public void setStreamInfo(StreamInfo streamInfo) {
public void setStreamInfo(StreamContent streamInfo) {
this.streamInfo = streamInfo;
}

View File

@@ -1,7 +1,5 @@
package com.genersoft.iot.vmp.vmanager.bean;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 全局错误码
*/
@@ -9,6 +7,7 @@ public enum ErrorCode {
SUCCESS(0, "成功"),
ERROR100(100, "失败"),
ERROR400(400, "参数不全或者错误"),
ERROR404(404, "资源未找到"),
ERROR403(403, "无权限操作"),
ERROR401(401, "请登录后重新请求"),
ERROR500(500, "系统异常");

View File

@@ -0,0 +1,358 @@
package com.genersoft.iot.vmp.vmanager.bean;
import com.genersoft.iot.vmp.common.StreamInfo;
public class StreamContent {
private String app;
private String stream;
private String ip;
private String flv;
private String https_flv;
private String ws_flv;
private String wss_flv;
private String fmp4;
private String https_fmp4;
private String ws_fmp4;
private String wss_fmp4;
private String hls;
private String https_hls;
private String ws_hls;
private String wss_hls;
private String ts;
private String https_ts;
private String ws_ts;
private String wss_ts;
private String rtmp;
private String rtmps;
private String rtsp;
private String rtsps;
private String rtc;
private String rtcs;
private String mediaServerId;
private Object tracks;
private String startTime;
private String endTime;
private double progress;
public StreamContent(StreamInfo streamInfo) {
if (streamInfo == null) {
return;
}
this.app = streamInfo.getApp();
this.stream = streamInfo.getStream();
if (streamInfo.getFlv() != null) {
this.flv = streamInfo.getFlv().getUrl();
}
if (streamInfo.getHttps_flv() != null) {
this.https_flv = streamInfo.getHttps_flv().getUrl();
}
if (streamInfo.getWs_flv() != null) {
this.ws_flv = streamInfo.getWs_flv().getUrl();
}
if (streamInfo.getWss_flv() != null) {
this.wss_flv = streamInfo.getWss_flv().getUrl();
}
if (streamInfo.getFmp4() != null) {
this.fmp4 = streamInfo.getFmp4().getUrl();
}
if (streamInfo.getWs_fmp4() != null) {
this.ws_fmp4 = streamInfo.getWs_fmp4().getUrl();
}
if (streamInfo.getWss_fmp4() != null) {
this.wss_fmp4 = streamInfo.getWss_fmp4().getUrl();
}
if (streamInfo.getHls() != null) {
this.hls = streamInfo.getHls().getUrl();
}
if (streamInfo.getHttps_hls() != null) {
this.https_hls = streamInfo.getHttps_hls().getUrl();
}
if (streamInfo.getWs_hls() != null) {
this.ws_hls = streamInfo.getWs_hls().getUrl();
}
if (streamInfo.getWss_hls() != null) {
this.wss_hls = streamInfo.getWss_hls().getUrl();
}
if (streamInfo.getTs() != null) {
this.ts = streamInfo.getTs().getUrl();
}
if (streamInfo.getHttps_ts() != null) {
this.https_ts = streamInfo.getHttps_ts().getUrl();
}
if (streamInfo.getWs_ts() != null) {
this.ws_ts = streamInfo.getWs_ts().getUrl();
}
if (streamInfo.getRtmp() != null) {
this.rtmp = streamInfo.getRtmp().getUrl();
}
if (streamInfo.getRtmps() != null) {
this.rtmps = streamInfo.getRtmps().getUrl();
}
if (streamInfo.getRtsp() != null) {
this.rtsp = streamInfo.getRtsp().getUrl();
}
if (streamInfo.getRtsps() != null) {
this.rtsps = streamInfo.getRtsps().getUrl();
}
if (streamInfo.getRtc() != null) {
this.rtc = streamInfo.getRtc().getUrl();
}
if (streamInfo.getRtcs() != null) {
this.rtcs = streamInfo.getRtcs().getUrl();
}
this.mediaServerId = streamInfo.getMediaServerId();
this.tracks = streamInfo.getTracks();
this.startTime = streamInfo.getStartTime();
this.endTime = streamInfo.getEndTime();
this.progress = streamInfo.getProgress();
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getFlv() {
return flv;
}
public void setFlv(String flv) {
this.flv = flv;
}
public String getHttps_flv() {
return https_flv;
}
public void setHttps_flv(String https_flv) {
this.https_flv = https_flv;
}
public String getWs_flv() {
return ws_flv;
}
public void setWs_flv(String ws_flv) {
this.ws_flv = ws_flv;
}
public String getWss_flv() {
return wss_flv;
}
public void setWss_flv(String wss_flv) {
this.wss_flv = wss_flv;
}
public String getFmp4() {
return fmp4;
}
public void setFmp4(String fmp4) {
this.fmp4 = fmp4;
}
public String getHttps_fmp4() {
return https_fmp4;
}
public void setHttps_fmp4(String https_fmp4) {
this.https_fmp4 = https_fmp4;
}
public String getWs_fmp4() {
return ws_fmp4;
}
public void setWs_fmp4(String ws_fmp4) {
this.ws_fmp4 = ws_fmp4;
}
public String getWss_fmp4() {
return wss_fmp4;
}
public void setWss_fmp4(String wss_fmp4) {
this.wss_fmp4 = wss_fmp4;
}
public String getHls() {
return hls;
}
public void setHls(String hls) {
this.hls = hls;
}
public String getHttps_hls() {
return https_hls;
}
public void setHttps_hls(String https_hls) {
this.https_hls = https_hls;
}
public String getWs_hls() {
return ws_hls;
}
public void setWs_hls(String ws_hls) {
this.ws_hls = ws_hls;
}
public String getWss_hls() {
return wss_hls;
}
public void setWss_hls(String wss_hls) {
this.wss_hls = wss_hls;
}
public String getTs() {
return ts;
}
public void setTs(String ts) {
this.ts = ts;
}
public String getHttps_ts() {
return https_ts;
}
public void setHttps_ts(String https_ts) {
this.https_ts = https_ts;
}
public String getWs_ts() {
return ws_ts;
}
public void setWs_ts(String ws_ts) {
this.ws_ts = ws_ts;
}
public String getWss_ts() {
return wss_ts;
}
public void setWss_ts(String wss_ts) {
this.wss_ts = wss_ts;
}
public String getRtmp() {
return rtmp;
}
public void setRtmp(String rtmp) {
this.rtmp = rtmp;
}
public String getRtmps() {
return rtmps;
}
public void setRtmps(String rtmps) {
this.rtmps = rtmps;
}
public String getRtsp() {
return rtsp;
}
public void setRtsp(String rtsp) {
this.rtsp = rtsp;
}
public String getRtsps() {
return rtsps;
}
public void setRtsps(String rtsps) {
this.rtsps = rtsps;
}
public String getRtc() {
return rtc;
}
public void setRtc(String rtc) {
this.rtc = rtc;
}
public String getRtcs() {
return rtcs;
}
public void setRtcs(String rtcs) {
this.rtcs = rtcs;
}
public String getMediaServerId() {
return mediaServerId;
}
public void setMediaServerId(String mediaServerId) {
this.mediaServerId = mediaServerId;
}
public Object getTracks() {
return tracks;
}
public void setTracks(Object tracks) {
this.tracks = tracks;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public double getProgress() {
return progress;
}
public void setProgress(double progress) {
this.progress = progress;
}
}

View File

@@ -14,7 +14,6 @@ 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.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -22,10 +21,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -130,15 +127,14 @@ public class DeviceControl {
*/
@Operation(summary = "布防/撤防命令")
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "guardCmdStr", description = "命令, 可选值SetGuard布防ResetGuard撤防", required = true)
@GetMapping("/guard/{deviceId}/{guardCmdStr}")
public DeferredResult<String> guardApi(@PathVariable String deviceId, String channelId, @PathVariable String guardCmdStr) {
public DeferredResult<String> guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) {
if (logger.isDebugEnabled()) {
logger.debug("布防/撤防API调用");
}
Device device = storager.queryVideoDevice(deviceId);
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId;
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId;
String uuid =UUID.randomUUID().toString();
try {
cmder.guardCmd(device, guardCmdStr, event -> {

View File

@@ -99,7 +99,7 @@ public class DeviceQuery {
@GetMapping("/devices")
public PageInfo<Device> devices(int page, int count){
return storager.queryVideoDeviceList(page, count);
return storager.queryVideoDeviceList(page, count,null);
}
/**

View File

@@ -5,11 +5,11 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -53,11 +53,11 @@ public class MediaController {
@Parameter(name = "useSourceIpAsStreamIp", description = "是否使用请求IP作为返回的地址IP")
@GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody
public StreamInfo getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId,
@RequestParam(required = false) String callId,
@RequestParam(required = false) Boolean useSourceIpAsStreamIp){
public StreamContent getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId,
@RequestParam(required = false) String callId,
@RequestParam(required = false) Boolean useSourceIpAsStreamIp){
boolean authority = false;
if (callId != null) {
// 权限校验
@@ -88,9 +88,8 @@ public class MediaController {
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfo != null){
return streamInfo;
return new StreamContent(streamInfo);
}else {
//获取流失败,重启拉流后重试一次
streamProxyService.stop(app,stream);
@@ -109,7 +108,7 @@ public class MediaController {
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
if (streamInfo != null){
return streamInfo;
return new StreamContent(streamInfo);
}else {
throw new ControllerException(ErrorCode.ERROR100);
}

View File

@@ -22,6 +22,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -85,8 +86,8 @@ public class PlayController {
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId,
@PathVariable String channelId) {
public DeferredResult<WVPResult<StreamContent>> play(HttpServletRequest request, @PathVariable String deviceId,
@PathVariable String channelId) {
// 获取可用的zlm
Device device = storager.queryVideoDevice(deviceId);
@@ -98,8 +99,8 @@ public class PlayController {
msg.setKey(key);
String uuid = UUID.randomUUID().toString();
msg.setId(uuid);
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
DeferredResultEx<WVPResult<StreamInfo>> deferredResultEx = new DeferredResultEx<>(result);
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
DeferredResultEx<WVPResult<StreamContent>> deferredResultEx = new DeferredResultEx<>(result);
result.onTimeout(()->{
logger.info("点播接口等待超时");
@@ -110,25 +111,22 @@ public class PlayController {
msg.setData(wvpResult);
resultHolder.invokeResult(msg);
});
if (userSetting.getUseSourceIpAsStreamIp()) {
// TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
deferredResultEx.setFilter(result1 -> {
WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
WVPResult<StreamInfo> clone = null;
try {
clone = (WVPResult<StreamInfo>)wvpResult1.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
if (clone.getCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo data = clone.getData().clone();
// TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
deferredResultEx.setFilter(result1 -> {
WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
WVPResult<StreamContent> resultStream = new WVPResult<>();
resultStream.setCode(wvpResult1.getCode());
resultStream.setMsg(wvpResult1.getMsg());
if (wvpResult1.getCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo data = wvpResult1.getData().clone();
if (userSetting.getUseSourceIpAsStreamIp()) {
data.channgeStreamIp(request.getLocalName());
clone.setData(data);
}
return clone;
});
}
resultStream.setData(new StreamContent(wvpResult1.getData()));
}
return resultStream;
});
// 录像查询以channelId作为deviceId查询
resultHolder.put(key, uuid, deferredResultEx);
@@ -273,7 +271,7 @@ public class PlayController {
@GetMapping("/1111")
public void broadcastApi1() {
MediaServerItem defaultMediaServer = mediaServerService.getMediaServerForMinimumLoad();
MediaServerItem defaultMediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
Device device = storager.queryVideoDevice("34020000001320090001");
playService.talk(defaultMediaServer, device, "34020000001370000001", null, null, null);

View File

@@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -32,6 +33,7 @@ import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.UUID;
/**
* @author lin
@@ -68,24 +70,37 @@ public class PlaybackController {
@Parameter(name = "startTime", description = "开始时间", required = true)
@Parameter(name = "endTime", description = "结束时间", required = true)
@GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime) {
public DeferredResult<WVPResult<StreamContent>> play(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备回放 API调用deviceId%s channelId%s", deviceId, channelId));
}
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(30000L);
resultHolder.put(key, uuid, result);
return playService.playBack(deviceId, channelId, startTime, endTime, null,
WVPResult<StreamContent> wvpResult = new WVPResult<>();
RequestMessage msg = new RequestMessage();
msg.setKey(key);
msg.setId(uuid);
playService.playBack(deviceId, channelId, startTime, endTime, null,
playBackResult->{
if (playBackResult.getCode() != ErrorCode.SUCCESS.getCode()) {
RequestMessage data = playBackResult.getData();
data.setData(WVPResult.fail(playBackResult.getCode(), playBackResult.getMsg()));
resultHolder.invokeResult(data);
}else {
resultHolder.invokeResult(playBackResult.getData());
wvpResult.setCode(playBackResult.getCode());
wvpResult.setMsg(playBackResult.getMsg());
if (playBackResult.getCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo streamInfo = (StreamInfo)playBackResult.getData();
wvpResult.setData(new StreamContent(streamInfo));
}
msg.setData(wvpResult);
resultHolder.invokeResult(msg);
});
return result;
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
@@ -121,15 +122,33 @@ public class GBRecordController {
@Parameter(name = "endTime", description = "结束时间", required = true)
@Parameter(name = "downloadSpeed", description = "下载倍速", required = true)
@GetMapping("/download/start/{deviceId}/{channelId}")
public DeferredResult<WVPResult<StreamInfo>> download(@PathVariable String deviceId, @PathVariable String channelId,
public DeferredResult<WVPResult<StreamContent>> download(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime, String downloadSpeed) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("历史媒体下载 API调用deviceId%schannelId%sdownloadSpeed%s", deviceId, channelId, downloadSpeed));
}
DeferredResult<WVPResult<StreamInfo>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{
resultHolder.invokeResult(hookCallBack.getData());
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(30000L);
resultHolder.put(key, uuid, result);
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
msg.setKey(key);
WVPResult<StreamContent> wvpResult = new WVPResult<>();
playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, playBackResult->{
wvpResult.setCode(playBackResult.getCode());
wvpResult.setMsg(playBackResult.getMsg());
if (playBackResult.getCode() == ErrorCode.SUCCESS.getCode()) {
StreamInfo streamInfo = (StreamInfo)playBackResult.getData();
wvpResult.setData(new StreamContent(streamInfo));
}
msg.setData(wvpResult);
resultHolder.invokeResult(msg);
});
return result;
@@ -168,7 +187,11 @@ public class GBRecordController {
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/download/progress/{deviceId}/{channelId}/{stream}")
public StreamInfo getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
return playService.getDownLoadInfo(deviceId, channelId, stream);
public StreamContent getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
StreamInfo downLoadInfo = playService.getDownLoadInfo(deviceId, channelId, stream);
if (downLoadInfo == null) {
throw new ControllerException(ErrorCode.ERROR404);
}
return new StreamContent(downLoadInfo);
}
}

View File

@@ -1,13 +1,13 @@
package com.genersoft.iot.vmp.vmanager.streamProxy;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -58,7 +58,7 @@ public class StreamProxyController {
})
@PostMapping(value = "/save")
@ResponseBody
public StreamInfo save(@RequestBody StreamProxyItem param){
public StreamContent save(@RequestBody StreamProxyItem param){
logger.info("添加代理: " + JSONObject.toJSONString(param));
if (ObjectUtils.isEmpty(param.getMediaServerId())) {
param.setMediaServerId("auto");
@@ -69,7 +69,7 @@ public class StreamProxyController {
if (ObjectUtils.isEmpty(param.getGbId())) {
param.setGbId(null);
}
return streamProxyService.save(param);
return new StreamContent(streamProxyService.save(param));
}
@GetMapping(value = "/ffmpeg_cmd/list")

View File

@@ -11,22 +11,16 @@ import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.bean.*;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.poi.sl.usermodel.Sheet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,12 +28,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -243,8 +235,8 @@ public class StreamPushController {
@Parameter(name = "app", description = "应用名", required = true)
@Parameter(name = "stream", description = "流id", required = true)
@Parameter(name = "mediaServerId", description = "媒体服务器id")
public StreamInfo getPlayUrl(@RequestParam String app,@RequestParam String stream,
@RequestParam(required = false) String mediaServerId){
public StreamContent getPlayUrl(@RequestParam String app, @RequestParam String stream,
@RequestParam(required = false) String mediaServerId){
boolean authority = false;
// 是否登陆用户, 登陆用户返回完整信息
LoginUser userInfo = SecurityUtils.getUserInfo();
@@ -259,7 +251,7 @@ public class StreamPushController {
if (streamInfo == null){
throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取播放地址失败");
}
return streamInfo;
return new StreamContent(streamInfo);
}
/**

View File

@@ -10,8 +10,10 @@ import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
@@ -59,10 +61,10 @@ public class ApiDeviceController {
JSONObject result = new JSONObject();
List<Device> devices;
if (start == null || limit ==null) {
devices = storager.queryVideoDeviceList();
devices = storager.queryVideoDeviceList(online);
result.put("DeviceCount", devices.size());
}else {
PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit);
PageInfo<Device> deviceList = storager.queryVideoDeviceList(start/limit, limit,online);
result.put("DeviceCount", deviceList.getTotal());
devices = deviceList.getList();
}
@@ -94,6 +96,7 @@ public class ApiDeviceController {
@RequestMapping(value = "/channellist")
public JSONObject channellist( String serial,
@RequestParam(required = false)String code,
@RequestParam(required = false)String channel_type,
@RequestParam(required = false)String dir_serial ,
@RequestParam(required = false)Integer start,
@@ -113,12 +116,17 @@ public class ApiDeviceController {
return result;
}
List<DeviceChannel> deviceChannels;
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial);
List<String> channelIds = null;
if (!StringUtils.isEmpty(code)) {
String[] split = code.trim().split(",");
channelIds = Arrays.asList(split);
}
List<DeviceChannel> allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds);
if (start == null || limit ==null) {
deviceChannels = allDeviceChannelList;
result.put("ChannelCount", deviceChannels.size());
}else {
deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, null,start, limit);
deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, online,start, limit,channelIds);
int total = allDeviceChannelList.size();
result.put("ChannelCount", total);
}
@@ -148,9 +156,9 @@ public class ApiDeviceController {
// 1-IETF RFC3261,
// 2-基于口令的双向认证,
// 3-基于数字证书的双向认证
deviceJOSNChannel.put("Status", deviceChannel.getStatus());
deviceJOSNChannel.put("Longitude", deviceChannel.getLongitudeWgs84());
deviceJOSNChannel.put("Latitude", deviceChannel.getLatitudeWgs84());
deviceJOSNChannel.put("Status", deviceChannel.getStatus() == 1 ? "ON":"OFF");
deviceJOSNChannel.put("Longitude", deviceChannel.getLongitude());
deviceJOSNChannel.put("Latitude", deviceChannel.getLatitude());
deviceJOSNChannel.put("PTZType ", deviceChannel.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球,
// 3 - 固定枪机, 4 - 遥控枪机
deviceJOSNChannel.put("CustomPTZType", "");

View File

@@ -12,7 +12,6 @@ import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -120,12 +119,12 @@ public class ApiStreamController {
result.put("ChannelID", code);
result.put("ChannelName", deviceChannel.getName());
result.put("ChannelCustomName", "");
result.put("FLV", streamInfo.getFlv());
result.put("WS_FLV", streamInfo.getWs_flv());
result.put("RTMP", streamInfo.getRtmp());
result.put("HLS", streamInfo.getHls());
result.put("RTSP", streamInfo.getRtsp());
result.put("WEBRTC", streamInfo.getRtc());
result.put("FLV", streamInfo.getFlv().getUrl());
result.put("WS_FLV", streamInfo.getWs_flv().getUrl());
result.put("RTMP", streamInfo.getRtmp().getUrl());
result.put("HLS", streamInfo.getHls().getUrl());
result.put("RTSP", streamInfo.getRtsp().getUrl());
result.put("WEBRTC", streamInfo.getRtc().getUrl());
result.put("CDN", "");
result.put("SnapURL", "");
result.put("Transport", device.getTransport());