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){
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;
}