[*] 日常优化
This commit is contained in:
@@ -28,7 +28,7 @@ public class RtpTest {
|
||||
final InputStream inputStream = socket.getInputStream();
|
||||
final OutputStream outputStream = socket.getOutputStream();
|
||||
// 随机密码:https://localhost:8888/config/socket
|
||||
final String secret = "TSFXzB7hcfE=".strip();
|
||||
final String secret = "2SPWy+TF1zM=".strip();
|
||||
final Cipher encrypt = CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.DES, secret);
|
||||
final Cipher decrypt = CipherUtils.buildCipher(Cipher.DECRYPT_MODE, Encrypt.DES, secret);
|
||||
// 接收
|
||||
@@ -63,7 +63,12 @@ public class RtpTest {
|
||||
buffer.flip();
|
||||
buffer.get(message);
|
||||
buffer.compact();
|
||||
log.debug("收到消息:{}", new String(decrypt.doFinal(message)));
|
||||
final String value = new String(decrypt.doFinal(message));
|
||||
if(value.contains("media::audio::volume")) {
|
||||
log.debug("收到消息:{}", value);
|
||||
} else {
|
||||
log.info("收到消息:{}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.acgist.taoyao.signal.party.room;
|
||||
|
||||
/**
|
||||
* 媒体路由类型
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public enum RouterType {
|
||||
|
||||
/**
|
||||
* 对讲:只有两个人之间的媒体相互路由
|
||||
*/
|
||||
ONE_TO_ONE,
|
||||
/**
|
||||
* 广播:只有一个人的媒体路由到其他人
|
||||
*/
|
||||
ONE_TO_ALL,
|
||||
/**
|
||||
* 网播:所有人的媒体相互路由
|
||||
*/
|
||||
ALL_TO_ALL,
|
||||
|
||||
}
|
||||
@@ -24,13 +24,14 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
||||
}
|
||||
""",
|
||||
"""
|
||||
{
|
||||
"codec": "编码解码",
|
||||
"roomId" : "房间标识",
|
||||
"rtpCapabilities": {
|
||||
"codec" : "编码解码",
|
||||
"headerExtensions": "扩展"
|
||||
}
|
||||
"""
|
||||
},
|
||||
flow = { "终端=>信令服务->媒体服务->信令服务->终端"}
|
||||
flow = { "终端=>信令服务->媒体服务"}
|
||||
)
|
||||
public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.acgist.taoyao.signal.protocol.media;
|
||||
|
||||
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.party.room.Room;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
||||
|
||||
/**
|
||||
* 设置路由类型信令
|
||||
* 注意:不会添加移除消费者生产者,只会暂停恢复操作。
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Protocol
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID"
|
||||
"routerType": "路由类型"
|
||||
}
|
||||
""",
|
||||
flow = "终端->信令服务->终端"
|
||||
)
|
||||
public class MediaSetRouterTypeProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
public static final String SIGNAL = "media::set::router::type";
|
||||
|
||||
public MediaSetRouterTypeProtocol() {
|
||||
super("设置路由类型信令", SIGNAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
// TODO:路由类型
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,13 +27,14 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@Protocol
|
||||
@Description(
|
||||
memo = "关闭通过回调实现所以不能同步响应",
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID"
|
||||
"roomId" : "房间ID"
|
||||
"transportId": "通道ID"
|
||||
}
|
||||
""",
|
||||
flow = "终端->信令服务->媒体服务->信令服务+)终端"
|
||||
flow = "终端->信令服务->媒体服务->信令服务->终端"
|
||||
)
|
||||
public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements ApplicationListener<TransportCloseEvent> {
|
||||
|
||||
@@ -46,10 +47,10 @@ public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(TransportCloseEvent event) {
|
||||
final Room room = event.getRoom();
|
||||
final Room room = event.getRoom();
|
||||
final Client mediaClient = event.getMediaClient();
|
||||
final Map<String, Object> body = Map.of(
|
||||
Constant.ROOM_ID, room.getRoomId(),
|
||||
Constant.ROOM_ID, room.getRoomId(),
|
||||
Constant.TRANSPORT_ID, event.getTransportId()
|
||||
);
|
||||
mediaClient.push(this.build(body));
|
||||
@@ -57,7 +58,7 @@ public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
final String transportId = MapUtils.get(body, Constant.TRANSPORT_ID);
|
||||
final String transportId = MapUtils.get(body, Constant.TRANSPORT_ID);
|
||||
final Transport transport = room.transport(transportId);
|
||||
if(transport == null) {
|
||||
log.debug("通道无效:{} - {}", transportId, clientType);
|
||||
@@ -67,7 +68,7 @@ public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements
|
||||
transport.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
transport.remove();
|
||||
room.broadcast(message);
|
||||
transport.getClient().push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 创建RTP输入通道信令
|
||||
*
|
||||
* 注意:
|
||||
* 1. ffmpeg不支持rtcpMux
|
||||
* 2. comedia必须开启srtp功能
|
||||
@@ -32,17 +33,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@Protocol
|
||||
@Description(
|
||||
memo = "用来接入RTP终端",
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID",
|
||||
"rtcpMux": RTP和RTCP端口复用(true|false),
|
||||
"comedia": 自动终端端口(true|false),
|
||||
"enableSctp": 是否开启sctp(true|false),
|
||||
"numSctpStreams": sctp数量,
|
||||
"enableSrtp": 是否开启srtp(true|false),
|
||||
"roomId" : "房间ID",
|
||||
"rtcpMux" : RTP和RTCP端口复用(true|false),
|
||||
"comedia" : 自动识别终端端口(true|false),
|
||||
"enableSctp" : 是否开启SCTP(true|false),
|
||||
"numSctpStreams": SCTP数量,
|
||||
"enableSrtp" : 是否开启SRTP(true|false),
|
||||
"srtpCryptoSuite": {
|
||||
"cryptoSuite": "算法(AEAD_AES_256_GCM|AEAD_AES_128_GCM|AES_CM_128_HMAC_SHA1_80|AES_CM_128_HMAC_SHA1_32)",
|
||||
"keyBase64": "密钥"
|
||||
"keyBase64" : "密钥"
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -86,7 +88,7 @@ public class MediaTransportPlainProtocol extends ProtocolRoomAdapter {
|
||||
* 重写IP地址
|
||||
*
|
||||
* @param clientIp 终端IP
|
||||
* @param body 消息主体
|
||||
* @param body 消息主体
|
||||
*/
|
||||
private void rewriteIp(String clientIp, Map<String, Object> body) {
|
||||
// 媒体服务返回IP
|
||||
|
||||
@@ -19,11 +19,11 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID",
|
||||
"roomId" : "房间ID",
|
||||
"transportId": "通道ID"
|
||||
}
|
||||
""",
|
||||
flow = "终端=>信令服务->媒体服务->信令服务->终端"
|
||||
flow = "终端=>信令服务->媒体服务"
|
||||
)
|
||||
public class MediaTransportStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user