[*] 优化Web SDK
This commit is contained in:
@@ -2100,12 +2100,7 @@ class Taoyao extends RemoteClient {
|
|||||||
if(!audioTrack || !videoTrack) {
|
if(!audioTrack || !videoTrack) {
|
||||||
await this.checkDevice();
|
await this.checkDevice();
|
||||||
}
|
}
|
||||||
if(!this.sendTransport) {
|
await this.mediaConnect();
|
||||||
await this.createSendTransport();
|
|
||||||
}
|
|
||||||
if(!this.recvTransport) {
|
|
||||||
await this.createRecvTransport();
|
|
||||||
}
|
|
||||||
await this.produceAudio(audioTrack);
|
await this.produceAudio(audioTrack);
|
||||||
await this.produceVideo(videoTrack);
|
await this.produceVideo(videoTrack);
|
||||||
await this.produceData();
|
await this.produceData();
|
||||||
@@ -2116,6 +2111,18 @@ class Taoyao extends RemoteClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接媒体
|
||||||
|
*/
|
||||||
|
async mediaConnect() {
|
||||||
|
if(!this.sendTransport) {
|
||||||
|
await this.createSendTransport();
|
||||||
|
}
|
||||||
|
if(!this.recvTransport) {
|
||||||
|
await this.createRecvTransport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产音频
|
* 生产音频
|
||||||
*
|
*
|
||||||
@@ -3672,18 +3679,33 @@ class Taoyao extends RemoteClient {
|
|||||||
console.debug("关闭视频房间媒体");
|
console.debug("关闭视频房间媒体");
|
||||||
this.roomId = null;
|
this.roomId = null;
|
||||||
await this.close();
|
await this.close();
|
||||||
this.consumers.forEach(async (consumer, consumerId) => {
|
await this.closeRoomMediaConsumer();
|
||||||
await consumer.close();
|
await this.closeRoomMediaProducer();
|
||||||
});
|
await this.closeRoomMediaConnect();
|
||||||
this.consumers.clear();
|
this.closeFileVideo();
|
||||||
this.dataConsumers.forEach(async (dataConsumer, consumerId) => {
|
}
|
||||||
await dataConsumer.close();
|
|
||||||
});
|
/**
|
||||||
this.dataConsumers.clear();
|
* 关闭媒体连接
|
||||||
this.remoteClients.forEach(async (remoteClient, clientId) => {
|
*/
|
||||||
await remoteClient.close();
|
async closeRoomMediaConnect() {
|
||||||
});
|
if (this.sendTransport) {
|
||||||
this.remoteClients.clear();
|
await this.sendTransport.close();
|
||||||
|
this.sendTransport = null;
|
||||||
|
}
|
||||||
|
if (this.recvTransport) {
|
||||||
|
await this.recvTransport.close();
|
||||||
|
this.recvTransport = null;
|
||||||
|
}
|
||||||
|
if(this.mediasoupDevice) {
|
||||||
|
this.mediasoupDevice = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭媒体生产者
|
||||||
|
*/
|
||||||
|
async closeRoomMediaProducer() {
|
||||||
if(this.audioProducer) {
|
if(this.audioProducer) {
|
||||||
await this.audioProducer.close();
|
await this.audioProducer.close();
|
||||||
this.audioProducer = null;
|
this.audioProducer = null;
|
||||||
@@ -3696,18 +3718,24 @@ class Taoyao extends RemoteClient {
|
|||||||
await this.dataProducer.close();
|
await this.dataProducer.close();
|
||||||
this.dataProducer = null;
|
this.dataProducer = null;
|
||||||
}
|
}
|
||||||
if (this.sendTransport) {
|
|
||||||
await this.sendTransport.close();
|
|
||||||
this.sendTransport = null;
|
|
||||||
}
|
}
|
||||||
if (this.recvTransport) {
|
|
||||||
await this.recvTransport.close();
|
/**
|
||||||
this.recvTransport = null;
|
* 关闭媒体消费者
|
||||||
}
|
*/
|
||||||
if(this.mediasoupDevice) {
|
async closeRoomMediaConsumer() {
|
||||||
this.mediasoupDevice = null;
|
this.consumers.forEach(async (consumer, consumerId) => {
|
||||||
}
|
await consumer.close();
|
||||||
this.closeFileVideo();
|
});
|
||||||
|
this.consumers.clear();
|
||||||
|
this.dataConsumers.forEach(async (dataConsumer, consumerId) => {
|
||||||
|
await dataConsumer.close();
|
||||||
|
});
|
||||||
|
this.dataConsumers.clear();
|
||||||
|
this.remoteClients.forEach(async (remoteClient, clientId) => {
|
||||||
|
await remoteClient.close();
|
||||||
|
});
|
||||||
|
this.remoteClients.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user