mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Release ressources whenever it is possible
This commit is contained in:
parent
a4f5228037
commit
65d1017aed
@ -364,15 +364,9 @@ class CallWindow extends CustomEvents {
|
|||||||
|
|
||||||
|
|
||||||
if(this.mainPeer) {
|
if(this.mainPeer) {
|
||||||
this.mainPeer.destroy();
|
this.closeMainPeer()
|
||||||
delete this.mainPeer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release user media
|
|
||||||
if(this.mainStream) {
|
|
||||||
this.mainStream.getTracks().forEach(e => e.stop())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy peer connections
|
// Destroy peer connections
|
||||||
for(const el of this.peersEls)
|
for(const el of this.peersEls)
|
||||||
el[1].destroy()
|
el[1].destroy()
|
||||||
@ -486,12 +480,18 @@ class CallWindow extends CustomEvents {
|
|||||||
const hasVideo = (this.mainPeer && !this.mainPeer.destroyed && this.mainStream && this.mainStream.getVideoTracks().length > 0) === true;
|
const hasVideo = (this.mainPeer && !this.mainPeer.destroyed && this.mainStream && this.mainStream.getVideoTracks().length > 0) === true;
|
||||||
|
|
||||||
// Check if current stream is not enough
|
// Check if current stream is not enough
|
||||||
if(hasAudio && isVideo && !hasVideo)
|
if(hasAudio && isVideo && !hasVideo) {
|
||||||
this.mainPeer.destroy()
|
this.closeMainPeer()
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we have to start stream or just to mute them
|
// Check if we have to start stream or just to mute them
|
||||||
if(!hasAudio || (isVideo && !hasVideo)) {
|
if(!hasAudio || (isVideo && !hasVideo)) {
|
||||||
await this.startStreaming(isVideo)
|
try {
|
||||||
|
await this.startStreaming(isVideo)
|
||||||
|
} catch(e) {
|
||||||
|
notify("Could not start streaming ! (did you block access to your camera / microphone ?)", "danger")
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle mute
|
// Toggle mute
|
||||||
@ -674,6 +674,25 @@ class CallWindow extends CustomEvents {
|
|||||||
});*/
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close main peer connection
|
||||||
|
*/
|
||||||
|
async closeMainPeer() {
|
||||||
|
|
||||||
|
|
||||||
|
// Close peer connection
|
||||||
|
if(this.mainPeer) {
|
||||||
|
this.mainPeer.destroy();
|
||||||
|
delete this.mainPeer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release user media
|
||||||
|
if(this.mainStream) {
|
||||||
|
this.mainStream.getTracks().forEach(e => e.stop())
|
||||||
|
delete this.mainStream
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start to receive video from remote peer
|
* Start to receive video from remote peer
|
||||||
*
|
*
|
||||||
@ -729,8 +748,6 @@ class CallWindow extends CustomEvents {
|
|||||||
callID: this.callID,
|
callID: this.callID,
|
||||||
peerID: peerID,
|
peerID: peerID,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(peer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user