Commit 10ae1bba597e562a20f44f777ae5afdefb5da6af
1 parent
a3649ca2
增加对zlm使用docker容器的支持
Showing
23 changed files
with
367 additions
and
175 deletions
pom.xml
| @@ -45,6 +45,7 @@ | @@ -45,6 +45,7 @@ | ||
| 45 | <properties> | 45 | <properties> |
| 46 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | 46 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 47 | <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> | 47 | <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> |
| 48 | + <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> | ||
| 48 | 49 | ||
| 49 | <!-- 依赖版本 --> | 50 | <!-- 依赖版本 --> |
| 50 | <pagehelper.version>5.2.0</pagehelper.version> | 51 | <pagehelper.version>5.2.0</pagehelper.version> |
src/main/java/com/genersoft/iot/vmp/conf/ApplicationCheckRunner.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.conf; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.conf; | ||
| 2 | 2 | ||
| 3 | import org.slf4j.Logger; | 3 | import org.slf4j.Logger; |
| 4 | import org.slf4j.LoggerFactory; | 4 | import org.slf4j.LoggerFactory; |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | import org.springframework.beans.factory.annotation.Value; | 6 | import org.springframework.beans.factory.annotation.Value; |
| 6 | import org.springframework.boot.CommandLineRunner; | 7 | import org.springframework.boot.CommandLineRunner; |
| 7 | import org.springframework.core.annotation.Order; | 8 | import org.springframework.core.annotation.Order; |
| @@ -17,46 +18,21 @@ public class ApplicationCheckRunner implements CommandLineRunner { | @@ -17,46 +18,21 @@ public class ApplicationCheckRunner implements CommandLineRunner { | ||
| 17 | 18 | ||
| 18 | private Logger logger = LoggerFactory.getLogger("ApplicationCheckRunner"); | 19 | private Logger logger = LoggerFactory.getLogger("ApplicationCheckRunner"); |
| 19 | 20 | ||
| 20 | - @Value("${sip.ip}") | ||
| 21 | - private String sipIp; | ||
| 22 | - | ||
| 23 | - @Value("${media.ip}") | ||
| 24 | - private String mediaIp; | ||
| 25 | - | ||
| 26 | - @Value("${media.wanIp}") | ||
| 27 | - private String mediaWanIp; | ||
| 28 | - | ||
| 29 | - @Value("${media.hookIp}") | ||
| 30 | - private String mediaHookIp; | ||
| 31 | - | ||
| 32 | - @Value("${media.port}") | ||
| 33 | - private int mediaPort; | ||
| 34 | - | ||
| 35 | - @Value("${media.secret}") | ||
| 36 | - private String mediaSecret; | ||
| 37 | - | ||
| 38 | - @Value("${media.streamNoneReaderDelayMS}") | ||
| 39 | - private String streamNoneReaderDelayMS; | ||
| 40 | - | ||
| 41 | - @Value("${sip.ip}") | ||
| 42 | - private String sipIP; | ||
| 43 | - | ||
| 44 | - @Value("${server.port}") | ||
| 45 | - private String serverPort; | ||
| 46 | - | ||
| 47 | - @Value("${media.autoConfig}") | ||
| 48 | - private boolean autoConfig; | 21 | + @Autowired |
| 22 | + private MediaConfig mediaConfig; | ||
| 49 | 23 | ||
| 24 | + @Autowired | ||
| 25 | + private SipConfig sipConfig; | ||
| 50 | 26 | ||
| 51 | @Override | 27 | @Override |
| 52 | public void run(String... args) throws Exception { | 28 | public void run(String... args) throws Exception { |
| 53 | - if (sipIP.equals("localhost") || sipIP.equals("127.0.0.1")) { | ||
| 54 | - logger.error("sip.ip不能使用 {} ,请使用类似192.168.1.44这样的来自网卡的IP!!!", sipIP ); | 29 | + if (sipConfig.getSipIp().equals("localhost") || sipConfig.getSipIp().equals("127.0.0.1")) { |
| 30 | + logger.error("sip.ip不能使用 {} ,请使用类似192.168.1.44这样的来自网卡的IP!!!", sipConfig.getSipIp() ); | ||
| 55 | System.exit(1); | 31 | System.exit(1); |
| 56 | } | 32 | } |
| 57 | 33 | ||
| 58 | - if (mediaIp.equals("localhost") || (mediaIp.equals("127.0.0.1") && mediaWanIp == null)) { | ||
| 59 | - logger.warn("mediaIp.ip使用 {} ,将无法收到网络内其他设备的推流!!!", mediaIp ); | 34 | + if (mediaConfig.getIp().equals("localhost") || (mediaConfig.getIp().equals("127.0.0.1") && mediaConfig.getWanIp() == null)) { |
| 35 | + logger.warn("mediaIp.ip使用 {} ,将无法收到网络内其他设备的推流!!!", mediaConfig.getIp() ); | ||
| 60 | } | 36 | } |
| 61 | 37 | ||
| 62 | } | 38 | } |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.conf; | ||
| 2 | + | ||
| 3 | +import org.springframework.beans.factory.annotation.Value; | ||
| 4 | +import org.springframework.context.annotation.Configuration; | ||
| 5 | + | ||
| 6 | +@Configuration("mediaConfig") | ||
| 7 | +public class MediaConfig { | ||
| 8 | + | ||
| 9 | + @Value("${media.ip}") | ||
| 10 | + private String ip; | ||
| 11 | + | ||
| 12 | + @Value("${media.wanIp}") | ||
| 13 | + private String wanIp; | ||
| 14 | + | ||
| 15 | + @Value("${media.hookIp}") | ||
| 16 | + private String hookIp; | ||
| 17 | + | ||
| 18 | + @Value("${media.httpPort}") | ||
| 19 | + private String httpPort; | ||
| 20 | + | ||
| 21 | + @Value("${media.httpSSlPort}") | ||
| 22 | + private String httpSSlPort; | ||
| 23 | + | ||
| 24 | + @Value("${media.rtmpPort}") | ||
| 25 | + private String rtmpPort; | ||
| 26 | + | ||
| 27 | + @Value("${media.rtmpSSlPort}") | ||
| 28 | + private String rtmpSSlPort; | ||
| 29 | + | ||
| 30 | + @Value("${media.rtpProxyPort}") | ||
| 31 | + private String rtpProxyPort; | ||
| 32 | + | ||
| 33 | + @Value("${media.rtspPort}") | ||
| 34 | + private String rtspPort; | ||
| 35 | + | ||
| 36 | + @Value("${media.rtspSSLPort}") | ||
| 37 | + private String rtspSSLPort; | ||
| 38 | + | ||
| 39 | + @Value("${media.autoConfig}") | ||
| 40 | + private boolean autoConfig; | ||
| 41 | + | ||
| 42 | + @Value("${media.secret}") | ||
| 43 | + private String secret; | ||
| 44 | + | ||
| 45 | + @Value("${media.streamNoneReaderDelayMS}") | ||
| 46 | + private String streamNoneReaderDelayMS; | ||
| 47 | + | ||
| 48 | + @Value("${media.rtp.enable}") | ||
| 49 | + private boolean rtpEnable; | ||
| 50 | + | ||
| 51 | + @Value("${media.rtp.portRange}") | ||
| 52 | + private String rtpPortRange; | ||
| 53 | + | ||
| 54 | + public String getIp() { | ||
| 55 | + return ip; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setIp(String ip) { | ||
| 59 | + this.ip = ip; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public String getWanIp() { | ||
| 63 | + return wanIp; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public void setWanIp(String wanIp) { | ||
| 67 | + this.wanIp = wanIp; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public String getHookIp() { | ||
| 71 | + return hookIp; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public void setHookIp(String hookIp) { | ||
| 75 | + this.hookIp = hookIp; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public String getHttpPort() { | ||
| 79 | + return httpPort; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public void setHttpPort(String httpPort) { | ||
| 83 | + this.httpPort = httpPort; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public boolean isAutoConfig() { | ||
| 87 | + return autoConfig; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public boolean getAutoConfig() { | ||
| 91 | + return autoConfig; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public void setAutoConfig(boolean autoConfig) { | ||
| 95 | + this.autoConfig = autoConfig; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public String getSecret() { | ||
| 99 | + return secret; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public void setSecret(String secret) { | ||
| 103 | + this.secret = secret; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + public String getStreamNoneReaderDelayMS() { | ||
| 107 | + return streamNoneReaderDelayMS; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + public void setStreamNoneReaderDelayMS(String streamNoneReaderDelayMS) { | ||
| 111 | + this.streamNoneReaderDelayMS = streamNoneReaderDelayMS; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public boolean isRtpEnable() { | ||
| 115 | + return rtpEnable; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public void setRtpEnable(boolean rtpEnable) { | ||
| 119 | + this.rtpEnable = rtpEnable; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public String getRtpPortRange() { | ||
| 123 | + return rtpPortRange; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public void setRtpPortRange(String rtpPortRange) { | ||
| 127 | + this.rtpPortRange = rtpPortRange; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + public String getHttpSSlPort() { | ||
| 131 | + return httpSSlPort; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public void setHttpSSlPort(String httpSSlPort) { | ||
| 135 | + this.httpSSlPort = httpSSlPort; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + public String getRtmpPort() { | ||
| 139 | + return rtmpPort; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public void setRtmpPort(String rtmpPort) { | ||
| 143 | + this.rtmpPort = rtmpPort; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public String getRtmpSSlPort() { | ||
| 147 | + return rtmpSSlPort; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public void setRtmpSSlPort(String rtmpSSlPort) { | ||
| 151 | + this.rtmpSSlPort = rtmpSSlPort; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + public String getRtpProxyPort() { | ||
| 155 | + return rtpProxyPort; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + public void setRtpProxyPort(String rtpProxyPort) { | ||
| 159 | + this.rtpProxyPort = rtpProxyPort; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public String getRtspPort() { | ||
| 163 | + return rtspPort; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public void setRtspPort(String rtspPort) { | ||
| 167 | + this.rtspPort = rtspPort; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public String getRtspSSLPort() { | ||
| 171 | + return rtspSSLPort; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public void setRtspSSLPort(String rtspSSLPort) { | ||
| 175 | + this.rtspSSLPort = rtspSSLPort; | ||
| 176 | + } | ||
| 177 | +} |
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
| @@ -77,6 +77,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -77,6 +77,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 77 | // 可以直接访问的静态数据 | 77 | // 可以直接访问的静态数据 |
| 78 | web.ignoring() | 78 | web.ignoring() |
| 79 | .antMatchers("/") | 79 | .antMatchers("/") |
| 80 | + .antMatchers("/#/**") | ||
| 80 | .antMatchers("/static/**") | 81 | .antMatchers("/static/**") |
| 81 | .antMatchers("/index.html") | 82 | .antMatchers("/index.html") |
| 82 | .antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**" | 83 | .antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**" |
| @@ -111,7 +112,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -111,7 +112,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 111 | http.headers().contentTypeOptions().disable(); | 112 | http.headers().contentTypeOptions().disable(); |
| 112 | http.authorizeRequests() | 113 | http.authorizeRequests() |
| 113 | // 放行接口 | 114 | // 放行接口 |
| 114 | - .antMatchers("/#/**", "/api/user/login","/index/hook/**").permitAll() | 115 | + .antMatchers("/api/user/login","/index/hook/**").permitAll() |
| 115 | // 除上面外的所有请求全部需要鉴权认证 | 116 | // 除上面外的所有请求全部需要鉴权认证 |
| 116 | .anyRequest().authenticated() | 117 | .anyRequest().authenticated() |
| 117 | // 异常处理(权限拒绝、登录失效等) | 118 | // 异常处理(权限拒绝、登录失效等) |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
| @@ -38,7 +38,7 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa | @@ -38,7 +38,7 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa | ||
| 38 | public void onMessage(Message message, byte[] pattern) { | 38 | public void onMessage(Message message, byte[] pattern) { |
| 39 | // 获取失效的key | 39 | // 获取失效的key |
| 40 | String expiredKey = message.toString(); | 40 | String expiredKey = message.toString(); |
| 41 | - logger.info(expiredKey); | 41 | + logger.debug(expiredKey); |
| 42 | if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX)){ | 42 | if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX)){ |
| 43 | logger.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX+",忽略"); | 43 | logger.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX+",忽略"); |
| 44 | return; | 44 | return; |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | ||
| 3 | import java.text.ParseException; | 3 | import java.text.ParseException; |
| 4 | -import java.util.regex.Matcher; | ||
| 5 | -import java.util.regex.Pattern; | ||
| 6 | 4 | ||
| 7 | import javax.sip.*; | 5 | import javax.sip.*; |
| 8 | import javax.sip.address.SipURI; | 6 | import javax.sip.address.SipURI; |
| @@ -10,11 +8,11 @@ import javax.sip.header.CallIdHeader; | @@ -10,11 +8,11 @@ import javax.sip.header.CallIdHeader; | ||
| 10 | import javax.sip.header.ViaHeader; | 8 | import javax.sip.header.ViaHeader; |
| 11 | import javax.sip.message.Request; | 9 | import javax.sip.message.Request; |
| 12 | 10 | ||
| 13 | -import com.alibaba.fastjson.JSON; | ||
| 14 | import com.alibaba.fastjson.JSONArray; | 11 | import com.alibaba.fastjson.JSONArray; |
| 15 | import com.alibaba.fastjson.JSONObject; | 12 | import com.alibaba.fastjson.JSONObject; |
| 16 | import com.genersoft.iot.vmp.common.StreamInfo; | 13 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 17 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 14 | +import com.genersoft.iot.vmp.conf.MediaConfig; |
| 15 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | ||
| 18 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 16 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 19 | import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 17 | import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; |
| 20 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 18 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| @@ -82,13 +80,13 @@ public class SIPCommander implements ISIPCommander { | @@ -82,13 +80,13 @@ public class SIPCommander implements ISIPCommander { | ||
| 82 | @Autowired | 80 | @Autowired |
| 83 | private ZLMRESTfulUtils zlmresTfulUtils; | 81 | private ZLMRESTfulUtils zlmresTfulUtils; |
| 84 | 82 | ||
| 85 | - @Value("${media.rtp.enable}") | ||
| 86 | - private boolean rtpEnable; | 83 | + @Autowired |
| 84 | + private MediaConfig mediaConfig; | ||
| 87 | 85 | ||
| 88 | - @Value("${media.seniorSdp}") | 86 | + @Value("${userSettings.seniorSdp}") |
| 89 | private boolean seniorSdp; | 87 | private boolean seniorSdp; |
| 90 | 88 | ||
| 91 | - @Value("${media.autoApplyPlay}") | 89 | + @Value("${userSettings.autoApplyPlay}") |
| 92 | private boolean autoApplyPlay; | 90 | private boolean autoApplyPlay; |
| 93 | 91 | ||
| 94 | @Value("${userSettings.waitTrack}") | 92 | @Value("${userSettings.waitTrack}") |
| @@ -353,20 +351,20 @@ public class SIPCommander implements ISIPCommander { | @@ -353,20 +351,20 @@ public class SIPCommander implements ISIPCommander { | ||
| 353 | try { | 351 | try { |
| 354 | if (device == null) return; | 352 | if (device == null) return; |
| 355 | String ssrc = streamSession.createPlaySsrc(); | 353 | String ssrc = streamSession.createPlaySsrc(); |
| 356 | - if (rtpEnable) { | 354 | + if (mediaConfig.isRtpEnable()) { |
| 357 | streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); | 355 | streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); |
| 358 | }else { | 356 | }else { |
| 359 | streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | 357 | streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); |
| 360 | } | 358 | } |
| 361 | String streamMode = device.getStreamMode().toUpperCase(); | 359 | String streamMode = device.getStreamMode().toUpperCase(); |
| 362 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 360 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 363 | if (mediaInfo == null) { | 361 | if (mediaInfo == null) { |
| 364 | logger.warn("点播时发现ZLM尚未连接..."); | 362 | logger.warn("点播时发现ZLM尚未连接..."); |
| 365 | return; | 363 | return; |
| 366 | } | 364 | } |
| 367 | String mediaPort = null; | 365 | String mediaPort = null; |
| 368 | // 使用动态udp端口 | 366 | // 使用动态udp端口 |
| 369 | - if (rtpEnable) { | 367 | + if (mediaConfig.isRtpEnable()) { |
| 370 | mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; | 368 | mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; |
| 371 | }else { | 369 | }else { |
| 372 | mediaPort = mediaInfo.getRtpProxyPort(); | 370 | mediaPort = mediaInfo.getRtpProxyPort(); |
| @@ -470,7 +468,7 @@ public class SIPCommander implements ISIPCommander { | @@ -470,7 +468,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 470 | public void playbackStreamCmd(Device device, String channelId, String startTime, String endTime, ZLMHttpHookSubscribe.Event event | 468 | public void playbackStreamCmd(Device device, String channelId, String startTime, String endTime, ZLMHttpHookSubscribe.Event event |
| 471 | , SipSubscribe.Event errorEvent) { | 469 | , SipSubscribe.Event errorEvent) { |
| 472 | try { | 470 | try { |
| 473 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 471 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 474 | String ssrc = streamSession.createPlayBackSsrc(); | 472 | String ssrc = streamSession.createPlayBackSsrc(); |
| 475 | String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | 473 | String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); |
| 476 | // 添加订阅 | 474 | // 添加订阅 |
| @@ -495,7 +493,7 @@ public class SIPCommander implements ISIPCommander { | @@ -495,7 +493,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 495 | +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); | 493 | +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); |
| 496 | String mediaPort = null; | 494 | String mediaPort = null; |
| 497 | // 使用动态udp端口 | 495 | // 使用动态udp端口 |
| 498 | - if (rtpEnable) { | 496 | + if (mediaConfig.isRtpEnable()) { |
| 499 | mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; | 497 | mediaPort = zlmrtpServerFactory.createRTPServer(streamId) + ""; |
| 500 | }else { | 498 | }else { |
| 501 | mediaPort = mediaInfo.getRtpProxyPort(); | 499 | mediaPort = mediaInfo.getRtpProxyPort(); |
| @@ -1445,7 +1443,7 @@ public class SIPCommander implements ISIPCommander { | @@ -1445,7 +1443,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 1445 | 1443 | ||
| 1446 | @Override | 1444 | @Override |
| 1447 | public void closeRTPServer(Device device, String channelId) { | 1445 | public void closeRTPServer(Device device, String channelId) { |
| 1448 | - if (rtpEnable) { | 1446 | + if (mediaConfig.isRtpEnable()) { |
| 1449 | String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); | 1447 | String streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); |
| 1450 | zlmrtpServerFactory.closeRTPServer(streamId); | 1448 | zlmrtpServerFactory.closeRTPServer(streamId); |
| 1451 | } | 1449 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.MediaConfig; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 4 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| @@ -63,9 +64,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -63,9 +64,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 63 | @Qualifier(value="udpSipProvider") | 64 | @Qualifier(value="udpSipProvider") |
| 64 | private SipProvider udpSipProvider; | 65 | private SipProvider udpSipProvider; |
| 65 | 66 | ||
| 66 | - @Value("${media.rtp.enable}") | ||
| 67 | - private boolean rtpEnable; | ||
| 68 | - | ||
| 69 | @Override | 67 | @Override |
| 70 | public boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) { | 68 | public boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) { |
| 71 | return register(parentPlatform, null, null, errorEvent, okEvent); | 69 | return register(parentPlatform, null, null, errorEvent, okEvent); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
| @@ -11,7 +11,7 @@ import javax.sip.header.*; | @@ -11,7 +11,7 @@ import javax.sip.header.*; | ||
| 11 | import javax.sip.message.Request; | 11 | import javax.sip.message.Request; |
| 12 | import javax.sip.message.Response; | 12 | import javax.sip.message.Response; |
| 13 | 13 | ||
| 14 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 14 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 15 | import com.genersoft.iot.vmp.gb28181.bean.*; | 15 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 16 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 16 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 17 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | 17 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| @@ -187,7 +187,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { | @@ -187,7 +187,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 187 | sendRtpItem.setStatus(1); | 187 | sendRtpItem.setStatus(1); |
| 188 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 188 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 189 | // TODO 添加对tcp的支持 | 189 | // TODO 添加对tcp的支持 |
| 190 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 190 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 191 | StringBuffer content = new StringBuffer(200); | 191 | StringBuffer content = new StringBuffer(200); |
| 192 | content.append("v=0\r\n"); | 192 | content.append("v=0\r\n"); |
| 193 | content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n"); | 193 | content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n"); |
| @@ -246,7 +246,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { | @@ -246,7 +246,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 246 | sendRtpItem.setStatus(1); | 246 | sendRtpItem.setStatus(1); |
| 247 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 247 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 248 | // TODO 添加对tcp的支持 | 248 | // TODO 添加对tcp的支持 |
| 249 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 249 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 250 | StringBuffer content = new StringBuffer(200); | 250 | StringBuffer content = new StringBuffer(200); |
| 251 | content.append("v=0\r\n"); | 251 | content.append("v=0\r\n"); |
| 252 | content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n"); | 252 | content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n"); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| @@ -17,7 +17,9 @@ import javax.sip.message.Request; | @@ -17,7 +17,9 @@ import javax.sip.message.Request; | ||
| 17 | import javax.sip.message.Response; | 17 | import javax.sip.message.Response; |
| 18 | 18 | ||
| 19 | import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; | 19 | import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; |
| 20 | +import gov.nist.javax.sip.RequestEventExt; | ||
| 20 | import gov.nist.javax.sip.header.SIPDateHeader; | 21 | import gov.nist.javax.sip.header.SIPDateHeader; |
| 22 | +import gov.nist.javax.sip.message.SIPRequest; | ||
| 21 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; | 24 | import org.slf4j.LoggerFactory; |
| 23 | import org.springframework.util.StringUtils; | 25 | import org.springframework.util.StringUtils; |
| @@ -59,7 +61,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -59,7 +61,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 59 | @Override | 61 | @Override |
| 60 | public void process(RequestEvent evt) { | 62 | public void process(RequestEvent evt) { |
| 61 | try { | 63 | try { |
| 62 | - logger.info("收到注册请求,开始处理"); | 64 | + RequestEventExt evtExt = (RequestEventExt)evt; |
| 65 | + String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort(); | ||
| 66 | + logger.info("[{}] 收到注册请求,开始处理", requestAddress); | ||
| 63 | Request request = evt.getRequest(); | 67 | Request request = evt.getRequest(); |
| 64 | 68 | ||
| 65 | Response response = null; | 69 | Response response = null; |
| @@ -78,9 +82,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -78,9 +82,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 78 | if (authorhead == null || !passwordCorrect) { | 82 | if (authorhead == null || !passwordCorrect) { |
| 79 | 83 | ||
| 80 | if (authorhead == null) { | 84 | if (authorhead == null) { |
| 81 | - logger.info("未携带授权头 回复401"); | 85 | + logger.info("[{}] 未携带授权头 回复401", requestAddress); |
| 82 | } else if (!passwordCorrect) { | 86 | } else if (!passwordCorrect) { |
| 83 | - logger.info("密码错误 回复401"); | 87 | + logger.info("[{}] 密码错误 回复401", requestAddress); |
| 84 | } | 88 | } |
| 85 | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); | 89 | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); |
| 86 | new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain()); | 90 | new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain()); |
| @@ -147,7 +151,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -147,7 +151,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 147 | // 保存到redis | 151 | // 保存到redis |
| 148 | // 下发catelog查询目录 | 152 | // 下发catelog查询目录 |
| 149 | if (registerFlag == 1 ) { | 153 | if (registerFlag == 1 ) { |
| 150 | - logger.info("注册成功! deviceId:" + device.getDeviceId()); | 154 | + logger.info("[{}] 注册成功! deviceId:" + device.getDeviceId(), requestAddress); |
| 151 | // boolean exists = storager.exists(device.getDeviceId()); | 155 | // boolean exists = storager.exists(device.getDeviceId()); |
| 152 | device.setRegisterTimeMillis(System.currentTimeMillis()); | 156 | device.setRegisterTimeMillis(System.currentTimeMillis()); |
| 153 | storager.updateDevice(device); | 157 | storager.updateDevice(device); |
| @@ -158,7 +162,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | @@ -158,7 +162,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 158 | handler.onRegister(device); | 162 | handler.onRegister(device); |
| 159 | //} | 163 | //} |
| 160 | } else if (registerFlag == 2) { | 164 | } else if (registerFlag == 2) { |
| 161 | - logger.info("注销成功! deviceId:" + device.getDeviceId()); | 165 | + logger.info("[{}] 注销成功! deviceId:" + device.getDeviceId(), requestAddress); |
| 162 | publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); | 166 | publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); |
| 163 | } | 167 | } |
| 164 | } catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) { | 168 | } catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) { |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHTTPProxyController.java
| 1 | package com.genersoft.iot.vmp.media.zlm; | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | ||
| 3 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 3 | +import com.genersoft.iot.vmp.conf.MediaConfig; |
| 4 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 4 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.beans.factory.annotation.Value; | 6 | import org.springframework.beans.factory.annotation.Value; |
| @@ -18,14 +18,11 @@ public class ZLMHTTPProxyController { | @@ -18,14 +18,11 @@ public class ZLMHTTPProxyController { | ||
| 18 | 18 | ||
| 19 | // private final static Logger logger = LoggerFactory.getLogger(ZLMHTTPProxyController.class); | 19 | // private final static Logger logger = LoggerFactory.getLogger(ZLMHTTPProxyController.class); |
| 20 | 20 | ||
| 21 | - // @Autowired | ||
| 22 | - // private IVideoManagerStorager storager; | ||
| 23 | - | ||
| 24 | @Autowired | 21 | @Autowired |
| 25 | private IRedisCatchStorage redisCatchStorage; | 22 | private IRedisCatchStorage redisCatchStorage; |
| 26 | 23 | ||
| 27 | - @Value("${media.port}") | ||
| 28 | - private int mediaHttpPort; | 24 | + @Autowired |
| 25 | + private MediaConfig mediaConfig; | ||
| 29 | 26 | ||
| 30 | @ResponseBody | 27 | @ResponseBody |
| 31 | @RequestMapping(value = "/**/**/**", produces = "application/json;charset=UTF-8") | 28 | @RequestMapping(value = "/**/**/**", produces = "application/json;charset=UTF-8") |
| @@ -34,10 +31,10 @@ public class ZLMHTTPProxyController { | @@ -34,10 +31,10 @@ public class ZLMHTTPProxyController { | ||
| 34 | if (redisCatchStorage.getMediaInfo() == null) { | 31 | if (redisCatchStorage.getMediaInfo() == null) { |
| 35 | return "未接入流媒体"; | 32 | return "未接入流媒体"; |
| 36 | } | 33 | } |
| 37 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 34 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 38 | String requestURI = String.format("http://%s:%s%s?%s&%s", | 35 | String requestURI = String.format("http://%s:%s%s?%s&%s", |
| 39 | mediaInfo.getLocalIP(), | 36 | mediaInfo.getLocalIP(), |
| 40 | - mediaHttpPort, | 37 | + mediaConfig.getHttpPort(), |
| 41 | request.getRequestURI().replace("/zlm",""), | 38 | request.getRequestURI().replace("/zlm",""), |
| 42 | mediaInfo.getHookAdminParams(), | 39 | mediaInfo.getHookAdminParams(), |
| 43 | request.getQueryString() | 40 | request.getQueryString() |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -6,7 +6,7 @@ import java.util.UUID; | @@ -6,7 +6,7 @@ import java.util.UUID; | ||
| 6 | import com.alibaba.fastjson.JSON; | 6 | import com.alibaba.fastjson.JSON; |
| 7 | import com.alibaba.fastjson.JSONArray; | 7 | import com.alibaba.fastjson.JSONArray; |
| 8 | import com.genersoft.iot.vmp.common.StreamInfo; | 8 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 9 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 9 | +import com.genersoft.iot.vmp.conf.MediaConfig; |
| 10 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 10 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 12 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 12 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| @@ -53,23 +53,20 @@ public class ZLMHttpHookListener { | @@ -53,23 +53,20 @@ public class ZLMHttpHookListener { | ||
| 53 | @Autowired | 53 | @Autowired |
| 54 | private IRedisCatchStorage redisCatchStorage; | 54 | private IRedisCatchStorage redisCatchStorage; |
| 55 | 55 | ||
| 56 | + @Autowired | ||
| 57 | + private ZLMServerManger zlmServerManger; | ||
| 58 | + | ||
| 56 | @Autowired | 59 | @Autowired |
| 57 | private ZLMMediaListManager zlmMediaListManager; | 60 | private ZLMMediaListManager zlmMediaListManager; |
| 58 | 61 | ||
| 59 | @Autowired | 62 | @Autowired |
| 60 | private ZLMHttpHookSubscribe subscribe; | 63 | private ZLMHttpHookSubscribe subscribe; |
| 61 | 64 | ||
| 62 | - @Value("${media.autoApplyPlay}") | 65 | + @Value("${userSettings.autoApplyPlay}") |
| 63 | private boolean autoApplyPlay; | 66 | private boolean autoApplyPlay; |
| 64 | 67 | ||
| 65 | - @Value("${media.ip}") | ||
| 66 | - private String mediaIp; | ||
| 67 | - | ||
| 68 | - @Value("${media.wanIp}") | ||
| 69 | - private String mediaWanIp; | ||
| 70 | - | ||
| 71 | - @Value("${media.port}") | ||
| 72 | - private int mediaPort; | 68 | + @Autowired |
| 69 | + private MediaConfig mediaConfig; | ||
| 73 | 70 | ||
| 74 | /** | 71 | /** |
| 75 | * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。 | 72 | * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。 |
| @@ -388,12 +385,8 @@ public class ZLMHttpHookListener { | @@ -388,12 +385,8 @@ public class ZLMHttpHookListener { | ||
| 388 | subscribe.response(json); | 385 | subscribe.response(json); |
| 389 | } | 386 | } |
| 390 | } | 387 | } |
| 391 | - | ||
| 392 | - MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class); | ||
| 393 | - mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp); | ||
| 394 | - mediaServerConfig.setLocalIP(mediaIp); | ||
| 395 | - redisCatchStorage.updateMediaInfo(mediaServerConfig); | ||
| 396 | - | 388 | + ZLMServerConfig ZLMServerConfig = JSON.toJavaObject(json, ZLMServerConfig.class); |
| 389 | + zlmServerManger.updateServerCatch(ZLMServerConfig); | ||
| 397 | // 重新发起代理 | 390 | // 重新发起代理 |
| 398 | 391 | ||
| 399 | JSONObject ret = new JSONObject(); | 392 | JSONObject ret = new JSONObject(); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| 1 | package com.genersoft.iot.vmp.media.zlm; | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 6 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | ||
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 5 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 9 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; | 7 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| @@ -126,7 +124,7 @@ public class ZLMMediaListManager { | @@ -126,7 +124,7 @@ public class ZLMMediaListManager { | ||
| 126 | public void clearAllSessions() { | 124 | public void clearAllSessions() { |
| 127 | logger.info("清空所有国标相关的session"); | 125 | logger.info("清空所有国标相关的session"); |
| 128 | JSONObject allSessionJSON = zlmresTfulUtils.getAllSession(); | 126 | JSONObject allSessionJSON = zlmresTfulUtils.getAllSession(); |
| 129 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 127 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 130 | HashSet<String> allLocalPorts = new HashSet(); | 128 | HashSet<String> allLocalPorts = new HashSet(); |
| 131 | if (allSessionJSON.getInteger("code") == 0) { | 129 | if (allSessionJSON.getInteger("code") == 0) { |
| 132 | JSONArray data = allSessionJSON.getJSONArray("data"); | 130 | JSONArray data = allSessionJSON.getJSONArray("data"); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| @@ -2,10 +2,13 @@ package com.genersoft.iot.vmp.media.zlm; | @@ -2,10 +2,13 @@ package com.genersoft.iot.vmp.media.zlm; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | +import com.genersoft.iot.vmp.conf.MediaConfig; | ||
| 5 | import okhttp3.*; | 6 | import okhttp3.*; |
| 7 | +import org.checkerframework.checker.units.qual.A; | ||
| 6 | import org.jetbrains.annotations.NotNull; | 8 | import org.jetbrains.annotations.NotNull; |
| 7 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | import org.springframework.beans.factory.annotation.Value; | 12 | import org.springframework.beans.factory.annotation.Value; |
| 10 | import org.springframework.stereotype.Component; | 13 | import org.springframework.stereotype.Component; |
| 11 | 14 | ||
| @@ -20,14 +23,8 @@ public class ZLMRESTfulUtils { | @@ -20,14 +23,8 @@ public class ZLMRESTfulUtils { | ||
| 20 | 23 | ||
| 21 | private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class); | 24 | private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class); |
| 22 | 25 | ||
| 23 | - @Value("${media.ip}") | ||
| 24 | - private String mediaIp; | ||
| 25 | - | ||
| 26 | - @Value("${media.port}") | ||
| 27 | - private int mediaPort; | ||
| 28 | - | ||
| 29 | - @Value("${media.secret}") | ||
| 30 | - private String mediaSecret; | 26 | + @Autowired |
| 27 | + private MediaConfig mediaConfig; | ||
| 31 | 28 | ||
| 32 | public interface RequestCallback{ | 29 | public interface RequestCallback{ |
| 33 | void run(JSONObject response); | 30 | void run(JSONObject response); |
| @@ -35,12 +32,12 @@ public class ZLMRESTfulUtils { | @@ -35,12 +32,12 @@ public class ZLMRESTfulUtils { | ||
| 35 | 32 | ||
| 36 | public JSONObject sendPost(String api, Map<String, Object> param, RequestCallback callback) { | 33 | public JSONObject sendPost(String api, Map<String, Object> param, RequestCallback callback) { |
| 37 | OkHttpClient client = new OkHttpClient(); | 34 | OkHttpClient client = new OkHttpClient(); |
| 38 | - String url = String.format("http://%s:%s/index/api/%s", mediaIp, mediaPort, api); | 35 | + String url = String.format("http://%s:%s/index/api/%s", mediaConfig.getIp(), mediaConfig.getHttpPort(), api); |
| 39 | JSONObject responseJSON = null; | 36 | JSONObject responseJSON = null; |
| 40 | logger.debug(url); | 37 | logger.debug(url); |
| 41 | 38 | ||
| 42 | FormBody.Builder builder = new FormBody.Builder(); | 39 | FormBody.Builder builder = new FormBody.Builder(); |
| 43 | - builder.add("secret",mediaSecret); | 40 | + builder.add("secret",mediaConfig.getSecret()); |
| 44 | if (param != null && param.keySet().size() > 0) { | 41 | if (param != null && param.keySet().size() > 0) { |
| 45 | for (String key : param.keySet()){ | 42 | for (String key : param.keySet()){ |
| 46 | if (param.get(key) != null) { | 43 | if (param.get(key) != null) { |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.media.zlm; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.media.zlm; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | +import com.genersoft.iot.vmp.conf.MediaConfig; | ||
| 5 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 6 | import com.genersoft.iot.vmp.gb28181.session.SsrcUtil; | 7 | import com.genersoft.iot.vmp.gb28181.session.SsrcUtil; |
| 7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| @@ -18,8 +19,8 @@ public class ZLMRTPServerFactory { | @@ -18,8 +19,8 @@ public class ZLMRTPServerFactory { | ||
| 18 | 19 | ||
| 19 | private Logger logger = LoggerFactory.getLogger("ZLMRTPServerFactory"); | 20 | private Logger logger = LoggerFactory.getLogger("ZLMRTPServerFactory"); |
| 20 | 21 | ||
| 21 | - @Value("${media.rtp.portRange}") | ||
| 22 | - private String portRange; | 22 | + @Autowired |
| 23 | + private MediaConfig mediaConfig; | ||
| 23 | 24 | ||
| 24 | @Autowired | 25 | @Autowired |
| 25 | private ZLMRESTfulUtils zlmresTfulUtils; | 26 | private ZLMRESTfulUtils zlmresTfulUtils; |
| @@ -103,7 +104,7 @@ public class ZLMRTPServerFactory { | @@ -103,7 +104,7 @@ public class ZLMRTPServerFactory { | ||
| 103 | 104 | ||
| 104 | private int getPortFromportRange() { | 105 | private int getPortFromportRange() { |
| 105 | if (currentPort == 0) { | 106 | if (currentPort == 0) { |
| 106 | - String[] portRangeStrArray = portRange.split(","); | 107 | + String[] portRangeStrArray = mediaConfig.getRtpPortRange().split(","); |
| 107 | portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]); | 108 | portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]); |
| 108 | portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]); | 109 | portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]); |
| 109 | } | 110 | } |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -3,7 +3,8 @@ package com.genersoft.iot.vmp.media.zlm; | @@ -3,7 +3,8 @@ package com.genersoft.iot.vmp.media.zlm; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 6 | +import com.genersoft.iot.vmp.conf.MediaConfig; |
| 7 | +import com.genersoft.iot.vmp.conf.SipConfig; | ||
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 8 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 9 | //import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 10 | //import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| @@ -34,36 +35,20 @@ public class ZLMRunner implements CommandLineRunner { | @@ -34,36 +35,20 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 34 | @Autowired | 35 | @Autowired |
| 35 | private IRedisCatchStorage redisCatchStorage; | 36 | private IRedisCatchStorage redisCatchStorage; |
| 36 | 37 | ||
| 37 | - @Value("${media.ip}") | ||
| 38 | - private String mediaIp; | ||
| 39 | - | ||
| 40 | - @Value("${media.wanIp}") | ||
| 41 | - private String mediaWanIp; | ||
| 42 | - | ||
| 43 | - @Value("${media.hookIp}") | ||
| 44 | - private String mediaHookIp; | ||
| 45 | - | ||
| 46 | - @Value("${media.port}") | ||
| 47 | - private int mediaPort; | ||
| 48 | - | ||
| 49 | - @Value("${media.secret}") | ||
| 50 | - private String mediaSecret; | ||
| 51 | - | ||
| 52 | - @Value("${media.streamNoneReaderDelayMS}") | ||
| 53 | - private String streamNoneReaderDelayMS; | 38 | + @Autowired |
| 39 | + private MediaConfig mediaConfig; | ||
| 54 | 40 | ||
| 55 | - @Value("${sip.ip}") | ||
| 56 | - private String sipIP; | 41 | + @Autowired |
| 42 | + private SipConfig sipConfig; | ||
| 57 | 43 | ||
| 58 | @Value("${server.port}") | 44 | @Value("${server.port}") |
| 59 | private String serverPort; | 45 | private String serverPort; |
| 60 | 46 | ||
| 61 | - @Value("${media.autoConfig}") | ||
| 62 | - private boolean autoConfig; | ||
| 63 | - | ||
| 64 | @Value("${server.ssl.enabled}") | 47 | @Value("${server.ssl.enabled}") |
| 65 | private boolean sslEnabled; | 48 | private boolean sslEnabled; |
| 66 | 49 | ||
| 50 | + private boolean startGetMedia = false; | ||
| 51 | + | ||
| 67 | @Autowired | 52 | @Autowired |
| 68 | private ZLMRESTfulUtils zlmresTfulUtils; | 53 | private ZLMRESTfulUtils zlmresTfulUtils; |
| 69 | 54 | ||
| @@ -74,32 +59,37 @@ public class ZLMRunner implements CommandLineRunner { | @@ -74,32 +59,37 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 74 | private ZLMHttpHookSubscribe hookSubscribe; | 59 | private ZLMHttpHookSubscribe hookSubscribe; |
| 75 | 60 | ||
| 76 | @Autowired | 61 | @Autowired |
| 62 | + private ZLMServerManger zlmServerManger; | ||
| 63 | + | ||
| 64 | + @Autowired | ||
| 77 | private IStreamProxyService streamProxyService; | 65 | private IStreamProxyService streamProxyService; |
| 78 | 66 | ||
| 79 | @Override | 67 | @Override |
| 80 | public void run(String... strings) throws Exception { | 68 | public void run(String... strings) throws Exception { |
| 81 | // 订阅 zlm启动事件 | 69 | // 订阅 zlm启动事件 |
| 82 | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{ | 70 | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{ |
| 83 | - MediaServerConfig mediaServerConfig = JSONObject.toJavaObject(response, MediaServerConfig.class); | ||
| 84 | - zLmRunning(mediaServerConfig); | 71 | + ZLMServerConfig ZLMServerConfig = JSONObject.toJavaObject(response, ZLMServerConfig.class); |
| 72 | + zLmRunning(ZLMServerConfig); | ||
| 85 | }); | 73 | }); |
| 86 | 74 | ||
| 87 | // 获取zlm信息 | 75 | // 获取zlm信息 |
| 88 | logger.info("等待zlm接入..."); | 76 | logger.info("等待zlm接入..."); |
| 89 | - MediaServerConfig mediaServerConfig = getMediaServerConfig(); | 77 | + startGetMedia = true; |
| 78 | + ZLMServerConfig ZLMServerConfig = getMediaServerConfig(); | ||
| 90 | 79 | ||
| 91 | - if (mediaServerConfig != null) { | ||
| 92 | - zLmRunning(mediaServerConfig); | 80 | + if (ZLMServerConfig != null) { |
| 81 | + zLmRunning(ZLMServerConfig); | ||
| 93 | } | 82 | } |
| 94 | } | 83 | } |
| 95 | 84 | ||
| 96 | - public MediaServerConfig getMediaServerConfig() { | 85 | + public ZLMServerConfig getMediaServerConfig() { |
| 86 | + if (!startGetMedia) return null; | ||
| 97 | JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(); | 87 | JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(); |
| 98 | - MediaServerConfig mediaServerConfig = null; | 88 | + ZLMServerConfig ZLMServerConfig = null; |
| 99 | if (responseJSON != null) { | 89 | if (responseJSON != null) { |
| 100 | JSONArray data = responseJSON.getJSONArray("data"); | 90 | JSONArray data = responseJSON.getJSONArray("data"); |
| 101 | if (data != null && data.size() > 0) { | 91 | if (data != null && data.size() > 0) { |
| 102 | - mediaServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), MediaServerConfig.class); | 92 | + ZLMServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); |
| 103 | 93 | ||
| 104 | } | 94 | } |
| 105 | } else { | 95 | } else { |
| @@ -109,20 +99,18 @@ public class ZLMRunner implements CommandLineRunner { | @@ -109,20 +99,18 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 109 | } catch (InterruptedException e) { | 99 | } catch (InterruptedException e) { |
| 110 | e.printStackTrace(); | 100 | e.printStackTrace(); |
| 111 | } | 101 | } |
| 112 | - mediaServerConfig = getMediaServerConfig(); | 102 | + ZLMServerConfig = getMediaServerConfig(); |
| 113 | } | 103 | } |
| 114 | - return mediaServerConfig; | 104 | + return ZLMServerConfig; |
| 115 | } | 105 | } |
| 116 | 106 | ||
| 117 | private void saveZLMConfig() { | 107 | private void saveZLMConfig() { |
| 118 | logger.info("设置zlm..."); | 108 | logger.info("设置zlm..."); |
| 119 | - if (StringUtils.isEmpty(mediaHookIp)) { | ||
| 120 | - mediaHookIp = sipIP; | ||
| 121 | - } | 109 | + if (StringUtils.isEmpty(mediaConfig.getHookIp())) mediaConfig.setHookIp(sipConfig.getSipIp()); |
| 122 | String protocol = sslEnabled ? "https" : "http"; | 110 | String protocol = sslEnabled ? "https" : "http"; |
| 123 | - String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaHookIp, serverPort); | 111 | + String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaConfig.getHookIp(), serverPort); |
| 124 | Map<String, Object> param = new HashMap<>(); | 112 | Map<String, Object> param = new HashMap<>(); |
| 125 | - param.put("api.secret",mediaSecret); // -profile:v Baseline | 113 | + param.put("api.secret",mediaConfig.getSecret()); // -profile:v Baseline |
| 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"); | 114 | 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"); |
| 127 | param.put("hook.enable","1"); | 115 | param.put("hook.enable","1"); |
| 128 | param.put("hook.on_flow_report",""); | 116 | param.put("hook.on_flow_report",""); |
| @@ -139,7 +127,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -139,7 +127,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 139 | param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex)); | 127 | param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex)); |
| 140 | param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex)); | 128 | param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex)); |
| 141 | param.put("hook.timeoutSec","20"); | 129 | param.put("hook.timeoutSec","20"); |
| 142 | - param.put("general.streamNoneReaderDelayMS",streamNoneReaderDelayMS); | 130 | + param.put("general.streamNoneReaderDelayMS",mediaConfig.getStreamNoneReaderDelayMS()); |
| 143 | 131 | ||
| 144 | JSONObject responseJSON = zlmresTfulUtils.setServerConfig(param); | 132 | JSONObject responseJSON = zlmresTfulUtils.setServerConfig(param); |
| 145 | 133 | ||
| @@ -153,17 +141,12 @@ public class ZLMRunner implements CommandLineRunner { | @@ -153,17 +141,12 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 153 | /** | 141 | /** |
| 154 | * zlm 连接成功或者zlm重启后 | 142 | * zlm 连接成功或者zlm重启后 |
| 155 | */ | 143 | */ |
| 156 | - private void zLmRunning(MediaServerConfig mediaServerConfig){ | ||
| 157 | - logger.info( "[ id: " + mediaServerConfig.getGeneralMediaServerId() + "] zlm接入成功..."); | ||
| 158 | - if (autoConfig) saveZLMConfig(); | ||
| 159 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | ||
| 160 | - if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ | ||
| 161 | - logger.info("[ id: " + mediaServerConfig.getGeneralMediaServerId() + "]zlm刚刚更新,忽略这次更新"); | ||
| 162 | - return; | ||
| 163 | - } | ||
| 164 | - mediaServerConfig.setLocalIP(mediaIp); | ||
| 165 | - mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp); | ||
| 166 | - redisCatchStorage.updateMediaInfo(mediaServerConfig); | 144 | + private void zLmRunning(ZLMServerConfig zlmServerConfig){ |
| 145 | + logger.info( "[ id: " + zlmServerConfig.getGeneralMediaServerId() + "] zlm接入成功..."); | ||
| 146 | + // 关闭循环获取zlm配置 | ||
| 147 | + startGetMedia = false; | ||
| 148 | + if (mediaConfig.getAutoConfig()) saveZLMConfig(); | ||
| 149 | + zlmServerManger.updateServerCatch(zlmServerConfig); | ||
| 167 | 150 | ||
| 168 | // 清空所有session | 151 | // 清空所有session |
| 169 | // zlmMediaListManager.clearAllSessions(); | 152 | // zlmMediaListManager.clearAllSessions(); |
src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java
| 1 | -package com.genersoft.iot.vmp.conf; | 1 | +package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.annotation.JSONField; | 3 | import com.alibaba.fastjson.annotation.JSONField; |
| 4 | 4 | ||
| 5 | -public class MediaServerConfig { | 5 | +public class ZLMServerConfig { |
| 6 | 6 | ||
| 7 | @JSONField(name = "api.apiDebug") | 7 | @JSONField(name = "api.apiDebug") |
| 8 | private String apiDebug; | 8 | private String apiDebug; |
| @@ -157,6 +157,9 @@ public class MediaServerConfig { | @@ -157,6 +157,9 @@ public class MediaServerConfig { | ||
| 157 | @JSONField(name = "rtmp.port") | 157 | @JSONField(name = "rtmp.port") |
| 158 | private String rtmpPort; | 158 | private String rtmpPort; |
| 159 | 159 | ||
| 160 | + @JSONField(name = "rtmp.sslport") | ||
| 161 | + private String rtmpSslPort; | ||
| 162 | + | ||
| 160 | @JSONField(name = "rtp.audioMtuSize") | 163 | @JSONField(name = "rtp.audioMtuSize") |
| 161 | private String rtpAudioMtuSize; | 164 | private String rtpAudioMtuSize; |
| 162 | 165 | ||
| @@ -749,4 +752,12 @@ public class MediaServerConfig { | @@ -749,4 +752,12 @@ public class MediaServerConfig { | ||
| 749 | public void setGeneralMediaServerId(String generalMediaServerId) { | 752 | public void setGeneralMediaServerId(String generalMediaServerId) { |
| 750 | this.generalMediaServerId = generalMediaServerId; | 753 | this.generalMediaServerId = generalMediaServerId; |
| 751 | } | 754 | } |
| 755 | + | ||
| 756 | + public String getRtmpSslPort() { | ||
| 757 | + return rtmpSslPort; | ||
| 758 | + } | ||
| 759 | + | ||
| 760 | + public void setRtmpSslPort(String rtmpSslPort) { | ||
| 761 | + this.rtmpSslPort = rtmpSslPort; | ||
| 762 | + } | ||
| 752 | } | 763 | } |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.annotation.JSONField; | ||
| 4 | +import com.genersoft.iot.vmp.conf.MediaConfig; | ||
| 5 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.stereotype.Component; | ||
| 8 | +import org.springframework.util.StringUtils; | ||
| 9 | + | ||
| 10 | +@Component | ||
| 11 | +public class ZLMServerManger { | ||
| 12 | + | ||
| 13 | + @Autowired | ||
| 14 | + private IRedisCatchStorage redisCatchStorage; | ||
| 15 | + | ||
| 16 | + @Autowired | ||
| 17 | + private MediaConfig mediaConfig; | ||
| 18 | + | ||
| 19 | + public void updateServerCatch(ZLMServerConfig zlmServerConfig) { | ||
| 20 | + | ||
| 21 | + zlmServerConfig.setLocalIP(mediaConfig.getIp()); | ||
| 22 | + zlmServerConfig.setWanIp(StringUtils.isEmpty(mediaConfig.getWanIp())? mediaConfig.getIp(): mediaConfig.getWanIp()); | ||
| 23 | + zlmServerConfig.setHttpPort(mediaConfig.getHttpPort()); | ||
| 24 | + | ||
| 25 | + if(!StringUtils.isEmpty(mediaConfig.getHttpSSlPort())) | ||
| 26 | + zlmServerConfig.setHttpSSLport(mediaConfig.getHttpSSlPort()); | ||
| 27 | + | ||
| 28 | + if(!StringUtils.isEmpty(mediaConfig.getRtspPort())) | ||
| 29 | + zlmServerConfig.setRtspPort(mediaConfig.getRtspPort()); | ||
| 30 | + | ||
| 31 | + if(!StringUtils.isEmpty(mediaConfig.getRtspSSLPort())) | ||
| 32 | + zlmServerConfig.setRtspSSlport(mediaConfig.getRtspSSLPort()); | ||
| 33 | + | ||
| 34 | + if(!StringUtils.isEmpty(mediaConfig.getRtmpPort())) | ||
| 35 | + zlmServerConfig.setRtmpPort(mediaConfig.getRtmpPort()); | ||
| 36 | + | ||
| 37 | + if(!StringUtils.isEmpty(mediaConfig.getRtmpSSlPort())) | ||
| 38 | + zlmServerConfig.setRtmpSslPort(mediaConfig.getRtmpSSlPort()); | ||
| 39 | + | ||
| 40 | + if(!StringUtils.isEmpty(mediaConfig.getRtpProxyPort())) | ||
| 41 | + zlmServerConfig.setRtpProxyPort(mediaConfig.getRtpProxyPort()); | ||
| 42 | + | ||
| 43 | + redisCatchStorage.updateMediaInfo(zlmServerConfig); | ||
| 44 | + } | ||
| 45 | +} |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON; | @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 7 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 8 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 8 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 10 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 10 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| @@ -28,7 +28,7 @@ public class MediaServiceImpl implements IMediaService { | @@ -28,7 +28,7 @@ public class MediaServiceImpl implements IMediaService { | ||
| 28 | 28 | ||
| 29 | @Override | 29 | @Override |
| 30 | public StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks) { | 30 | public StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks) { |
| 31 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 31 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 32 | StreamInfo streamInfoResult = new StreamInfo(); | 32 | StreamInfo streamInfoResult = new StreamInfo(); |
| 33 | streamInfoResult.setStreamId(stream); | 33 | streamInfoResult.setStreamId(stream); |
| 34 | streamInfoResult.setApp(app); | 34 | streamInfoResult.setApp(app); |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| 1 | package com.genersoft.iot.vmp.service.impl; | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 4 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 5 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 5 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| @@ -41,7 +41,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -41,7 +41,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 41 | 41 | ||
| 42 | @Override | 42 | @Override |
| 43 | public String save(StreamProxyItem param) { | 43 | public String save(StreamProxyItem param) { |
| 44 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 44 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 45 | String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), | 45 | String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), |
| 46 | param.getStream() ); | 46 | param.getStream() ); |
| 47 | param.setDst_url(dstUrl); | 47 | param.setDst_url(dstUrl); |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| 1 | package com.genersoft.iot.vmp.storager; | 1 | package com.genersoft.iot.vmp.storager; |
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.common.StreamInfo; | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 4 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| @@ -41,16 +41,16 @@ public interface IRedisCatchStorage { | @@ -41,16 +41,16 @@ public interface IRedisCatchStorage { | ||
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * 更新流媒体信息 | 43 | * 更新流媒体信息 |
| 44 | - * @param mediaServerConfig | 44 | + * @param ZLMServerConfig |
| 45 | * @return | 45 | * @return |
| 46 | */ | 46 | */ |
| 47 | - boolean updateMediaInfo(MediaServerConfig mediaServerConfig); | 47 | + boolean updateMediaInfo(ZLMServerConfig ZLMServerConfig); |
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | * 获取流媒体信息 | 50 | * 获取流媒体信息 |
| 51 | * @return | 51 | * @return |
| 52 | */ | 52 | */ |
| 53 | - MediaServerConfig getMediaInfo(); | 53 | + ZLMServerConfig getMediaInfo(); |
| 54 | 54 | ||
| 55 | Map<String, StreamInfo> queryPlayByDeviceId(String deviceId); | 55 | Map<String, StreamInfo> queryPlayByDeviceId(String deviceId); |
| 56 | 56 |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.storager.impl; | @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.storager.impl; | ||
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.common.StreamInfo; | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 5 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 8 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; | 8 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| @@ -86,13 +86,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -86,13 +86,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 86 | 86 | ||
| 87 | /** | 87 | /** |
| 88 | * 更新流媒体信息 | 88 | * 更新流媒体信息 |
| 89 | - * @param mediaServerConfig | 89 | + * @param ZLMServerConfig |
| 90 | * @return | 90 | * @return |
| 91 | */ | 91 | */ |
| 92 | @Override | 92 | @Override |
| 93 | - public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) { | ||
| 94 | - mediaServerConfig.setUpdateTime(System.currentTimeMillis()); | ||
| 95 | - return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX,mediaServerConfig); | 93 | + public boolean updateMediaInfo(ZLMServerConfig ZLMServerConfig) { |
| 94 | + ZLMServerConfig.setUpdateTime(System.currentTimeMillis()); | ||
| 95 | + return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX, ZLMServerConfig); | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | /** | 98 | /** |
| @@ -100,8 +100,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -100,8 +100,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 100 | * @return | 100 | * @return |
| 101 | */ | 101 | */ |
| 102 | @Override | 102 | @Override |
| 103 | - public MediaServerConfig getMediaInfo() { | ||
| 104 | - return (MediaServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX); | 103 | + public ZLMServerConfig getMediaInfo() { |
| 104 | + return (ZLMServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX); | ||
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | @Override | 107 | @Override |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| 1 | package com.genersoft.iot.vmp.vmanager.gb28181.play; | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.play; |
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.common.StreamInfo; | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | -import com.genersoft.iot.vmp.conf.MediaServerConfig; | 4 | +import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 7 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| @@ -162,7 +162,7 @@ public class PlayController { | @@ -162,7 +162,7 @@ public class PlayController { | ||
| 162 | logger.warn("视频转码API调用失败!, 视频流已停止推流!"); | 162 | logger.warn("视频转码API调用失败!, 视频流已停止推流!"); |
| 163 | return new ResponseEntity<String>("推流信息在流媒体中不存在, 视频流可能已停止推流", HttpStatus.OK); | 163 | return new ResponseEntity<String>("推流信息在流媒体中不存在, 视频流可能已停止推流", HttpStatus.OK); |
| 164 | } else { | 164 | } else { |
| 165 | - MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 165 | + ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 166 | String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), | 166 | String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), |
| 167 | streamId ); | 167 | streamId ); |
| 168 | String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); | 168 | String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); |
src/main/resources/application-dev.yml
| @@ -67,17 +67,25 @@ media: | @@ -67,17 +67,25 @@ media: | ||
| 67 | # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip | 67 | # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip |
| 68 | hookIp: | 68 | hookIp: |
| 69 | # [必须修改] zlm服务器的http.port | 69 | # [必须修改] zlm服务器的http.port |
| 70 | - port: 80 | 70 | + 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: | ||
| 71 | # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 | 83 | # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 |
| 72 | autoConfig: true | 84 | autoConfig: true |
| 73 | # [可选] zlm服务器的hook.admin_params=secret | 85 | # [可选] zlm服务器的hook.admin_params=secret |
| 74 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc | 86 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc |
| 75 | # [可选] zlm服务器的general.streamNoneReaderDelayMS | 87 | # [可选] zlm服务器的general.streamNoneReaderDelayMS |
| 76 | streamNoneReaderDelayMS: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流 | 88 | streamNoneReaderDelayMS: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流 |
| 77 | - # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true | ||
| 78 | - autoApplyPlay: false | ||
| 79 | - # [可选] 部分设备需要扩展SDP,需要打开此设置 | ||
| 80 | - seniorSdp: false | ||
| 81 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 | 89 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 |
| 82 | rtp: | 90 | rtp: |
| 83 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 | 91 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 |
| @@ -95,9 +103,13 @@ logging: | @@ -95,9 +103,13 @@ logging: | ||
| 95 | level: | 103 | level: |
| 96 | com: | 104 | com: |
| 97 | genersoft: | 105 | genersoft: |
| 98 | - iot: debug | 106 | + iot: info |
| 99 | # [根据业务需求配置] | 107 | # [根据业务需求配置] |
| 100 | userSettings: | 108 | userSettings: |
| 109 | + # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true | ||
| 110 | + autoApplyPlay: false | ||
| 111 | + # [可选] 部分设备需要扩展SDP,需要打开此设置 | ||
| 112 | + seniorSdp: false | ||
| 101 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) | 113 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) |
| 102 | savePositionHistory: false | 114 | savePositionHistory: false |
| 103 | # 点播等待超时时间,单位:毫秒 | 115 | # 点播等待超时时间,单位:毫秒 |