From a6374eb95482ff66f5cc7ed30167594b42ab7c91 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 21 Aug 2024 10:47:04 +0800 Subject: [PATCH] bugfix --- bricks/rtc.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bricks/rtc.js b/bricks/rtc.js index 14ef1e0..054fc58 100644 --- a/bricks/rtc.js +++ b/bricks/rtc.js @@ -99,9 +99,6 @@ bricks.RTCClient = class extends bricks.VBox { async call_peer(event){ console.log('event params=', event.params); bricks.Body.remove_widget(this.menu); - if (! this.localVideo.get_stream()){ - await this.getLocalStream(); - } var peer_info = { id:event.params.name, name:event.params.label @@ -170,9 +167,6 @@ bricks.RTCClient = class extends bricks.VBox { if (this.peer_info){ this.call_close(); } - if (! this.localVideo.get_stream()){ - await this.getLocalStream(); - } this.peer_info = peer_info this.role = 'responser' await this.createPeerConnection(); @@ -259,6 +253,9 @@ bricks.RTCClient = class extends bricks.VBox { // 创建 PeerConnection async createPeerConnection(to_info) { this.phone.set_state('using'); + if (! this.localVideo.get_stream()){ + await this.getLocalStream(); + } const configuration = { iceServers: [ { urls: this.ice_url }, @@ -273,7 +270,7 @@ bricks.RTCClient = class extends bricks.VBox { .forEach(track => { this.peerConnection.addTrack(track, this.localVideo.stream); }); - if (this.peerConnection){ + if (! this.peerConnection){ console.log('peerConnection is null'); return; }