[*] 日常优化
This commit is contained in:
@@ -865,13 +865,13 @@ class Taoyao {
|
||||
});
|
||||
producer.observer.on("close", () => {
|
||||
if(room.producers.delete(producer.id)) {
|
||||
console.info("生产者关闭", producer.id, streamId);
|
||||
console.debug("生产者关闭", producer.id, streamId);
|
||||
me.push(protocol.buildMessage("media::producer::close", {
|
||||
roomId,
|
||||
producerId: producer.id
|
||||
}));
|
||||
} else {
|
||||
console.info("生产者关闭(无效)", producer.id, streamId);
|
||||
console.debug("生产者关闭(生产者无效)", producer.id, streamId);
|
||||
}
|
||||
});
|
||||
producer.observer.on("pause", () => {
|
||||
@@ -933,25 +933,6 @@ class Taoyao {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} message 消息
|
||||
* @param {*} body 消息主体
|
||||
*/
|
||||
async mediaProducerClose(message, body) {
|
||||
const me = this;
|
||||
const { roomId, producerId } = body;
|
||||
const room = me.rooms.get(roomId);
|
||||
const producer = room?.producers.get(producerId);
|
||||
if(producer) {
|
||||
console.info("关闭生产者", producerId);
|
||||
await producer.close();
|
||||
} else {
|
||||
console.debug("关闭生产者(无效)", producerId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费媒体信令
|
||||
*
|
||||
@@ -1503,6 +1484,27 @@ class Taoyao {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
* @param {*} body 消息主体
|
||||
*/
|
||||
async mediaProducerClose(message, body) {
|
||||
const {
|
||||
roomId,
|
||||
producerId
|
||||
} = body;
|
||||
const room = this.rooms.get(roomId);
|
||||
const producer = room?.producers.get(producerId);
|
||||
if(!producer) {
|
||||
console.debug("关闭生产者(生产者无效)", roomId, producerId);
|
||||
return;
|
||||
}
|
||||
console.debug("关闭生产者", producerId);
|
||||
await producer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停生产者信令
|
||||
*
|
||||
@@ -1517,7 +1519,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const producer = room?.producers.get(producerId);
|
||||
if(!producer) {
|
||||
console.debug("暂停生产者(无效生产者)", roomId, producerId);
|
||||
console.warn("暂停生产者(生产者无效)", roomId, producerId);
|
||||
return;
|
||||
}
|
||||
console.debug("暂停生产者", producerId);
|
||||
@@ -1538,7 +1540,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const producer = room?.producers.get(producerId);
|
||||
if(!producer) {
|
||||
console.debug("恢复生产者(无效生产者)", roomId, producerId);
|
||||
console.warn("恢复生产者(生产者无效)", roomId, producerId);
|
||||
return;
|
||||
}
|
||||
console.debug("恢复生产者", producerId);
|
||||
@@ -1559,7 +1561,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const producer = room?.producers.get(producerId);
|
||||
if(!producer) {
|
||||
console.warn("查询生产者状态(无效生产者)", roomId, producerId);
|
||||
console.warn("查询生产者状态(生产者无效)", roomId, producerId);
|
||||
return;
|
||||
}
|
||||
console.debug("查询生产者状态", producerId);
|
||||
@@ -1602,7 +1604,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const transport = room?.transports.get(transportId);
|
||||
if(!transport) {
|
||||
console.info("关闭传输通道(无效通道)", roomId, transportId);
|
||||
console.debug("关闭传输通道(通道无效)", roomId, transportId);
|
||||
return;
|
||||
}
|
||||
console.debug("关闭传输通道", transportId);
|
||||
@@ -1637,7 +1639,7 @@ class Taoyao {
|
||||
};
|
||||
const room = this.rooms.get(roomId);
|
||||
if(!room) {
|
||||
console.warn("创建RTP输入通道(无效房间)", roomId);
|
||||
console.warn("创建RTP输入通道(房间无效)", roomId);
|
||||
return;
|
||||
}
|
||||
const transport = await room?.mediasoupRouter.createPlainTransport(plainTransportOptions);
|
||||
@@ -1669,7 +1671,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const transport = room?.transports.get(transportId);
|
||||
if(!transport) {
|
||||
console.warn("查询通道状态(无效通道)", roomId, transportId);
|
||||
console.warn("查询通道状态(通道无效)", roomId, transportId);
|
||||
return;
|
||||
}
|
||||
console.debug("查询通道状态", transportId);
|
||||
@@ -1695,7 +1697,7 @@ class Taoyao {
|
||||
const room = this.rooms.get(roomId);
|
||||
const transport = room?.transports.get(transportId);
|
||||
if(!transport) {
|
||||
console.warn("连接WebRTC通道(无效通道)", roomId, transportId);
|
||||
console.warn("连接WebRTC通道(通道无效)", roomId, transportId);
|
||||
return;
|
||||
}
|
||||
await transport.connect({
|
||||
@@ -1739,7 +1741,7 @@ class Taoyao {
|
||||
}
|
||||
const room = this.rooms.get(roomId);
|
||||
if(!room) {
|
||||
console.warn("创建WebRTC通道(无效房间)", roomId);
|
||||
console.warn("创建WebRTC通道(房间无效)", roomId);
|
||||
return;
|
||||
}
|
||||
const transport = await room.mediasoupRouter.createWebRtcTransport({
|
||||
@@ -1798,7 +1800,7 @@ class Taoyao {
|
||||
transportId,
|
||||
}));
|
||||
} else {
|
||||
console.info("通道关闭(无效通道)", roomId, transportId);
|
||||
console.debug("通道关闭(通道无效)", roomId, transportId);
|
||||
}
|
||||
});
|
||||
// transport.observer.on("newproducer", (producer) => {});
|
||||
@@ -1870,7 +1872,7 @@ class Taoyao {
|
||||
} = body;
|
||||
const room = this.rooms.get(roomId);
|
||||
if(!room) {
|
||||
console.info("关闭房间(无效房间)", roomId);
|
||||
console.warn("关闭房间(房间无效)", roomId);
|
||||
return;
|
||||
}
|
||||
room.closeAll();
|
||||
@@ -1934,7 +1936,7 @@ class Taoyao {
|
||||
roomId
|
||||
}));
|
||||
} else {
|
||||
console.info("路由关闭(无效房间)", roomId, mediasoupRouter.id);
|
||||
console.debug("路由关闭(房间无效)", roomId, mediasoupRouter.id);
|
||||
}
|
||||
});
|
||||
// mediasoupRouter.observer.on("newtransport", (transport) => {});
|
||||
|
||||
@@ -1823,46 +1823,6 @@ class Taoyao extends RemoteClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} producerId 生产者ID
|
||||
*/
|
||||
mediaProducerClose(producerId) {
|
||||
this.push(
|
||||
protocol.buildMessage("media::producer::close", {
|
||||
roomId : this.roomId,
|
||||
producerId: producerId
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
async defaultMediaProducerClose(message) {
|
||||
const me = this;
|
||||
const {
|
||||
roomId,
|
||||
producerId
|
||||
} = message.body;
|
||||
const producer = me.getProducer(producerId);
|
||||
if (producer) {
|
||||
console.debug("关闭生产者", producerId);
|
||||
producer.close();
|
||||
if(producer.kind === "audio") {
|
||||
me.audioProducer = null;
|
||||
} else if(producer.kind === "video") {
|
||||
me.videoProducer = null;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
console.debug("关闭生产者无效", producerId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费媒体信令
|
||||
*
|
||||
@@ -2430,6 +2390,43 @@ class Taoyao extends RemoteClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} producerId 生产者ID
|
||||
*/
|
||||
mediaProducerClose(producerId) {
|
||||
this.push(protocol.buildMessage("media::producer::close", {
|
||||
producerId,
|
||||
roomId: this.roomId,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭生产者信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
async defaultMediaProducerClose(message) {
|
||||
const {
|
||||
producerId
|
||||
} = message.body;
|
||||
const producer = this.getProducer(producerId);
|
||||
if(!producer) {
|
||||
console.debug("关闭生产者(生产者无效)", producerId);
|
||||
return;
|
||||
}
|
||||
console.debug("关闭生产者", producerId);
|
||||
producer.close();
|
||||
if(producer.kind === "audio") {
|
||||
this.audioProducer = null;
|
||||
} else if(producer.kind === "video") {
|
||||
this.videoProducer = null;
|
||||
} else {
|
||||
console.warn("关闭生产者(生产者类型不支持)", producerId, producer.kind);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停生产者信令
|
||||
*
|
||||
@@ -3253,7 +3250,7 @@ class Taoyao extends RemoteClient {
|
||||
await session.close();
|
||||
this.sessionClients.delete(sessionId);
|
||||
} else {
|
||||
console.debug("关闭媒体(无效会话)", sessionId);
|
||||
console.debug("关闭媒体(会话无效)", sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3306,7 +3303,7 @@ class Taoyao extends RemoteClient {
|
||||
}));
|
||||
session.pauseRemote(type);
|
||||
} else {
|
||||
console.debug("暂停媒体(无效会话)", type, sessionId);
|
||||
console.debug("暂停媒体(会话无效)", type, sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3325,7 +3322,7 @@ class Taoyao extends RemoteClient {
|
||||
console.debug("暂停媒体", type, sessionId);
|
||||
session.pause(type);
|
||||
} else {
|
||||
console.debug("暂停媒体(无效会话)", type, sessionId);
|
||||
console.debug("暂停媒体(会话无效)", type, sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3345,7 +3342,7 @@ class Taoyao extends RemoteClient {
|
||||
}));
|
||||
session.resumeRemote(type);
|
||||
} else {
|
||||
console.debug("恢复媒体(无效会话)", type, sessionId);
|
||||
console.debug("恢复媒体(会话无效)", type, sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3364,7 +3361,7 @@ class Taoyao extends RemoteClient {
|
||||
console.debug("恢复媒体", type, sessionId);
|
||||
session.resume(type);
|
||||
} else {
|
||||
console.debug("恢复媒体(无效会话)", type, sessionId);
|
||||
console.debug("恢复媒体(会话无效)", type, sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user