This commit is contained in:
yumoqing 2024-08-21 17:34:18 +08:00
parent 554e5218e7
commit 4a48b85fc1

View File

@ -280,9 +280,7 @@ bricks.RTCClient = class extends bricks.VBox {
this.peer_w.set_text(to_info.name); this.peer_w.set_text(to_info.name);
await this.getLocalStream(); await this.getLocalStream();
const configuration = { const configuration = {
iceServers: [ iceServers: this.ice_servers,
{ urls: this.ice_url }
]
}; };
console.log('configuration=', configuration); console.log('configuration=', configuration);
this.pc = new RTCPeerConnection(configuration); this.pc = new RTCPeerConnection(configuration);
@ -297,10 +295,6 @@ bricks.RTCClient = class extends bricks.VBox {
console.log('pc is null'); console.log('pc is null');
return; return;
} }
if (this.role == 'requester'){
await this.send_offer();
}
// 处理 ICE 候选 // 处理 ICE 候选
this.pc.onicecandidate = this.send_candidate.bind(this, to_info); this.pc.onicecandidate = this.send_candidate.bind(this, to_info);
@ -308,6 +302,11 @@ bricks.RTCClient = class extends bricks.VBox {
this.pc.ontrack = event => { this.pc.ontrack = event => {
this.remoteVideo.set_stream(event.streams[0]); this.remoteVideo.set_stream(event.streams[0]);
}; };
if (this.role == 'requester'){
await this.send_offer();
}
console.log('createPeerConnection() finished'); console.log('createPeerConnection() finished');
} }
} }