From 3c8507daeedc535eef622e43b450d497a767f187 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 2 Dec 2020 15:33:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0hookip=E8=AE=BE=E7=BD=AE,=20?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E8=87=AA=E5=8A=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/media/zlm/ZLMRunner.java | 20 ++++-- .../iot/vmp/vmanager/play/PlayController.java | 1 + src/main/resources/application.yml | 70 ++++++++++++++----- 3 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index 66f8e61e..4a4f1f0d 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -36,6 +36,9 @@ public class ZLMRunner implements CommandLineRunner { @Value("${media.wanIp}") private String mediaWanIp; + @Value("${media.hookIp}") + private String mediaHookIp; + @Value("${media.port}") private int mediaPort; @@ -51,6 +54,9 @@ public class ZLMRunner implements CommandLineRunner { @Value("${server.port}") private String serverPort; + @Value("${media.autoConfig}") + private boolean autoConfig; + @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -61,8 +67,7 @@ public class ZLMRunner implements CommandLineRunner { MediaServerConfig mediaServerConfig = getMediaServerConfig(); if (mediaServerConfig != null) { logger.info("zlm接入成功..."); - logger.info("设置zlm..."); - saveZLMConfig(); + if (autoConfig) saveZLMConfig(); mediaServerConfig = getMediaServerConfig(); storager.updateMediaInfo(mediaServerConfig); } @@ -91,12 +96,15 @@ public class ZLMRunner implements CommandLineRunner { } private void saveZLMConfig() { - String hookIP = sipIP; - if (mediaIp.equals(sipIP)) { - hookIP = "127.0.0.1"; + logger.info("设置zlm..."); + if (StringUtils.isEmpty(mediaHookIp)) { + mediaHookIp = sipIP; + } + if (mediaIp.equals(mediaHookIp)) { + mediaHookIp = "127.0.0.1"; } - String hookPrex = String.format("http://%s:%s/index/hook", hookIP, serverPort); + String hookPrex = String.format("http://%s:%s/index/hook", mediaHookIp, serverPort); Map param = new HashMap<>(); param.put("api.secret",mediaSecret); // -profile:v Baseline 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"); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java index 300ffc3d..3594affd 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java @@ -93,6 +93,7 @@ public class PlayController { lockFlag = false; logger.info("流编码信息已获取"); JSONArray tracks = mediaInfo.getJSONArray("tracks"); + logger.info(tracks.toJSONString()); streamInfo.setTracks(tracks); storager.startPlay(streamInfo); } else { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 463548a2..a15c88ca 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,20 +1,24 @@ spring: + # [不需要改] application: name: iot-vmp-vmanager - # 影子数据存储方式,支持redis、jdbc,暂不支持mysql + # [不需要改] 影子数据存储方式,支持redis、jdbc,暂不支持mysql, database: redis - # 通信方式,支持kafka、http + # [不需要改] 通信方式,支持kafka、http communicate: http + # REDIS数据库配置 redis: - # Redis服务器IP - host: 127.0.0.1 - #端口号 + # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 + host: 192.168.1.141 + # [必须修改] 端口号 port: 6379 + # [可选] 数据库 DB database: 6 - #访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 - password: - #超时时间 + # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 + password: 4767cb971b40a1300fa09b7f87b09d1c + # [可选] 超时时间 timeout: 10000 + # [不可用] jdbc数据库配置, 暂不支持 datasource: name: eiot url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true @@ -22,36 +26,62 @@ spring: password: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver + +# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 server: port: 18080 + +# 作为28181服务器的配置 sip: - ip: 192.168.1.44 + # [必须修改] 本机的IP, 必须是网卡上的IP + ip: 192.168.1.20 + # [可选] 28181服务监听的端口 port: 5060 # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) # 后两位为行业编码,定义参照附录D.3 # 3701020049标识山东济南历下区 信息行业接入 + # [可选] domain: 3402000000 + # [可选] id: 34020000002000000001 - # 默认设备认证密码,后续扩展使用设备单独密码 + # [可选] 默认设备认证密码,后续扩展使用设备单独密码 password: 12345678 -auth: #32位小写md5加密(默认密码为admin) +# 登陆的用户名密码 +auth: + # [可选] 用户名 username: admin + # [可选] 密码, 默认为admin password: 21232f297a57a5a743894a0e4a801fc3 -media: #zlm服务器的ip与http端口, 重点: 这是http端口 - ip: 192.168.1.44 - wanIp: - port: 80 +#zlm服务器配置 +media: + # [必须修改] zlm服务器的内网IP + ip: 127.0.0.1 + # [可选] zlm服务器的公网IP, 内网部署置空即可 + wanIp: 192.168.1.20 + # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip + hookIp: + # [必须修改] zlm服务器的http.port + port: 6080 + # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 + autoConfig: true + # [可选] zlm服务器的hook.admin_params=secret secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc + # [可选] zlm服务器的general.streamNoneReaderDelayMS streamNoneReaderDelayMS: 600000 # 无人观看多久自动关闭流 - # 关闭等待收到流编码信息后在返回, + # [可选] 关闭等待收到流编码信息后在返回, # 设为false可以获得更好的兼容性,保证返回后流就可以播放, # 设为true可以快速打开播放窗口,可以获得更好的体验 - closeWaitRTPInfo: true - rtp: # 启用udp多端口模式 + closeWaitRTPInfo: false + # 启用udp多端口模式, 详细解释参考: https://github.com/xia-chu/ZLMediaKit/wiki/GB28181%E6%8E%A8%E6%B5%81 下的高阶使用 + rtp: + # [可选] 是否启用udp多端口模式, 开启后会在udpPortRange范围内选择端口用于媒体流传输 enable: true + # [可选] 在此范围内选择端口用于媒体流传输, 不只是udp, 使用TCP被动传输模式时,也是从这个范围内选择端口 udpPortRange: 30000,30500 # 端口范围 + +# [可选] 日志配置, 一般不需要改 logging: file: name: logs/wvp.log @@ -61,4 +91,6 @@ logging: level: com: genersoft: - iot: debug \ No newline at end of file + iot: debug + +