[*]
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>taoyao-boot</name>
|
||||
<description>启动模块:启动模块</description>
|
||||
<description>启动模块:基础模块</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.acgist.taoyao.boot.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 终端
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
@Documented
|
||||
public @interface Client {
|
||||
|
||||
}
|
||||
@@ -50,6 +50,7 @@ import com.acgist.taoyao.boot.controller.TaoyaoErrorController;
|
||||
import com.acgist.taoyao.boot.model.MessageCode;
|
||||
import com.acgist.taoyao.boot.property.IdProperties;
|
||||
import com.acgist.taoyao.boot.property.MediaProperties;
|
||||
import com.acgist.taoyao.boot.property.ScriptProperties;
|
||||
import com.acgist.taoyao.boot.property.SecurityProperties;
|
||||
import com.acgist.taoyao.boot.property.TaoyaoProperties;
|
||||
import com.acgist.taoyao.boot.property.WebrtcProperties;
|
||||
@@ -77,7 +78,14 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
@EnableAspectJAutoProxy(exposeProxy = false)
|
||||
@EnableConfigurationProperties({ IdProperties.class, MediaProperties.class, TaoyaoProperties.class, WebrtcProperties.class, SecurityProperties.class })
|
||||
@EnableConfigurationProperties({
|
||||
IdProperties.class,
|
||||
MediaProperties.class,
|
||||
ScriptProperties.class,
|
||||
TaoyaoProperties.class,
|
||||
WebrtcProperties.class,
|
||||
SecurityProperties.class
|
||||
})
|
||||
public class BootAutoConfiguration {
|
||||
|
||||
@Value("${spring.application.name:taoyao}")
|
||||
@@ -195,6 +203,7 @@ public class BootAutoConfiguration {
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
log.info("系统关闭:{}", this.name);
|
||||
// TODO:通知关闭
|
||||
// 刷出日志缓存
|
||||
final ILoggerFactory factory = LoggerFactory.getILoggerFactory();
|
||||
if (factory instanceof LoggerContext context) {
|
||||
|
||||
@@ -43,6 +43,6 @@ public class Header implements Serializable {
|
||||
* 协议标识
|
||||
*/
|
||||
@Schema(title = "协议标识", description = "协议标识")
|
||||
private Integer pid;
|
||||
private String signal;
|
||||
|
||||
}
|
||||
|
||||
@@ -47,5 +47,10 @@ public class MediaProperties {
|
||||
*/
|
||||
@Schema(title = "流畅视频", description = "流畅视频")
|
||||
private MediaVideoProperties flowVideo;
|
||||
/**
|
||||
* 录像存放路径
|
||||
*/
|
||||
@Schema(title = "录像存放路径", description = "录像存放路径")
|
||||
private String recordStoragePath;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Mediasoup配置
|
||||
* 媒体终端配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@@ -16,6 +16,11 @@ import lombok.Setter;
|
||||
@Schema(title = "Mediasoup配置", description = "Mediasoup配置")
|
||||
public class MediasoupProperties {
|
||||
|
||||
/**
|
||||
* Mediasoup名称
|
||||
*/
|
||||
@Schema(title = "Mediasoup名称", description = "Mediasoup名称")
|
||||
private String name;
|
||||
/**
|
||||
* Mediasoup主机
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.acgist.taoyao.boot.property;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 脚本配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "taoyao.script")
|
||||
public class ScriptProperties {
|
||||
|
||||
/**
|
||||
* 系统类型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum SystemType {
|
||||
|
||||
/**
|
||||
* Mac
|
||||
*/
|
||||
MAC("Mac OS", "Mac OS X"),
|
||||
/**
|
||||
* Linux
|
||||
*/
|
||||
LINUX("Linux"),
|
||||
/**
|
||||
* Windows
|
||||
*/
|
||||
WINDOWS("Windows XP", "Windows Vista", "Windows 7", "Windows 10", "Windows 11"),
|
||||
/**
|
||||
* Android
|
||||
*/
|
||||
ANDROID("Android");
|
||||
|
||||
/**
|
||||
* 系统名称
|
||||
*/
|
||||
private final String[] osNames;
|
||||
|
||||
/**
|
||||
* @param osNames 系统名称
|
||||
*/
|
||||
private SystemType(String ... osNames) {
|
||||
this.osNames = osNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param osName 系统名称
|
||||
*
|
||||
* @return 系统类型
|
||||
*/
|
||||
private static final SystemType of(String osName) {
|
||||
final SystemType[] values = SystemType.values();
|
||||
for (SystemType value : values) {
|
||||
if(ArrayUtils.contains(value.osNames, osName)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return SystemType.LINUX;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Linux脚本
|
||||
*/
|
||||
private Map<String, String> linux;
|
||||
/**
|
||||
* Windows脚本
|
||||
*/
|
||||
private Map<String, String> windows;
|
||||
/**
|
||||
* 重启媒体服务
|
||||
*/
|
||||
private String mediaReboot;
|
||||
/**
|
||||
* 关闭媒体服务
|
||||
*/
|
||||
private String mediaShutdown;
|
||||
/**
|
||||
* 重启系统
|
||||
*/
|
||||
private String systemReboot;
|
||||
/**
|
||||
* 关闭系统
|
||||
*/
|
||||
private String systemShutdown;
|
||||
/**
|
||||
* 重启平台
|
||||
*/
|
||||
private String platformReboot;
|
||||
/**
|
||||
* 关闭平台
|
||||
*/
|
||||
private String platformShutdown;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
final String osName = System.getProperty("os.name");
|
||||
final SystemType type = SystemType.of(osName);
|
||||
switch (type) {
|
||||
case LINUX -> this.set(this.linux);
|
||||
case WINDOWS -> this.set(this.windows);
|
||||
default -> log.error("没有配置系统脚本:{}", type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置脚本
|
||||
*
|
||||
* @param map 脚本
|
||||
*/
|
||||
private void set(Map<String, String> map) {
|
||||
this.mediaReboot = map.get("media-reboot");
|
||||
this.mediaShutdown = map.get("media-shutdown");
|
||||
this.systemReboot = map.get("system-reboot");
|
||||
this.systemShutdown = map.get("system-shutdown");
|
||||
this.platformReboot = map.get("platform-reboot");
|
||||
this.platformShutdown = map.get("platform-shutdown");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.acgist.taoyao.boot.property;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 信令配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(title = "信令配置", description = "信令配置")
|
||||
public class SignalProperties {
|
||||
|
||||
/**
|
||||
* 信令主机
|
||||
*/
|
||||
@Schema(title = "信令主机", description = "信令主机")
|
||||
private String host;
|
||||
/**
|
||||
* 信令端口
|
||||
*/
|
||||
@Schema(title = "信令端口", description = "信令端口")
|
||||
private Integer port;
|
||||
/**
|
||||
* 信令协议
|
||||
*/
|
||||
@Schema(title = "信令协议", description = "信令协议")
|
||||
private String schema;
|
||||
/**
|
||||
* 信令地址
|
||||
*/
|
||||
@Schema(title = "信令地址", description = "信令地址")
|
||||
private String websocket;
|
||||
|
||||
/**
|
||||
* @return 完整信令地址
|
||||
*/
|
||||
@Schema(title = "完整信令地址", description = "完整信令地址")
|
||||
public String getAddress() {
|
||||
return this.schema + "://" + this.host + ":" + this.port + this.websocket;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,11 +26,22 @@ public class TaoyaoProperties {
|
||||
*/
|
||||
@Schema(title = "项目名称", description = "项目名称")
|
||||
private String name;
|
||||
/**
|
||||
* 服务节点ID
|
||||
* 集群使用
|
||||
*/
|
||||
@Schema(title = "服务节点ID", description = "服务节点ID")
|
||||
private String nodeId;
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
@Schema(title = "超时时间", description = "超时时间")
|
||||
private Long timeout;
|
||||
/**
|
||||
* 最大超时时间
|
||||
*/
|
||||
@Schema(title = "最大超时时间", description = "最大超时时间")
|
||||
private Long maxTimeout;
|
||||
/**
|
||||
* 项目版本
|
||||
*/
|
||||
@@ -41,11 +52,5 @@ public class TaoyaoProperties {
|
||||
*/
|
||||
@Schema(title = "项目描述", description = "项目描述")
|
||||
private String description;
|
||||
/**
|
||||
* 服务节点ID
|
||||
* 集群使用
|
||||
*/
|
||||
@Schema(title = "服务节点ID", description = "服务节点ID")
|
||||
private String serverId;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,29 +19,6 @@ import lombok.Setter;
|
||||
@ConfigurationProperties(prefix = "taoyao.webrtc")
|
||||
public class WebrtcProperties {
|
||||
|
||||
/**
|
||||
* 架构模型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum Framework {
|
||||
|
||||
/**
|
||||
* MESH架构
|
||||
*/
|
||||
MESH,
|
||||
/**
|
||||
* MOON架构
|
||||
*/
|
||||
MOON;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型
|
||||
*/
|
||||
@Schema(title = "架构模型", description = "WebRTC架构模型")
|
||||
private Framework framework;
|
||||
/**
|
||||
* 媒体最小端口
|
||||
*/
|
||||
@@ -62,11 +39,6 @@ public class WebrtcProperties {
|
||||
*/
|
||||
@Schema(title = "turn服务器", description = "turn服务器")
|
||||
private String[] turn;
|
||||
/**
|
||||
* 信令配置
|
||||
*/
|
||||
@Schema(title = "信令配置", description = "信令配置")
|
||||
private SignalProperties signal;
|
||||
/**
|
||||
* Mediasoup配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user