Commit 0faa5936584c7e816034db997017d90648a4ada6
1 parent
b24be124
规范配置文件,添加接口鉴权的例外接口配置
Showing
10 changed files
with
237 additions
and
90 deletions
Too many changes to show.
To preserve performance only 10 of 11 files are displayed.
pom.xml
| @@ -66,6 +66,11 @@ | @@ -66,6 +66,11 @@ | ||
| 66 | <artifactId>spring-boot-starter-web</artifactId> | 66 | <artifactId>spring-boot-starter-web</artifactId> |
| 67 | </dependency> | 67 | </dependency> |
| 68 | <dependency> | 68 | <dependency> |
| 69 | + <groupId>org.springframework.boot</groupId> | ||
| 70 | + <artifactId>spring-boot-configuration-processor</artifactId> | ||
| 71 | + <optional>true</optional> | ||
| 72 | + </dependency> | ||
| 73 | + <dependency> | ||
| 69 | <groupId>org.mybatis.spring.boot</groupId> | 74 | <groupId>org.mybatis.spring.boot</groupId> |
| 70 | <artifactId>mybatis-spring-boot-starter</artifactId> | 75 | <artifactId>mybatis-spring-boot-starter</artifactId> |
| 71 | <version>2.1.4</version> | 76 | <version>2.1.4</version> |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| @@ -10,55 +10,55 @@ public class MediaConfig { | @@ -10,55 +10,55 @@ public class MediaConfig { | ||
| 10 | @Value("${media.ip}") | 10 | @Value("${media.ip}") |
| 11 | private String ip; | 11 | private String ip; |
| 12 | 12 | ||
| 13 | - @Value("${media.hookIp:${sip.ip}}") | 13 | + @Value("${media.hook-ip:${sip.ip}}") |
| 14 | private String hookIp; | 14 | private String hookIp; |
| 15 | 15 | ||
| 16 | @Value("${sip.ip}") | 16 | @Value("${sip.ip}") |
| 17 | private String sipIp; | 17 | private String sipIp; |
| 18 | 18 | ||
| 19 | - @Value("${media.sdpIp:${media.ip}}") | 19 | + @Value("${media.sdp-ip:${media.ip}}") |
| 20 | private String sdpIp; | 20 | private String sdpIp; |
| 21 | 21 | ||
| 22 | - @Value("${media.streamIp:${media.ip}}") | 22 | + @Value("${media.stream-ip:${media.ip}}") |
| 23 | private String streamIp; | 23 | private String streamIp; |
| 24 | 24 | ||
| 25 | - @Value("${media.httpPort}") | 25 | + @Value("${media.http-port}") |
| 26 | private Integer httpPort; | 26 | private Integer httpPort; |
| 27 | 27 | ||
| 28 | - @Value("${media.httpSSlPort:}") | 28 | + @Value("${media.http-ssl-port:}") |
| 29 | private Integer httpSSlPort; | 29 | private Integer httpSSlPort; |
| 30 | 30 | ||
| 31 | - @Value("${media.rtmpPort:}") | 31 | + @Value("${media.rtmp-port:}") |
| 32 | private Integer rtmpPort; | 32 | private Integer rtmpPort; |
| 33 | 33 | ||
| 34 | - @Value("${media.rtmpSSlPort:}") | 34 | + @Value("${media.rtmp-ssl-port:}") |
| 35 | private Integer rtmpSSlPort; | 35 | private Integer rtmpSSlPort; |
| 36 | 36 | ||
| 37 | - @Value("${media.rtpProxyPort:}") | 37 | + @Value("${media.rtp-proxy-port:}") |
| 38 | private Integer rtpProxyPort; | 38 | private Integer rtpProxyPort; |
| 39 | 39 | ||
| 40 | - @Value("${media.rtspPort:}") | 40 | + @Value("${media.rtsp-port:}") |
| 41 | private Integer rtspPort; | 41 | private Integer rtspPort; |
| 42 | 42 | ||
| 43 | - @Value("${media.rtspSSLPort:}") | 43 | + @Value("${media.rtsp-ssl-port:}") |
| 44 | private Integer rtspSSLPort; | 44 | private Integer rtspSSLPort; |
| 45 | 45 | ||
| 46 | - @Value("${media.autoConfig:true}") | 46 | + @Value("${media.auto-config:true}") |
| 47 | private boolean autoConfig; | 47 | private boolean autoConfig; |
| 48 | 48 | ||
| 49 | @Value("${media.secret}") | 49 | @Value("${media.secret}") |
| 50 | private String secret; | 50 | private String secret; |
| 51 | 51 | ||
| 52 | - @Value("${media.streamNoneReaderDelayMS:18000}") | 52 | + @Value("${media.stream-none-reader-delay-ms:18000}") |
| 53 | private String streamNoneReaderDelayMS; | 53 | private String streamNoneReaderDelayMS; |
| 54 | 54 | ||
| 55 | @Value("${media.rtp.enable}") | 55 | @Value("${media.rtp.enable}") |
| 56 | private boolean rtpEnable; | 56 | private boolean rtpEnable; |
| 57 | 57 | ||
| 58 | - @Value("${media.rtp.portRange}") | 58 | + @Value("${media.rtp.port-range}") |
| 59 | private String rtpPortRange; | 59 | private String rtpPortRange; |
| 60 | 60 | ||
| 61 | - @Value("${media.recordAssistPort}") | 61 | + @Value("${media.record-assist-port}") |
| 62 | private Integer recordAssistPort; | 62 | private Integer recordAssistPort; |
| 63 | 63 | ||
| 64 | public String getIp() { | 64 | public String getIp() { |
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
| @@ -13,7 +13,7 @@ public class SipConfig { | @@ -13,7 +13,7 @@ public class SipConfig { | ||
| 13 | /** | 13 | /** |
| 14 | * 默认使用sip.ip | 14 | * 默认使用sip.ip |
| 15 | */ | 15 | */ |
| 16 | - @Value("${sip.monitorIp:0.0.0.0}") | 16 | + @Value("${sip.monitor-ip:0.0.0.0}") |
| 17 | private String monitorIp; | 17 | private String monitorIp; |
| 18 | 18 | ||
| 19 | @Value("${sip.port}") | 19 | @Value("${sip.port}") |
| @@ -31,10 +31,10 @@ public class SipConfig { | @@ -31,10 +31,10 @@ public class SipConfig { | ||
| 31 | @Value("${sip.ptz.speed:50}") | 31 | @Value("${sip.ptz.speed:50}") |
| 32 | Integer speed; | 32 | Integer speed; |
| 33 | 33 | ||
| 34 | - @Value("${sip.keepaliveTimeOut:180}") | 34 | + @Value("${sip.keepalive-timeout:180}") |
| 35 | Integer keepaliveTimeOut; | 35 | Integer keepaliveTimeOut; |
| 36 | 36 | ||
| 37 | - @Value("${sip.registerTimeInterval:60}") | 37 | + @Value("${sip.register-time-interval:60}") |
| 38 | Integer registerTimeInterval; | 38 | Integer registerTimeInterval; |
| 39 | 39 | ||
| 40 | public String getMonitorIp() { | 40 | public String getMonitorIp() { |
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java
| 1 | package com.genersoft.iot.vmp.conf; | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | ||
| 3 | import org.springframework.beans.factory.annotation.Value; | 3 | import org.springframework.beans.factory.annotation.Value; |
| 4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 4 | import org.springframework.context.annotation.Configuration; | 5 | import org.springframework.context.annotation.Configuration; |
| 5 | - | ||
| 6 | -@Configuration("userSetup") | 6 | +import org.springframework.stereotype.Component; |
| 7 | + | ||
| 8 | +import java.util.ArrayList; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +//@Configuration("userSetup") | ||
| 12 | +//public class UserSetup { | ||
| 13 | +// @Value("${userSettings.savePositionHistory:false}") | ||
| 14 | +// boolean savePositionHistory; | ||
| 15 | +// | ||
| 16 | +// @Value("${userSettings.autoApplyPlay}") | ||
| 17 | +// private boolean autoApplyPlay; | ||
| 18 | +// | ||
| 19 | +// @Value("${userSettings.seniorSdp:false}") | ||
| 20 | +// private boolean seniorSdp; | ||
| 21 | +// | ||
| 22 | +// @Value("${userSettings.playTimeout:18000}") | ||
| 23 | +// private long playTimeout; | ||
| 24 | +// | ||
| 25 | +// @Value("${userSettings.waitTrack:false}") | ||
| 26 | +// private boolean waitTrack; | ||
| 27 | +// | ||
| 28 | +// @Value("${userSettings.interfaceAuthentication}") | ||
| 29 | +// private boolean interfaceAuthentication; | ||
| 30 | +// | ||
| 31 | +// @Value("${userSettings.recordPushLive}") | ||
| 32 | +// private boolean recordPushLive; | ||
| 33 | +// | ||
| 34 | +// @Value("${userSettings.interfaceAuthenticationExcludes:}") | ||
| 35 | +// private String interfaceAuthenticationExcludes; | ||
| 36 | +// | ||
| 37 | +// public boolean getSavePositionHistory() { | ||
| 38 | +// return savePositionHistory; | ||
| 39 | +// } | ||
| 40 | +// | ||
| 41 | +// public boolean isSavePositionHistory() { | ||
| 42 | +// return savePositionHistory; | ||
| 43 | +// } | ||
| 44 | +// | ||
| 45 | +// public boolean isAutoApplyPlay() { | ||
| 46 | +// return autoApplyPlay; | ||
| 47 | +// } | ||
| 48 | +// | ||
| 49 | +// public boolean isSeniorSdp() { | ||
| 50 | +// return seniorSdp; | ||
| 51 | +// } | ||
| 52 | +// | ||
| 53 | +// public long getPlayTimeout() { | ||
| 54 | +// return playTimeout; | ||
| 55 | +// } | ||
| 56 | +// | ||
| 57 | +// public boolean isWaitTrack() { | ||
| 58 | +// return waitTrack; | ||
| 59 | +// } | ||
| 60 | +// | ||
| 61 | +// public boolean isInterfaceAuthentication() { | ||
| 62 | +// return interfaceAuthentication; | ||
| 63 | +// } | ||
| 64 | +// | ||
| 65 | +// public boolean isRecordPushLive() { | ||
| 66 | +// return recordPushLive; | ||
| 67 | +// } | ||
| 68 | +// | ||
| 69 | +// public String getInterfaceAuthenticationExcludes() { | ||
| 70 | +// return interfaceAuthenticationExcludes; | ||
| 71 | +// } | ||
| 72 | +//} | ||
| 73 | + | ||
| 74 | + | ||
| 75 | +@Component | ||
| 76 | +@ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true) | ||
| 7 | public class UserSetup { | 77 | public class UserSetup { |
| 8 | - @Value("${userSettings.savePositionHistory:false}") | ||
| 9 | - boolean savePositionHistory; | ||
| 10 | 78 | ||
| 11 | - @Value("${userSettings.autoApplyPlay}") | ||
| 12 | - private boolean autoApplyPlay; | 79 | + private Boolean savePositionHistory = Boolean.FALSE; |
| 80 | + | ||
| 81 | + private Boolean autoApplyPlay = Boolean.FALSE; | ||
| 82 | + | ||
| 83 | + private Boolean seniorSdp = Boolean.FALSE; | ||
| 13 | 84 | ||
| 14 | - @Value("${userSettings.seniorSdp:false}") | ||
| 15 | - private boolean seniorSdp; | 85 | + private Long playTimeout = 18000L; |
| 16 | 86 | ||
| 17 | - @Value("${userSettings.playTimeout:18000}") | ||
| 18 | - private long playTimeout; | 87 | + private Boolean waitTrack = Boolean.FALSE; |
| 19 | 88 | ||
| 20 | - @Value("${userSettings.waitTrack:false}") | ||
| 21 | - private boolean waitTrack; | 89 | + private Boolean interfaceAuthentication = Boolean.TRUE; |
| 22 | 90 | ||
| 23 | - @Value("${userSettings.interfaceAuthentication}") | ||
| 24 | - private boolean interfaceAuthentication; | 91 | + private Boolean recordPushLive = Boolean.FALSE; |
| 25 | 92 | ||
| 26 | - @Value("${userSettings.recordPushLive}") | ||
| 27 | - private boolean recordPushLive; | 93 | + private List<String> interfaceAuthenticationExcludes = new ArrayList<>(); |
| 28 | 94 | ||
| 29 | - public boolean getSavePositionHistory() { | 95 | + public Boolean getSavePositionHistory() { |
| 30 | return savePositionHistory; | 96 | return savePositionHistory; |
| 31 | } | 97 | } |
| 32 | 98 | ||
| 33 | - public boolean isSavePositionHistory() { | 99 | + public Boolean isSavePositionHistory() { |
| 34 | return savePositionHistory; | 100 | return savePositionHistory; |
| 35 | } | 101 | } |
| 36 | 102 | ||
| 37 | - public boolean isAutoApplyPlay() { | 103 | + public Boolean isAutoApplyPlay() { |
| 38 | return autoApplyPlay; | 104 | return autoApplyPlay; |
| 39 | } | 105 | } |
| 40 | 106 | ||
| 41 | - public boolean isSeniorSdp() { | 107 | + public Boolean isSeniorSdp() { |
| 42 | return seniorSdp; | 108 | return seniorSdp; |
| 43 | } | 109 | } |
| 44 | 110 | ||
| 45 | - public long getPlayTimeout() { | 111 | + public Long getPlayTimeout() { |
| 46 | return playTimeout; | 112 | return playTimeout; |
| 47 | } | 113 | } |
| 48 | 114 | ||
| 49 | - public boolean isWaitTrack() { | 115 | + public Boolean isWaitTrack() { |
| 50 | return waitTrack; | 116 | return waitTrack; |
| 51 | } | 117 | } |
| 52 | 118 | ||
| 53 | - public boolean isInterfaceAuthentication() { | 119 | + public Boolean isInterfaceAuthentication() { |
| 54 | return interfaceAuthentication; | 120 | return interfaceAuthentication; |
| 55 | } | 121 | } |
| 56 | 122 | ||
| 57 | - public boolean isRecordPushLive() { | 123 | + public Boolean isRecordPushLive() { |
| 58 | return recordPushLive; | 124 | return recordPushLive; |
| 59 | } | 125 | } |
| 126 | + | ||
| 127 | + public List<String> getInterfaceAuthenticationExcludes() { | ||
| 128 | + return interfaceAuthenticationExcludes; | ||
| 129 | + } | ||
| 60 | } | 130 | } |
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
| @@ -14,6 +14,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe | @@ -14,6 +14,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe | ||
| 14 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | 14 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| 16 | 16 | ||
| 17 | +import java.util.List; | ||
| 18 | + | ||
| 17 | /** | 19 | /** |
| 18 | * 配置Spring Security | 20 | * 配置Spring Security |
| 19 | */ | 21 | */ |
| @@ -85,6 +87,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -85,6 +87,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 85 | .antMatchers("/swagger-resources/**") | 87 | .antMatchers("/swagger-resources/**") |
| 86 | .antMatchers("/v3/api-docs/**") | 88 | .antMatchers("/v3/api-docs/**") |
| 87 | .antMatchers("/js/**"); | 89 | .antMatchers("/js/**"); |
| 90 | + List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes(); | ||
| 91 | + System.out.println(interfaceAuthenticationExcludes.size()); | ||
| 92 | + for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) { | ||
| 93 | + web.ignoring().antMatchers(interfaceAuthenticationExclude); | ||
| 94 | + } | ||
| 88 | } | 95 | } |
| 89 | } | 96 | } |
| 90 | 97 |
src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
| @@ -24,4 +24,19 @@ public interface IMediaService { | @@ -24,4 +24,19 @@ public interface IMediaService { | ||
| 24 | */ | 24 | */ |
| 25 | StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks); | 25 | StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks); |
| 26 | 26 | ||
| 27 | + /** | ||
| 28 | + * 根据应用名和流ID获取播放地址, 只是地址拼接,返回的ip使用远程访问ip,适用与zlm与wvp在一台主机的情况 | ||
| 29 | + * @param app | ||
| 30 | + * @param stream | ||
| 31 | + * @return | ||
| 32 | + */ | ||
| 33 | + StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks, String addr); | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 根据应用名和流ID获取播放地址, 通过zlm接口检查是否存在, 返回的ip使用远程访问ip,适用与zlm与wvp在一台主机的情况 | ||
| 37 | + * @param app | ||
| 38 | + * @param stream | ||
| 39 | + * @return | ||
| 40 | + */ | ||
| 41 | + StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String addr); | ||
| 27 | } | 42 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| @@ -28,27 +28,40 @@ public class MediaServiceImpl implements IMediaService { | @@ -28,27 +28,40 @@ 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 | + return getStreamInfoByAppAndStream(app, stream, tracks, null); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream) { | ||
| 36 | + return getStreamInfoByAppAndStreamWithCheck(app, stream, null); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public StreamInfo getStreamInfoByAppAndStream(String app, String stream, JSONArray tracks, String addr) { | ||
| 31 | ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 41 | ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 32 | StreamInfo streamInfoResult = new StreamInfo(); | 42 | StreamInfo streamInfoResult = new StreamInfo(); |
| 33 | streamInfoResult.setStreamId(stream); | 43 | streamInfoResult.setStreamId(stream); |
| 34 | streamInfoResult.setApp(app); | 44 | streamInfoResult.setApp(app); |
| 35 | - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtmpPort(), app, stream)); | ||
| 36 | - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtspPort(), app, stream)); | ||
| 37 | - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 38 | - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 39 | - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 40 | - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 41 | - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 42 | - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 43 | - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | ||
| 44 | - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | 45 | + if (addr == null) { |
| 46 | + addr = mediaInfo.getStreamIp(); | ||
| 47 | + } | ||
| 48 | + streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", addr, mediaInfo.getRtmpPort(), app, stream)); | ||
| 49 | + streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", addr, mediaInfo.getRtspPort(), app, stream)); | ||
| 50 | + streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 51 | + streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 52 | + streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 53 | + streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 54 | + streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 55 | + streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 56 | + streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 57 | + streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpPort(), app, stream)); | ||
| 45 | streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | 58 | streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); |
| 46 | streamInfoResult.setTracks(tracks); | 59 | streamInfoResult.setTracks(tracks); |
| 47 | return streamInfoResult; | 60 | return streamInfoResult; |
| 48 | } | 61 | } |
| 49 | 62 | ||
| 50 | @Override | 63 | @Override |
| 51 | - public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream) { | 64 | + public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String addr) { |
| 52 | StreamInfo streamInfo = null; | 65 | StreamInfo streamInfo = null; |
| 53 | JSONObject mediaList = zlmresTfulUtils.getMediaList(app, stream); | 66 | JSONObject mediaList = zlmresTfulUtils.getMediaList(app, stream); |
| 54 | if (mediaList != null) { | 67 | if (mediaList != null) { |
| @@ -57,7 +70,7 @@ public class MediaServiceImpl implements IMediaService { | @@ -57,7 +70,7 @@ public class MediaServiceImpl implements IMediaService { | ||
| 57 | if (data == null) return null; | 70 | if (data == null) return null; |
| 58 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); | 71 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); |
| 59 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); | 72 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); |
| 60 | - streamInfo = getStreamInfoByAppAndStream(app, stream, tracks); | 73 | + streamInfo = getStreamInfoByAppAndStream(app, stream, tracks, addr); |
| 61 | } | 74 | } |
| 62 | } | 75 | } |
| 63 | return streamInfo; | 76 | return streamInfo; |
src/main/java/com/genersoft/iot/vmp/web/ApiCompatibleController.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.web; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.common.StreamInfo; | ||
| 4 | +import com.genersoft.iot.vmp.service.IMediaService; | ||
| 5 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.web.bind.annotation.*; | ||
| 10 | + | ||
| 11 | +import javax.servlet.http.HttpServletRequest; | ||
| 12 | + | ||
| 13 | +@CrossOrigin | ||
| 14 | +@RestController | ||
| 15 | +public class ApiCompatibleController { | ||
| 16 | + | ||
| 17 | + private final static Logger logger = LoggerFactory.getLogger(ApiCompatibleController.class); | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + private IMediaService mediaService; | ||
| 21 | + | ||
| 22 | + @GetMapping(value = "/api/v1/stream_info_by_app_and_stream") | ||
| 23 | + @ResponseBody | ||
| 24 | + public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, @RequestParam String stream){ | ||
| 25 | + String localAddr = request.getLocalAddr(); | ||
| 26 | + StreamInfo streamINfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, localAddr); | ||
| 27 | + WVPResult<StreamInfo> wvpResult = new WVPResult<>(); | ||
| 28 | + wvpResult.setCode(0); | ||
| 29 | + wvpResult.setMsg("success"); | ||
| 30 | + wvpResult.setData(streamINfo); | ||
| 31 | + return wvpResult; | ||
| 32 | + } | ||
| 33 | +} |
src/main/resources/all-application.yml
| @@ -52,7 +52,7 @@ server: | @@ -52,7 +52,7 @@ server: | ||
| 52 | # 作为28181服务器的配置 | 52 | # 作为28181服务器的配置 |
| 53 | sip: | 53 | sip: |
| 54 | # [必须修改] 本机的IP, 必须是网卡上的IP,用于sip下协议栈监听ip,如果监听所有设置为0.0.0.0 | 54 | # [必须修改] 本机的IP, 必须是网卡上的IP,用于sip下协议栈监听ip,如果监听所有设置为0.0.0.0 |
| 55 | - monitorIp: 0.0.0.0 | 55 | + monitor-ip: 0.0.0.0 |
| 56 | # [必须修改] 本机的IP | 56 | # [必须修改] 本机的IP |
| 57 | ip: 192.168.0.100 | 57 | ip: 192.168.0.100 |
| 58 | # [可选] 28181服务监听的端口 | 58 | # [可选] 28181服务监听的端口 |
| @@ -67,48 +67,48 @@ sip: | @@ -67,48 +67,48 @@ sip: | ||
| 67 | # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 | 67 | # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 |
| 68 | password: admin123 | 68 | password: admin123 |
| 69 | # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 | 69 | # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 |
| 70 | - keepaliveTimeOut: 180 | 70 | + keepalive-timeout: 180 |
| 71 | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 | 71 | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 |
| 72 | - registerTimeInterval: 60 | 72 | + register-time-interval: 60 |
| 73 | 73 | ||
| 74 | #zlm 默认服务器配置 | 74 | #zlm 默认服务器配置 |
| 75 | media: | 75 | media: |
| 76 | # [必须修改] zlm服务器的内网IP | 76 | # [必须修改] zlm服务器的内网IP |
| 77 | ip: 192.168.0.100 | 77 | ip: 192.168.0.100 |
| 78 | # [可选] 返回流地址时的ip,置空使用 media.ip | 78 | # [可选] 返回流地址时的ip,置空使用 media.ip |
| 79 | - streamIp: | 79 | + stream-ip: |
| 80 | # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip | 80 | # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip |
| 81 | - sdpIp: | 81 | + sdp-ip: |
| 82 | # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip | 82 | # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip |
| 83 | - hookIp: | 83 | + hook-ip: |
| 84 | # [必须修改] zlm服务器的http.port | 84 | # [必须修改] zlm服务器的http.port |
| 85 | - httpPort: 80 | 85 | + http-port: 80 |
| 86 | # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 | 86 | # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 |
| 87 | - httpSSlPort: | 87 | + http-ssl-port: |
| 88 | # [可选] zlm服务器的rtmp.port, 置空使用zlm配置文件配置 | 88 | # [可选] zlm服务器的rtmp.port, 置空使用zlm配置文件配置 |
| 89 | - rtmpPort: | 89 | + rtmp-port: |
| 90 | # [可选] zlm服务器的rtmp.sslport, 置空使用zlm配置文件配置 | 90 | # [可选] zlm服务器的rtmp.sslport, 置空使用zlm配置文件配置 |
| 91 | - rtmpSSlPort: | 91 | + rtmp-ssl-port: |
| 92 | # [可选] zlm服务器的 rtp_proxy.port, 置空使用zlm配置文件配置 | 92 | # [可选] zlm服务器的 rtp_proxy.port, 置空使用zlm配置文件配置 |
| 93 | - rtpProxyPort: | 93 | + rtp-proxy-port: |
| 94 | # [可选] zlm服务器的 rtsp.port, 置空使用zlm配置文件配置 | 94 | # [可选] zlm服务器的 rtsp.port, 置空使用zlm配置文件配置 |
| 95 | - rtspPort: | 95 | + rtsp-port: |
| 96 | # [可选] zlm服务器的 rtsp.sslport, 置空使用zlm配置文件配置 | 96 | # [可选] zlm服务器的 rtsp.sslport, 置空使用zlm配置文件配置 |
| 97 | - rtspSSLPort: | 97 | + rtsp-ssl-port: |
| 98 | # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 | 98 | # [可选] 是否自动配置ZLM, 如果希望手动配置ZLM, 可以设为false, 不建议新接触的用户修改 |
| 99 | - autoConfig: true | 99 | + auto-config: true |
| 100 | # [可选] zlm服务器的hook.admin_params=secret | 100 | # [可选] zlm服务器的hook.admin_params=secret |
| 101 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc | 101 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc |
| 102 | # [可选] zlm服务器的general.streamNoneReaderDelayMS | 102 | # [可选] zlm服务器的general.streamNoneReaderDelayMS |
| 103 | - streamNoneReaderDelayMS: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流 | 103 | + stream-none-reader-delay-ms: 18000 # 无人观看多久自动关闭流, -1表示永不自动关闭,即 关闭按需拉流 |
| 104 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 | 104 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 |
| 105 | rtp: | 105 | rtp: |
| 106 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 | 106 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 |
| 107 | enable: true | 107 | enable: true |
| 108 | # [可选] 在此范围内选择端口用于媒体流传输, | 108 | # [可选] 在此范围内选择端口用于媒体流传输, |
| 109 | - portRange: 30000,30500 # 端口范围 | 109 | + port-range: 30000,30500 # 端口范围 |
| 110 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 | 110 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 |
| 111 | - recordAssistPort: 0 | 111 | + record-assist-port: 0 |
| 112 | 112 | ||
| 113 | # [可选] 日志配置, 一般不需要改 | 113 | # [可选] 日志配置, 一般不需要改 |
| 114 | logging: | 114 | logging: |
| @@ -122,21 +122,24 @@ logging: | @@ -122,21 +122,24 @@ logging: | ||
| 122 | genersoft: | 122 | genersoft: |
| 123 | iot: info | 123 | iot: info |
| 124 | # [根据业务需求配置] | 124 | # [根据业务需求配置] |
| 125 | -userSettings: | 125 | +user-settings: |
| 126 | # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true | 126 | # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true |
| 127 | - autoApplyPlay: false | 127 | + auto-apply-play: false |
| 128 | # [可选] 部分设备需要扩展SDP,需要打开此设置 | 128 | # [可选] 部分设备需要扩展SDP,需要打开此设置 |
| 129 | - seniorSdp: false | 129 | + senior-sdp: false |
| 130 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) | 130 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) |
| 131 | - savePositionHistory: false | 131 | + save-position-history: false |
| 132 | # 点播等待超时时间,单位:毫秒 | 132 | # 点播等待超时时间,单位:毫秒 |
| 133 | - playTimeout: 3000 | 133 | + play-timeout: 3000 |
| 134 | # 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播 | 134 | # 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播 |
| 135 | - waitTrack: false | 135 | + wait-track: false |
| 136 | # 是否开启接口鉴权 | 136 | # 是否开启接口鉴权 |
| 137 | - interfaceAuthentication: true | 137 | + interface-authentication: true |
| 138 | + # 接口鉴权例外的接口, 即不进行接口鉴权的接口 | ||
| 139 | + interface-authentication-excludes: | ||
| 140 | + -"/" | ||
| 138 | # 推流直播是否录制 | 141 | # 推流直播是否录制 |
| 139 | - recordPushLive: true | 142 | + record-push-live: true |
| 140 | 143 | ||
| 141 | # 在线文档: swagger-ui(生产环境建议关闭) | 144 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 142 | springfox: | 145 | springfox: |
src/main/resources/application-dev.yml
| @@ -13,10 +13,15 @@ spring: | @@ -13,10 +13,15 @@ spring: | ||
| 13 | timeout: 10000 | 13 | timeout: 10000 |
| 14 | # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置 | 14 | # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置 |
| 15 | datasource: | 15 | datasource: |
| 16 | + # 使用mysql 打开23-28行注释, 删除29-36行 | ||
| 17 | + # name: wvp | ||
| 18 | + # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | ||
| 19 | + # username: | ||
| 20 | + # password: | ||
| 21 | + # type: com.alibaba.druid.pool.DruidDataSource | ||
| 22 | + # driver-class-name: com.mysql.cj.jdbc.Driver | ||
| 16 | name: eiot | 23 | name: eiot |
| 17 | url: jdbc:sqlite::resource:wvp.sqlite | 24 | url: jdbc:sqlite::resource:wvp.sqlite |
| 18 | - # 打包为jar运行时把wvp.sqlite发到jar同级文件夹,同时url改为: | ||
| 19 | - # url: jdbc:sqlite:wvp.sqlite | ||
| 20 | username: | 25 | username: |
| 21 | password: | 26 | password: |
| 22 | type: com.alibaba.druid.pool.DruidDataSource | 27 | type: com.alibaba.druid.pool.DruidDataSource |
| @@ -49,7 +54,7 @@ media: | @@ -49,7 +54,7 @@ media: | ||
| 49 | # [必须修改] zlm服务器的内网IP | 54 | # [必须修改] zlm服务器的内网IP |
| 50 | ip: 192.168.0.100 | 55 | ip: 192.168.0.100 |
| 51 | # [必须修改] zlm服务器的http.port | 56 | # [必须修改] zlm服务器的http.port |
| 52 | - httpPort: 80 | 57 | + http-port: 80 |
| 53 | # [可选] zlm服务器的hook.admin_params=secret | 58 | # [可选] zlm服务器的hook.admin_params=secret |
| 54 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc | 59 | secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc |
| 55 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 | 60 | # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 |
| @@ -57,10 +62,9 @@ media: | @@ -57,10 +62,9 @@ media: | ||
| 57 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 | 62 | # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 |
| 58 | enable: true | 63 | enable: true |
| 59 | # [可选] 在此范围内选择端口用于媒体流传输, | 64 | # [可选] 在此范围内选择端口用于媒体流传输, |
| 60 | - portRange: 30000,30500 # 端口范围 | 65 | + port-range: 30000,30500 # 端口范围 |
| 61 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 | 66 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 |
| 62 | - recordAssistPort: 0 | ||
| 63 | - | 67 | + record-assist-port: 0 |
| 64 | 68 | ||
| 65 | # [可选] 日志配置, 一般不需要改 | 69 | # [可选] 日志配置, 一般不需要改 |
| 66 | logging: | 70 | logging: |
| @@ -74,16 +78,12 @@ logging: | @@ -74,16 +78,12 @@ logging: | ||
| 74 | genersoft: | 78 | genersoft: |
| 75 | iot: info | 79 | iot: info |
| 76 | # [根据业务需求配置] | 80 | # [根据业务需求配置] |
| 77 | -userSettings: | ||
| 78 | - # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true | ||
| 79 | - autoApplyPlay: false | ||
| 80 | - # 是否开启接口鉴权 | ||
| 81 | - interfaceAuthentication: true | 81 | +user-settings: |
| 82 | # 推流直播是否录制 | 82 | # 推流直播是否录制 |
| 83 | - recordPushLive: true | 83 | + record-push-live: true |
| 84 | 84 | ||
| 85 | # 在线文档: swagger-ui(生产环境建议关闭) | 85 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 86 | springfox: | 86 | springfox: |
| 87 | documentation: | 87 | documentation: |
| 88 | swagger-ui: | 88 | swagger-ui: |
| 89 | - enabled: true | 89 | - enabled: true |
| 90 | + enabled: true | ||
| 90 | \ No newline at end of file | 91 | \ No newline at end of file |