openvidu-browser: Fixed sendVideoData bug when peerConnection is closed

pull/609/head
csantosm 2021-02-25 15:16:18 +01:00
parent 811409d250
commit cc02fa4f7a
1 changed files with 19 additions and 16 deletions

View File

@ -1170,7 +1170,9 @@ export class Session extends EventDispatcher {
platform.isSamsungBrowser() || platform.isIonicAndroid() || (platform.isIPhoneOrIPad() && platform.isIOSWithSafari()) platform.isSamsungBrowser() || platform.isIonicAndroid() || (platform.isIPhoneOrIPad() && platform.isIOSWithSafari())
) { ) {
const obtainAndSendVideo = async () => { const obtainAndSendVideo = async () => {
const statsMap = await streamManager.stream.getRTCPeerConnection().getStats(); const pc = streamManager.stream.getRTCPeerConnection();
if (pc.connectionState === 'connected') {
const statsMap = await pc.getStats();
const arr: any[] = []; const arr: any[] = [];
statsMap.forEach(stats => { statsMap.forEach(stats => {
if (("frameWidth" in stats) && ("frameHeight" in stats) && (arr.length === 0)) { if (("frameWidth" in stats) && ("frameHeight" in stats) && (arr.length === 0)) {
@ -1190,6 +1192,7 @@ export class Session extends EventDispatcher {
}); });
} }
} }
}
if (doInterval) { if (doInterval) {
let loops = 1; let loops = 1;
this.videoDataInterval = setInterval(() => { this.videoDataInterval = setInterval(() => {