支持彻底关闭文档页面 + 修复云端录像偶现callId错误问题
| | |
| | | import io.swagger.v3.oas.models.info.Info; |
| | | import io.swagger.v3.oas.models.info.License; |
| | | import io.swagger.v3.oas.models.security.SecurityScheme; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springdoc.core.GroupedOpenApi; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | */ |
| | | @Configuration |
| | | @Order(1) |
| | | @ConditionalOnProperty(value = "user-settings.doc-enable", havingValue = "true", matchIfMissing = true) |
| | | public class SpringDocConfig { |
| | | |
| | | @Value("${doc.enabled: true}") |
| | |
| | | private Boolean deviceStatusNotify = Boolean.TRUE; |
| | | private Boolean useCustomSsrcForParentInvite = Boolean.TRUE; |
| | | |
| | | private Boolean docEnable = Boolean.TRUE; |
| | | |
| | | private String serverId = "000000"; |
| | | |
| | | private String thirdPartyGBIdReg = "[\\s\\S]*"; |
| | |
| | | public void setRegisterKeepIntDialog(boolean registerKeepIntDialog) { |
| | | this.registerKeepIntDialog = registerKeepIntDialog; |
| | | } |
| | | |
| | | public Boolean getDocEnable() { |
| | | return docEnable; |
| | | } |
| | | |
| | | public void setDocEnable(Boolean docEnable) { |
| | | this.docEnable = docEnable; |
| | | } |
| | | } |
| | |
| | | |
| | | // 忽ç¥ç»å½è¯·æ±çtokenéªè¯ |
| | | String requestURI = request.getRequestURI(); |
| | | System.out.println(requestURI); |
| | | if ((requestURI.startsWith("/doc.html") || requestURI.startsWith("/swagger-ui") ) && !userSetting.getDocEnable()) { |
| | | response.setStatus(HttpServletResponse.SC_NOT_FOUND); |
| | | return; |
| | | } |
| | | if (requestURI.equalsIgnoreCase("/api/user/login")) { |
| | | chain.doFilter(request, response); |
| | | return; |
| | | } |
| | | |
| | | if (!userSetting.isInterfaceAuthentication()) { |
| | | UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, null, new ArrayList<>() ); |
| | | SecurityContextHolder.getContext().setAuthentication(token); |
| | |
| | | .authorizeRequests() |
| | | .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() |
| | | .antMatchers(userSetting.getInterfaceAuthenticationExcludes().toArray(new String[0])).permitAll() |
| | | .antMatchers("/api/user/login", "/index/hook/**", "/swagger-ui/**", "/doc.html").permitAll() |
| | | .antMatchers("/api/user/login", "/index/hook/**", "/swagger-ui/**", "/doc.html#/**").permitAll() |
| | | .anyRequest().authenticated() |
| | | // å¼å¸¸å¤çå¨ |
| | | .and() |
| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
| | | import com.genersoft.iot.vmp.utils.DateUtil;
|
| | | import com.genersoft.iot.vmp.utils.MediaServerUtils;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.OtherPsSendInfo;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
|
| | |
| | | import javax.sip.InvalidArgumentException;
|
| | | import javax.sip.SipException;
|
| | | import java.text.ParseException;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
| | | }
|
| | | });
|
| | | if (!"rtp".equals(param.getApp())) {
|
| | | Map<String, String> paramMap = urlParamToMap(param.getParams());
|
| | | Map<String, String> paramMap = MediaServerUtils.urlParamToMap(param.getParams());
|
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
|
| | | if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) {
|
| | | return new HookResult(401, "Unauthorized");
|
| | |
| | | logger.info("æ¨æµé´æå¤±è´¥ï¼ 缺å°å¿
è¦åæ°ï¼sign=md5(user表çpushKey)");
|
| | | return new HookResultForOnPublish(401, "Unauthorized");
|
| | | }
|
| | | Map<String, String> paramMap = urlParamToMap(param.getParams());
|
| | | Map<String, String> paramMap = MediaServerUtils.urlParamToMap(param.getParams());
|
| | | String sign = paramMap.get("sign");
|
| | | if (sign == null) {
|
| | | logger.info("æ¨æµé´æå¤±è´¥ï¼ 缺å°å¿
è¦åæ°ï¼sign=md5(user表çpushKey)");
|
| | |
| | | });
|
| | |
|
| | | return HookResult.SUCCESS();
|
| | | }
|
| | |
|
| | | private Map<String, String> urlParamToMap(String params) {
|
| | | HashMap<String, String> map = new HashMap<>();
|
| | | if (ObjectUtils.isEmpty(params)) {
|
| | | return map;
|
| | | }
|
| | | String[] paramsArray = params.split("&");
|
| | | if (paramsArray.length == 0) {
|
| | | return map;
|
| | | }
|
| | | for (String param : paramsArray) {
|
| | | String[] paramArray = param.split("=");
|
| | | if (paramArray.length == 2) {
|
| | | map.put(paramArray[0], paramArray[1]);
|
| | | }
|
| | | }
|
| | | return map;
|
| | | }
|
| | | }
|
| | |
| | | private String vhost; |
| | | private long start_time; |
| | | private double time_len; |
| | | private String params; |
| | | |
| | | public String getApp() { |
| | | return app; |
| | |
| | | this.time_len = time_len; |
| | | } |
| | | |
| | | public String getParams() { |
| | | return params; |
| | | } |
| | | |
| | | public void setParams(String params) { |
| | | this.params = params; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "OnRecordMp4HookParam{" + |
| | |
| | | ", vhost='" + vhost + '\'' + |
| | | ", start_time=" + start_time + |
| | | ", time_len=" + time_len + |
| | | ", params=" + params + |
| | | '}'; |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.service.bean; |
| | | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam; |
| | | import com.genersoft.iot.vmp.utils.MediaServerUtils; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * äºç«¯å½åæ°æ® |
| | |
| | | cloudRecordItem.setMediaServerId(param.getMediaServerId()); |
| | | cloudRecordItem.setTimeLen((long) param.getTime_len() * 1000); |
| | | cloudRecordItem.setEndTime((param.getStart_time() + (long)param.getTime_len()) * 1000); |
| | | Map<String, String> paramsMap = MediaServerUtils.urlParamToMap(param.getParams()); |
| | | if (paramsMap.get("callId") != null) { |
| | | cloudRecordItem.setCallId(paramsMap.get("callId")); |
| | | } |
| | | return cloudRecordItem; |
| | | } |
| | | |
| | |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam; |
| | | import com.genersoft.iot.vmp.service.ICloudRecordService; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.*; |
| | | import java.util.*; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneOffset; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Service |
| | | @DS("share") |
| | |
| | | @Override |
| | | public void addRecord(OnRecordMp4HookParam param) { |
| | | CloudRecordItem cloudRecordItem = CloudRecordItem.getInstance(param); |
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); |
| | | if (streamAuthorityInfo != null) { |
| | | cloudRecordItem.setCallId(streamAuthorityInfo.getCallId()); |
| | | } |
| | | logger.info("[æ·»å å½åè®°å½] {}/{} æä»¶å¤§å°ï¼{}, æ¶é¿ï¼ {}ç§", param.getApp(), param.getStream(), param.getFile_size(),param.getTime_len()); |
| | | logger.info("[æ·»å å½åè®°å½] {}/{}, callId: {}, æä»¶å¤§å°ï¼{}, æ¶é¿ï¼ {}ç§", param.getApp(), param.getStream(),cloudRecordItem.getCallId(), param.getFile_size(),param.getTime_len()); |
| | | cloudRecordServiceMapper.add(cloudRecordItem); |
| | | } |
| | | |
New file |
| | |
| | | package com.genersoft.iot.vmp.utils; |
| | | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class MediaServerUtils { |
| | | public static Map<String, String> urlParamToMap(String params) { |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | if (ObjectUtils.isEmpty(params)) { |
| | | return map; |
| | | } |
| | | String[] paramsArray = params.split("&"); |
| | | if (paramsArray.length == 0) { |
| | | return map; |
| | | } |
| | | for (String param : paramsArray) { |
| | | String[] paramArray = param.split("="); |
| | | if (paramArray.length == 2) { |
| | | map.put(paramArray[0], paramArray[1]); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | } |
| | |
| | | register-again-after-time: 60 |
| | | # 彿 ç»è®¢æ¹å¼ï¼true为ç»è®¢ï¼æ¯æ¬¡æ³¨åå¨åä¸ä¸ªä¼è¯éï¼falseä¸ºéæ°æ³¨åï¼æ¯æ¬¡ä½¿ç¨æ°çä¼è¯ |
| | | register-keep-int-dialog: false |
| | | # å¼å¯æ¥å£ææ¡£é¡µé¢ã é»è®¤å¼å¯ï¼ç产ç¯å¢å»ºè®®å
³éï¼éå°swaggerç¸å
³çæ¼æ´æ¶ä¹å¯ä»¥å
³é |
| | | doc-enable: true |
| | | # è·¨åé
ç½®ï¼ä¸é
ç½®æ¤é¡¹åå
许ææè·¨å请æ±ï¼é
ç½®åååªå
许é
ç½®ç页é¢çå°å请æ±ï¼ å¯ä»¥é
ç½®å¤ä¸ª |
| | | allowed-origins: |
| | | - http://localhost:8008 |
| | |
| | | auto-apply-play: true |
| | | # 设å¤/ééç¶æååæ¶åéæ¶æ¯ |
| | | device-status-notify: true |
| | | # [å¯é] æ¥å¿é
ç½®, ä¸è¬ä¸éè¦æ¹ |
| | | logging: |
| | | config: classpath:logback-spring.xml |
| | | |
| | |
| | | hook_alive_interval integer, |
| | | record_path character varying(255), |
| | | record_day integer default 7, |
| | | transcode_suffix character varying(255), |
| | | constraint uk_media_server_unique_ip_http_port unique (ip, http_port) |
| | | ); |
| | | |
| | |
| | | hook_alive_interval integer, |
| | | record_path character varying(255), |
| | | record_day integer default 7, |
| | | transcode_suffix character varying(255), |
| | | constraint uk_media_server_unique_ip_http_port unique (ip, http_port) |
| | | ); |
| | | |