Commit 1b677c6dc79b8e3b650acd94da7fc770c3d2718d

Authored by 64850858
1 parent 8aaac8c4

增加zlm代理的secret自动添加, 增加配置文件的默认值,缺少非关键参数不会无法启动,简化配置文件给新手带来的压力,前端使用wvp代理流。

src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
... ... @@ -3,6 +3,7 @@ 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;
6 7 import org.springframework.boot.autoconfigure.SpringBootApplication;
7 8 import org.springframework.context.ConfigurableApplicationContext;
8 9 import springfox.documentation.oas.annotations.EnableOpenApi;
... ...
src/main/java/com/genersoft/iot/vmp/conf/ApplicationCheckRunner.java
... ... @@ -31,9 +31,5 @@ public class ApplicationCheckRunner implements CommandLineRunner {
31 31 System.exit(1);
32 32 }
33 33  
34   - if (mediaConfig.getIp().equals("localhost") || (mediaConfig.getIp().equals("127.0.0.1") && mediaConfig.getWanIp() == null)) {
35   - logger.warn("mediaIp.ip使用 {} ,将无法收到网络内其他设备的推流!!!", mediaConfig.getIp() );
36   - }
37   -
38 34 }
39 35 }
... ...
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;
3 4 import org.springframework.beans.factory.annotation.Value;
4 5 import org.springframework.context.annotation.Configuration;
  6 +import org.springframework.util.StringUtils;
5 7  
6 8 @Configuration("mediaConfig")
7 9 public class MediaConfig {
... ... @@ -9,40 +11,40 @@ public class MediaConfig {
9 11 @Value("${media.ip}")
10 12 private String ip;
11 13  
12   - @Value("${media.wanIp}")
13   - private String wanIp;
14   -
15   - @Value("${media.hookIp}")
  14 + @Value("${media.hookIp:${sip.ip}}")
16 15 private String hookIp;
17 16  
  17 + @Value("${media.sdpIp:${media.ip}}")
  18 + private String sdpIp;
  19 +
18 20 @Value("${media.httpPort}")
19 21 private String httpPort;
20 22  
21   - @Value("${media.httpSSlPort}")
  23 + @Value("${media.httpSSlPort:}")
22 24 private String httpSSlPort;
23 25  
24   - @Value("${media.rtmpPort}")
  26 + @Value("${media.rtmpPort:}")
25 27 private String rtmpPort;
26 28  
27   - @Value("${media.rtmpSSlPort}")
  29 + @Value("${media.rtmpSSlPort:}")
28 30 private String rtmpSSlPort;
29 31  
30   - @Value("${media.rtpProxyPort}")
  32 + @Value("${media.rtpProxyPort:}")
31 33 private String rtpProxyPort;
32 34  
33   - @Value("${media.rtspPort}")
  35 + @Value("${media.rtspPort:}")
34 36 private String rtspPort;
35 37  
36   - @Value("${media.rtspSSLPort}")
  38 + @Value("${media.rtspSSLPort:}")
37 39 private String rtspSSLPort;
38 40  
39   - @Value("${media.autoConfig}")
  41 + @Value("${media.autoConfig:true}")
40 42 private boolean autoConfig;
41 43  
42 44 @Value("${media.secret}")
43 45 private String secret;
44 46  
45   - @Value("${media.streamNoneReaderDelayMS}")
  47 + @Value("${media.streamNoneReaderDelayMS:18000}")
46 48 private String streamNoneReaderDelayMS;
47 49  
48 50 @Value("${media.rtp.enable}")
... ... @@ -62,14 +64,6 @@ public class MediaConfig {
62 64 this.ip = ip;
63 65 }
64 66  
65   - public String getWanIp() {
66   - return wanIp;
67   - }
68   -
69   - public void setWanIp(String wanIp) {
70   - this.wanIp = wanIp;
71   - }
72   -
73 67 public String getHookIp() {
74 68 return hookIp;
75 69 }
... ... @@ -185,4 +179,16 @@ public class MediaConfig {
185 179 public void setRecordAssistPort(int recordAssistPort) {
186 180 this.recordAssistPort = recordAssistPort;
187 181 }
  182 +
  183 + public String getSdpIp() {
  184 + if (StringUtils.isEmpty(sdpIp)) {
  185 + return ip;
  186 + }else {
  187 + return sdpIp;
  188 + }
  189 + }
  190 +
  191 + public void setSdpIp(String sdpIp) {
  192 + this.sdpIp = sdpIp;
  193 + }
188 194 }
... ...
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
... ... @@ -2,6 +2,8 @@ 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 7 import org.mitre.dsmiley.httpproxy.ProxyServlet;
6 8 import org.slf4j.Logger;
7 9 import org.slf4j.LoggerFactory;
... ... @@ -12,9 +14,14 @@ import org.springframework.context.annotation.Configuration;
12 14 import org.springframework.util.StringUtils;
13 15  
14 16 import javax.servlet.ServletException;
  17 +import javax.servlet.ServletRequest;
  18 +import javax.servlet.ServletResponse;
  19 +import javax.servlet.http.HttpServletRequest;
  20 +import javax.servlet.http.HttpServletResponse;
15 21 import java.io.IOException;
16 22 import java.net.ConnectException;
17 23 import java.util.Locale;
  24 +import java.util.Map;
18 25  
19 26  
20 27 @Configuration
... ... @@ -27,10 +34,10 @@ public class ProxyServletConfig {
27 34  
28 35 @Bean
29 36 public ServletRegistrationBean zlmServletRegistrationBean(){
30   - String ip = StringUtils.isEmpty(mediaConfig.getWanIp())? mediaConfig.getIp(): mediaConfig.getWanIp();
31 37 ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ZLMProxySerlet(),"/zlm/*");
32 38 servletRegistrationBean.setName("zlm_Proxy");
33   - servletRegistrationBean.addInitParameter("targetUri", String.format("http://%s:%s", ip, mediaConfig.getHttpPort()));
  39 + servletRegistrationBean.addInitParameter("targetUri", String.format("http://%s:%s", mediaConfig.getIp(), mediaConfig.getHttpPort()));
  40 + servletRegistrationBean.addUrlMappings();
34 41 if (logger.isDebugEnabled()) {
35 42 servletRegistrationBean.addInitParameter("log", "true");
36 43 }
... ... @@ -38,6 +45,21 @@ public class ProxyServletConfig {
38 45 }
39 46  
40 47 class ZLMProxySerlet extends ProxyServlet{
  48 +
  49 +
  50 +
  51 + @Override
  52 + protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) {
  53 + String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString);
  54 + if (queryStr != null) {
  55 + queryStr += "&";
  56 + }else {
  57 + queryStr = "?";
  58 + }
  59 + queryStr += "secret=" + mediaConfig.getSecret();
  60 + return queryStr;
  61 + }
  62 +
41 63 @Override
42 64 protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){
43 65 System.out.println(e.getMessage());
... ...
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
... ... @@ -9,18 +9,32 @@ public class SipConfig {
9 9  
10 10 @Value("${sip.ip}")
11 11 private String sipIp;
  12 +
  13 + /**
  14 + * 默认使用sip.ip
  15 + */
  16 + @Value("${sip.monitorIp:0.0.0.0}")
  17 + private String monitorIp;
  18 +
12 19 @Value("${sip.port}")
13 20 private Integer sipPort;
  21 +
14 22 @Value("${sip.domain}")
15 23 private String sipDomain;
  24 +
16 25 @Value("${sip.id}")
17 26 private String sipId;
  27 +
18 28 @Value("${sip.password}")
19 29 private String sipPassword;
20 30  
21 31 @Value("${sip.ptz.speed:50}")
22 32 Integer speed;
23 33  
  34 + public String getMonitorIp() {
  35 + return monitorIp;
  36 + }
  37 +
24 38 public String getSipIp() {
25 39 return sipIp;
26 40 }
... ...
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java
... ... @@ -5,19 +5,19 @@ import org.springframework.context.annotation.Configuration;
5 5  
6 6 @Configuration("userSetup")
7 7 public class UserSetup {
8   - @Value("${userSettings.savePositionHistory}")
  8 + @Value("${userSettings.savePositionHistory:false}")
9 9 boolean savePositionHistory;
10 10  
11 11 @Value("${userSettings.autoApplyPlay}")
12 12 private boolean autoApplyPlay;
13 13  
14   - @Value("${userSettings.seniorSdp}")
  14 + @Value("${userSettings.seniorSdp:false}")
15 15 private boolean seniorSdp;
16 16  
17   - @Value("${userSettings.playTimeout}")
  17 + @Value("${userSettings.playTimeout:18000}")
18 18 private long playTimeout;
19 19  
20   - @Value("${userSettings.waitTrack}")
  20 + @Value("${userSettings.waitTrack:false}")
21 21 private boolean waitTrack;
22 22  
23 23 @Value("${userSettings.interfaceAuthentication}")
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
... ... @@ -68,6 +68,12 @@ public class Device {
68 68 */
69 69 private Long registerTimeMillis;
70 70  
  71 +
  72 + /**
  73 + * 心跳时间
  74 + */
  75 + private Long KeepaliveTimeMillis;
  76 +
71 77 /**
72 78 * 通道个数
73 79 */
... ... @@ -176,4 +182,12 @@ public class Device {
176 182 public void setRegisterTimeMillis(Long registerTimeMillis) {
177 183 this.registerTimeMillis = registerTimeMillis;
178 184 }
  185 +
  186 + public Long getKeepaliveTimeMillis() {
  187 + return KeepaliveTimeMillis;
  188 + }
  189 +
  190 + public void setKeepaliveTimeMillis(Long keepaliveTimeMillis) {
  191 + KeepaliveTimeMillis = keepaliveTimeMillis;
  192 + }
179 193 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -379,9 +379,9 @@ public class SIPCommander implements ISIPCommander {
379 379 StringBuffer content = new StringBuffer(200);
380 380 content.append("v=0\r\n");
381 381 // content.append("o=" + sipConfig.getSipId() + " 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
382   - content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  382 + content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
383 383 content.append("s=Play\r\n");
384   - content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  384 + content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
385 385 content.append("t=0 0\r\n");
386 386  
387 387 if (userSetup.isSeniorSdp()) {
... ... @@ -482,7 +482,7 @@ public class SIPCommander implements ISIPCommander {
482 482 content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n");
483 483 content.append("s=Playback\r\n");
484 484 content.append("u="+channelId+":0\r\n");
485   - content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  485 + content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
486 486 content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "
487 487 +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
488 488 String mediaPort = null;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
... ... @@ -198,9 +198,9 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
198 198 ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
199 199 StringBuffer content = new StringBuffer(200);
200 200 content.append("v=0\r\n");
201   - content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  201 + content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
202 202 content.append("s=Play\r\n");
203   - content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  203 + content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
204 204 content.append("t=0 0\r\n");
205 205 content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
206 206 content.append("a=sendonly\r\n");
... ... @@ -254,9 +254,9 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
254 254 ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
255 255 StringBuffer content = new StringBuffer(200);
256 256 content.append("v=0\r\n");
257   - content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  257 + content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
258 258 content.append("s=Play\r\n");
259   - content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
  259 + content.append("c=IN IP4 "+mediaInfo.getSdpIp()+"\r\n");
260 260 content.append("t=0 0\r\n");
261 261 content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
262 262 content.append("a=sendonly\r\n");
... ...
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;
4 5  
5 6 public class ZLMServerConfig {
6 7  
... ... @@ -34,9 +35,9 @@ public class ZLMServerConfig {
34 35 @JSONField(name = "general.streamNoneReaderDelayMS")
35 36 private String generalStreamNoneReaderDelayMS;
36 37  
37   - private String localIP;
  38 + private String ip;
38 39  
39   - private String wanIp;
  40 + private String sdpIp;
40 41  
41 42 private long updateTime;
42 43  
... ... @@ -281,12 +282,12 @@ public class ZLMServerConfig {
281 282 this.generalStreamNoneReaderDelayMS = generalStreamNoneReaderDelayMS;
282 283 }
283 284  
284   - public String getLocalIP() {
285   - return localIP;
  285 + public String getIp() {
  286 + return ip;
286 287 }
287 288  
288   - public void setLocalIP(String localIP) {
289   - this.localIP = localIP;
  289 + public void setIp(String ip) {
  290 + this.ip = ip;
290 291 }
291 292  
292 293 public String getHlsFileBufSize() {
... ... @@ -729,14 +730,6 @@ public class ZLMServerConfig {
729 730 this.shellPhell = shellPhell;
730 731 }
731 732  
732   - public String getWanIp() {
733   - return wanIp;
734   - }
735   -
736   - public void setWanIp(String wanIp) {
737   - this.wanIp = wanIp;
738   - }
739   -
740 733 public long getUpdateTime() {
741 734 return updateTime;
742 735 }
... ... @@ -760,4 +753,16 @@ public class ZLMServerConfig {
760 753 public void setRtmpSslPort(String rtmpSslPort) {
761 754 this.rtmpSslPort = rtmpSslPort;
762 755 }
  756 +
  757 + public String getSdpIp() {
  758 + if (StringUtils.isEmpty(sdpIp)) {
  759 + return ip;
  760 + }else {
  761 + return sdpIp;
  762 + }
  763 + }
  764 +
  765 + public void setSdpIp(String sdpIp) {
  766 + this.sdpIp = sdpIp;
  767 + }
763 768 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java
... ... @@ -18,8 +18,8 @@ public class ZLMServerManger {
18 18  
19 19 public void updateServerCatch(ZLMServerConfig zlmServerConfig) {
20 20  
21   - zlmServerConfig.setLocalIP(mediaConfig.getIp());
22   - zlmServerConfig.setWanIp(StringUtils.isEmpty(mediaConfig.getWanIp())? mediaConfig.getIp(): mediaConfig.getWanIp());
  21 + zlmServerConfig.setIp(mediaConfig.getIp());
  22 + zlmServerConfig.setSdpIp(mediaConfig.getSdpIp());
23 23 zlmServerConfig.setHttpPort(mediaConfig.getHttpPort());
24 24  
25 25 if(!StringUtils.isEmpty(mediaConfig.getHttpSSlPort()))
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
... ... @@ -32,17 +32,17 @@ public class MediaServiceImpl implements IMediaService {
32 32 StreamInfo streamInfoResult = new StreamInfo();
33 33 streamInfoResult.setStreamId(stream);
34 34 streamInfoResult.setApp(app);
35   - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getWanIp(), mediaInfo.getRtmpPort(), app, stream));
36   - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getWanIp(), mediaInfo.getRtspPort(), app, stream));
37   - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
38   - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
39   - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
40   - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
41   - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
42   - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
43   - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
44   - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
45   - streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
  35 + streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtmpPort(), app, stream));
  36 + streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtspPort(), app, stream));
  37 + streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  38 + streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  39 + streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  40 + streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  41 + streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  42 + streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  43 + streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  44 + streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
  45 + streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream));
46 46 streamInfoResult.setTracks(tracks);
47 47 return streamInfoResult;
48 48 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/record/RecoderProxyController.java
... ... @@ -48,7 +48,7 @@ public class RecoderProxyController {
48 48 // 后续改为根据Id获取对应的ZLM
49 49 ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
50 50 String requestURI = String.format("http://%s:%s%s?%s",
51   - mediaInfo.getLocalIP(),
  51 + mediaInfo.getSdpIp(),
52 52 mediaConfig.getRecordAssistPort(),
53 53 baseRequestURI.substring(baseRequestURI.indexOf(mediaId) + mediaId.length()),
54 54 URLDecoder.decode(request.getQueryString())
... ...
src/main/resources/all-application.yml 0 → 100644
  1 +
  2 +
  3 +
  4 +# 此配置文件只是用作展示所有配置项, 不可不直接使用
  5 +
  6 +
  7 +spring:
  8 + # REDIS数据库配置
  9 + redis:
  10 + # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
  11 + host: 127.0.0.1
  12 + # [必须修改] 端口号
  13 + port: 6379
  14 + # [可选] 数据库 DB
  15 + database: 6
  16 + # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
  17 + password:
  18 + # [可选] 超时时间
  19 + timeout: 10000
  20 + # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置
  21 + datasource:
  22 + # name: wvp
  23 + # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
  24 + # username:
  25 + # password:
  26 + # type: com.alibaba.druid.pool.DruidDataSource
  27 + # driver-class-name: com.mysql.cj.jdbc.Driver
  28 + name: eiot
  29 + url: jdbc:sqlite::resource:wvp.sqlite
  30 + username:
  31 + password:
  32 + type: com.alibaba.druid.pool.DruidDataSource
  33 + driver-class-name: org.sqlite.JDBC
  34 + max-active: 1
  35 + min-idle: 1
  36 +
  37 +# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
  38 +server:
  39 + port: 18080
  40 + # [可选] HTTPS配置, 默认不开启
  41 + ssl:
  42 + # [可选] 是否开启HTTPS访问
  43 + enabled: false
  44 + # [可选] 证书文件路径,放置在resource/目录下即可,修改xxx为文件名
  45 + key-store: classpath:xxx.jks
  46 + # [可选] 证书密码
  47 + key-password: password
  48 + # [可选] 证书类型, 默认为jks,根据实际修改
  49 + key-store-type: JKS
  50 +
  51 +# 作为28181服务器的配置
  52 +sip:
  53 + # [必须修改] 本机的IP, 必须是网卡上的IP,用于sip下协议栈监听ip,如果监听所有设置为0.0.0.0
  54 + monitorIp: 0.0.0.0
  55 + # [必须修改] 本机的IP
  56 + ip: 192.168.0.100
  57 + # [可选] 28181服务监听的端口
  58 + port: 5060
  59 + # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
  60 + # 后两位为行业编码,定义参照附录D.3
  61 + # 3701020049标识山东济南历下区 信息行业接入
  62 + # [可选]
  63 + domain: 4401020049
  64 + # [可选]
  65 + id: 44010200492000000001
  66 + # [可选] 默认设备认证密码,后续扩展使用设备单独密码
  67 + password: admin123
  68 +
  69 +#zlm服务器配置
  70 +media:
  71 + # [必须修改] 本机的IP, 必须是网卡上的IP,用于sip下协议栈监听ip,如果监听所有设置为0.0.0.0
  72 + monitorIp: 0.0.0.0
  73 + # [必须修改] zlm服务器的内网IP
  74 + ip: 192.168.0.100
  75 + # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip
  76 + sdpIp:
  77 + # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip
  78 + hookIp:
  79 + # [必须修改] zlm服务器的http.port
  80 + httpPort: 80
  81 + # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置
  82 + httpSSlPort:
  83 + # [可选] zlm服务器的rtmp.port, 置空使用zlm配置文件配置
  84 + rtmpPort:
  85 + # [可选] zlm服务器的rtmp.sslport, 置空使用zlm配置文件配置
  86 + rtmpSSlPort:
  87 + # [可选] zlm服务器的 rtp_proxy.port, 置空使用zlm配置文件配置
  88 + rtpProxyPort:
  89 + # [可选] zlm服务器的 rtsp.port, 置空使用zlm配置文件配置
  90 + rtspPort:
  91 + # [可选] zlm服务器的 rtsp.sslport, 置空使用zlm配置文件配置
  92 + rtspSSLPort:
  93 + # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改
  94 + autoConfig: true
  95 + # [可选] zlm服务器的hook.admin_params=secret
  96 + secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
  97 + # [可选] zlm服务器的general.streamNoneReaderDelayMS
  98 + streamNoneReaderDelayMS: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流
  99 + # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试
  100 + rtp:
  101 + # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
  102 + enable: true
  103 + # [可选] 在此范围内选择端口用于媒体流传输,
  104 + portRange: 30000,30500 # 端口范围
  105 + # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
  106 + recordAssistPort: 0
  107 +
  108 +# [可选] 日志配置, 一般不需要改
  109 +logging:
  110 + file:
  111 + name: logs/wvp.log
  112 + max-history: 30
  113 + max-size: 10MB
  114 + total-size-cap: 300MB
  115 + level:
  116 + com:
  117 + genersoft:
  118 + iot: info
  119 +# [根据业务需求配置]
  120 +userSettings:
  121 + # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true
  122 + autoApplyPlay: false
  123 + # [可选] 部分设备需要扩展SDP,需要打开此设置
  124 + seniorSdp: false
  125 + # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认)
  126 + savePositionHistory: false
  127 + # 点播等待超时时间,单位:毫秒
  128 + playTimeout: 3000
  129 + # 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播
  130 + waitTrack: false
  131 + # 是否开启接口鉴权
  132 + interfaceAuthentication: true
  133 + # 推流直播是否录制
  134 + recordPushLive: true
  135 +
  136 +# 在线文档: swagger-ui(生产环境建议关闭)
  137 +springfox:
  138 + documentation:
  139 + swagger-ui:
  140 + enabled: true
0 141 \ No newline at end of file
... ...
src/main/resources/application-dev.yml
... ... @@ -13,12 +13,6 @@ spring:
13 13 timeout: 10000
14 14 # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置
15 15 datasource:
16   - # name: wvp
17   - # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
18   - # username:
19   - # password:
20   - # type: com.alibaba.druid.pool.DruidDataSource
21   - # driver-class-name: com.mysql.cj.jdbc.Driver
22 16 name: eiot
23 17 url: jdbc:sqlite::resource:wvp.sqlite
24 18 username:
... ... @@ -31,20 +25,10 @@ spring:
31 25 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
32 26 server:
33 27 port: 18080
34   - # [可选] HTTPS配置, 默认不开启
35   - ssl:
36   - # [可选] 是否开启HTTPS访问
37   - enabled: false
38   - # [可选] 证书文件路径,放置在resource/目录下即可,修改xxx为文件名
39   - key-store: classpath:xxx.jks
40   - # [可选] 证书密码
41   - key-password: password
42   - # [可选] 证书类型, 默认为jks,根据实际修改
43   - key-store-type: JKS
44 28  
45 29 # 作为28181服务器的配置
46 30 sip:
47   - # [必须修改] 本机的IP, 必须是网卡上的IP
  31 + # [必须修改] 本机的IP
48 32 ip: 192.168.0.100
49 33 # [可选] 28181服务监听的端口
50 34 port: 5060
... ... @@ -62,30 +46,10 @@ sip:
62 46 media:
63 47 # [必须修改] zlm服务器的内网IP
64 48 ip: 192.168.0.100
65   - # [可选] zlm服务器的公网IP, 内网部署置空即可
66   - wanIp:
67   - # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip
68   - hookIp:
69 49 # [必须修改] zlm服务器的http.port
70 50 httpPort: 80
71   - # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置
72   - httpSSlPort:
73   - # [可选] zlm服务器的rtmp.port, 置空使用zlm配置文件配置
74   - rtmpPort:
75   - # [可选] zlm服务器的rtmp.sslport, 置空使用zlm配置文件配置
76   - rtmpSSlPort:
77   - # [可选] zlm服务器的 rtp_proxy.port, 置空使用zlm配置文件配置
78   - rtpProxyPort:
79   - # [可选] zlm服务器的 rtsp.port, 置空使用zlm配置文件配置
80   - rtspPort:
81   - # [可选] zlm服务器的 rtsp.sslport, 置空使用zlm配置文件配置
82   - rtspSSLPort:
83   - # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改
84   - autoConfig: true
85 51 # [可选] zlm服务器的hook.admin_params=secret
86 52 secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
87   - # [可选] zlm服务器的general.streamNoneReaderDelayMS
88   - streamNoneReaderDelayMS: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流
89 53 # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试
90 54 rtp:
91 55 # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
... ... @@ -95,29 +59,10 @@ media:
95 59 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
96 60 recordAssistPort: 0
97 61  
98   -# [可选] 日志配置, 一般不需要改
99   -logging:
100   - file:
101   - name: logs/wvp.log
102   - max-history: 30
103   - max-size: 10MB
104   - total-size-cap: 300MB
105   - level:
106   - com:
107   - genersoft:
108   - iot: info
109 62 # [根据业务需求配置]
110 63 userSettings:
111 64 # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true
112 65 autoApplyPlay: false
113   - # [可选] 部分设备需要扩展SDP,需要打开此设置
114   - seniorSdp: false
115   - # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认)
116   - savePositionHistory: false
117   - # 点播等待超时时间,单位:毫秒
118   - playTimeout: 3000
119   - # 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播
120   - waitTrack: false
121 66 # 是否开启接口鉴权
122 67 interfaceAuthentication: true
123 68 # 推流直播是否录制
... ... @@ -127,4 +72,16 @@ userSettings:
127 72 springfox:
128 73 documentation:
129 74 swagger-ui:
130   - enabled: true
131 75 \ No newline at end of file
  76 + enabled: true
  77 +
  78 +# [可选] 日志配置, 一般不需要改
  79 +logging:
  80 + file:
  81 + name: logs/wvp.log
  82 + max-history: 30
  83 + max-size: 10MB
  84 + total-size-cap: 300MB
  85 + level:
  86 + com:
  87 + genersoft:
  88 + iot: info
132 89 \ No newline at end of file
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -270,11 +270,18 @@ export default {
270 270 this.hasaudio = hasAudio;
271 271 this.isLoging = false;
272 272 // this.videoUrl = streamInfo.rtc;
273   - this.videoUrl = streamInfo.ws_flv;
  273 + this.videoUrl = this.getUrlByStreamInfo(streamInfo);
274 274 this.streamId = streamInfo.streamId;
275 275 this.app = streamInfo.app;
276 276 this.playFromStreamInfo(false, streamInfo)
277 277 },
  278 + getUrlByStreamInfo(streamInfo){
  279 + let baseZlmApi = process.env.NODE_ENV === 'development'?`${location.host}/debug/zlm`:`${location.host}/zlm`
  280 + console.log(12121212)
  281 + console.log(baseZlmApi)
  282 + // return `${baseZlmApi}/${streamInfo.app}/${streamInfo.streamId}.flv`;
  283 + return `http://${baseZlmApi}/${streamInfo.app}/${streamInfo.streamId}.flv`;
  284 + },
278 285 coverPlay: function () {
279 286 var that = this;
280 287 this.coverPlaying = true;
... ... @@ -335,7 +342,7 @@ export default {
335 342 playFromStreamInfo: function (realHasAudio, streamInfo) {
336 343 this.showVideoDialog = true;
337 344 this.hasaudio = realHasAudio && this.hasaudio;
338   - this.$refs.videoPlayer.play(streamInfo.ws_flv)
  345 + this.$refs.videoPlayer.play(this.getUrlByStreamInfo(streamInfo))
339 346 },
340 347 close: function () {
341 348 console.log('关闭视频');
... ... @@ -418,7 +425,7 @@ export default {
418 425 }).then(function (res) {
419 426 var streamInfo = res.data;
420 427 that.streamId = streamInfo.streamId;
421   - that.videoUrl = streamInfo.ws_flv;
  428 + that.videoUrl = this.getUrlByStreamInfo(streamInfo);
422 429 that.recordPlay = true;
423 430 });
424 431 }
... ...
web_src/src/main.js
... ... @@ -55,7 +55,6 @@ axios.interceptors.response.use(function (response) {
55 55  
56 56 Vue.prototype.$cookies.config(60*30);
57 57  
58   -
59 58 new Vue({
60 59 router: router,
61 60 render: h => h(App),
... ...