[*] 日常优化

This commit is contained in:
acgist
2023-09-09 10:00:19 +08:00
parent 587b3c99d5
commit eb4510bf3d
4 changed files with 46 additions and 43 deletions

View File

@@ -1905,44 +1905,6 @@ class Taoyao extends RemoteClient {
console.debug("生产者评分", message); console.debug("生产者评分", message);
} }
/**
* 关闭通道信令
*
* @param {*} transportId 通道ID
*/
mediaTransportClose(transportId) {
const me = this;
console.debug("关闭通道", transportId);
me.push(protocol.buildMessage("media::transport::close", {
roomId : me.roomId,
transportId: transportId,
}));
}
/**
* 关闭通道信令
*
* @param {*} message
*/
defaultMediaTransportClose(message) {
const me = this;
const {
roomId,
transportId
} = message.body;
if(me.recvTransport && me.recvTransport.id === transportId) {
console.debug("关闭接收通道", transportId);
me.recvTransport.close();
me.recvTransport = null;
} else if(me.sendTransport && me.sendTransport.id === transportId) {
console.debug("关闭发送通道", transportId);
me.sendTransport.close();
me.sendTransport = null;
} else {
console.debug("关闭通道无效", transportId);
}
}
/** /**
* 查询生产者状态信令 * 查询生产者状态信令
* *
@@ -2519,6 +2481,42 @@ class Taoyao extends RemoteClient {
} }
} }
/**
* 关闭通道信令
*
* @param {*} transportId 通道ID
*/
mediaTransportClose(transportId) {
console.debug("关闭通道", transportId);
this.push(protocol.buildMessage("media::transport::close", {
transportId,
roomId: this.roomId,
}));
}
/**
* 关闭通道信令
*
* @param {*} message 信令消息
*/
defaultMediaTransportClose(message) {
const {
roomId,
transportId
} = message.body;
if(this.recvTransport && this.recvTransport.id === transportId) {
console.debug("关闭接收通道", transportId);
this.recvTransport.close();
this.recvTransport = null;
} else if(this.sendTransport && this.sendTransport.id === transportId) {
console.debug("关闭发送通道", transportId);
this.sendTransport.close();
this.sendTransport = null;
} else {
console.debug("关闭通道无效", roomId, transportId);
}
}
/** /**
* 查询通道状态信令 * 查询通道状态信令
* *

View File

@@ -31,7 +31,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
} }
""" """
}, },
flow = { "终端=>信令服务->媒体服务"} flow = "终端=>信令服务->媒体服务"
) )
public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter { public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {

View File

@@ -34,7 +34,10 @@ import lombok.extern.slf4j.Slf4j;
"transportId": "通道ID" "transportId": "通道ID"
} }
""", """,
flow = "终端->信令服务->媒体服务->信令服务->终端" flow = {
"终端->信令服务->媒体服务->信令服务->终端",
"终端-[离开房间]>信令服务->媒体服务->信令服务->终端"
}
) )
public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements ApplicationListener<TransportCloseEvent> { public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements ApplicationListener<TransportCloseEvent> {

View File

@@ -23,6 +23,8 @@ import lombok.extern.slf4j.Slf4j;
/** /**
* 创建RTP输入通道信令 * 创建RTP输入通道信令
* *
* TODO优化接收通道
*
* 注意: * 注意:
* 1. ffmpeg不支持rtcpMux * 1. ffmpeg不支持rtcpMux
* 2. comedia必须开启srtp功能 * 2. comedia必须开启srtp功能
@@ -54,7 +56,8 @@ import lombok.extern.slf4j.Slf4j;
port : "RTP媒体端口", port : "RTP媒体端口",
rtcpPort : "RTP媒体RTCP端口" rtcpPort : "RTP媒体RTCP端口"
} }
""" """,
flow = "终端=>信令服务->媒体服务"
) )
public class MediaTransportPlainCreateProtocol extends ProtocolRoomAdapter { public class MediaTransportPlainCreateProtocol extends ProtocolRoomAdapter {
@@ -68,7 +71,7 @@ public class MediaTransportPlainCreateProtocol extends ProtocolRoomAdapter {
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) { public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
body.put(Constant.CLIENT_ID, clientId); body.put(Constant.CLIENT_ID, clientId);
final Message response = room.requestMedia(message); final Message response = room.requestMedia(message);
final Map<String, Object> responseBody = response.body(); final Map<String, Object> responseBody = response.body();
final Map<String, Transport> transports = room.getTransports(); final Map<String, Transport> transports = room.getTransports();
final String transportId = MapUtils.get(responseBody, Constant.TRANSPORT_ID); final String transportId = MapUtils.get(responseBody, Constant.TRANSPORT_ID);
// 重写地址 // 重写地址
@@ -84,7 +87,6 @@ public class MediaTransportPlainCreateProtocol extends ProtocolRoomAdapter {
log.warn("发送通道已经存在:{}", transportId); log.warn("发送通道已经存在:{}", transportId);
} }
clientWrapper.setSendTransport(sendTransport); clientWrapper.setSendTransport(sendTransport);
// TODO需要测试
// 消费者 // 消费者
Transport recvTransport = clientWrapper.getRecvTransport(); Transport recvTransport = clientWrapper.getRecvTransport();
if(recvTransport == null) { if(recvTransport == null) {