Procházet zdrojové kódy

提高注册兼容性, 修复sql兼容mysql

64850858 před 4 roky
rodič
revize
377f0f2c82

+ 84 - 16
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java

@@ -21,25 +21,25 @@ public class MediaConfig {
     private String streamIp;
 
     @Value("${media.httpPort}")
-    private String httpPort;
+    private Integer httpPort;
 
     @Value("${media.httpSSlPort:}")
-    private String httpSSlPort;
+    private Integer httpSSlPort;
 
     @Value("${media.rtmpPort:}")
-    private String rtmpPort;
+    private Integer rtmpPort;
 
     @Value("${media.rtmpSSlPort:}")
-    private String rtmpSSlPort;
+    private Integer rtmpSSlPort;
 
     @Value("${media.rtpProxyPort:}")
-    private String rtpProxyPort;
+    private Integer rtpProxyPort;
 
     @Value("${media.rtspPort:}")
-    private String rtspPort;
+    private Integer rtspPort;
 
     @Value("${media.rtspSSLPort:}")
-    private String rtspSSLPort;
+    private Integer rtspSSLPort;
 
     @Value("${media.autoConfig:true}")
     private boolean autoConfig;
@@ -57,73 +57,141 @@ public class MediaConfig {
     private String rtpPortRange;
 
     @Value("${media.recordAssistPort}")
-    private int recordAssistPort;
+    private Integer recordAssistPort;
 
     public String getIp() {
         return ip;
     }
 
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
     public String getHookIp() {
         return hookIp;
     }
 
+    public void setHookIp(String hookIp) {
+        this.hookIp = hookIp;
+    }
+
     public String getSdpIp() {
         return sdpIp;
     }
 
+    public void setSdpIp(String sdpIp) {
+        this.sdpIp = sdpIp;
+    }
+
     public String getStreamIp() {
         return streamIp;
     }
 
-    public String getHttpPort() {
+    public void setStreamIp(String streamIp) {
+        this.streamIp = streamIp;
+    }
+
+    public Integer getHttpPort() {
         return httpPort;
     }
 
-    public String getHttpSSlPort() {
+    public void setHttpPort(Integer httpPort) {
+        this.httpPort = httpPort;
+    }
+
+    public Integer getHttpSSlPort() {
         return httpSSlPort;
     }
 
-    public String getRtmpPort() {
+    public void setHttpSSlPort(Integer httpSSlPort) {
+        this.httpSSlPort = httpSSlPort;
+    }
+
+    public Integer getRtmpPort() {
         return rtmpPort;
     }
 
-    public String getRtmpSSlPort() {
+    public void setRtmpPort(Integer rtmpPort) {
+        this.rtmpPort = rtmpPort;
+    }
+
+    public Integer getRtmpSSlPort() {
         return rtmpSSlPort;
     }
 
-    public String getRtpProxyPort() {
+    public void setRtmpSSlPort(Integer rtmpSSlPort) {
+        this.rtmpSSlPort = rtmpSSlPort;
+    }
+
+    public Integer getRtpProxyPort() {
         return rtpProxyPort;
     }
 
-    public String getRtspPort() {
+    public void setRtpProxyPort(Integer rtpProxyPort) {
+        this.rtpProxyPort = rtpProxyPort;
+    }
+
+    public Integer getRtspPort() {
         return rtspPort;
     }
 
-    public String getRtspSSLPort() {
+    public void setRtspPort(Integer rtspPort) {
+        this.rtspPort = rtspPort;
+    }
+
+    public Integer getRtspSSLPort() {
         return rtspSSLPort;
     }
 
+    public void setRtspSSLPort(Integer rtspSSLPort) {
+        this.rtspSSLPort = rtspSSLPort;
+    }
+
     public boolean isAutoConfig() {
         return autoConfig;
     }
 
+    public void setAutoConfig(boolean autoConfig) {
+        this.autoConfig = autoConfig;
+    }
+
     public String getSecret() {
         return secret;
     }
 
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
     public String getStreamNoneReaderDelayMS() {
         return streamNoneReaderDelayMS;
     }
 
+    public void setStreamNoneReaderDelayMS(String streamNoneReaderDelayMS) {
+        this.streamNoneReaderDelayMS = streamNoneReaderDelayMS;
+    }
+
     public boolean isRtpEnable() {
         return rtpEnable;
     }
 
+    public void setRtpEnable(boolean rtpEnable) {
+        this.rtpEnable = rtpEnable;
+    }
+
     public String getRtpPortRange() {
         return rtpPortRange;
     }
 
-    public int getRecordAssistPort() {
+    public void setRtpPortRange(String rtpPortRange) {
+        this.rtpPortRange = rtpPortRange;
+    }
+
+    public Integer getRecordAssistPort() {
         return recordAssistPort;
     }
+
+    public void setRecordAssistPort(Integer recordAssistPort) {
+        this.recordAssistPort = recordAssistPort;
+    }
 }

+ 11 - 14
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java

@@ -109,13 +109,10 @@ public class DigestServerAuthenticationHelper  {
             WWWAuthenticateHeader proxyAuthenticate = headerFactory
                     .createWWWAuthenticateHeader(DEFAULT_SCHEME);
             proxyAuthenticate.setParameter("realm", realm);
+            proxyAuthenticate.setParameter("qop", "auth");
             proxyAuthenticate.setParameter("nonce", generateNonce());
-
-            proxyAuthenticate.setParameter("opaque", "");
-            proxyAuthenticate.setParameter("stale", "FALSE");
             proxyAuthenticate.setParameter("algorithm", DEFAULT_ALGORITHM);
 
-//            proxyAuthenticate.setParameter("qop", "auth");
             response.setHeader(proxyAuthenticate);
         } catch (Exception ex) {
             InternalErrorHandler.handleException(ex);
@@ -243,26 +240,26 @@ public class DigestServerAuthenticationHelper  {
     }
 
     public static void main(String[] args) throws NoSuchAlgorithmException {
-        String realm = "4401000000";
-        String username = "44010000001110008008";
+        String realm = "3402000000";
+        String username = "44010000001180008012";
 
 
-        String nonce = "0074b397f86fc263b1b7f9eb72553267";
-        String uri = "sip:44010000002000000001@4401000000";
+        String nonce = "07cab60999fbf643264ace27d3b7de8b";
+        String uri = "sip:34020000002000000001@3402000000";
         // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略
-        String qop = null;
+        String qop = "auth";
 
         // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。
         // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护
         //String cNonce = authHeader.getCNonce();
 
         // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量
-        int nc = -1;
+        int nc = 1;
         String ncStr = new DecimalFormat("00000000").format(nc);
 //        String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16));
         MessageDigest messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM);
-        String A1 = username + ":" + realm + ":" + "crservice@123";
-        String A2 = "REGISTER" + ":" + uri.toString();
+        String A1 = username + ":" + realm + ":" + "12345678";
+        String A2 = "REGISTER" + ":" + uri;
         byte mdbytes[] = messageDigest.digest(A1.getBytes());
         String HA1 = toHexString(mdbytes);
         System.out.println("A1: " + A1);
@@ -272,7 +269,7 @@ public class DigestServerAuthenticationHelper  {
         String HA2 = toHexString(mdbytes);
         System.out.println("HA1: " + HA1);
         System.out.println("HA2: " + HA2);
-        String cnonce = null;
+        String cnonce = "0a4f113b";
         System.out.println("nonce: " + nonce);
         System.out.println("nc: " + ncStr);
         System.out.println("cnonce: " + cnonce);
@@ -293,7 +290,7 @@ public class DigestServerAuthenticationHelper  {
         mdbytes = messageDigest.digest(KD.getBytes());
         String mdString = toHexString(mdbytes);
         System.out.println("mdString: " + mdString);
-        String response = "fdb1608a7a3b96f0598f40b8ba78d6a9";
+        String response = "4f0507d4b87cdecff04bdaf4c96348f0";
         System.out.println("response: " + response);
     }
 }

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@@ -356,10 +356,10 @@ public class SIPCommander implements ISIPCommander {
 				logger.warn("点播时发现ZLM尚未连接...");
 				return;
 			}
-			String mediaPort = null;
+			Integer mediaPort = null;
 			// 使用动态udp端口
 			if (mediaConfig.isRtpEnable()) {
-				mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
+				mediaPort = zlmrtpServerFactory.createRTPServer(streamId);
 			}else {
 				mediaPort = mediaInfo.getRtpProxyPort();
 			}
@@ -485,10 +485,10 @@ public class SIPCommander implements ISIPCommander {
 	        content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
 	        content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "
 					+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
-			String mediaPort = null;
+			Integer mediaPort = null;
 			// 使用动态udp端口
 			if (mediaConfig.isRtpEnable()) {
-				mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + "";
+				mediaPort = zlmrtpServerFactory.createRTPServer(streamId);
 			}else {
 				mediaPort = mediaInfo.getRtpProxyPort();
 			}

+ 0 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java

@@ -336,11 +336,6 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
 					String username = sdp.getOrigin().getUsername();
 					String addressStr = sdp.getOrigin().getAddress();
 					logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}", username, addressStr, port, ssrc);
-					
-
-
-
-
 
 				} else {
 					logger.warn("来自无效设备/平台的请求");

+ 72 - 67
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java

@@ -43,6 +43,8 @@ public class ZLMServerConfig {
 
     private String updateTime;
 
+    private String createTime;
+
     @JSONField(name = "hls.fileBufSize")
     private String hlsFileBufSize;
 
@@ -65,7 +67,7 @@ public class ZLMServerConfig {
     private String hookEnable;
 
     @JSONField(name = "hook.on_flow_report")
-    private String hookOnFlowReport;
+    private Integer hookOnFlowReport;
 
     @JSONField(name = "hook.on_http_access")
     private String hookOnHttpAccess;
@@ -116,7 +118,7 @@ public class ZLMServerConfig {
     private String httpNotFound;
 
     @JSONField(name = "http.port")
-    private String httpPort;
+    private Integer httpPort;
 
     @JSONField(name = "http.rootPath")
     private String httpRootPath;
@@ -125,7 +127,7 @@ public class ZLMServerConfig {
     private String httpSendBufSize;
 
     @JSONField(name = "http.sslport")
-    private String httpSSLport;
+    private Integer httpSSLport;
 
     @JSONField(name = "multicast.addrMax")
     private String multicastAddrMax;
@@ -158,10 +160,10 @@ public class ZLMServerConfig {
     private String rtmpModifyStamp;
 
     @JSONField(name = "rtmp.port")
-    private String rtmpPort;
+    private Integer rtmpPort;
 
     @JSONField(name = "rtmp.sslport")
-    private String rtmpSslPort;
+    private Integer rtmpSslPort;
 
     @JSONField(name = "rtp.audioMtuSize")
     private String rtpAudioMtuSize;
@@ -185,7 +187,7 @@ public class ZLMServerConfig {
     private String rtpProxyDumpDir;
 
     @JSONField(name = "rtp_proxy.port")
-    private String rtpProxyPort;
+    private Integer rtpProxyPort;
 
     @JSONField(name = "rtp_proxy.timeoutSec")
     private String rtpProxyTimeoutSec;
@@ -200,10 +202,10 @@ public class ZLMServerConfig {
     private String rtspKeepAliveSecond;
 
     @JSONField(name = "rtsp.port")
-    private String rtspPort;
+    private Integer rtspPort;
 
     @JSONField(name = "rtsp.sslport")
-    private String rtspSSlport;
+    private Integer rtspSSlport;
 
     @JSONField(name = "shell.maxReqSize")
     private String shellMaxReqSize;
@@ -211,7 +213,6 @@ public class ZLMServerConfig {
     @JSONField(name = "shell.shell")
     private String shellPhell;
 
-
     public String getApiDebug() {
         return apiDebug;
     }
@@ -260,6 +261,14 @@ public class ZLMServerConfig {
         this.generalEnableVhost = generalEnableVhost;
     }
 
+    public String getGeneralMediaServerId() {
+        return generalMediaServerId;
+    }
+
+    public void setGeneralMediaServerId(String generalMediaServerId) {
+        this.generalMediaServerId = generalMediaServerId;
+    }
+
     public String getGeneralFlowThreshold() {
         return generalFlowThreshold;
     }
@@ -292,6 +301,38 @@ public class ZLMServerConfig {
         this.ip = ip;
     }
 
+    public String getSdpIp() {
+        return sdpIp;
+    }
+
+    public void setSdpIp(String sdpIp) {
+        this.sdpIp = sdpIp;
+    }
+
+    public String getStreamIp() {
+        return streamIp;
+    }
+
+    public void setStreamIp(String streamIp) {
+        this.streamIp = streamIp;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
     public String getHlsFileBufSize() {
         return hlsFileBufSize;
     }
@@ -348,11 +389,11 @@ public class ZLMServerConfig {
         this.hookEnable = hookEnable;
     }
 
-    public String getHookOnFlowReport() {
+    public Integer getHookOnFlowReport() {
         return hookOnFlowReport;
     }
 
-    public void setHookOnFlowReport(String hookOnFlowReport) {
+    public void setHookOnFlowReport(Integer hookOnFlowReport) {
         this.hookOnFlowReport = hookOnFlowReport;
     }
 
@@ -484,11 +525,11 @@ public class ZLMServerConfig {
         this.httpNotFound = httpNotFound;
     }
 
-    public String getHttpPort() {
+    public Integer getHttpPort() {
         return httpPort;
     }
 
-    public void setHttpPort(String httpPort) {
+    public void setHttpPort(Integer httpPort) {
         this.httpPort = httpPort;
     }
 
@@ -508,11 +549,11 @@ public class ZLMServerConfig {
         this.httpSendBufSize = httpSendBufSize;
     }
 
-    public String getHttpSSLport() {
+    public Integer getHttpSSLport() {
         return httpSSLport;
     }
 
-    public void setHttpSSLport(String httpSSLport) {
+    public void setHttpSSLport(Integer httpSSLport) {
         this.httpSSLport = httpSSLport;
     }
 
@@ -596,14 +637,22 @@ public class ZLMServerConfig {
         this.rtmpModifyStamp = rtmpModifyStamp;
     }
 
-    public String getRtmpPort() {
+    public Integer getRtmpPort() {
         return rtmpPort;
     }
 
-    public void setRtmpPort(String rtmpPort) {
+    public void setRtmpPort(Integer rtmpPort) {
         this.rtmpPort = rtmpPort;
     }
 
+    public Integer getRtmpSslPort() {
+        return rtmpSslPort;
+    }
+
+    public void setRtmpSslPort(Integer rtmpSslPort) {
+        this.rtmpSslPort = rtmpSslPort;
+    }
+
     public String getRtpAudioMtuSize() {
         return rtpAudioMtuSize;
     }
@@ -660,11 +709,11 @@ public class ZLMServerConfig {
         this.rtpProxyDumpDir = rtpProxyDumpDir;
     }
 
-    public String getRtpProxyPort() {
+    public Integer getRtpProxyPort() {
         return rtpProxyPort;
     }
 
-    public void setRtpProxyPort(String rtpProxyPort) {
+    public void setRtpProxyPort(Integer rtpProxyPort) {
         this.rtpProxyPort = rtpProxyPort;
     }
 
@@ -700,19 +749,19 @@ public class ZLMServerConfig {
         this.rtspKeepAliveSecond = rtspKeepAliveSecond;
     }
 
-    public String getRtspPort() {
+    public Integer getRtspPort() {
         return rtspPort;
     }
 
-    public void setRtspPort(String rtspPort) {
+    public void setRtspPort(Integer rtspPort) {
         this.rtspPort = rtspPort;
     }
 
-    public String getRtspSSlport() {
+    public Integer getRtspSSlport() {
         return rtspSSlport;
     }
 
-    public void setRtspSSlport(String rtspSSlport) {
+    public void setRtspSSlport(Integer rtspSSlport) {
         this.rtspSSlport = rtspSSlport;
     }
 
@@ -731,48 +780,4 @@ public class ZLMServerConfig {
     public void setShellPhell(String shellPhell) {
         this.shellPhell = shellPhell;
     }
-
-    public String getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(String updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public String getGeneralMediaServerId() {
-        return generalMediaServerId;
-    }
-
-    public void setGeneralMediaServerId(String generalMediaServerId) {
-        this.generalMediaServerId = generalMediaServerId;
-    }
-
-    public String getRtmpSslPort() {
-        return rtmpSslPort;
-    }
-
-    public void setRtmpSslPort(String rtmpSslPort) {
-        this.rtmpSslPort = rtmpSslPort;
-    }
-
-    public String getSdpIp() {
-        if (StringUtils.isEmpty(sdpIp)) {
-            return ip;
-        }else {
-            return sdpIp;
-        }
-    }
-
-    public void setSdpIp(String sdpIp) {
-        this.sdpIp = sdpIp;
-    }
-
-    public String getStreamIp() {
-        return streamIp;
-    }
-
-    public void setStreamIp(String streamIp) {
-        this.streamIp = streamIp;
-    }
 }

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@@ -19,12 +19,12 @@ public interface DeviceChannelMapper {
             "ipAddress, port, password, PTZType, status, streamId, longitude, latitude, createTime, updateTime) " +
             "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}, datetime('now','localtime'), datetime('now','localtime'))")
+            "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude},'${createTime}', '${updateTime}')")
     int add(DeviceChannel channel);
 
     @Update(value = {" <script>" +
             "UPDATE device_channel " +
-            "SET updateTime=datetime('now','localtime')" +
+            "SET updateTime='${updateTime}'" +
             "<if test=\"name != null\">, name='${name}'</if>" +
             "<if test=\"manufacture != null\">, manufacture='${manufacture}'</if>" +
             "<if test=\"model != null\">, model='${model}'</if>" +

+ 3 - 3
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

@@ -47,15 +47,15 @@ public interface DeviceMapper {
                 "#{expires}," +
                 "#{registerTime}," +
                 "#{keepaliveTime}," +
-                "datetime('now','localtime')," +
-                "datetime('now','localtime')," +
+                "#{createTime}," +
+                "#{updateTime}," +
                 "#{online}" +
             ")")
     int add(Device device);
 
     @Update(value = {" <script>" +
                 "UPDATE device " +
-                "SET updateTime=datetime('now','localtime')" +
+                "SET updateTime='${updateTime}'" +
                 "<if test=\"name != null\">, name='${name}'</if>" +
                 "<if test=\"manufacturer != null\">, manufacturer='${manufacturer}'</if>" +
                 "<if test=\"model != null\">, model='${model}'</if>" +

+ 9 - 0
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@@ -1,5 +1,6 @@
 package com.genersoft.iot.vmp.storager.impl;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 import com.genersoft.iot.vmp.common.StreamInfo;
@@ -70,6 +71,8 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 	@Autowired
     private VideoStreamSessionManager streamSession;
 
+	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
 
 	/**
 	 * 根据设备ID判断设备是否存在
@@ -103,8 +106,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 	 */
 	@Override
 	public synchronized boolean updateDevice(Device device) {
+		String now = this.format.format(new Date(System.currentTimeMillis()));
+		device.setUpdateTime(now);
 		Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
 		if (deviceByDeviceId == null) {
+			device.setCreateTime(now);
 			return deviceMapper.add(device) > 0;
 		}else {
 			return deviceMapper.update(device) > 0;
@@ -117,8 +123,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 		String channelId = channel.getChannelId();
 		channel.setDeviceId(deviceId);
 		channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+		String now = this.format.format(new Date(System.currentTimeMillis()));
+		channel.setUpdateTime(now);
 		DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
 		if (deviceChannel == null) {
+			channel.setCreateTime(now);
 			deviceChannelMapper.add(channel);
 		}else {
 			deviceChannelMapper.update(channel);

+ 1 - 0
src/main/resources/all-application.yml

@@ -19,6 +19,7 @@ spring:
         timeout: 10000
     # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置
     datasource:
+        # 使用mysql 打开23-28行注释, 删除29-36行
         # name: wvp
         # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
         # username:

+ 1 - 4
web_src/src/components/DeviceList.vue

@@ -13,16 +13,13 @@
 				</div>
 				<!-- <devicePlayer ref="devicePlayer"></devicePlayer> -->
 				<!--设备列表-->
-				<el-table :data="deviceList" border style="width: 100%" :height="winHeight">
+				<el-table :data="deviceList" border style="width: 100%;font-size: 12px;" :height="winHeight">
 					<el-table-column prop="name" label="名称"  align="center">
 					</el-table-column>
 					<el-table-column prop="deviceId" label="设备编号" width="180" align="center">
 					</el-table-column>
-
 					<el-table-column prop="manufacturer" label="厂家" align="center">
 					</el-table-column>
-					<el-table-column prop="model" label="固件版本" align="center" width="120">
-					</el-table-column>
 					<el-table-column label="流传输模式" align="center" width="120">
             <template slot-scope="scope">
               <el-select size="mini" @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择">