Commit 11e8fad2e981b3dca22dad4048246d012ce326b7

Authored by 648540858
Committed by GitHub
2 parents d09ee0c2 f92a5da7

Merge pull request #113 from lawrencehj/wvp-28181-2.0

修正SSE、jar路径和API代理部分错误
Showing 30 changed files with 44 additions and 66 deletions
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
... ... @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp;
3 3 import java.util.logging.LogManager;
4 4  
5 5 import org.springframework.boot.SpringApplication;
6   -import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
7 6 import org.springframework.boot.autoconfigure.SpringBootApplication;
8 7 import org.springframework.context.ConfigurableApplicationContext;
9 8 import springfox.documentation.oas.annotations.EnableOpenApi;
... ...
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
... ... @@ -16,7 +16,7 @@ public class VideoManagerConstants {
16 16  
17 17 public static final String CACHEKEY_PREFIX = "VMP_channel_";
18 18  
19   - public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPLIVE_";
  19 + public static final String KEEPLIVEKEY_PREFIX = "VMP_keeplive_";
20 20  
21 21 public static final String PLAYER_PREFIX = "VMP_player_";
22 22  
... ...
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
3   -import io.netty.util.internal.StringUtil;
4 3 import org.springframework.beans.factory.annotation.Value;
5 4 import org.springframework.context.annotation.Configuration;
6 5 import org.springframework.util.StringUtils;
... ...
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
... ... @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf;
2 2  
3 3 import org.apache.http.HttpRequest;
4 4 import org.apache.http.HttpResponse;
5   -import org.apache.http.client.config.RequestConfig;
6   -import org.apache.http.impl.client.HttpClientBuilder;
  5 +import org.apache.catalina.connector.ClientAbortException;
7 6 import org.mitre.dsmiley.httpproxy.ProxyServlet;
8 7 import org.slf4j.Logger;
9 8 import org.slf4j.LoggerFactory;
... ... @@ -14,16 +13,11 @@ import org.springframework.context.annotation.Configuration;
14 13 import org.springframework.util.StringUtils;
15 14  
16 15 import javax.servlet.ServletException;
17   -import javax.servlet.ServletRequest;
18   -import javax.servlet.ServletResponse;
19 16 import javax.servlet.http.HttpServletRequest;
20   -import javax.servlet.http.HttpServletResponse;
21 17 import java.io.IOException;
22 18 import java.net.ConnectException;
23   -import java.util.Locale;
24   -import java.util.Map;
25   -
26 19  
  20 +@SuppressWarnings(value = {"rawtypes", "unchecked"})
27 21 @Configuration
28 22 public class ProxyServletConfig {
29 23  
... ... @@ -61,7 +55,7 @@ public class ProxyServletConfig {
61 55  
62 56 @Override
63 57 protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){
64   - System.out.println(e.getMessage());
  58 + //System.out.println(e.getMessage());
65 59 try {
66 60 super.handleRequestException(proxyRequest, proxyResonse, e);
67 61 } catch (ServletException servletException) {
... ... @@ -69,7 +63,9 @@ public class ProxyServletConfig {
69 63 } catch (IOException ioException) {
70 64 if (ioException instanceof ConnectException) {
71 65 logger.error("zlm 连接失败");
72   - }else {
  66 + } else if (ioException instanceof ClientAbortException) {
  67 + logger.error("用户已中断连接,代理终止");
  68 + } else {
73 69 logger.error("zlm 代理失败: ", e);
74 70 }
75 71 } catch (RuntimeException exception){
... ...
src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
3   -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
4   -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
5   -import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
6 3 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
7 4 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
8 5 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -10,7 +7,6 @@ import org.springframework.boot.CommandLineRunner;
10 7 import org.springframework.core.annotation.Order;
11 8 import org.springframework.stereotype.Component;
12 9  
13   -import java.util.List;
14 10  
15 11 /**
16 12 * 系统启动时控制设备离线
... ...
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
... ... @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.conf.security;
2 2  
3 3 import com.genersoft.iot.vmp.conf.UserSetup;
4 4 import org.springframework.beans.factory.annotation.Autowired;
5   -import org.springframework.beans.factory.annotation.Value;
6 5 import org.springframework.context.annotation.Bean;
7 6 import org.springframework.context.annotation.Configuration;
8 7 import org.springframework.security.authentication.AuthenticationManager;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/session/SsrcUtil.java
... ... @@ -5,7 +5,6 @@ import java.util.List;
5 5 import java.util.Random;
6 6  
7 7 import com.genersoft.iot.vmp.conf.SipConfig;
8   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
9 8 import com.genersoft.iot.vmp.utils.SpringBeanFactory;
10 9 import org.slf4j.Logger;
11 10 import org.slf4j.LoggerFactory;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
2 2  
3   -import com.genersoft.iot.vmp.conf.MediaConfig;
4 3 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
5 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
6 5 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
... ... @@ -12,7 +11,6 @@ import org.slf4j.Logger;
12 11 import org.slf4j.LoggerFactory;
13 12 import org.springframework.beans.factory.annotation.Autowired;
14 13 import org.springframework.beans.factory.annotation.Qualifier;
15   -import org.springframework.beans.factory.annotation.Value;
16 14 import org.springframework.context.annotation.DependsOn;
17 15 import org.springframework.context.annotation.Lazy;
18 16 import org.springframework.lang.Nullable;
... ... @@ -23,8 +21,6 @@ import javax.sip.header.CallIdHeader;
23 21 import javax.sip.header.WWWAuthenticateHeader;
24 22 import javax.sip.message.Request;
25 23 import java.text.ParseException;
26   -import java.util.Timer;
27   -import java.util.TimerTask;
28 24 import java.util.UUID;
29 25  
30 26 @Component
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
... ... @@ -2,10 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
2 2  
3 3 import java.security.NoSuchAlgorithmException;
4 4 import java.text.ParseException;
5   -import java.text.SimpleDateFormat;
6   -import java.time.LocalDateTime;
7 5 import java.util.Calendar;
8   -import java.util.Date;
9 6 import java.util.Locale;
10 7  
11 8 import javax.sip.InvalidArgumentException;
... ... @@ -22,7 +19,6 @@ import javax.sip.message.Response;
22 19 import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate;
23 20 import gov.nist.javax.sip.RequestEventExt;
24 21 import gov.nist.javax.sip.header.SIPDateHeader;
25   -import gov.nist.javax.sip.message.SIPRequest;
26 22 import org.slf4j.Logger;
27 23 import org.slf4j.LoggerFactory;
28 24 import org.springframework.util.StringUtils;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java
... ... @@ -5,7 +5,6 @@ import com.genersoft.iot.vmp.gb28181.SipLayer;
5 5 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
6 6 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
7 7 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
8   -import com.genersoft.iot.vmp.gb28181.transmit.request.impl.RegisterRequestProcessor;
9 8 import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
10 9 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
11 10 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -15,10 +15,8 @@ import com.genersoft.iot.vmp.service.IPlayService;
15 15 import org.slf4j.Logger;
16 16 import org.slf4j.LoggerFactory;
17 17 import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.beans.factory.annotation.Value;
19 18 import org.springframework.http.HttpStatus;
20 19 import org.springframework.http.ResponseEntity;
21   -import org.springframework.util.StringUtils;
22 20 import org.springframework.web.bind.annotation.PostMapping;
23 21 import org.springframework.web.bind.annotation.RequestBody;
24 22 import org.springframework.web.bind.annotation.RequestMapping;
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
... ... @@ -8,7 +8,6 @@ import com.genersoft.iot.vmp.gb28181.session.SsrcUtil;
8 8 import org.slf4j.Logger;
9 9 import org.slf4j.LoggerFactory;
10 10 import org.springframework.beans.factory.annotation.Autowired;
11   -import org.springframework.beans.factory.annotation.Value;
12 11 import org.springframework.stereotype.Component;
13 12  
14 13 import java.util.HashMap;
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java
1 1 package com.genersoft.iot.vmp.media.zlm;
2 2  
3 3 import com.alibaba.fastjson.annotation.JSONField;
4   -import org.springframework.util.StringUtils;
5 4  
6 5 public class ZLMServerConfig {
7 6  
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java
1 1 package com.genersoft.iot.vmp.media.zlm;
2 2  
3   -import com.alibaba.fastjson.annotation.JSONField;
4 3 import com.genersoft.iot.vmp.conf.MediaConfig;
5 4 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
6 5 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java
... ... @@ -12,8 +12,6 @@ import org.slf4j.Logger;
12 12 import org.slf4j.LoggerFactory;
13 13 import org.springframework.stereotype.Service;
14 14  
15   -import java.net.URI;
16   -import java.net.URISyntaxException;
17 15 import java.util.ArrayList;
18 16 import java.util.HashMap;
19 17 import java.util.List;
... ...
src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
1 1 package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.alibaba.fastjson.JSONArray;
4   -import com.alibaba.fastjson.JSONObject;
5 4 import com.genersoft.iot.vmp.common.StreamInfo;
6 5  
7 6 /**
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
... ... @@ -24,7 +24,6 @@ import gov.nist.javax.sip.stack.SIPDialog;
24 24 import org.slf4j.Logger;
25 25 import org.slf4j.LoggerFactory;
26 26 import org.springframework.beans.factory.annotation.Autowired;
27   -import org.springframework.beans.factory.annotation.Value;
28 27 import org.springframework.http.HttpStatus;
29 28 import org.springframework.http.ResponseEntity;
30 29 import org.springframework.stereotype.Service;
... ... @@ -32,13 +31,11 @@ import org.springframework.util.ResourceUtils;
32 31 import org.springframework.web.context.request.async.DeferredResult;
33 32  
34 33 import javax.sip.ClientTransaction;
35   -import javax.sip.Dialog;
36   -import javax.sip.header.CallIdHeader;
37 34 import javax.sip.message.Response;
38   -import java.io.File;
39 35 import java.io.FileNotFoundException;
40 36 import java.util.UUID;
41 37  
  38 +@SuppressWarnings(value = {"rawtypes", "unchecked"})
42 39 @Service
43 40 public class PlayServiceImpl implements IPlayService {
44 41  
... ... @@ -97,7 +94,20 @@ public class PlayServiceImpl implements IPlayService {
97 94 result.onCompletion(()->{
98 95 // 点播结束时调用截图接口
99 96 try {
100   - String path = ResourceUtils.getURL("classpath:").getPath()+"static/static/snap/";
  97 + String classPath = ResourceUtils.getURL("classpath:").getPath();
  98 + // System.out.println(classPath);
  99 + String path = classPath + "static/static/snap/";
  100 + if(classPath.contains("jar")) {
  101 + classPath = classPath.substring(0, classPath.lastIndexOf("."));
  102 + classPath = classPath.substring(0, classPath.lastIndexOf("/"));
  103 + path = classPath + "/snap/";
  104 + }
  105 + if (path.startsWith("file:")) {
  106 + path = path.substring(path.indexOf(":") + 1, path.length());
  107 + }
  108 + if(System.getProperty("os.name").contains("indows")) {
  109 + path = path.substring(1, path.length());
  110 + }
101 111 String fileName = deviceId + "_" + channelId + ".jpg";
102 112 ResponseEntity responseEntity = (ResponseEntity)result.getResult();
103 113 if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
... ... @@ -109,7 +119,6 @@ public class PlayServiceImpl implements IPlayService {
109 119 zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName);
110 120 }
111 121 }
112   -
113 122 System.out.println(path);
114 123 } catch (FileNotFoundException e) {
115 124 e.printStackTrace();
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/RecordInfoServerImpl.java
1 1 package com.genersoft.iot.vmp.service.impl;
2 2  
3   -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
4 3 import com.genersoft.iot.vmp.service.IRecordInfoServer;
5 4 import com.genersoft.iot.vmp.storager.dao.RecordInfoDao;
6 5 import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/RecordInfoDao.java
1 1 package com.genersoft.iot.vmp.storager.dao;
2 2  
3 3 import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
4   -import com.genersoft.iot.vmp.storager.dao.dto.User;
5 4 import org.apache.ibatis.annotations.Delete;
6 5 import org.apache.ibatis.annotations.Insert;
7 6 import org.apache.ibatis.annotations.Mapper;
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
... ... @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.storager.impl;
3 3 import java.text.SimpleDateFormat;
4 4 import java.util.*;
5 5  
6   -import com.genersoft.iot.vmp.common.StreamInfo;
7 6 import com.genersoft.iot.vmp.gb28181.bean.*;
8 7 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
9 8 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/SseController/SseController.java
... ... @@ -8,7 +8,7 @@ import io.swagger.annotations.ApiOperation;
8 8 import org.springframework.beans.factory.annotation.Autowired;
9 9 import org.springframework.stereotype.Controller;
10 10 import org.springframework.web.bind.annotation.CrossOrigin;
11   -import org.springframework.web.bind.annotation.PostMapping;
  11 +import org.springframework.web.bind.annotation.GetMapping;
12 12 import org.springframework.web.bind.annotation.RequestMapping;
13 13 import org.springframework.web.bind.annotation.RequestParam;
14 14 import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
... ... @@ -30,7 +30,7 @@ public class SseController {
30 30 @ApiImplicitParams({
31 31 @ApiImplicitParam(name = "browserId", value = "浏览器ID", dataTypeClass = String.class),
32 32 })
33   - @PostMapping("/emit")
  33 + @GetMapping("/emit")
34 34 public SseEmitter emit(@RequestParam String browserId) {
35 35 final SseEmitter sseEmitter = new SseEmitter(0L);
36 36 try {
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
... ... @@ -120,7 +120,7 @@ public class DeviceControl {
120 120 * @param deviceId 设备ID
121 121 * @param guardCmdStr SetGuard:布防,ResetGuard:撤防
122 122 */
123   - @ApiOperation("录像控制命令")
  123 + @ApiOperation("布防/撤防命令")
124 124 @ApiImplicitParams({
125 125 @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
126 126 @ApiImplicitParam(name = "guardCmdStr", value ="命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true,
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
... ... @@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
19 19 import org.springframework.beans.factory.annotation.Autowired;
20 20 import org.springframework.http.HttpStatus;
21 21 import org.springframework.http.ResponseEntity;
22   -import org.springframework.util.ResourceUtils;
23 22 import org.springframework.web.bind.annotation.CrossOrigin;
24 23 import org.springframework.web.bind.annotation.GetMapping;
25 24 import org.springframework.web.bind.annotation.PathVariable;
... ... @@ -32,7 +31,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
32 31 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
33 32 import org.springframework.web.context.request.async.DeferredResult;
34 33  
35   -import java.io.FileNotFoundException;
36 34 import java.util.UUID;
37 35  
38 36 import javax.sip.message.Response;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/onvif/ONVIFController.java
... ... @@ -17,6 +17,7 @@ import org.springframework.web.context.request.async.DeferredResult;
17 17 import java.util.List;
18 18 import java.util.UUID;
19 19  
  20 +@SuppressWarnings(value = {"rawtypes", "unchecked"})
20 21 @Api(tags = "onvif设备")
21 22 @CrossOrigin
22 23 @RestController
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
... ... @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.vmanager.server;
3 3 import com.genersoft.iot.vmp.VManageBootstrap;
4 4 import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
5 5 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
6   -import com.genersoft.iot.vmp.storager.impl.RedisCatchStorageImpl;
7 6 import com.genersoft.iot.vmp.utils.SpringBeanFactory;
8 7 import gov.nist.javax.sip.SipStackImpl;
9 8 import io.swagger.annotations.Api;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
... ... @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
16 16 import org.springframework.stereotype.Controller;
17 17 import org.springframework.web.bind.annotation.*;
18 18  
  19 +@SuppressWarnings("rawtypes")
19 20 /**
20 21 * 拉流代理接口
21 22 */
... ...
src/main/resources/application-dev.yml
... ... @@ -15,6 +15,8 @@ spring:
15 15 datasource:
16 16 name: eiot
17 17 url: jdbc:sqlite::resource:wvp.sqlite
  18 + # 打包为jar运行时把wvp.sqlite发到jar同级文件夹,同时url改为:
  19 + # url: jdbc:sqlite:wvp.sqlite
18 20 username:
19 21 password:
20 22 type: com.alibaba.druid.pool.DruidDataSource
... ... @@ -59,6 +61,18 @@ media:
59 61 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
60 62 recordAssistPort: 0
61 63  
  64 +
  65 +# [可选] 日志配置, 一般不需要改
  66 +logging:
  67 + file:
  68 + name: logs/wvp.log
  69 + max-history: 30
  70 + max-size: 10MB
  71 + total-size-cap: 300MB
  72 + level:
  73 + com:
  74 + genersoft:
  75 + iot: info
62 76 # [根据业务需求配置]
63 77 userSettings:
64 78 # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true
... ... @@ -73,15 +87,3 @@ springfox:
73 87 documentation:
74 88 swagger-ui:
75 89 enabled: true
76   -
77   -# [可选] 日志配置, 一般不需要改
78   -logging:
79   - file:
80   - name: logs/wvp.log
81   - max-history: 30
82   - max-size: 10MB
83   - total-size-cap: 300MB
84   - level:
85   - com:
86   - genersoft:
87   - iot: info
88 90 \ No newline at end of file
... ...
web_src/src/components/Login.vue
... ... @@ -80,7 +80,7 @@ export default {
80 80  
81 81 this.$axios({
82 82 method: 'get',
83   - url:"/api/user/login",
  83 + url:"/api/user/login",
84 84 params: loginParam
85 85 }).then(function (res) {
86 86 console.log(JSON.stringify(res));
... ...
web_src/src/components/ParentPlatformList.vue
... ... @@ -156,7 +156,7 @@ export default {
156 156  
157 157 this.$axios({
158 158 method: 'get',
159   - url:`/api/platform/query/${that.count}/${that.currentPage}`
  159 + url:`/api/platform/query/${that.count}/${that.currentPage}`
160 160 }).then(function (res) {
161 161 that.total = res.data.total;
162 162 that.platformList = res.data.list;
... ...
web_src/src/main.js
... ... @@ -47,7 +47,7 @@ axios.interceptors.response.use(function (response) {
47 47 }, function (error) {
48 48 // 对响应错误做点什么
49 49 if (error.response.status === 401) {
50   - console.log((1111))
  50 + console.log("Received 401 Response")
51 51 router.push('/login');
52 52 }
53 53 return Promise.reject(error);
... ...