This commit is contained in:
yumoqing 2024-08-21 10:47:04 +08:00
parent 6ab4daddca
commit a6374eb954

View File

@ -99,9 +99,6 @@ bricks.RTCClient = class extends bricks.VBox {
async call_peer(event){ async call_peer(event){
console.log('event params=', event.params); console.log('event params=', event.params);
bricks.Body.remove_widget(this.menu); bricks.Body.remove_widget(this.menu);
if (! this.localVideo.get_stream()){
await this.getLocalStream();
}
var peer_info = { var peer_info = {
id:event.params.name, id:event.params.name,
name:event.params.label name:event.params.label
@ -170,9 +167,6 @@ bricks.RTCClient = class extends bricks.VBox {
if (this.peer_info){ if (this.peer_info){
this.call_close(); this.call_close();
} }
if (! this.localVideo.get_stream()){
await this.getLocalStream();
}
this.peer_info = peer_info this.peer_info = peer_info
this.role = 'responser' this.role = 'responser'
await this.createPeerConnection(); await this.createPeerConnection();
@ -259,6 +253,9 @@ bricks.RTCClient = class extends bricks.VBox {
// 创建 PeerConnection // 创建 PeerConnection
async createPeerConnection(to_info) { async createPeerConnection(to_info) {
this.phone.set_state('using'); this.phone.set_state('using');
if (! this.localVideo.get_stream()){
await this.getLocalStream();
}
const configuration = { const configuration = {
iceServers: [ iceServers: [
{ urls: this.ice_url }, { urls: this.ice_url },
@ -273,7 +270,7 @@ bricks.RTCClient = class extends bricks.VBox {
.forEach(track => { .forEach(track => {
this.peerConnection.addTrack(track, this.localVideo.stream); this.peerConnection.addTrack(track, this.localVideo.stream);
}); });
if (this.peerConnection){ if (! this.peerConnection){
console.log('peerConnection is null'); console.log('peerConnection is null');
return; return;
} }