[*] 调整接口
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.acgist.taoyao.signal.config.camera;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* AI识别配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(title = "AI识别配置", description = "AI识别配置")
|
||||
public class AiProperties {
|
||||
|
||||
/**
|
||||
* 识别类型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
// 人
|
||||
PERSON;
|
||||
|
||||
}
|
||||
|
||||
@Schema(title = "是否开启", description = "是否开启")
|
||||
@NotNull(message = "没有指定操作")
|
||||
private Boolean enabled;
|
||||
@Schema(title = "识别类型", description = "识别类型")
|
||||
@NotNull(message = "无效识别类型")
|
||||
private Type type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.acgist.taoyao.signal.config.camera;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 美颜配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(title = "美颜配置", description = "美颜配置")
|
||||
public class BeautyProperties {
|
||||
|
||||
@Schema(title = "是否开启", description = "是否开启")
|
||||
private Boolean enabled;
|
||||
@Schema(title = "美颜级别", description = "美颜级别")
|
||||
private Integer level;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.acgist.taoyao.signal.config.camera;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 摄像头配置
|
||||
*
|
||||
* 音频:
|
||||
* 混音:不用混音
|
||||
* 变声:
|
||||
* 降噪:
|
||||
*
|
||||
* 视频:
|
||||
* 录制:
|
||||
* 水印:
|
||||
* 美颜:
|
||||
* AI识别:
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(title = "摄像头配置", description = "摄像头配置")
|
||||
@ConfigurationProperties(prefix = "taoyao.camera")
|
||||
public class CameraProperties {
|
||||
|
||||
@Schema(title = "混音", description = "混音")
|
||||
private Boolean audioMixer = Boolean.FALSE;
|
||||
@Schema(title = "变声", description = "变声")
|
||||
private Boolean audioChanger;
|
||||
@Schema(title = "降噪", description = "降噪")
|
||||
private Boolean audioDenoise;
|
||||
@Schema(title = "存储目录", description = "存储目录")
|
||||
private String storagePath;
|
||||
@Schema(title = "图片存储目录", description = "图片存储目录")
|
||||
private String storageImagePath;
|
||||
@Schema(title = "视频存储目录", description = "视频存储目录")
|
||||
private String storageVideoPath;
|
||||
@Schema(title = "AI识别配置", description = "AI识别配置")
|
||||
private AiProperties ai;
|
||||
@Schema(title = "美颜配置", description = "美颜配置")
|
||||
private BeautyProperties beauty;
|
||||
@Schema(title = "水印配置", description = "水印配置")
|
||||
private WatermarkProperties watermark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.acgist.taoyao.signal.config.camera;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 水印配置
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(title = "水印配置", description = "水印配置")
|
||||
public class WatermarkProperties {
|
||||
|
||||
@Schema(title = "是否开启", description = "是否开启")
|
||||
private Boolean enabled;
|
||||
@Schema(title = "水印内容", description = "水印内容")
|
||||
private String text;
|
||||
@Schema(title = "X坐标", description = "X坐标")
|
||||
private Integer posx;
|
||||
@Schema(title = "Y坐标", description = "Y坐标")
|
||||
private Integer posy;
|
||||
@Schema(title = "透明度", description = "透明度")
|
||||
private Double opacity;
|
||||
|
||||
}
|
||||
@@ -3,10 +3,12 @@ package com.acgist.taoyao.signal.configuration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import com.acgist.taoyao.boot.runner.OrderedCommandLineRunner;
|
||||
import com.acgist.taoyao.signal.config.camera.CameraProperties;
|
||||
import com.acgist.taoyao.signal.event.EventPublisher;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolManager;
|
||||
|
||||
@@ -18,6 +20,9 @@ import jakarta.annotation.PostConstruct;
|
||||
* @author acgist
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties({
|
||||
CameraProperties.class
|
||||
})
|
||||
public class SignalAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.acgist.taoyao.signal.model.control;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* PTZ控制参数
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Schema(title = "PTZ控制参数", description = "PTZ控制参数")
|
||||
public class PtzControl {
|
||||
|
||||
/**
|
||||
* PTZ类型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
// 水平
|
||||
PAN,
|
||||
// 垂直
|
||||
TILT,
|
||||
// 变焦
|
||||
ZOOM;
|
||||
|
||||
}
|
||||
|
||||
@Schema(title = "PTZ类型", description = "PTZ类型")
|
||||
@NotNull(message = "PTZ类型不能为空")
|
||||
private Type type;
|
||||
@Schema(title = "PTZ参数", description = "PTZ参数")
|
||||
@NotNull(message = "PTZ参数不能为空")
|
||||
private Double value;
|
||||
|
||||
}
|
||||
@@ -43,5 +43,22 @@ public class ProtocolControlAdapter extends ProtocolClientAdapter {
|
||||
*/
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求终端执行控制信令
|
||||
*
|
||||
* @param clientId 终端ID
|
||||
* @param request 请求
|
||||
*
|
||||
* @return 响应
|
||||
*/
|
||||
protected Message request(String clientId, Message request) {
|
||||
final Client client = this.clientManager.clients(clientId);
|
||||
if(client == null) {
|
||||
return Message.fail("无效终端:" + clientId);
|
||||
} else {
|
||||
return client.request(request);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.acgist.taoyao.signal.protocol.control;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.config.camera.AiProperties;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
|
||||
/**
|
||||
* 打开AI识别信令
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Protocol
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"to": "目标终端ID",
|
||||
...AiProperties
|
||||
}
|
||||
""",
|
||||
flow = {
|
||||
"信令服务->终端",
|
||||
"终端=>信令服务->终端"
|
||||
}
|
||||
)
|
||||
public class ControlAiProtocol extends ProtocolControlAdapter {
|
||||
|
||||
public static final String SIGNAL = "control::ai";
|
||||
|
||||
public ControlAiProtocol() {
|
||||
super("打开AI识别信令", SIGNAL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId 终端标识
|
||||
* @param aiProperties AI识别配置
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
public Message execute(String clientId, AiProperties aiProperties) {
|
||||
return this.request(clientId, this.build(aiProperties));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.acgist.taoyao.signal.protocol.control;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
|
||||
/**
|
||||
* 打开美颜信令
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Protocol
|
||||
@Description(
|
||||
)
|
||||
public class ControlBeautyProtocol {
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.util.Map;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.config.Constant;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
@@ -18,7 +19,8 @@ import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"to": "目标终端ID"
|
||||
"to": "目标终端ID",
|
||||
"active": 是否响铃(true|false)
|
||||
}
|
||||
""",
|
||||
flow = {
|
||||
@@ -36,14 +38,17 @@ public class ControlBellProtocol extends ProtocolControlAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
targetClient.push(message);
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId 终端ID
|
||||
* @param active 操作
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
public void execute(String clientId) {
|
||||
this.clientManager.unicast(clientId, this.build());
|
||||
public Message execute(String clientId, Boolean active) {
|
||||
return this.request(clientId, this.build(Map.of(Constant.ACTIVE, active)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.signal.protocol.control;
|
||||
|
||||
/**
|
||||
* 配置音频
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class ControlConfigAudioProtocol {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.signal.protocol.control;
|
||||
|
||||
/**
|
||||
* 配置视频
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class ControlConfigVideoProtocol {
|
||||
|
||||
}
|
||||
@@ -36,14 +36,16 @@ public class ControlPhotographProtocol extends ProtocolControlAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
targetClient.push(message);
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId 终端标识
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
public void execute(String clientId) {
|
||||
this.clientManager.unicast(clientId, this.build());
|
||||
public Message execute(String clientId) {
|
||||
return this.request(clientId, this.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.model.control.PtzControl;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
|
||||
/**
|
||||
@@ -19,8 +20,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
body = """
|
||||
{
|
||||
"to": "目标终端ID",
|
||||
"type": "PTZ类型(PAN|TILT|ZOOM)",
|
||||
"value": PTZ参数
|
||||
...PtzControl
|
||||
}
|
||||
""",
|
||||
flow = {
|
||||
@@ -35,35 +35,20 @@ public class ControlPtzProtocol extends ProtocolControlAdapter {
|
||||
public ControlPtzProtocol() {
|
||||
super("PTZ信令", SIGNAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* PTZ类型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
// 水平
|
||||
PAN,
|
||||
// 垂直
|
||||
TILT,
|
||||
// 变焦
|
||||
ZOOM;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
targetClient.push(message);
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type PTZ类型
|
||||
* @param value PTZ参数
|
||||
* @param clientId 终端标识
|
||||
* @param ptzControl PTZ控制参数
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
public void execute(Type type, Double value, String clientId) {
|
||||
this.clientManager.unicast(clientId, this.build(Map.of(type, value)));
|
||||
public Message execute(String clientId, PtzControl ptzControl) {
|
||||
return this.request(clientId, this.build(ptzControl));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Map;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.config.Constant;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
@@ -16,15 +17,15 @@ import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
*/
|
||||
@Protocol
|
||||
@Description(
|
||||
memo = "状态通过心跳回传",
|
||||
body = """
|
||||
{
|
||||
"to": "目标终端ID"
|
||||
"to": "目标终端ID",
|
||||
"active": 是否录像(true|false)
|
||||
}
|
||||
""",
|
||||
flow = {
|
||||
"信令服务->终端",
|
||||
"终端->信令服务->终端"
|
||||
"终端=>信令服务->终端"
|
||||
}
|
||||
)
|
||||
public class ControlRecordProtocol extends ProtocolControlAdapter {
|
||||
@@ -37,14 +38,17 @@ public class ControlRecordProtocol extends ProtocolControlAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
targetClient.push(message);
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId 终端标识
|
||||
* @param active 操作
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
public void execute(String clientId) {
|
||||
this.clientManager.unicast(clientId, this.build());
|
||||
public Message execute(String clientId, Boolean active) {
|
||||
return this.request(clientId, this.build(Map.of(Constant.ACTIVE, active)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.acgist.taoyao.signal.protocol.control;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
|
||||
/**
|
||||
* 打开水印信令
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Protocol
|
||||
@Description(
|
||||
)
|
||||
public class ControlWatermarkProtocol {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user