Commit 3c8507daeedc535eef622e43b450d497a767f187
1 parent
fe09511a
增加hookip设置, 是否开启自动配置设置
Showing
3 changed files
with
66 additions
and
25 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -36,6 +36,9 @@ public class ZLMRunner implements CommandLineRunner { | @@ -36,6 +36,9 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 36 | @Value("${media.wanIp}") | 36 | @Value("${media.wanIp}") |
| 37 | private String mediaWanIp; | 37 | private String mediaWanIp; |
| 38 | 38 | ||
| 39 | + @Value("${media.hookIp}") | ||
| 40 | + private String mediaHookIp; | ||
| 41 | + | ||
| 39 | @Value("${media.port}") | 42 | @Value("${media.port}") |
| 40 | private int mediaPort; | 43 | private int mediaPort; |
| 41 | 44 | ||
| @@ -51,6 +54,9 @@ public class ZLMRunner implements CommandLineRunner { | @@ -51,6 +54,9 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 51 | @Value("${server.port}") | 54 | @Value("${server.port}") |
| 52 | private String serverPort; | 55 | private String serverPort; |
| 53 | 56 | ||
| 57 | + @Value("${media.autoConfig}") | ||
| 58 | + private boolean autoConfig; | ||
| 59 | + | ||
| 54 | @Autowired | 60 | @Autowired |
| 55 | private ZLMRESTfulUtils zlmresTfulUtils; | 61 | private ZLMRESTfulUtils zlmresTfulUtils; |
| 56 | 62 | ||
| @@ -61,8 +67,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -61,8 +67,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 61 | MediaServerConfig mediaServerConfig = getMediaServerConfig(); | 67 | MediaServerConfig mediaServerConfig = getMediaServerConfig(); |
| 62 | if (mediaServerConfig != null) { | 68 | if (mediaServerConfig != null) { |
| 63 | logger.info("zlm接入成功..."); | 69 | logger.info("zlm接入成功..."); |
| 64 | - logger.info("设置zlm..."); | ||
| 65 | - saveZLMConfig(); | 70 | + if (autoConfig) saveZLMConfig(); |
| 66 | mediaServerConfig = getMediaServerConfig(); | 71 | mediaServerConfig = getMediaServerConfig(); |
| 67 | storager.updateMediaInfo(mediaServerConfig); | 72 | storager.updateMediaInfo(mediaServerConfig); |
| 68 | } | 73 | } |
| @@ -91,12 +96,15 @@ public class ZLMRunner implements CommandLineRunner { | @@ -91,12 +96,15 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 91 | } | 96 | } |
| 92 | 97 | ||
| 93 | private void saveZLMConfig() { | 98 | private void saveZLMConfig() { |
| 94 | - String hookIP = sipIP; | ||
| 95 | - if (mediaIp.equals(sipIP)) { | ||
| 96 | - hookIP = "127.0.0.1"; | 99 | + logger.info("设置zlm..."); |
| 100 | + if (StringUtils.isEmpty(mediaHookIp)) { | ||
| 101 | + mediaHookIp = sipIP; | ||
| 102 | + } | ||
| 103 | + if (mediaIp.equals(mediaHookIp)) { | ||
| 104 | + mediaHookIp = "127.0.0.1"; | ||
| 97 | } | 105 | } |
| 98 | 106 | ||
| 99 | - String hookPrex = String.format("http://%s:%s/index/hook", hookIP, serverPort); | 107 | + String hookPrex = String.format("http://%s:%s/index/hook", mediaHookIp, serverPort); |
| 100 | Map<String, Object> param = new HashMap<>(); | 108 | Map<String, Object> param = new HashMap<>(); |
| 101 | param.put("api.secret",mediaSecret); // -profile:v Baseline | 109 | param.put("api.secret",mediaSecret); // -profile:v Baseline |
| 102 | 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"); | 110 | 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/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
| @@ -93,6 +93,7 @@ public class PlayController { | @@ -93,6 +93,7 @@ public class PlayController { | ||
| 93 | lockFlag = false; | 93 | lockFlag = false; |
| 94 | logger.info("流编码信息已获取"); | 94 | logger.info("流编码信息已获取"); |
| 95 | JSONArray tracks = mediaInfo.getJSONArray("tracks"); | 95 | JSONArray tracks = mediaInfo.getJSONArray("tracks"); |
| 96 | + logger.info(tracks.toJSONString()); | ||
| 96 | streamInfo.setTracks(tracks); | 97 | streamInfo.setTracks(tracks); |
| 97 | storager.startPlay(streamInfo); | 98 | storager.startPlay(streamInfo); |
| 98 | } else { | 99 | } else { |
src/main/resources/application.yml
| 1 | spring: | 1 | spring: |
| 2 | + # [不需要改] | ||
| 2 | application: | 3 | application: |
| 3 | name: iot-vmp-vmanager | 4 | name: iot-vmp-vmanager |
| 4 | - # 影子数据存储方式,支持redis、jdbc,暂不支持mysql | 5 | + # [不需要改] 影子数据存储方式,支持redis、jdbc,暂不支持mysql, |
| 5 | database: redis | 6 | database: redis |
| 6 | - # 通信方式,支持kafka、http | 7 | + # [不需要改] 通信方式,支持kafka、http |
| 7 | communicate: http | 8 | communicate: http |
| 9 | + # REDIS数据库配置 | ||
| 8 | redis: | 10 | redis: |
| 9 | - # Redis服务器IP | ||
| 10 | - host: 127.0.0.1 | ||
| 11 | - #端口号 | 11 | + # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 |
| 12 | + host: 192.168.1.141 | ||
| 13 | + # [必须修改] 端口号 | ||
| 12 | port: 6379 | 14 | port: 6379 |
| 15 | + # [可选] 数据库 DB | ||
| 13 | database: 6 | 16 | database: 6 |
| 14 | - #访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 | ||
| 15 | - password: | ||
| 16 | - #超时时间 | 17 | + # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 |
| 18 | + password: 4767cb971b40a1300fa09b7f87b09d1c | ||
| 19 | + # [可选] 超时时间 | ||
| 17 | timeout: 10000 | 20 | timeout: 10000 |
| 21 | + # [不可用] jdbc数据库配置, 暂不支持 | ||
| 18 | datasource: | 22 | datasource: |
| 19 | name: eiot | 23 | name: eiot |
| 20 | url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | 24 | url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true |
| @@ -22,36 +26,62 @@ spring: | @@ -22,36 +26,62 @@ spring: | ||
| 22 | password: | 26 | password: |
| 23 | type: com.alibaba.druid.pool.DruidDataSource | 27 | type: com.alibaba.druid.pool.DruidDataSource |
| 24 | driver-class-name: com.mysql.jdbc.Driver | 28 | driver-class-name: com.mysql.jdbc.Driver |
| 29 | + | ||
| 30 | +# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 | ||
| 25 | server: | 31 | server: |
| 26 | port: 18080 | 32 | port: 18080 |
| 33 | + | ||
| 34 | +# 作为28181服务器的配置 | ||
| 27 | sip: | 35 | sip: |
| 28 | - ip: 192.168.1.44 | 36 | + # [必须修改] 本机的IP, 必须是网卡上的IP |
| 37 | + ip: 192.168.1.20 | ||
| 38 | + # [可选] 28181服务监听的端口 | ||
| 29 | port: 5060 | 39 | port: 5060 |
| 30 | # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) | 40 | # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) |
| 31 | # 后两位为行业编码,定义参照附录D.3 | 41 | # 后两位为行业编码,定义参照附录D.3 |
| 32 | # 3701020049标识山东济南历下区 信息行业接入 | 42 | # 3701020049标识山东济南历下区 信息行业接入 |
| 43 | + # [可选] | ||
| 33 | domain: 3402000000 | 44 | domain: 3402000000 |
| 45 | + # [可选] | ||
| 34 | id: 34020000002000000001 | 46 | id: 34020000002000000001 |
| 35 | - # 默认设备认证密码,后续扩展使用设备单独密码 | 47 | + # [可选] 默认设备认证密码,后续扩展使用设备单独密码 |
| 36 | password: 12345678 | 48 | password: 12345678 |
| 37 | 49 | ||
| 38 | -auth: #32位小写md5加密(默认密码为admin) | 50 | +# 登陆的用户名密码 |
| 51 | +auth: | ||
| 52 | + # [可选] 用户名 | ||
| 39 | username: admin | 53 | username: admin |
| 54 | + # [可选] 密码, 默认为admin | ||
| 40 | password: 21232f297a57a5a743894a0e4a801fc3 | 55 | password: 21232f297a57a5a743894a0e4a801fc3 |
| 41 | 56 | ||
| 42 | -media: #zlm服务器的ip与http端口, 重点: 这是http端口 | ||
| 43 | - ip: 192.168.1.44 | ||
| 44 | - wanIp: | ||
| 45 | - port: 80 | 57 | +#zlm服务器配置 |
| 58 | +media: | ||
| 59 | + # [必须修改] zlm服务器的内网IP | ||
| 60 | + ip: 127.0.0.1 | ||
| 61 | + # [可选] zlm服务器的公网IP, 内网部署置空即可 | ||
| 62 | + wanIp: 192.168.1.20 | ||
| 63 | + # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip | ||
| 64 | + hookIp: | ||
| 65 | + # [必须修改] zlm服务器的http.port | ||
| 66 | + port: 6080 | ||
| 67 | + # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 | ||
| 68 | + autoConfig: true | ||
| 69 | + # [可选] zlm服务器的hook.admin_params=secret | ||
| 46 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc | 70 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc |
| 71 | + # [可选] zlm服务器的general.streamNoneReaderDelayMS | ||
| 47 | streamNoneReaderDelayMS: 600000 # 无人观看多久自动关闭流 | 72 | streamNoneReaderDelayMS: 600000 # 无人观看多久自动关闭流 |
| 48 | - # 关闭等待收到流编码信息后在返回, | 73 | + # [可选] 关闭等待收到流编码信息后在返回, |
| 49 | # 设为false可以获得更好的兼容性,保证返回后流就可以播放, | 74 | # 设为false可以获得更好的兼容性,保证返回后流就可以播放, |
| 50 | # 设为true可以快速打开播放窗口,可以获得更好的体验 | 75 | # 设为true可以快速打开播放窗口,可以获得更好的体验 |
| 51 | - closeWaitRTPInfo: true | ||
| 52 | - rtp: # 启用udp多端口模式 | 76 | + closeWaitRTPInfo: false |
| 77 | + # 启用udp多端口模式, 详细解释参考: https://github.com/xia-chu/ZLMediaKit/wiki/GB28181%E6%8E%A8%E6%B5%81 下的高阶使用 | ||
| 78 | + rtp: | ||
| 79 | + # [可选] 是否启用udp多端口模式, 开启后会在udpPortRange范围内选择端口用于媒体流传输 | ||
| 53 | enable: true | 80 | enable: true |
| 81 | + # [可选] 在此范围内选择端口用于媒体流传输, 不只是udp, 使用TCP被动传输模式时,也是从这个范围内选择端口 | ||
| 54 | udpPortRange: 30000,30500 # 端口范围 | 82 | udpPortRange: 30000,30500 # 端口范围 |
| 83 | + | ||
| 84 | +# [可选] 日志配置, 一般不需要改 | ||
| 55 | logging: | 85 | logging: |
| 56 | file: | 86 | file: |
| 57 | name: logs/wvp.log | 87 | name: logs/wvp.log |
| @@ -61,4 +91,6 @@ logging: | @@ -61,4 +91,6 @@ logging: | ||
| 61 | level: | 91 | level: |
| 62 | com: | 92 | com: |
| 63 | genersoft: | 93 | genersoft: |
| 64 | - iot: debug | ||
| 65 | \ No newline at end of file | 94 | \ No newline at end of file |
| 95 | + iot: debug | ||
| 96 | + | ||
| 97 | + |