From 5a9354639e52b2f9c9bdeda5e76f7d54370441c3 Mon Sep 17 00:00:00 2001 From: zxb <919411476@qq.com> Date: Fri, 4 Aug 2023 11:16:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20lombok=20=E5=92=8C=20mapst?= =?UTF-8?q?ruct=20=E6=94=AF=E6=8C=81=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=90=AF=E5=8A=A8=E7=B1=BB=E5=8F=8A=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + pom.xml | 97 +++++++++--- .../cmd/impl/SIPCommanderFroPlatform.java | 5 +- .../vmp/web/gb28181/ApiStreamController.java | 24 ++- .../iot/vmp/web/gb28181/AuthController.java | 5 +- .../iot/vmp/VManageBootstrapTest.java | 14 ++ src/test/resources/application.yml | 142 ++++++++++++++++++ 7 files changed, 247 insertions(+), 42 deletions(-) create mode 100644 src/test/java/com/genersoft/iot/vmp/VManageBootstrapTest.java create mode 100644 src/test/resources/application.yml diff --git a/.gitignore b/.gitignore index 776ebe10..29e3ddc7 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ hs_err_pid* /target/ /src/main/resources/static/ +/web_src/node_modules/ +/web_src/build/ certificates diff --git a/pom.xml b/pom.xml index 2ecfad30..92972d21 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 org.springframework.boot @@ -55,6 +55,8 @@ ${project.build.directory}/asciidoc ${project.build.directory}/asciidoc/html ${project.build.directory}/asciidoc/pdf + 1.5.3.Final + 2.7.2 @@ -241,11 +243,11 @@ - - - - - + + + + + @@ -280,13 +282,13 @@ spring-session-core - - - - - - - + + + + + + + @@ -299,9 +301,28 @@ org.springframework.boot spring-boot-starter-test - + + + + + org.projectlombok + lombok + + + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + compile + @@ -316,15 +337,6 @@ true - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - pl.project13.maven @@ -346,6 +358,41 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + + + + + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index 06a08e24..09c8ab4b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -112,7 +112,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { toTag, callIdHeader, isRegister? parentPlatform.getExpires() : 0); // 将 callid 写入缓存, 等注册成功可以更新状态 String callIdFromHeader = callIdHeader.getCallId(); - redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister)); + PlatformRegisterInfo instance = PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister); + logger.info("callIdFromHeader {}",callIdFromHeader); + logger.info("PlatformRegisterInfo {}",instance); + redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, instance); sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ if (event != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java index ddf677ce..1ead9375 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,30 +36,25 @@ import java.text.ParseException; @RestController @RequestMapping(value = "/api/v1/stream") +@RequiredArgsConstructor public class ApiStreamController { private final static Logger logger = LoggerFactory.getLogger(ApiStreamController.class); - @Autowired - private SIPCommander cmder; - @Autowired - private IVideoManagerStorage storager; + private final SIPCommander cmder; - @Autowired - private UserSetting userSetting; + private final IVideoManagerStorage storager; - @Autowired - private IRedisCatchStorage redisCatchStorage; + private final UserSetting userSetting; - @Autowired - private IDeviceService deviceService; + private final IRedisCatchStorage redisCatchStorage; - @Autowired - private IPlayService playService; + private final IDeviceService deviceService; - @Autowired - private IInviteStreamService inviteStreamService; + private final IPlayService playService; + + private final IInviteStreamService inviteStreamService; /** * 实时直播 - 开始直播 diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java index d503f153..04a3af99 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java @@ -2,16 +2,17 @@ package com.genersoft.iot.vmp.web.gb28181; import com.genersoft.iot.vmp.service.IUserService; import com.genersoft.iot.vmp.storager.dao.dto.User; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping(value = "/auth") +@RequiredArgsConstructor public class AuthController { - @Autowired - private IUserService userService; + private final IUserService userService; @RequestMapping("/login") public String devices(String name, String passwd){ diff --git a/src/test/java/com/genersoft/iot/vmp/VManageBootstrapTest.java b/src/test/java/com/genersoft/iot/vmp/VManageBootstrapTest.java new file mode 100644 index 00000000..49543bea --- /dev/null +++ b/src/test/java/com/genersoft/iot/vmp/VManageBootstrapTest.java @@ -0,0 +1,14 @@ +package com.genersoft.iot.vmp; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +@ServletComponentScan("com.genersoft.iot.vmp.conf") +@SpringBootApplication +@EnableScheduling +public class VManageBootstrapTest { + public static void main(String[] args) { + VManageBootstrap.main(args); + } +} diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 00000000..ebef37d5 --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,142 @@ +spring: + # 设置接口超时时间 + mvc: + async: + request-timeout: 20000 + thymeleaf: + cache: false + # [可选]上传文件大小限制 + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + # REDIS数据库配置 + redis: + # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 + host: 192.168.1.241 + # [必须修改] 端口号 + port: 6379 + # [可选] 数据库 DB + database: 7 + # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 + password: + # [可选] 超时时间 + timeout: 10000 + # mysql数据源 + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.1.241:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true + username: root + password: 123456a + hikari: + connection-timeout: 20000 # 是客户端等待连接池连接的最大毫秒数 + initialSize: 10 # 连接池初始化连接数 + maximum-pool-size: 200 # 连接池最大连接数 + minimum-idle: 5 # 连接池最小空闲连接数 + idle-timeout: 300000 # 允许连接在连接池中空闲的最长时间(以毫秒为单位) + max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) +#[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 +server: + port: 18978 + # [可选] HTTPS配置, 默认不开启 + ssl: + # [可选] 是否开启HTTPS访问 + enabled: false + # [可选] 证书文件路径,放置在resource/目录下即可,修改xxx为文件名 + key-store: classpath:test.monitor.89iot.cn.jks + # [可选] 证书密码 + key-store-password: gpf64qmw + # [可选] 证书类型, 默认为jks,根据实际修改 + key-store-type: JKS + +# 作为28181服务器的配置 +sip: + # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, + # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 + # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 + # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 + ip: 192.168.0.195,10.27.0.1 + # [可选] 28181服务监听的端口 + port: 5060 + # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) + # 后两位为行业编码,定义参照附录D.3 + # 3701020049标识山东济南历下区 信息行业接入 + # [可选] + domain: 4405010000 + # [可选] + id: 44050100002000000002 + # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 + password: 123456 + # 是否存储alarm信息 + alarm: true + +##zlm 默认服务器配置 +#media: +# id: your_server_id +# # [必须修改] zlm服务器的内网IP +# ip: 192.168.1.241 +# # [必须修改] zlm服务器的http.port +# http-port: 5080 +# # [可选] 返回流地址时的ip,置空使用 media.ip +## stream-ip: 192.168.10.241 +# # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip +## sdp-ip: 192.168.10.241 +# # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip +# hook-ip: +# # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 +# http-ssl-port: 5443 +# # [可选] zlm服务器的hook.admin_params=secret +# secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc +# # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 +# rtp: +# # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 +# enable: true +# # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 +# port-range: 51000,51300 # 端口范围 +# # [可选] 国标级联在此范围内选择端口发送媒体流, +# send-port-range: 51000,51300 # 端口范围 +# # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 +# record-assist-port: 18979 +#zlm 默认服务器配置 +media: + id: amrWMKmbKqoBjRQ9 + # [必须修改] zlm服务器的内网IP + ip: 10.10.10.200 + # [必须修改] zlm服务器的http.port + http-port: 5080 + # [可选] 返回流地址时的ip,置空使用 media.ip + stream-ip: + # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip + sdp-ip: + # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip + hook-ip: + # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 + http-ssl-port: 5443 + # [可选] zlm服务器的hook.admin_params=secret + secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333 + # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 + rtp: + # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 + enable: true + # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 + port-range: 61200,61250 # 端口范围 + # [可选] 国标级联在此范围内选择端口发送媒体流, + send-port-range: 61200,61250 # 端口范围 + # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 + record-assist-port: 0 +# [根据业务需求配置] +user-settings: + # 点播/录像回放 等待超时时间,单位:毫秒 + play-timeout: 180000 + # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true + auto-apply-play: true + # 设备/通道状态变化时发送消息 + device-status-notify: true + # 跨域配置,配置你访问前端页面的地址即可, 可以配置多个 + allowed-origins: + - http://localhost:8080 + - http://127.0.0.1:8080 +# [可选] 日志配置, 一般不需要改 +logging: + config: classpath:logback-spring-local.xml