Commit fe98e57fc4350ddc2220b5f6f2201d0d73573c01

Authored by panlinlin
1 parent 41ca4e93

增加对https的支持

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
@@ -61,6 +61,9 @@ public class ZLMRunner implements CommandLineRunner { @@ -61,6 +61,9 @@ public class ZLMRunner implements CommandLineRunner {
61 @Value("${media.autoConfig}") 61 @Value("${media.autoConfig}")
62 private boolean autoConfig; 62 private boolean autoConfig;
63 63
  64 + @Value("${server.ssl.enabled}")
  65 + private boolean sslEnabled;
  66 +
64 @Autowired 67 @Autowired
65 private ZLMRESTfulUtils zlmresTfulUtils; 68 private ZLMRESTfulUtils zlmresTfulUtils;
66 69
@@ -116,8 +119,8 @@ public class ZLMRunner implements CommandLineRunner { @@ -116,8 +119,8 @@ public class ZLMRunner implements CommandLineRunner {
116 if (StringUtils.isEmpty(mediaHookIp)) { 119 if (StringUtils.isEmpty(mediaHookIp)) {
117 mediaHookIp = sipIP; 120 mediaHookIp = sipIP;
118 } 121 }
119 -  
120 - String hookPrex = String.format("http://%s:%s/index/hook", mediaHookIp, serverPort); 122 + String protocol = sslEnabled ? "https" : "http";
  123 + String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaHookIp, serverPort);
121 Map<String, Object> param = new HashMap<>(); 124 Map<String, Object> param = new HashMap<>();
122 param.put("api.secret",mediaSecret); // -profile:v Baseline 125 param.put("api.secret",mediaSecret); // -profile:v Baseline
123 param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"); 126 param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");
src/main/resources/application-dev.yml
@@ -31,6 +31,16 @@ spring: @@ -31,6 +31,16 @@ spring:
31 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 31 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
32 server: 32 server:
33 port: 18080 33 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
34 44
35 # 作为28181服务器的配置 45 # 作为28181服务器的配置
36 sip: 46 sip: