[*] 日常优化
This commit is contained in:
@@ -866,24 +866,20 @@ class Taoyao {
|
|||||||
producer.observer.on("close", () => {
|
producer.observer.on("close", () => {
|
||||||
if(room.producers.delete(producer.id)) {
|
if(room.producers.delete(producer.id)) {
|
||||||
console.info("生产者关闭", producer.id, streamId);
|
console.info("生产者关闭", producer.id, streamId);
|
||||||
me.push(
|
me.push(protocol.buildMessage("media::producer::close", {
|
||||||
protocol.buildMessage("media::producer::close", {
|
roomId,
|
||||||
roomId : roomId,
|
producerId: producer.id
|
||||||
producerId: producer.id
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
console.info("生产者关闭(无效)", producer.id, streamId);
|
console.info("生产者关闭(无效)", producer.id, streamId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
producer.observer.on("pause", () => {
|
producer.observer.on("pause", () => {
|
||||||
console.debug("生产者暂停", producer.id, streamId);
|
console.debug("生产者暂停", producer.id, streamId);
|
||||||
me.push(
|
me.push(protocol.buildMessage("media::producer::pause", {
|
||||||
protocol.buildMessage("media::producer::pause", {
|
roomId,
|
||||||
roomId : roomId,
|
producerId: producer.id
|
||||||
producerId: producer.id
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
producer.observer.on("resume", () => {
|
producer.observer.on("resume", () => {
|
||||||
console.debug("生产者恢复", producer.id, streamId);
|
console.debug("生产者恢复", producer.id, streamId);
|
||||||
@@ -956,44 +952,6 @@ class Taoyao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停生产者信令
|
|
||||||
*
|
|
||||||
* @param {*} message 消息
|
|
||||||
* @param {*} body 消息主体
|
|
||||||
*/
|
|
||||||
async mediaProducerPause(message, body) {
|
|
||||||
const me = this;
|
|
||||||
const { roomId, producerId } = body;
|
|
||||||
const room = me.rooms.get(roomId);
|
|
||||||
const producer = room?.producers.get(producerId);
|
|
||||||
if(producer) {
|
|
||||||
console.debug("暂停生产者", producerId);
|
|
||||||
await producer.pause();
|
|
||||||
} else {
|
|
||||||
console.debug("暂停生产者无效(无效)", producerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复生产者信令
|
|
||||||
*
|
|
||||||
* @param {*} message 消息
|
|
||||||
* @param {*} body 消息主体
|
|
||||||
*/
|
|
||||||
async mediaProducerResume(message, body) {
|
|
||||||
const me = this;
|
|
||||||
const { roomId, producerId } = body;
|
|
||||||
const room = me.rooms.get(roomId);
|
|
||||||
const producer = room?.producers.get(producerId);
|
|
||||||
if(producer) {
|
|
||||||
console.debug("恢复生产者", producerId);
|
|
||||||
await producer.resume();
|
|
||||||
} else {
|
|
||||||
console.debug("恢复生产者(无效)", producerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费媒体信令
|
* 消费媒体信令
|
||||||
*
|
*
|
||||||
@@ -1545,6 +1503,48 @@ class Taoyao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂停生产者信令
|
||||||
|
*
|
||||||
|
* @param {*} message 信令消息
|
||||||
|
* @param {*} body 消息主体
|
||||||
|
*/
|
||||||
|
async mediaProducerPause(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.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复生产者信令
|
||||||
|
*
|
||||||
|
* @param {*} message 信令消息
|
||||||
|
* @param {*} body 消息主体
|
||||||
|
*/
|
||||||
|
async mediaProducerResume(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.resume();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询生产者状态信令
|
* 查询生产者状态信令
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export default {
|
|||||||
switch (signal) {
|
switch (signal) {
|
||||||
case "media::track" :
|
case "media::track" :
|
||||||
const { clientId, track } = body;
|
const { clientId, track } = body;
|
||||||
console.info("新增媒体轨道", clientId, track);
|
console.debug("新增媒体轨道", clientId, track);
|
||||||
break;
|
break;
|
||||||
case "client::config" :
|
case "client::config" :
|
||||||
this.roomVisible = true;
|
this.roomVisible = true;
|
||||||
|
|||||||
@@ -2,13 +2,18 @@
|
|||||||
* 配置
|
* 配置
|
||||||
*/
|
*/
|
||||||
const config = {
|
const config = {
|
||||||
|
// 媒体配置
|
||||||
|
media: {
|
||||||
|
// 是否预览共享文件
|
||||||
|
filePreview: true
|
||||||
|
},
|
||||||
// 信令配置
|
// 信令配置
|
||||||
signal: {
|
signal: {
|
||||||
// 信令版本
|
// 信令版本
|
||||||
version : "1.0.0",
|
version : "1.0.0",
|
||||||
// 终端类型
|
// 终端类型
|
||||||
clientType: "WEB",
|
clientType: "WEB",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 音频默认配置
|
* 音频默认配置
|
||||||
|
|||||||
@@ -957,8 +957,11 @@ class Taoyao extends RemoteClient {
|
|||||||
this.fileVideo.muted = true;
|
this.fileVideo.muted = true;
|
||||||
this.fileVideo.controls = true;
|
this.fileVideo.controls = true;
|
||||||
this.fileVideo.src = URL.createObjectURL(input.files[0]);
|
this.fileVideo.src = URL.createObjectURL(input.files[0]);
|
||||||
this.fileVideo.style = "position:fixed;top:1rem;left:1rem;width:128px;border:2px solid #FFF;";
|
if(config.media.filePreview) {
|
||||||
// this.fileVideo.style.display = "none";
|
this.fileVideo.style = "position:fixed;top:1rem;left:1rem;width:128px;border:2px solid #FFF;";
|
||||||
|
} else {
|
||||||
|
this.fileVideo.style.display = "none";
|
||||||
|
}
|
||||||
document.body.appendChild(this.fileVideo);
|
document.body.appendChild(this.fileVideo);
|
||||||
// 开始播放不然不能采集
|
// 开始播放不然不能采集
|
||||||
await this.fileVideo.play();
|
await this.fileVideo.play();
|
||||||
@@ -1860,48 +1863,6 @@ class Taoyao extends RemoteClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停生产者信令
|
|
||||||
*
|
|
||||||
* @param {*} producerId 生产者ID
|
|
||||||
*/
|
|
||||||
mediaProducerPause(producerId) {
|
|
||||||
const me = this;
|
|
||||||
const producer = me.getProducer(producerId);
|
|
||||||
if(producer) {
|
|
||||||
if(producer.paused) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.debug("暂停生产者", producerId);
|
|
||||||
me.push(protocol.buildMessage("media::producer::pause", {
|
|
||||||
roomId : me.roomId,
|
|
||||||
producerId: producerId,
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
console.debug("暂停生产者无效", producerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停生产者信令
|
|
||||||
*
|
|
||||||
* @param {*} message 消息
|
|
||||||
*/
|
|
||||||
async defaultMediaProducerPause(message) {
|
|
||||||
const me = this;
|
|
||||||
const {
|
|
||||||
roomId,
|
|
||||||
producerId
|
|
||||||
} = message.body;
|
|
||||||
const producer = me.getProducer(producerId);
|
|
||||||
if (producer) {
|
|
||||||
console.debug("暂停生产者", producerId);
|
|
||||||
producer.pause();
|
|
||||||
} else {
|
|
||||||
console.debug("暂停生产者无效", producerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费媒体信令
|
* 消费媒体信令
|
||||||
*
|
*
|
||||||
@@ -2469,6 +2430,50 @@ class Taoyao extends RemoteClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂停生产者信令
|
||||||
|
*
|
||||||
|
* @param {*} producerId 生产者ID
|
||||||
|
*/
|
||||||
|
mediaProducerPause(producerId) {
|
||||||
|
const producer = this.getProducer(producerId);
|
||||||
|
if(!producer) {
|
||||||
|
console.debug("暂停生产者(生产者无效)", producerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(producer.paused) {
|
||||||
|
console.debug("暂停生产者(生产者已经暂停)", producerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.debug("暂停生产者", producerId);
|
||||||
|
this.push(protocol.buildMessage("media::producer::pause", {
|
||||||
|
producerId,
|
||||||
|
roomId: this.roomId,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂停生产者信令
|
||||||
|
*
|
||||||
|
* @param {*} message 消息
|
||||||
|
*/
|
||||||
|
async defaultMediaProducerPause(message) {
|
||||||
|
const {
|
||||||
|
producerId
|
||||||
|
} = message.body;
|
||||||
|
const producer = this.getProducer(producerId);
|
||||||
|
if (!producer) {
|
||||||
|
console.debug("暂停生产者(生产者无效)", producerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(producer.paused) {
|
||||||
|
console.debug("暂停生产者(生产者已经暂停)", producerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.debug("暂停生产者", producerId);
|
||||||
|
producer.pause();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 恢复生产者信令
|
* 恢复生产者信令
|
||||||
*
|
*
|
||||||
@@ -3696,6 +3701,7 @@ class Taoyao extends RemoteClient {
|
|||||||
await client.close();
|
await client.close();
|
||||||
});
|
});
|
||||||
me.remoteClients.clear();
|
me.remoteClients.clear();
|
||||||
|
me.closeFileVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3709,6 +3715,7 @@ class Taoyao extends RemoteClient {
|
|||||||
console.debug("关闭会话", sessionId);
|
console.debug("关闭会话", sessionId);
|
||||||
});
|
});
|
||||||
me.sessionClients.clear();
|
me.sessionClients.clear();
|
||||||
|
me.closeFileVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,6 +47,13 @@
|
|||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!--
|
||||||
|
同时部署多个分支使用:修改脚本`${project.artifactId}-${project.version}`->`${project.artifactId}-${git.branch}-${project.version}`
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
-->
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user