[+] 信令优化

This commit is contained in:
acgist
2023-03-03 21:53:21 +08:00
parent c3dbe52d5c
commit 9c5ab2ec9f
24 changed files with 203 additions and 128 deletions

View File

@@ -21,12 +21,12 @@ public @interface Description {
/**
* @return 消息主体
*/
String[] body() default { "" };
String[] body() default { "{}" };
/**
* @return 数据流向
*/
String[] flow() default { "终端=>信令服务->终端" };
String[] flow() default { "终端->信令服务->终端" };
/**
* @return 描述信息

View File

@@ -83,22 +83,6 @@ public interface Constant {
* 建议
*/
String IDEAL = "ideal";
/**
* 最小宽度
*/
Integer MIN_WIDTH = 720;
/**
* 最大宽度
*/
Integer MAX_WIDTH = 4096;
/**
* 最小高度
*/
Integer MIN_HEIGHT = 480;
/**
* 最大高度
*/
Integer MAX_HEIGHT = 2160;
/**
* 脚本
*/

View File

@@ -30,7 +30,7 @@ public class MediaAudioProperties {
@Schema(title = "格式", description = "格式", example = "G722|PCMA|PCMU|OPUS")
private Format format;
@Schema(title = "采样数", description = "采样数", example = "16")
@Schema(title = "采样数", description = "采样数", example = "8|16|32")
private Integer sampleSize;
@Schema(title = "采样率", description = "采样率", example = "8000|16000|32000|48000")
private Integer sampleRate;

View File

@@ -16,7 +16,31 @@ import lombok.Setter;
@Schema(title = "媒体配置", description = "媒体配置")
@ConfigurationProperties(prefix = "taoyao.media")
public class MediaProperties {
@Schema(title = "最小视频宽度", description = "最小视频宽度")
private Integer minWidth;
@Schema(title = "最大视频宽度", description = "最大视频宽度")
private Integer maxWidth;
@Schema(title = "最小视频高度", description = "最小视频高度")
private Integer minHeight;
@Schema(title = "最大视频高度", description = "最大视频高度")
private Integer maxHeight;
@Schema(title = "最小视频码率", description = "最小视频码率")
private Integer minBitrate;
@Schema(title = "最大视频码率", description = "最大视频码率")
private Integer maxBitrate;
@Schema(title = "最小视频帧率", description = "最小视频帧率")
private Integer minFrameRate;
@Schema(title = "最大视频帧率", description = "最大视频帧率")
private Integer maxFrameRate;
@Schema(title = "最小音频采样数", description = "最小音频采样数")
private Integer minSampleSize;
@Schema(title = "最大音频采样数", description = "最大音频采样数")
private Integer maxSampleSize;
@Schema(title = "最小音频采样率", description = "最小音频采样率")
private Integer minSampleRate;
@Schema(title = "最大音频采样率", description = "最大音频采样率")
private Integer maxSampleRate;
@Schema(title = "音频默认配置", description = "音频默认配置")
private MediaAudioProperties audio;
@Schema(title = "视频默认配置", description = "视频默认配置")

View File

@@ -1,8 +1,5 @@
package com.acgist.taoyao.boot.config;
import java.util.LinkedHashMap;
import java.util.Map;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@@ -35,35 +32,29 @@ public class MediaVideoProperties {
private Format format;
@Schema(title = "码率", description = "码率影响画质", example = "600|1200|1500|1800")
private Integer bitrate;
@Schema(title = "帧率", description = "帧率影响流畅", example = "20|24|30|60")
@Schema(title = "帧率", description = "帧率影响流畅", example = "15|18|20|24|30|45")
private Integer frameRate;
@Schema(title = "分辨率", description = "分辨率影响画面大小", example = "1920*1080|1280*720")
@Schema(title = "分辨率", description = "分辨率影响画面大小", example = "4096*2160|2560*1440|1920*1080|1280*720|720*480")
private String resolution;
@Schema(title = "宽度", description = "宽度", example = "{ min: 720, ideal: 1280, max: 4096 }")
private Map<String, Object> width;
@Schema(title = "高度", description = "高度", example = "{ min: 480, ideal: 720, max: 2160 }")
private Map<String, Object> height;
@Schema(title = "宽度", description = "宽度", example = "4096|2560|1920|1280|720")
private Integer width;
@Schema(title = "高度", description = "高度", example = "2160|1440|1080|720|480")
private Integer height;
public Map<String, Object> getWidth() {
if(this.width == null) {
final int index = this.resolution.indexOf('*');
this.width = new LinkedHashMap<>();
this.width.put(Constant.MIN, Constant.MIN_WIDTH);
this.width.put(Constant.IDEAL, Integer.valueOf(this.resolution.substring(0, index).strip()));
this.width.put(Constant.MAX, Constant.MAX_WIDTH);
}
return this.width;
}
public Map<String, Object> getHeight() {
if(this.height == null) {
final int index = this.resolution.indexOf('*');
this.height = new LinkedHashMap<>();
this.height.put(Constant.MIN, Constant.MIN_HEIGHT);
this.height.put(Constant.IDEAL, Integer.valueOf(this.resolution.substring(index + 1).strip()));
this.height.put(Constant.MAX, Constant.MAX_HEIGHT);
}
return this.height;
}
public Integer getWidth() {
if (this.width == null) {
final int index = this.resolution.indexOf('*');
return this.width = Integer.valueOf(this.resolution.substring(0, index).strip());
}
return this.width;
}
public Integer getHeight() {
if (this.height == null) {
final int index = this.resolution.indexOf('*');
return this.height = Integer.valueOf(this.resolution.substring(index + 1).strip());
}
return this.height;
}
}

View File

@@ -102,5 +102,21 @@ public final class MapUtils {
}
return Boolean.valueOf(object.toString());
}
/**
* @param <T> 参数泛型
*
* @param body 消息主体
* @param key 参数名称
*
* @return 参数值
*/
@SuppressWarnings("unchecked")
public static final <T> T remove(Map<?, ?> body, String key) {
if(body == null) {
return null;
}
return (T) body.remove(key);
}
}