Merge remote-tracking branch 'github/wvp-28181-2.0' into wvp-28181-2.0

# Conflicts:
#	pom.xml
#	src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
#	src/main/resources/application-dev.yml
This commit is contained in:
zxb 2023-12-18 22:45:18 +08:00
commit cc896bb83d
42 changed files with 983 additions and 806 deletions

586
pom.xml
View File

@ -1,53 +1,54 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.2</version> <version>2.7.17</version>
</parent> </parent>
<groupId>com.genersoft</groupId> <groupId>com.genersoft</groupId>
<artifactId>wvp-pro</artifactId> <artifactId>wvp-pro</artifactId>
<version>2.6.9</version> <version>2.6.9</version>
<name>web video platform</name> <name>web video platform</name>
<description>国标28181视频平台</description> <description>国标28181视频平台</description>
<packaging>${project.packaging}</packaging> <packaging>${project.packaging}</packaging>
<repositories> <repositories>
<repository> <repository>
<id>nexus-aliyun</id> <id>nexus-aliyun</id>
<name>Nexus aliyun</name> <name>Nexus aliyun</name>
<url>https://maven.aliyun.com/repository/public</url> <url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout> <layout>default</layout>
<snapshots> <snapshots>
<enabled>false</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties> <pluginRepositories>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <pluginRepository>
<maven.build.timestamp.format>MMddHHmm</maven.build.timestamp.format> <id>nexus-aliyun</id>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <name>Nexus aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>MMddHHmm</maven.build.timestamp.format>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<!-- 依赖版本 --> <!-- 依赖版本 -->
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
@ -59,90 +60,90 @@
<springboot.version>2.7.2</springboot.version> <springboot.version>2.7.2</springboot.version>
</properties> </properties>
<profiles> <profiles>
<profile> <profile>
<id>jar</id> <id>jar</id>
<activation> <activation>
<activeByDefault>true</activeByDefault> <activeByDefault>true</activeByDefault>
</activation> </activation>
<properties> <properties>
<project.packaging>jar</project.packaging> <project.packaging>jar</project.packaging>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>war</id> <id>war</id>
<properties> <properties>
<project.packaging>war</project.packaging> <project.packaging>war</project.packaging>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId> <artifactId>spring-boot-starter-jetty</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</profile> </profile>
</profiles> </profiles>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version> <version>2.2.2</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> </dependency>
<!-- mysql数据库 --> <!-- mysql数据库 -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>com.mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-j</artifactId>
<version>8.0.30</version> <version>8.2.0</version>
</dependency> </dependency>
<!--postgresql--> <!--postgresql-->
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>42.5.1</version> <version>42.5.1</version>
</dependency> </dependency>
<!-- kingbase人大金仓 --> <!-- kingbase人大金仓 -->
<!-- https://mvnrepository.com/artifact/cn.com.kingbase/kingbase8 --> <!-- https://mvnrepository.com/artifact/cn.com.kingbase/kingbase8 -->
@ -152,152 +153,168 @@
<version>8.6.0</version> <version>8.6.0</version>
</dependency> </dependency>
<!--Mybatis分页插件 --> <!--Mybatis分页插件 -->
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId> <artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.6</version> <version>1.4.6</version>
</dependency> </dependency>
<!--在线文档 --> <!--在线文档 -->
<dependency> <dependency>
<groupId>org.springdoc</groupId> <groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId> <artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.10</version> <version>1.7.0</version>
</dependency> <exclusions>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-springdoc-ui</artifactId> <artifactId>knife4j-springdoc-ui</artifactId>
<version>3.0.3</version> <version>3.0.3</version>
</dependency> </dependency>
<!--参数校验 --> <!--参数校验 -->
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<!-- 日志相关 --> <!-- 日志相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<!-- sip协议栈 --> <!-- sip协议栈 -->
<dependency> <dependency>
<groupId>javax.sip</groupId> <groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId> <artifactId>jain-sip-ri</artifactId>
<version>1.3.0-91</version> <version>1.3.0-91</version>
</dependency> </dependency>
<!-- 取代log4j --> <!-- 取代log4j -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId> <artifactId>log4j-over-slf4j</artifactId>
<version>1.7.36</version> <version>1.7.36</version>
</dependency> </dependency>
<!-- xml解析库 --> <!-- xml解析库 -->
<dependency> <dependency>
<groupId>org.dom4j</groupId> <groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId> <artifactId>dom4j</artifactId>
<version>2.1.3</version> <version>2.1.3</version>
</dependency> </dependency>
<dependency> <!-- json解析库fastjson2 -->
<groupId>com.google.guava</groupId> <dependency>
<artifactId>guava</artifactId> <groupId>com.alibaba.fastjson2</groupId>
<version>20.0</version> <artifactId>fastjson2</artifactId>
</dependency> <version>2.0.17</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.17</version>
</dependency>
<!-- json解析库fastjson2 --> <!-- okhttp -->
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.squareup.okhttp3</groupId>
<artifactId>fastjson2</artifactId> <artifactId>okhttp</artifactId>
<version>2.0.17</version> <version>4.10.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.17</version>
</dependency>
<!-- okhttp --> <!-- okhttp 调试日志 -->
<dependency> <dependency>
<groupId>com.squareup.okhttp3</groupId> <groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId> <artifactId>logging-interceptor</artifactId>
<version>4.10.0</version> <version>4.10.0</version>
</dependency> </dependency>
<!-- okhttp 调试日志 --> <!-- okhttp-digest -->
<dependency> <dependency>
<groupId>com.squareup.okhttp3</groupId> <groupId>io.github.rburgst</groupId>
<artifactId>logging-interceptor</artifactId> <artifactId>okhttp-digest</artifactId>
<version>4.10.0</version> <version>2.7</version>
</dependency> </dependency>
<!-- okhttp-digest --> <!-- https://mvnrepository.com/artifact/net.sf.kxml/kxml2 -->
<dependency> <!-- <dependency>-->
<groupId>io.github.rburgst</groupId> <!-- <groupId>net.sf.kxml</groupId>-->
<artifactId>okhttp-digest</artifactId> <!-- <artifactId>kxml2</artifactId>-->
<version>2.7</version> <!-- <version>2.3.0</version>-->
</dependency> <!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/net.sf.kxml/kxml2 --> <!-- jwt实现 -->
<!-- <dependency>--> <dependency>
<!-- <groupId>net.sf.kxml</groupId>--> <groupId>org.bitbucket.b_c</groupId>
<!-- <artifactId>kxml2</artifactId>--> <artifactId>jose4j</artifactId>
<!-- <version>2.3.0</version>--> <version>0.9.3</version>
<!-- </dependency>--> </dependency>
<!-- jwt实现 --> <!--反向代理-->
<dependency> <dependency>
<groupId>org.bitbucket.b_c</groupId> <groupId>org.mitre.dsmiley.httpproxy</groupId>
<artifactId>jose4j</artifactId> <artifactId>smiley-http-proxy-servlet</artifactId>
<version>0.9.3</version> <version>1.12.1</version>
</dependency> </dependency>
<!--反向代理--> <!--excel解析库-->
<dependency> <dependency>
<groupId>org.mitre.dsmiley.httpproxy</groupId> <groupId>com.alibaba</groupId>
<artifactId>smiley-http-proxy-servlet</artifactId> <artifactId>easyexcel</artifactId>
<version>1.12.1</version> <version>3.3.2</version>
</dependency> <exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.24.0</version>
</dependency>
<!--excel解析库--> <!-- 获取系统信息 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.github.oshi</groupId>
<artifactId>easyexcel</artifactId> <artifactId>oshi-core</artifactId>
<version>3.1.1</version> <version>6.2.2</version>
</dependency> </dependency>
<!-- 获取系统信息 --> <dependency>
<dependency> <groupId>org.springframework.session</groupId>
<groupId>com.github.oshi</groupId> <artifactId>spring-session-core</artifactId>
<artifactId>oshi-core</artifactId> </dependency>
<version>6.2.2</version>
</dependency>
<dependency> <!-- 检测文件编码 -->
<groupId>org.springframework.session</groupId> <!-- https://mvnrepository.com/artifact/cpdetector/cpdetector -->
<artifactId>spring-session-core</artifactId> <!--<dependency>-->
</dependency> <!-- <groupId>cpdetector</groupId>-->
<!-- <artifactId>cpdetector</artifactId>-->
<!-- <version>1.0.8</version>-->
<!--</dependency>-->
<!-- &lt;!&ndash; 检测文件编码 &ndash;&gt;--> <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/cpdetector/cpdetector &ndash;&gt;--> <dependency>
<!-- <dependency>--> <groupId>com.google.guava</groupId>
<!-- <groupId>cpdetector</groupId>--> <artifactId>guava</artifactId>
<!-- <artifactId>cpdetector</artifactId>--> <version>32.1.3-jre</version>
<!-- <version>1.0.8</version>--> </dependency>
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency> <dependency>
@ -335,37 +352,36 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>pl.project13.maven</groupId> <groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId> <artifactId>git-commit-id-plugin</artifactId>
<version>3.0.1</version> <version>3.0.1</version>
<configuration> <configuration>
<offline>true</offline> <offline>true</offline>
<failOnNoGitDirectory>false</failOnNoGitDirectory> <failOnNoGitDirectory>false</failOnNoGitDirectory>
<dateFormat>yyyyMMdd</dateFormat> <dateFormat>yyyyMMdd</dateFormat>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
<configuration> <configuration>
<skipTests>true</skipTests> <skipTests>true</skipTests>
</configuration> </configuration>
</plugin> </plugin>
</plugins>
</plugins> <resources>
<resources> <resource>
<resource> <directory>src/main/resources</directory>
<directory>src/main/resources</directory> </resource>
</resource> <resource>
<resource> <directory>src/main/java</directory>
<directory>src/main/java</directory> <includes>
<includes> <include>**/*.xml</include>
<include>**/*.xml</include> </includes>
</includes> </resource>
</resource> </resources>
</resources> </build>
</build>
</project> </project>

View File

@ -5,4 +5,4 @@ alter table wvp_platform
add auto_push_channel bool default false add auto_push_channel bool default false
alter table wvp_stream_proxy alter table wvp_stream_proxy
add stream_key varying(255) add stream_key character varying(255)

View File

@ -78,6 +78,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
// 构建UsernamePasswordAuthenticationToken,这里密码为null是因为提供了正确的JWT,实现自动登录 // 构建UsernamePasswordAuthenticationToken,这里密码为null是因为提供了正确的JWT,实现自动登录
User user = new User(); User user = new User();
user.setId(jwtUser.getUserId());
user.setUsername(jwtUser.getUserName()); user.setUsername(jwtUser.getUserName());
user.setPassword(jwtUser.getPassword()); user.setPassword(jwtUser.getPassword());
Role role = new Role(); Role role = new Role();

View File

@ -144,6 +144,7 @@ public class JwtUtils implements InitializingBean {
jwtUser.setUserName(username); jwtUser.setUserName(username);
jwtUser.setPassword(user.getPassword()); jwtUser.setPassword(user.getPassword());
jwtUser.setRoleId(user.getRole().getId()); jwtUser.setRoleId(user.getRole().getId());
jwtUser.setUserId(user.getId());
return jwtUser; return jwtUser;
} catch (InvalidJwtException e) { } catch (InvalidJwtException e) {

View File

@ -1,12 +1,12 @@
package com.genersoft.iot.vmp.conf.security; package com.genersoft.iot.vmp.conf.security;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import org.springframework.core.annotation.Order;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
@ -28,6 +28,7 @@ import java.util.Arrays;
/** /**
* 配置Spring Security * 配置Spring Security
*
* @author lin * @author lin
*/ */
@Configuration @Configuration
@ -75,7 +76,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
matchers.add("/js/**"); matchers.add("/js/**");
matchers.add("/api/device/query/snap/**"); matchers.add("/api/device/query/snap/**");
matchers.add("/record_proxy/*/**"); matchers.add("/record_proxy/*/**");
matchers.addAll(userSetting.getInterfaceAuthenticationExcludes()); matchers.add("/api/emit");
// 可以直接访问的静态数据 // 可以直接访问的静态数据
web.ignoring().antMatchers(matchers.toArray(new String[0])); web.ignoring().antMatchers(matchers.toArray(new String[0]));
} }
@ -83,6 +84,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
/** /**
* 配置认证方式 * 配置认证方式
*
* @param auth * @param auth
* @throws Exception * @throws Exception
*/ */
@ -111,7 +113,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.authorizeRequests() .authorizeRequests()
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.antMatchers(userSetting.getInterfaceAuthenticationExcludes().toArray(new String[0])).permitAll() .antMatchers(userSetting.getInterfaceAuthenticationExcludes().toArray(new String[0])).permitAll()
.antMatchers("/api/user/login","/index/hook/**","/zlm_Proxy/FhTuMYqB2HeCuNOb/record/t/1/2023-03-25/16:35:07-16:35:16-9353.mp4").permitAll() .antMatchers("/api/user/login", "/index/hook/**").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated()
// 异常处理器 // 异常处理器
.and() .and()
@ -124,7 +126,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
} }
CorsConfigurationSource configurationSource(){ CorsConfigurationSource configurationSource() {
// 配置跨域 // 配置跨域
CorsConfiguration corsConfiguration = new CorsConfiguration(); CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowedHeaders(Arrays.asList("*")); corsConfiguration.setAllowedHeaders(Arrays.asList("*"));
@ -135,7 +137,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
corsConfiguration.setExposedHeaders(Arrays.asList(JwtUtils.getHeader())); corsConfiguration.setExposedHeaders(Arrays.asList(JwtUtils.getHeader()));
UrlBasedCorsConfigurationSource url = new UrlBasedCorsConfigurationSource(); UrlBasedCorsConfigurationSource url = new UrlBasedCorsConfigurationSource();
url.registerCorsConfiguration("/**",corsConfiguration); url.registerCorsConfiguration("/**", corsConfiguration);
return url; return url;
} }

View File

@ -21,6 +21,7 @@ public class JwtUser {
EXCEPTION EXCEPTION
} }
private int userId;
private String userName; private String userName;
private String password; private String password;
@ -29,6 +30,14 @@ public class JwtUser {
private TokenStatus status; private TokenStatus status;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() { public String getUserName() {
return userName; return userName;
} }

View File

@ -1,8 +1,8 @@
package com.genersoft.iot.vmp.gb28181.conf; package com.genersoft.iot.vmp.gb28181.conf;
import gov.nist.core.StackLogger; import gov.nist.core.StackLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.spi.LocationAwareLogger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Properties; import java.util.Properties;
@ -10,100 +10,132 @@ import java.util.Properties;
@Component @Component
public class StackLoggerImpl implements StackLogger { public class StackLoggerImpl implements StackLogger {
private final static Logger logger = LoggerFactory.getLogger(StackLoggerImpl.class); /**
* 完全限定类名(Fully Qualified Class Name)用于定位日志位置
*/
private static final String FQCN = StackLoggerImpl.class.getName();
@Override /**
public void logStackTrace() { * 获取栈中类信息(以便底层日志记录系统能够提取正确的位置信息(方法名行号))
* @return LocationAwareLogger
*/
private static LocationAwareLogger getLocationAwareLogger() {
return (LocationAwareLogger) LoggerFactory.getLogger(new Throwable().getStackTrace()[4].getClassName());
}
}
@Override /**
public void logStackTrace(int traceLevel) { * 封装打印日志的位置信息
System.out.println("traceLevel: " + traceLevel); * @param level 日志级别
} * @param message 日志事件的消息
*/
private static void log(int level, String message) {
LocationAwareLogger locationAwareLogger = getLocationAwareLogger();
locationAwareLogger.log(null, FQCN, level, message, null, null);
}
@Override /**
public int getLineCount() { * 封装打印日志的位置信息
return 0; * @param level 日志级别
} * @param message 日志事件的消息
*/
private static void log(int level, String message, Throwable throwable) {
LocationAwareLogger locationAwareLogger = getLocationAwareLogger();
locationAwareLogger.log(null, FQCN, level, message, null, throwable);
}
@Override @Override
public void logException(Throwable ex) { public void logStackTrace() {
} }
@Override @Override
public void logDebug(String message) { public void logStackTrace(int traceLevel) {
// logger.debug(message); System.out.println("traceLevel: " + traceLevel);
} }
@Override @Override
public void logDebug(String message, Exception ex) { public int getLineCount() {
// logger.debug(message); return 0;
} }
@Override @Override
public void logTrace(String message) { public void logException(Throwable ex) {
logger.trace(message);
}
@Override }
public void logFatalError(String message) {
// logger.error(message);
}
@Override @Override
public void logError(String message) { public void logDebug(String message) {
// logger.error(message); log(LocationAwareLogger.INFO_INT, message);
} }
@Override @Override
public boolean isLoggingEnabled() { public void logDebug(String message, Exception ex) {
return true; log(LocationAwareLogger.INFO_INT, message, ex);
} }
@Override @Override
public boolean isLoggingEnabled(int logLevel) { public void logTrace(String message) {
return true; log(LocationAwareLogger.INFO_INT, message);
} }
@Override @Override
public void logError(String message, Exception ex) { public void logFatalError(String message) {
// logger.error(message); log(LocationAwareLogger.INFO_INT, message);
} }
@Override @Override
public void logWarning(String message) { public void logError(String message) {
logger.warn(message); log(LocationAwareLogger.INFO_INT, message);
} }
@Override @Override
public void logInfo(String message) { public boolean isLoggingEnabled() {
logger.info(message); return true;
} }
@Override @Override
public void disableLogging() { public boolean isLoggingEnabled(int logLevel) {
return true;
}
} @Override
public void logError(String message, Exception ex) {
log(LocationAwareLogger.INFO_INT, message, ex);
}
@Override @Override
public void enableLogging() { public void logWarning(String message) {
log(LocationAwareLogger.INFO_INT, message);
}
} @Override
public void logInfo(String message) {
log(LocationAwareLogger.INFO_INT, message);
}
@Override @Override
public void setBuildTimeStamp(String buildTimeStamp) { public void disableLogging() {
} }
@Override @Override
public void setStackProperties(Properties stackProperties) { public void enableLogging() {
} }
@Override @Override
public String getLoggerName() { public void setBuildTimeStamp(String buildTimeStamp) {
return null;
} }
@Override
public void setStackProperties(Properties stackProperties) {
}
@Override
public String getLoggerName() {
return null;
}
} }

View File

@ -1,55 +1,68 @@
package com.genersoft.iot.vmp.gb28181.event.alarm; package com.genersoft.iot.vmp.gb28181.event.alarm;
import org.springframework.context.ApplicationListener; import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* @description: 报警事件监听 * 报警事件监听器.
* @author: lawrencehj *
* @data: 2021-01-20 * @author lawrencehj
* @author <a href="mailto:xiaoQQya@126.com">xiaoQQya</a>
* @since 2021/01/20
*/ */
@Component @Component
public class AlarmEventListener implements ApplicationListener<AlarmEvent> { public class AlarmEventListener implements ApplicationListener<AlarmEvent> {
private final static Logger logger = LoggerFactory.getLogger(AlarmEventListener.class); private static final Logger logger = LoggerFactory.getLogger(AlarmEventListener.class);
private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); private static final Map<String, PrintWriter> SSE_CACHE = new ConcurrentHashMap<>();
public void addSseEmitters(String browserId, SseEmitter sseEmitter) { public void addSseEmitter(String browserId, PrintWriter writer) {
sseEmitters.put(browserId, sseEmitter); SSE_CACHE.put(browserId, writer);
logger.info("SSE 在线数量: {}", SSE_CACHE.size());
}
public void removeSseEmitter(String browserId, PrintWriter writer) {
SSE_CACHE.remove(browserId, writer);
logger.info("SSE 在线数量: {}", SSE_CACHE.size());
} }
@Override @Override
public void onApplicationEvent(AlarmEvent event) { public void onApplicationEvent(@NotNull AlarmEvent event) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("设备报警事件触发deviceId" + event.getAlarmInfo().getDeviceId() + ", " logger.debug("设备报警事件触发, deviceId: {}, {}", event.getAlarmInfo().getDeviceId(), event.getAlarmInfo().getAlarmDescription());
+ event.getAlarmInfo().getAlarmDescription());
} }
String msg = "<strong>设备编码:</strong> <i>" + event.getAlarmInfo().getDeviceId() + "</i>"
+ "<br><strong>报警描述:</strong> <i>" + event.getAlarmInfo().getAlarmDescription() + "</i>"
+ "<br><strong>报警时间:</strong> <i>" + event.getAlarmInfo().getAlarmTime() + "</i>"
+ "<br><strong>报警位置:</strong> <i>" + event.getAlarmInfo().getLongitude() + "</i>"
+ ", <i>" + event.getAlarmInfo().getLatitude() + "</i>";
for (Iterator<Map.Entry<String, SseEmitter>> it = sseEmitters.entrySet().iterator(); it.hasNext();) { String msg = "<strong>设备编号:</strong> <i>" + event.getAlarmInfo().getDeviceId() + "</i>"
Map.Entry<String, SseEmitter> emitter = it.next(); + "<br><strong>通道编号:</strong> <i>" + event.getAlarmInfo().getChannelId() + "</i>"
logger.info("推送到SSE连接浏览器ID: " + emitter.getKey()); + "<br><strong>报警描述:</strong> <i>" + event.getAlarmInfo().getAlarmDescription() + "</i>"
+ "<br><strong>报警时间:</strong> <i>" + event.getAlarmInfo().getAlarmTime() + "</i>";
for (Iterator<Map.Entry<String, PrintWriter>> it = SSE_CACHE.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, PrintWriter> response = it.next();
logger.info("推送到 SSE 连接, 浏览器 ID: {}", response.getKey());
try { try {
emitter.getValue().send(msg); PrintWriter writer = response.getValue();
} catch (IOException | IllegalStateException e) {
if (logger.isDebugEnabled()) { if (writer.checkError()) {
logger.debug("SSE连接已关闭"); it.remove();
continue;
} }
// 移除已关闭的连接
String sseMsg = "event:message\n" +
"data:" + msg + "\n" +
"\n";
writer.write(sseMsg);
writer.flush();
} catch (Exception e) {
it.remove(); it.remove();
} }
} }

View File

@ -117,8 +117,19 @@ public class VideoStreamSessionManager {
} }
public void remove(String deviceId, String channelId, String stream) { public void remove(String deviceId, String channelId, String stream) {
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); List<SsrcTransaction> ssrcTransactionList = getSsrcTransactionForAll(deviceId, channelId, null, stream);
if (ssrcTransaction == null) { if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) {
return;
}
for (SsrcTransaction ssrcTransaction : ssrcTransactionList) {
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
+ deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
}
}
public void removeByCallId(String deviceId, String channelId, String callId) {
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null);
if (ssrcTransaction == null ) {
return; return;
} }
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"

View File

@ -89,17 +89,17 @@ public class CatalogSubscribeTask implements ISubscribeTask {
ResponseEvent event = (ResponseEvent) eventResult.event; ResponseEvent event = (ResponseEvent) eventResult.event;
if (event.getResponse().getRawContent() != null) { if (event.getResponse().getRawContent() != null) {
// 成功 // 成功
logger.info("[取消目录订阅订阅]成功: {}", device.getDeviceId()); logger.info("[取消目录订阅]成功: {}", device.getDeviceId());
}else { }else {
// 成功 // 成功
logger.info("[取消目录订阅订阅]成功: {}", device.getDeviceId()); logger.info("[取消目录订阅]成功: {}", device.getDeviceId());
} }
},eventResult -> { },eventResult -> {
// 失败 // 失败
logger.warn("[取消目录订阅订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); logger.warn("[取消目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg);
}); });
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 取消目录订阅订阅: {}", e.getMessage()); logger.error("[命令发送失败] 取消目录订阅: {}", e.getMessage());
} }
} }
} }

View File

@ -164,6 +164,7 @@ public class SIPRequestHeaderProvider {
Request request = null; Request request = null;
//请求行 //请求行
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
// SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
// via // via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
@ -174,6 +175,7 @@ public class SIPRequestHeaderProvider {
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
//to //to
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress()); SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
// SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(),device.getHostAddress());
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());

View File

@ -40,6 +40,7 @@ import javax.sip.SipFactory;
import javax.sip.header.CallIdHeader; import javax.sip.header.CallIdHeader;
import javax.sip.message.Request; import javax.sip.message.Request;
import java.text.ParseException; import java.text.ParseException;
import java.util.List;
/** /**
* @description:设备能力接口用于定义设备的控制查询能力 * @description:设备能力接口用于定义设备的控制查询能力
@ -373,7 +374,8 @@ public class SIPCommander implements ISIPCommander {
}), e -> { }), e -> {
ResponseEvent responseEvent = (ResponseEvent) e.event; ResponseEvent responseEvent = (ResponseEvent) e.event;
SIPResponse response = (SIPResponse) responseEvent.getResponse(); SIPResponse response = (SIPResponse) responseEvent.getResponse();
streamSession.put(device.getDeviceId(), channelId, "play", stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, String callId = response.getCallIdHeader().getCallId();
streamSession.put(device.getDeviceId(), channelId, callId, stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response,
InviteSessionType.PLAY); InviteSessionType.PLAY);
okEvent.response(e); okEvent.response(e);
}); });
@ -612,17 +614,21 @@ public class SIPCommander implements ISIPCommander {
*/ */
@Override @Override
public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream); List<SsrcTransaction> ssrcTransactionList = streamSession.getSsrcTransactionForAll(device.getDeviceId(), channelId, callId, stream);
if (ssrcTransaction == null) { if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) {
logger.info("[发送BYE] 未找到事务信息,设备: device: {}, channel: {}", device.getDeviceId(), channelId);
throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream); throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream);
} }
mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); for (SsrcTransaction ssrcTransaction : ssrcTransactionList) {
mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); logger.info("[发送BYE] 设备: device: {}, channel: {}, callId: {}", device.getDeviceId(), channelId, ssrcTransaction.getCallId());
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); streamSession.removeByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getCallId());
Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
}
} }
/** /**

View File

@ -178,7 +178,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
if (mediaServerItem != null) { if (mediaServerItem != null) {
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
} }
streamSession.remove(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getStream()); streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId());
} }
} }
} }

View File

@ -132,7 +132,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
if (CmdType.CATALOG.equals(cmd)) { if (CmdType.CATALOG.equals(cmd)) {
logger.info("接收到Catalog通知"); logger.info("接收到Catalog通知");
processNotifyCatalogList(take.getEvt());
notifyRequestForCatalogProcessor.process(take.getEvt()); notifyRequestForCatalogProcessor.process(take.getEvt());
} else if (CmdType.ALARM.equals(cmd)) { } else if (CmdType.ALARM.equals(cmd)) {
logger.info("接收到Alarm通知"); logger.info("接收到Alarm通知");
@ -371,114 +370,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
} }
} }
/***
* 处理catalog设备目录列表Notify
*
* @param evt
*/
private void processNotifyCatalogList(RequestEvent evt) {
try {
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null || !device.isOnLine()) {
logger.warn("[收到目录订阅]{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" ));
return;
}
Element rootElement = getRootElement(evt, device.getCharset());
if (rootElement == null) {
logger.warn("[ 收到目录订阅 ] content cannot be null, {}", evt.getRequest());
return;
}
Element deviceListElement = rootElement.element("DeviceList");
if (deviceListElement == null) {
return;
}
Iterator<Element> deviceListIterator = deviceListElement.elementIterator();
if (deviceListIterator != null) {
// 遍历DeviceList
while (deviceListIterator.hasNext()) {
Element itemDevice = deviceListIterator.next();
Element channelDeviceElement = itemDevice.element("DeviceID");
if (channelDeviceElement == null) {
continue;
}
Element eventElement = itemDevice.element("Event");
String event;
if (eventElement == null) {
logger.warn("[收到目录订阅]{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" ));
event = CatalogEvent.ADD;
}else {
event = eventElement.getText().toUpperCase();
}
DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf);
if (channel == null) {
logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent()));
continue;
}
if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) {
channel.setParentId(null);
}
channel.setDeviceId(device.getDeviceId());
logger.info("[收到目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId());
switch (event) {
case CatalogEvent.ON:
// 上线
logger.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
storager.deviceChannelOnline(deviceId, channel.getChannelId());
break;
case CatalogEvent.OFF :
// 离线
logger.info("[收到通道离线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
storager.deviceChannelOffline(deviceId, channel.getChannelId());
}else {
logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
}
break;
case CatalogEvent.VLOST:
// 视频丢失
logger.info("[收到通道视频丢失通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
storager.deviceChannelOffline(deviceId, channel.getChannelId());
}else {
logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
}
break;
case CatalogEvent.DEFECT:
// 故障
break;
case CatalogEvent.ADD:
// 增加
logger.info("[收到增加通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
deviceChannelService.updateChannel(deviceId, channel);
break;
case CatalogEvent.DEL:
// 删除
logger.info("[收到删除通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
storager.delChannel(deviceId, channel.getChannelId());
break;
case CatalogEvent.UPDATE:
// 更新
logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
deviceChannelService.updateChannel(deviceId, channel);
break;
default:
logger.warn("[ NotifyCatalog ] event not found {}", event );
}
// 转发变化信息
eventPublisher.catalogEventPublish(null, channel, event);
}
}
} catch (DocumentException e) {
logger.error("未处理的异常 ", e);
}
}
public void setCmder(SIPCommander cmder) { public void setCmder(SIPCommander cmder) {
} }

View File

@ -61,7 +61,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
return; return;
} }
SIPRequest request = (SIPRequest) evt.getRequest(); SIPRequest request = (SIPRequest) evt.getRequest();
logger.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); logger.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
// 回复200 OK // 回复200 OK
try { try {
@ -80,6 +80,11 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setPort(remoteAddressInfo.getPort()); device.setPort(remoteAddressInfo.getPort());
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));
device.setIp(remoteAddressInfo.getIp()); device.setIp(remoteAddressInfo.getIp());
// 设备地址变化会引起目录订阅任务失效需要重新添加
if (device.getSubscribeCycleForCatalog() > 0) {
deviceService.removeCatalogSubscribe(device);
deviceService.addCatalogSubscribe(device);
}
} }
if (device.getKeepaliveTime() == null) { if (device.getKeepaliveTime() == null) {
device.setKeepaliveIntervalTime(60); device.setKeepaliveIntervalTime(60);

View File

@ -262,29 +262,40 @@ public class ZLMHttpHookListener {
} else { } else {
result.setEnable_mp4(userSetting.isRecordPushLive()); result.setEnable_mp4(userSetting.isRecordPushLive());
} }
// 替换流地址
if ("rtp".equals(param.getApp()) && !mediaInfo.isRtpEnable()) { // 国标流
String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));; if ("rtp".equals(param.getApp()) ) {
InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
if (inviteInfo != null) { InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream());
result.setStream_replace(inviteInfo.getStream());
logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream()); // 单端口模式下修改流 ID
} if (!mediaInfo.isRtpEnable() && inviteInfo == null) {
} String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));
List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, param.getStream()); inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { if (inviteInfo != null) {
String deviceId = ssrcTransactionForAll.get(0).getDeviceId(); result.setStream_replace(inviteInfo.getStream());
String channelId = ssrcTransactionForAll.get(0).getChannelId(); logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream());
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); }
if (deviceChannel != null) { }
result.setEnable_audio(deviceChannel.isHasAudio());
} // 设置音频信息及录制信息
// 如果是录像下载就设置视频间隔十秒 List<SsrcTransaction> ssrcTransactionForAll = (inviteInfo == null ? null :
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) { sessionManager.getSsrcTransactionForAll(inviteInfo.getDeviceId(), inviteInfo.getChannelId(), null, null));
result.setMp4_max_second(10); if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
result.setEnable_mp4(true); String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
String channelId = ssrcTransactionForAll.get(0).getChannelId();
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel != null) {
result.setEnable_audio(deviceChannel.isHasAudio());
}
// 如果是录像下载就设置视频间隔十秒
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
result.setMp4_max_second(10);
result.setEnable_mp4(true);
}
} }
} }
if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) { if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) {
logger.info("推流时发现尚未设置录像路径从assist服务中读取"); logger.info("推流时发现尚未设置录像路径从assist服务中读取");
JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null); JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null);
@ -524,11 +535,15 @@ public class ZLMHttpHookListener {
if (info != null) { if (info != null) {
cmder.streamByeCmd(device, inviteInfo.getChannelId(), cmder.streamByeCmd(device, inviteInfo.getChannelId(),
inviteInfo.getStream(), null); inviteInfo.getStream(), null);
}else {
logger.info("[无人观看] 未找到设备的点播信息: {} 流:{}", inviteInfo.getDeviceId(), param.getStream());
} }
} catch (InvalidArgumentException | ParseException | SipException | } catch (InvalidArgumentException | ParseException | SipException |
SsrcTransactionNotFoundException e) { SsrcTransactionNotFoundException e) {
logger.error("[无人观看]点播, 发送BYE失败 {}", e.getMessage()); logger.error("[无人观看]点播, 发送BYE失败 {}", e.getMessage());
} }
}else {
logger.info("[无人观看] 未找到设备: {},流:{}", inviteInfo.getDeviceId(), param.getStream());
} }
inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(),
@ -593,7 +608,7 @@ public class ZLMHttpHookListener {
String deviceId = s[0]; String deviceId = s[0];
String channelId = s[1]; String channelId = s[1];
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) { if (device == null || !device.isOnLine()) {
defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg())); defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg()));
return defaultResult; return defaultResult;
} }

View File

@ -215,6 +215,21 @@ public class ZLMRESTfulUtils {
} }
} }
public JSONObject isMediaOnline(MediaServerItem mediaServerItem, String app, String stream, String schema){
Map<String, Object> param = new HashMap<>();
if (app != null) {
param.put("app",app);
}
if (stream != null) {
param.put("stream",stream);
}
if (schema != null) {
param.put("schema",schema);
}
param.put("vhost","__defaultVhost__");
return sendPost(mediaServerItem, "isMediaOnline", param, null);
}
public JSONObject getMediaList(MediaServerItem mediaServerItem, String app, String stream, String schema, RequestCallback callback){ public JSONObject getMediaList(MediaServerItem mediaServerItem, String app, String stream, String schema, RequestCallback callback){
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
if (app != null) { if (app != null) {

View File

@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -120,17 +120,17 @@ public class OnStreamChangedHookParam extends HookParam{
/** /**
* H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4 * H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4
*/ */
private int codecId; private int codec_id;
/** /**
* 编码类型名称 CodecAAC CodecH264 * 编码类型名称 CodecAAC CodecH264
*/ */
private String codecIdName; private String codec_id_name;
/** /**
* Video = 0, Audio = 1 * Video = 0, Audio = 1
*/ */
private int codecType; private int codec_type;
/** /**
* 轨道是否准备就绪 * 轨道是否准备就绪
@ -140,17 +140,17 @@ public class OnStreamChangedHookParam extends HookParam{
/** /**
* 音频采样位数 * 音频采样位数
*/ */
private int sampleBit; private int sample_bit;
/** /**
* 音频采样率 * 音频采样率
*/ */
private int sampleRate; private int sample_rate;
/** /**
* 视频fps * 视频fps
*/ */
private int fps; private float fps;
/** /**
* 视频高 * 视频高
@ -162,6 +162,31 @@ public class OnStreamChangedHookParam extends HookParam{
*/ */
private int width; private int width;
/**
* 帧数
*/
private int frames;
/**
* 关键帧数
*/
private int key_frames;
/**
* GOP大小
*/
private int gop_size;
/**
* GOP间隔时长(ms)
*/
private int gop_interval_ms;
/**
* 丢帧率
*/
private float loss;
public int getChannels() { public int getChannels() {
return channels; return channels;
} }
@ -170,28 +195,28 @@ public class OnStreamChangedHookParam extends HookParam{
this.channels = channels; this.channels = channels;
} }
public int getCodecId() { public int getCodec_id() {
return codecId; return codec_id;
} }
public void setCodecId(int codecId) { public void setCodec_id(int codec_id) {
this.codecId = codecId; this.codec_id = codec_id;
} }
public String getCodecIdName() { public String getCodec_id_name() {
return codecIdName; return codec_id_name;
} }
public void setCodecIdName(String codecIdName) { public void setCodec_id_name(String codec_id_name) {
this.codecIdName = codecIdName; this.codec_id_name = codec_id_name;
} }
public int getCodecType() { public int getCodec_type() {
return codecType; return codec_type;
} }
public void setCodecType(int codecType) { public void setCodec_type(int codec_type) {
this.codecType = codecType; this.codec_type = codec_type;
} }
public boolean isReady() { public boolean isReady() {
@ -202,27 +227,27 @@ public class OnStreamChangedHookParam extends HookParam{
this.ready = ready; this.ready = ready;
} }
public int getSampleBit() { public int getSample_bit() {
return sampleBit; return sample_bit;
} }
public void setSampleBit(int sampleBit) { public void setSample_bit(int sample_bit) {
this.sampleBit = sampleBit; this.sample_bit = sample_bit;
} }
public int getSampleRate() { public int getSample_rate() {
return sampleRate; return sample_rate;
} }
public void setSampleRate(int sampleRate) { public void setSample_rate(int sample_rate) {
this.sampleRate = sampleRate; this.sample_rate = sample_rate;
} }
public int getFps() { public float getFps() {
return fps; return fps;
} }
public void setFps(int fps) { public void setFps(float fps) {
this.fps = fps; this.fps = fps;
} }
@ -241,6 +266,46 @@ public class OnStreamChangedHookParam extends HookParam{
public void setWidth(int width) { public void setWidth(int width) {
this.width = width; this.width = width;
} }
public int getFrames() {
return frames;
}
public void setFrames(int frames) {
this.frames = frames;
}
public int getKey_frames() {
return key_frames;
}
public void setKey_frames(int key_frames) {
this.key_frames = key_frames;
}
public int getGop_size() {
return gop_size;
}
public void setGop_size(int gop_size) {
this.gop_size = gop_size;
}
public int getGop_interval_ms() {
return gop_interval_ms;
}
public void setGop_interval_ms(int gop_interval_ms) {
this.gop_interval_ms = gop_interval_ms;
}
public float getLoss() {
return loss;
}
public void setLoss(float loss) {
this.loss = loss;
}
} }
public static class OriginSock{ public static class OriginSock{

View File

@ -243,6 +243,10 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override @Override
public void batchUpdateChannel(List<DeviceChannel> channels) { public void batchUpdateChannel(List<DeviceChannel> channels) {
String now = DateUtil.getNow();
for (DeviceChannel channel : channels) {
channel.setUpdateTime(now);
}
channelMapper.batchUpdate(channels); channelMapper.batchUpdate(channels);
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) { if (channel.getParentId() != null) {

View File

@ -216,8 +216,8 @@ public class DeviceServiceImpl implements IDeviceService {
if (ssrcTransactions != null && ssrcTransactions.size() > 0) { if (ssrcTransactions != null && ssrcTransactions.size() > 0) {
for (SsrcTransaction ssrcTransaction : ssrcTransactions) { for (SsrcTransaction ssrcTransaction : ssrcTransactions) {
mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
// mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
// streamSession.remove(deviceId, ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); streamSession.remove(deviceId, ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
} }
} }
// 移除订阅 // 移除订阅
@ -520,16 +520,18 @@ public class DeviceServiceImpl implements IDeviceService {
// 目录订阅相关的信息 // 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) { if (deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { if (device.getSubscribeCycleForCatalog() > 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); // 若已开启订阅但订阅周期不同则先取消
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
removeCatalogSubscribe(deviceInStore);
}
// 开启订阅 // 开启订阅
addCatalogSubscribe(deviceInStore);
}
}else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
addCatalogSubscribe(deviceInStore);
}else if (device.getSubscribeCycleForCatalog() == 0) {
// 取消订阅 // 取消订阅
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
removeCatalogSubscribe(deviceInStore); removeCatalogSubscribe(deviceInStore);
} }
} }
@ -544,6 +546,8 @@ public class DeviceServiceImpl implements IDeviceService {
} }
}else if (device.getSubscribeCycleForMobilePosition() == 0) { }else if (device.getSubscribeCycleForMobilePosition() == 0) {
if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) { if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
// 取消订阅 // 取消订阅
removeMobilePositionSubscribe(deviceInStore); removeMobilePositionSubscribe(deviceInStore);
} }
@ -564,7 +568,7 @@ public class DeviceServiceImpl implements IDeviceService {
deviceInStore.setSsrcCheck(device.isSsrcCheck()); deviceInStore.setSsrcCheck(device.isSsrcCheck());
//作为消息通道 //作为消息通道
deviceInStore.setAsMessageChannel(device.isAsMessageChannel()); deviceInStore.setAsMessageChannel(device.isAsMessageChannel());
// 更新redis // 更新redis
deviceMapper.updateCustom(deviceInStore); deviceMapper.updateCustom(deviceInStore);
redisCatchStorage.removeDevice(deviceInStore.getDeviceId()); redisCatchStorage.removeDevice(deviceInStore.getDeviceId());

View File

@ -257,7 +257,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
":" + inviteInfo.getDeviceId() + ":" + inviteInfo.getDeviceId() +
":" + inviteInfo.getChannelId() + ":" + inviteInfo.getChannelId() +
":" + inviteInfo.getStream() + ":" + inviteInfo.getStream() +
":" + inviteInfo.getSsrcInfo().getSsrc(); ":" + ssrc;
if (inviteInfoInDb.getSsrcInfo() != null) { if (inviteInfoInDb.getSsrcInfo() != null) {
inviteInfoInDb.getSsrcInfo().setSsrc(ssrc); inviteInfoInDb.getSsrcInfo().setSsrc(ssrc);
} }

View File

@ -166,14 +166,13 @@ public class MediaServerServiceImpl implements IMediaServerService {
if (streamId == null) { if (streamId == null) {
streamId = String.format("%08x", Long.parseLong(ssrc)).toUpperCase(); streamId = String.format("%08x", Long.parseLong(ssrc)).toUpperCase();
} }
int ssrcCheckParam = 0; if (ssrcCheck && tcpMode > 0) {
if (ssrcCheck && tcpMode > 1) {
// 目前zlm不支持 tcp模式更新ssrc暂时关闭ssrc校验 // 目前zlm不支持 tcp模式更新ssrc暂时关闭ssrc校验
logger.warn("[openRTPServer] TCP被动/TCP主动收流时默认关闭ssrc检"); logger.warn("[openRTPServer] 平台对接时下级可能自定义ssrc但是tcp模式zlm收流目前无法更新ssrc可能收流超时此时请使用udp收流或者关闭ssrc校");
} }
int rtpServerPort; int rtpServerPort;
if (mediaServerItem.isRtpEnable()) { if (mediaServerItem.isRtpEnable()) {
rtpServerPort = zlmServerFactory.createRTPServer(mediaServerItem, streamId, (ssrcCheck && tcpMode == 0) ? Long.parseLong(ssrc) : 0, port, reUsePort, tcpMode); rtpServerPort = zlmServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck ? Long.parseLong(ssrc) : 0, port, reUsePort, tcpMode);
} else { } else {
rtpServerPort = mediaServerItem.getRtpProxyPort(); rtpServerPort = mediaServerItem.getRtpProxyPort();
} }
@ -200,7 +199,10 @@ public class MediaServerServiceImpl implements IMediaServerService {
@Override @Override
public void closeRTPServer(String mediaServerId, String streamId) { public void closeRTPServer(String mediaServerId, String streamId) {
MediaServerItem mediaServerItem = this.getOne(mediaServerId); MediaServerItem mediaServerItem = this.getOne(mediaServerId);
closeRTPServer(mediaServerItem, streamId); if (mediaServerItem.isRtpEnable()) {
closeRTPServer(mediaServerItem, streamId);
}
zlmresTfulUtils.closeStreams(mediaServerItem, "rtp", streamId);
} }
@Override @Override
@ -572,7 +574,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
if (mediaServerItem.getRtspPort() != 0) { if (mediaServerItem.getRtspPort() != 0) {
param.put("ffmpeg.snap", "%s -rtsp_transport tcp -i %s -y -f mjpeg -t 0.001 %s"); param.put("ffmpeg.snap", "%s -rtsp_transport tcp -i %s -y -f mjpeg -frames:v 1 %s");
} }
param.put("hook.enable","1"); param.put("hook.enable","1");
param.put("hook.on_flow_report",""); param.put("hook.on_flow_report","");

View File

@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
return 0; return 0;
} }
if (ObjectUtils.isEmpty(catalogId)) { if (ObjectUtils.isEmpty(catalogId)) {
catalogId = platform.getDeviceGBId(); catalogId = null;
} }
if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {

View File

@ -238,6 +238,15 @@ public class PlayServiceImpl implements IPlayService {
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
subscribe.removeSubscribe(hookSubscribe); subscribe.removeSubscribe(hookSubscribe);
} }
}else {
logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流类型:{},端口:{}, SSRC: {}",
device.getDeviceId(), channelId, device.isSwitchPrimarySubStream() ? "辅码流" : "主码流",
ssrcInfo.getPort(), ssrcInfo.getSsrc());
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
mediaServerService.closeRTPServer(mediaServerItem.getId(), ssrcInfo.getStream());
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
} }
}, userSetting.getPlayTimeout()); }, userSetting.getPlayTimeout());
@ -268,6 +277,7 @@ public class PlayServiceImpl implements IPlayService {
InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId,
timeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAY); timeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAY);
}, (event) -> { }, (event) -> {
logger.info("[点播失败] deviceId: {}, channelId:{}, {}: {}", device.getDeviceId(), channelId, event.statusCode, event.msg);
dynamicTask.stop(timeOutTaskKey); dynamicTask.stop(timeOutTaskKey);
mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream());
// 释放ssrc // 释放ssrc
@ -309,7 +319,13 @@ public class PlayServiceImpl implements IPlayService {
if (!device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { if (!device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) {
return; return;
} }
String substring = contentString.substring(0, contentString.indexOf("y="));
String substring;
if (contentString.indexOf("y=") > 0) {
substring = contentString.substring(0, contentString.indexOf("y="));
}else {
substring = contentString;
}
try { try {
SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring);
int port = -1; int port = -1;
@ -399,7 +415,7 @@ public class PlayServiceImpl implements IPlayService {
deviceChannel.setStreamId(streamInfo.getStream()); deviceChannel.setStreamId(streamInfo.getStream());
storager.startPlay(deviceId, channelId, streamInfo.getStream()); storager.startPlay(deviceId, channelId, streamInfo.getStream());
} }
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAYBACK, deviceId, channelId); InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, ((OnStreamChangedHookParam) param).getStream());
if (inviteInfo != null) { if (inviteInfo != null) {
inviteInfo.setStatus(InviteSessionStatus.ok); inviteInfo.setStatus(InviteSessionStatus.ok);
@ -553,7 +569,6 @@ public class PlayServiceImpl implements IPlayService {
// 处理收到200ok后的TCP主动连接以及SSRC不一致的问题 // 处理收到200ok后的TCP主动连接以及SSRC不一致的问题
InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId,
playBackTimeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAYBACK); playBackTimeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAYBACK);
}, errorEvent); }, errorEvent);
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 录像回放: {}", e.getMessage()); logger.error("[命令发送失败] 录像回放: {}", e.getMessage());
@ -574,6 +589,10 @@ public class PlayServiceImpl implements IPlayService {
ResponseEvent responseEvent = (ResponseEvent) eventResult.event; ResponseEvent responseEvent = (ResponseEvent) eventResult.event;
String contentString = new String(responseEvent.getResponse().getRawContent()); String contentString = new String(responseEvent.getResponse().getRawContent());
String ssrcInResponse = SipUtils.getSsrcFromSdp(contentString); String ssrcInResponse = SipUtils.getSsrcFromSdp(contentString);
// 兼容回复的消息中缺少ssrc(y字段)的情况
if (ssrcInResponse == null) {
ssrcInResponse = ssrcInfo.getSsrc();
}
if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { if (ssrcInfo.getSsrc().equals(ssrcInResponse)) {
// ssrc 一致 // ssrc 一致
if (mediaServerItem.isRtpEnable()) { if (mediaServerItem.isRtpEnable()) {
@ -652,6 +671,7 @@ public class PlayServiceImpl implements IPlayService {
@Override @Override
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback) { public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback) {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);

View File

@ -35,15 +35,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 视频代理业务 * 视频代理业务
@ -403,6 +407,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"),
streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl()); streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl());
} }
} else if (streamProxy != null && streamProxy.isEnable()) {
return true ;
} }
return result; return result;
} }
@ -560,4 +566,43 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
return new ResourceBaseInfo(total, online); return new ResourceBaseInfo(total, online);
} }
@Scheduled(cron = "* 0/10 * * * ?")
public void asyncCheckStreamProxyStatus() {
List<MediaServerItem> all = mediaServerService.getAllOnline();
if (CollectionUtils.isEmpty(all)){
return;
}
Map<String, MediaServerItem> serverItemMap = all.stream().collect(Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1));
List<StreamProxyItem> list = videoManagerStorager.getStreamProxyListForEnable(true);
if (CollectionUtils.isEmpty(list)){
return;
}
for (StreamProxyItem streamProxyItem : list) {
MediaServerItem mediaServerItem = serverItemMap.get(streamProxyItem.getMediaServerId());
// TODO 支持其他 schema
JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), streamProxyItem.getStream(), "rtsp");
if (mediaInfo == null){
streamProxyItem.setStatus(false);
} else {
if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
streamProxyItem.setStatus(true);
} else {
streamProxyItem.setStatus(false);
}
}
updateStreamProxy(streamProxyItem);
}
}
} }

View File

@ -506,6 +506,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
stream.setUpdateTime(DateUtil.getNow()); stream.setUpdateTime(DateUtil.getNow());
stream.setCreateTime(DateUtil.getNow()); stream.setCreateTime(DateUtil.getNow());
stream.setServerId(userSetting.getServerId()); stream.setServerId(userSetting.getServerId());
stream.setMediaServerId(mediaConfig.getId());
stream.setSelf(true);
stream.setPushIng(true);
// 放在事务内执行 // 放在事务内执行
boolean result = false; boolean result = false;

View File

@ -31,8 +31,8 @@ public interface PlatformCatalogMapper {
@Update(value = {" <script>" + @Update(value = {" <script>" +
"UPDATE wvp_platform_catalog " + "UPDATE wvp_platform_catalog " +
"SET name=#{name}" + "SET name=#{platformCatalog.name}" +
"WHERE id=#{id} and platform_id=#{platformId}"+ "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
"</script>"}) "</script>"})
int update(@Param("platformCatalog") PlatformCatalog platformCatalog); int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
@ -51,4 +51,16 @@ public interface PlatformCatalogMapper {
" from wvp_platform_catalog pc " + " from wvp_platform_catalog pc " +
" WHERE pc.id=#{id} and pc.platform_id=#{platformId}") " WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id); PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
@Delete("<script> "+
"DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
"<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach>" +
"</script>")
int deleteAll(String platformId, List<String> ids);
@Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
} }

View File

@ -105,7 +105,8 @@ public interface PlatformChannelMapper {
void delByPlatformId(String serverGBId); void delByPlatformId(String serverGBId);
@Delete("<script> " + @Delete("<script> " +
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" + "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
" <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
"</script>") "</script>")
int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@ -116,6 +117,6 @@ public interface PlatformChannelMapper {
"where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}") "where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
List<Device> queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId); List<Device> queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
@Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id='${channelId}'") @Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId}")
List<String> queryParentPlatformByChannelId(String channelId); List<String> queryParentPlatformByChannelId(@Param("channelId") String channelId);
} }

View File

@ -73,6 +73,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Autowired @Autowired
private PlatformChannelMapper platformChannelMapper; private PlatformChannelMapper platformChannelMapper;
@Autowired
private PlatformCatalogMapper platformCatalogMapper;
@Autowired @Autowired
private StreamProxyMapper streamProxyMapper; private StreamProxyMapper streamProxyMapper;
@ -126,6 +129,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
List<DeviceChannel> updateChannels = new ArrayList<>(); List<DeviceChannel> updateChannels = new ArrayList<>();
List<DeviceChannel> addChannels = new ArrayList<>(); List<DeviceChannel> addChannels = new ArrayList<>();
List<DeviceChannel> deleteChannels = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
Map<String, Integer> subContMap = new HashMap<>(); Map<String, Integer> subContMap = new HashMap<>();
@ -156,6 +160,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
deviceChannel.setUpdateTime(DateUtil.getNow()); deviceChannel.setUpdateTime(DateUtil.getNow());
addChannels.add(deviceChannel); addChannels.add(deviceChannel);
} }
allChannelMap.remove(deviceChannel.getChannelId());
channels.add(deviceChannel); channels.add(deviceChannel);
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) { if (subContMap.get(deviceChannel.getParentId()) == null) {
@ -166,7 +171,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
} }
} }
if (channels.size() > 0) { deleteChannels.addAll(allChannelMap.values());
if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){ if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId()); Integer count = subContMap.get(channel.getChannelId());
@ -187,20 +193,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
try { try {
int limitCount = 50; int limitCount = 50;
int cleanChannelsResult = 0; boolean result = false;
if (channels.size() > limitCount) { if (!result && !addChannels.isEmpty()) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
cleanChannelsResult += this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels.subList(i, toIndex));
}
} else {
cleanChannelsResult = this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
}
boolean result = cleanChannelsResult < 0;
if (!result && addChannels.size() > 0) {
if (addChannels.size() > limitCount) { if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) { for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount; int toIndex = i + limitCount;
@ -213,7 +207,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
result = result || deviceChannelMapper.batchAdd(addChannels) < 0; result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
} }
} }
if (!result && updateChannels.size() > 0) { if (!result && !updateChannels.isEmpty()) {
if (updateChannels.size() > limitCount) { if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) { for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount; int toIndex = i + limitCount;
@ -226,6 +220,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
} }
} }
if (!result && !deleteChannels.isEmpty()) {
System.out.println("删除: " + deleteChannels.size());
if (deleteChannels.size() > limitCount) {
for (int i = 0; i < deleteChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > deleteChannels.size()) {
toIndex = deleteChannels.size();
}
result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchDel(deleteChannels) < 0;
}
}
if (result) { if (result) {
//事务回滚 //事务回滚
@ -910,9 +918,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
} }
int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
// 查看是否存在子目录如果存在一并删除
List<String> allChildCatalog = getAllChildCatalog(id, platformId);
if (!allChildCatalog.isEmpty()) {
int limitCount = 50;
if (allChildCatalog.size() > limitCount) {
for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > allChildCatalog.size()) {
toIndex = allChildCatalog.size();
}
delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
}
}else {
delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
}
}
return delresult + delChannelresult + delStreamresult; return delresult + delChannelresult + delStreamresult;
} }
private List<String> getAllChildCatalog(String id, String platformId) {
List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
List<String> catalogListChild = new ArrayList<>();
if (catalogList != null && !catalogList.isEmpty()) {
for (String childId : catalogList) {
List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
catalogListChild.addAll(allChildCatalog);
}
}
}
if (!catalogListChild.isEmpty()) {
catalogList.addAll(catalogListChild);
}
return catalogList;
}
@Override @Override
public int updateCatalog(PlatformCatalog platformCatalog) { public int updateCatalog(PlatformCatalog platformCatalog) {

View File

@ -1,37 +0,0 @@
package com.genersoft.iot.vmp.vmanager.gb28181.SseController;
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
* @description: SSE推送
* @author: lawrencehj
* @data: 2021-01-20
*/
@Tag(name = "SSE推送")
@Controller
@RequestMapping("/api")
public class SseController {
@Autowired
AlarmEventListener alarmEventListener;
@GetMapping("/emit")
public SseEmitter emit(@RequestParam String browserId) {
final SseEmitter sseEmitter = new SseEmitter(0L);
try {
alarmEventListener.addSseEmitters(browserId, sseEmitter);
}catch (Exception e){
sseEmitter.completeWithError(e);
}
return sseEmitter;
}
}

View File

@ -0,0 +1,55 @@
package com.genersoft.iot.vmp.vmanager.gb28181.sse;
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
/**
* SSE 推送.
*
* @author lawrencehj
* @author <a href="mailto:xiaoQQya@126.com">xiaoQQya</a>
* @since 2021/01/20
*/
@Tag(name = "SSE 推送")
@RestController
@RequestMapping("/api")
public class SseController {
@Resource
private AlarmEventListener alarmEventListener;
/**
* SSE 推送.
*
* @param response 响应
* @param browserId 浏览器ID
* @throws IOException IOEXCEPTION
* @author <a href="mailto:xiaoQQya@126.com">xiaoQQya</a>
* @since 2023/11/06
*/
@GetMapping("/emit")
public void emit(HttpServletResponse response, @RequestParam String browserId) throws IOException, InterruptedException {
response.setContentType("text/event-stream");
response.setCharacterEncoding("utf-8");
PrintWriter writer = response.getWriter();
alarmEventListener.addSseEmitter(browserId, writer);
while (!writer.checkError()) {
Thread.sleep(1000);
writer.write(":keep alive\n\n");
writer.flush();
}
alarmEventListener.removeSseEmitter(browserId, writer);
}
}

View File

@ -150,9 +150,9 @@ media:
# 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用
record-assist-port: 0 record-assist-port: 0
# [可选] 日志配置, 一般不需要改 # [可选] 日志配置, 如果不需要在jar外修改日志内容那么可以不配置此项
logging: logging:
config: classpath:logback-spring-local.xml config: classpath:logback-spring.xml
# [根据业务需求配置] # [根据业务需求配置]
user-settings: user-settings:

View File

@ -26,7 +26,7 @@ spring:
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test_gb-89wulian?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true
username: root username: root
password: root password: root
hikari: hikari:

View File

@ -71,10 +71,6 @@ media:
record-assist-port: 18081 record-assist-port: 18081
sdp-ip: ${sip.ip} sdp-ip: ${sip.ip}
stream-ip: ${sip.ip} stream-ip: ${sip.ip}
# [可选] 日志配置, 一般不需要改
# [可选] 日志配置, 一般不需要改
logging:
config: classpath:logback-spring-local.xml
# [根据业务需求配置] # [根据业务需求配置]
user-settings: user-settings:

View File

@ -4,8 +4,8 @@
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/> <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
<property name="LOG_HOME" value="logs" /> <property name="LOG_HOME" value="logs" />
<substitutionProperty name="log.pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr(%-1.30logger{0}){cyan} %clr(:){faint} %m%n%wEx"/> <substitutionProperty name="log.pattern"
value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr([%thread]) %clr(%5p) %clr(---){faint} %clr(%logger{50}){cyan}%clr(:) %clr(%L){cyan} %m%n%wEx"/>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>

View File

@ -1,6 +1,6 @@
<template> <template>
<div ref="container" @dblclick="fullscreenSwich" <div ref="container" @dblclick="fullscreenSwich"
style="width:100%;height:100%;background-color: #000000;margin:0 auto;"> style="width:100%;height:100%;background-color: #000000;margin:0 auto;position: relative;">
<div class="buttons-box" id="buttonsBox"> <div class="buttons-box" id="buttonsBox">
<div class="buttons-box-left"> <div class="buttons-box-left">
<i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
@ -47,10 +47,6 @@ export default {
}, },
props: ['videoUrl', 'error', 'hasAudio', 'height'], props: ['videoUrl', 'error', 'hasAudio', 'height'],
mounted() { mounted() {
window.onerror = (msg) => {
// console.error(msg)
};
console.log(this._uid)
let paramUrl = decodeURIComponent(this.$route.params.url) let paramUrl = decodeURIComponent(this.$route.params.url)
this.$nextTick(() => { this.$nextTick(() => {
this.updatePlayerDomSize() this.updatePlayerDomSize()
@ -61,15 +57,17 @@ export default {
this.videoUrl = paramUrl; this.videoUrl = paramUrl;
} }
this.btnDom = document.getElementById("buttonsBox"); this.btnDom = document.getElementById("buttonsBox");
console.log("初始化时的地址为: " + this.videoUrl)
this.play(this.videoUrl)
}) })
}, },
watch: { watch: {
videoUrl(newData, oldData) { videoUrl: {
this.play(newData) handler(val, _) {
}, this.$nextTick(() => {
immediate: true this.play(val);
})
},
immediate: true
}
}, },
methods: { methods: {
updatePlayerDomSize() { updatePlayerDomSize() {
@ -87,70 +85,54 @@ export default {
dom.style.height = height + "px"; dom.style.height = height + "px";
}, },
create() { create() {
let options = {}; let options = {
console.log("hasAudio " + this.hasAudio) container: this.$refs.container,
autoWasm: true,
jessibucaPlayer[this._uid] = new window.Jessibuca(Object.assign( background: "",
{ controlAutoHide: false,
container: this.$refs.container, debug: false,
autoWasm: true, decoder: "static/js/jessibuca/decoder.js",
background: "", forceNoOffscreen: false,
controlAutoHide: false, hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio,
debug: false, heartTimeout: 5,
decoder: "static/js/jessibuca/decoder.js", heartTimeoutReplay: true,
forceNoOffscreen: true, heartTimeoutReplayTimes: 3,
hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio, hiddenAutoPause: false,
hasVideo: true, hotKey: true,
heartTimeout: 5, isFlv: false,
heartTimeoutReplay: true, isFullResize: false,
heartTimeoutReplayTimes: 3, isNotMute: this.isNotMute,
hiddenAutoPause: false, isResize: false,
hotKey: false, keepScreenOn: true,
isFlv: false, loadingText: "请稍等, 视频加载中......",
isFullResize: false, loadingTimeout: 10,
isNotMute: this.isNotMute, loadingTimeoutReplay: true,
isResize: false, loadingTimeoutReplayTimes: 3,
keepScreenOn: false, openWebglAlignment: false,
loadingText: "请稍等, 视频加载中......", operateBtns: {
loadingTimeout: 10, fullscreen: false,
loadingTimeoutReplay: true, screenshot: false,
loadingTimeoutReplayTimes: 3, play: false,
openWebglAlignment: false, audio: false,
operateBtns: { record: false
fullscreen: false,
screenshot: false,
play: false,
audio: false,
record: false
},
recordType: "webm",
rotate: 0,
showBandwidth: false,
supportDblclickFullscreen: false,
timeout: 10,
useMSE: location.hostname !== "localhost" && location.protocol !== "https:",
useOffscreen: false,
useWCS: location.hostname === "localhost" || location.protocol === "https",
useWebFullScreen: false,
videoBuffer: 0,
wasmDecodeAudioSyncVideo: true,
wasmDecodeErrorReplay: true,
wcsUseVideoRender: true
}, },
options recordType: "mp4",
)); rotate: 0,
showBandwidth: false,
supportDblclickFullscreen: false,
timeout: 10,
useMSE: true,
useWCS: location.hostname === "localhost" || location.protocol === "https:",
useWebFullScreen: true,
videoBuffer: 0.1,
wasmDecodeErrorReplay: true,
wcsUseVideoRender: true
};
console.log("Jessibuca -> options: ", options);
jessibucaPlayer[this._uid] = new window.Jessibuca({...options});
let jessibuca = jessibucaPlayer[this._uid]; let jessibuca = jessibucaPlayer[this._uid];
let _this = this; let _this = this;
jessibuca.on("load", function () {
console.log("on load init");
});
jessibuca.on("log", function (msg) {
console.log("on log", msg);
});
jessibuca.on("record", function (msg) {
console.log("on record:", msg);
});
jessibuca.on("pause", function () { jessibuca.on("pause", function () {
_this.playing = false; _this.playing = false;
}); });
@ -158,44 +140,11 @@ export default {
_this.playing = true; _this.playing = true;
}); });
jessibuca.on("fullscreen", function (msg) { jessibuca.on("fullscreen", function (msg) {
console.log("on fullscreen", msg);
_this.fullscreen = msg _this.fullscreen = msg
}); });
jessibuca.on("mute", function (msg) { jessibuca.on("mute", function (msg) {
console.log("on mute", msg);
_this.isNotMute = !msg; _this.isNotMute = !msg;
}); });
jessibuca.on("audioInfo", function (msg) {
console.log("audioInfo", msg);
});
jessibuca.on("bps", function (bps) {
// console.log('bps', bps);
});
let _ts = 0;
jessibuca.on("timeUpdate", function (ts) {
// console.log('timeUpdate,old,new,timestamp', _ts, ts, ts - _ts);
_ts = ts;
});
jessibuca.on("videoInfo", function (info) {
console.log("videoInfo", info);
});
jessibuca.on("error", function (error) {
console.log("error", error);
});
jessibuca.on("timeout", function () {
console.log("timeout");
});
jessibuca.on('start', function () {
console.log('start');
})
jessibuca.on("performance", function (performance) { jessibuca.on("performance", function (performance) {
let show = "卡顿"; let show = "卡顿";
if (performance === 2) { if (performance === 2) {
@ -205,33 +154,36 @@ export default {
} }
_this.performance = show; _this.performance = show;
}); });
jessibuca.on('buffer', function (buffer) {
// console.log('buffer', buffer);
})
jessibuca.on('stats', function (stats) {
// console.log('stats', stats);
})
jessibuca.on('kBps', function (kBps) { jessibuca.on('kBps', function (kBps) {
_this.kBps = Math.round(kBps); _this.kBps = Math.round(kBps);
}); });
jessibuca.on("videoInfo", function (msg) {
// PTS console.log("Jessibuca -> videoInfo: ", msg);
jessibuca.on('videoFrame', function () { });
jessibuca.on("audioInfo", function (msg) {
}) console.log("Jessibuca -> audioInfo: ", msg);
});
// jessibuca.on("error", function (msg) {
jessibuca.on('metadata', function () { console.log("Jessibuca -> error: ", msg);
});
jessibuca.on("timeout", function (msg) {
console.log("Jessibuca -> timeout: ", msg);
});
jessibuca.on("loadingTimeout", function (msg) {
console.log("Jessibuca -> timeout: ", msg);
});
jessibuca.on("delayTimeout", function (msg) {
console.log("Jessibuca -> timeout: ", msg);
});
jessibuca.on("playToRenderTimes", function (msg) {
console.log("Jessibuca -> playToRenderTimes: ", msg);
}); });
}, },
playBtnClick: function (event) { playBtnClick: function (event) {
this.play(this.videoUrl) this.play(this.videoUrl)
}, },
play: function (url) { play: function (url) {
console.log(url) console.log("Jessibuca -> url: ", url);
if (jessibucaPlayer[this._uid]) { if (jessibucaPlayer[this._uid]) {
this.destroy(); this.destroy();
} }
@ -245,7 +197,6 @@ export default {
jessibucaPlayer[this._uid].play(url); jessibucaPlayer[this._uid].play(url);
} else { } else {
jessibucaPlayer[this._uid].on("load", () => { jessibucaPlayer[this._uid].on("load", () => {
console.log("load 播放")
jessibucaPlayer[this._uid].play(url); jessibucaPlayer[this._uid].play(url);
}); });
} }
@ -286,11 +237,6 @@ export default {
this.performance = ""; this.performance = "";
}, },
eventcallbacK: function (type, message) {
// console.log("player ")
// console.log(type)
// console.log(message)
},
fullscreenSwich: function () { fullscreenSwich: function () {
let isFull = this.isFullscreen() let isFull = this.isFullscreen()
jessibucaPlayer[this._uid].setFullscreen(!isFull) jessibucaPlayer[this._uid].setFullscreen(!isFull)

View File

@ -1,7 +1,7 @@
<template> <template>
<div id="devicePlayer" v-loading="isLoging"> <div id="devicePlayer" v-loading="isLoging">
<el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()"> <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()" v-if="showVideoDialog">
<div style="width: 100%; height: 100%"> <div style="width: 100%; height: 100%">
<el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1"> <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1">
<!-- <el-tab-pane label="LivePlayer" name="livePlayer">--> <!-- <el-tab-pane label="LivePlayer" name="livePlayer">-->

View File

@ -37,7 +37,6 @@
</template> </template>
<script> <script>
import changePasswordDialog from '../components/dialog/changePassword.vue' import changePasswordDialog from '../components/dialog/changePassword.vue'
import userService from '../components/service/UserService' import userService from '../components/service/UserService'
import {Notification} from 'element-ui'; import {Notification} from 'element-ui';
@ -55,18 +54,19 @@ export default {
}; };
}, },
created() { created() {
console.log(4444)
console.log(JSON.stringify(userService.getUser())) console.log(JSON.stringify(userService.getUser()))
if (this.$route.path.startsWith("/channelList")) { if (this.$route.path.startsWith("/channelList")) {
this.activeIndex = "/deviceList" this.activeIndex = "/deviceList"
} }
}, },
mounted() { mounted() {
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e)) window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
// window.addEventListener('unload', e => this.unloadHandler(e))
this.alarmNotify = this.getAlarmSwitchStatus() === "true"; this.alarmNotify = this.getAlarmSwitchStatus() === "true";
this.sseControl();
// TODO: sse, sse browserId ,
setTimeout(() => {
this.sseControl()
}, 3000);
}, },
methods: { methods: {
loginout() { loginout() {
@ -107,10 +107,12 @@ export default {
this.sseSource = new EventSource('/api/emit?browserId=' + this.$browserId); this.sseSource = new EventSource('/api/emit?browserId=' + this.$browserId);
this.sseSource.addEventListener('message', function (evt) { this.sseSource.addEventListener('message', function (evt) {
that.$notify({ that.$notify({
title: '收到报警信息', title: '报警信息',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
message: evt.data, message: evt.data,
type: 'warning' type: 'warning',
position: 'bottom-right',
duration: 3000
}); });
console.log("收到信息:" + evt.data); console.log("收到信息:" + evt.data);
}); });

View File

@ -1,22 +1,20 @@
import Vue from 'vue'; import Vue from 'vue';
import App from './App.vue'; import App from './App.vue';
import ElementUI, {Notification} from 'element-ui';
Vue.config.productionTip = false;
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; import 'element-ui/lib/theme-chalk/index.css';
import router from './router/index.js'; import router from './router/index.js';
import axios from 'axios'; import axios from 'axios';
import VueCookies from 'vue-cookies'; import VueCookies from 'vue-cookies';
import echarts from 'echarts';
import VCharts from 'v-charts'; import VCharts from 'v-charts';
import VueClipboard from 'vue-clipboard2'; import VueClipboard from 'vue-clipboard2';
import {Notification} from 'element-ui';
import Fingerprint2 from 'fingerprintjs2'; import Fingerprint2 from 'fingerprintjs2';
import VueClipboards from 'vue-clipboards'; import VueClipboards from 'vue-clipboards';
import Contextmenu from "vue-contextmenujs" import Contextmenu from "vue-contextmenujs"
import userService from "./components/service/UserService" import userService from "./components/service/UserService"
Vue.config.productionTip = false;
// 生成唯一ID // 生成唯一ID
Fingerprint2.get(function (components) { Fingerprint2.get(function (components) {
@ -29,10 +27,9 @@ Fingerprint2.get(function (components) {
//console.log(values) //使用的浏览器信息npm //console.log(values) //使用的浏览器信息npm
// 生成最终id // 生成最终id
let port = window.location.port; let port = window.location.port;
console.log(port);
const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31) const fingerPrint = Fingerprint2.x64hash128(values.join(port), 31)
Vue.prototype.$browserId = fingerPrint; Vue.prototype.$browserId = fingerPrint;
console.log("唯一标识码:" + fingerPrint); console.log("浏览器 ID: " + fingerPrint);
}); });
Vue.use(VueClipboard); Vue.use(VueClipboard);
@ -75,7 +72,7 @@ axios.interceptors.request.use(
); );
Vue.prototype.$axios = axios; Vue.prototype.$axios = axios;
Vue.prototype.$cookies.config(60*30); Vue.prototype.$cookies.config(60 * 30);
new Vue({ new Vue({
router: router, router: router,

View File

@ -561,9 +561,9 @@ declare class Jessibuca {
buf: number; buf: number;
/** 当前视频帧率 */ /** 当前视频帧率 */
fps: number; fps: number;
/** 当前音频码率单位bit */ /** 当前音频码率单位byte */
abps: number; abps: number;
/** 当前视频码率单位bit */ /** 当前视频码率单位byte */
vbps: number; vbps: number;
/** 当前视频帧pts单位毫秒 */ /** 当前视频帧pts单位毫秒 */
ts: number; ts: number;

File diff suppressed because one or more lines are too long