From 1659fa400fdd2bcf047c5a83e3f3b6599814a199 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 6 Jan 2021 17:09:17 +0100 Subject: [PATCH 1/6] Increase stability to force stopped screen sharing --- front/src/WebRtc/MediaManager.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 4aa240cd..a85992ae 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -318,6 +318,8 @@ export class MediaManager { const localScreenCapture = this.localScreenCapture; this.getCamera().then((stream) => { this.triggerStoppedScreenSharingCallbacks(localScreenCapture); + }).catch(() => { //catch error get camera + this.triggerStoppedScreenSharingCallbacks(localScreenCapture); }); this.localScreenCapture = null; } From d4c7a20dfa60128eb4c16f6e0cc8e04e08d0209c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 09:42:11 +0100 Subject: [PATCH 2/6] Update feedback @moufmouf --- front/src/WebRtc/MediaManager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index a85992ae..dcb7717e 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -318,7 +318,8 @@ export class MediaManager { const localScreenCapture = this.localScreenCapture; this.getCamera().then((stream) => { this.triggerStoppedScreenSharingCallbacks(localScreenCapture); - }).catch(() => { //catch error get camera + }).catch((err) => { //catch error get camera + console.error(err); this.triggerStoppedScreenSharingCallbacks(localScreenCapture); }); this.localScreenCapture = null; From 8c89b5e0b168f5a387d174ee788376711a30864f Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 10:30:28 +0100 Subject: [PATCH 3/6] Permit to change style when getCamera was ready and permission accorded --- front/src/WebRtc/MediaManager.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index dcb7717e..18a15ab6 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -209,9 +209,10 @@ export class MediaManager { } public enableCamera() { - this.enableCameraStyle(); this.constraintsMedia.video = videoConstraint; + this.getCamera().then((stream: MediaStream) => { + this.enableCameraStyle(); this.triggerUpdatedLocalStreamCallbacks(stream); }); } @@ -228,10 +229,10 @@ export class MediaManager { } public enableMicrophone() { - this.enableMicrophoneStyle(); this.constraintsMedia.audio = true; this.getCamera().then((stream) => { + this.enableMicrophoneStyle(); this.triggerUpdatedLocalStreamCallbacks(stream); }); } From 018f01e8780b65a2c728999f100cb29f6d68bf0f Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 11:02:00 +0100 Subject: [PATCH 4/6] Increase stability camera and microphone permission --- front/src/WebRtc/MediaManager.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 18a15ab6..09378642 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -212,8 +212,16 @@ export class MediaManager { this.constraintsMedia.video = videoConstraint; this.getCamera().then((stream: MediaStream) => { + //TODO show error message tooltip upper of camera button + //TODO message : please check camera permission of your navigator + if(stream.getVideoTracks().length === 0) { + throw Error('Video track is empty, please check camera permission of your navigator') + } this.enableCameraStyle(); this.triggerUpdatedLocalStreamCallbacks(stream); + }).catch((err) => { + console.error(err); + this.disableCameraStyle(); }); } @@ -232,8 +240,16 @@ export class MediaManager { this.constraintsMedia.audio = true; this.getCamera().then((stream) => { + //TODO show error message tooltip upper of camera button + //TODO message : please check microphone permission of your navigator + if(stream.getAudioTracks().length === 0) { + throw Error('Audio track is empty, please check microphone permission of your navigator') + } this.enableMicrophoneStyle(); this.triggerUpdatedLocalStreamCallbacks(stream); + }).catch((err) => { + console.error(err); + this.disableMicrophoneStyle(); }); } From a88ad3cf4d48db66d7fcf8a4c9a3d0557cbab525 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 12:13:12 +0100 Subject: [PATCH 5/6] Dont delete PeerSharingConnection because it will be resuse When user try to screen charing with same user, the event send is not a offer but renegociation. So could clear arry only when user out of circle. --- front/src/WebRtc/SimplePeer.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 2d8e5162..08ae99fe 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -245,9 +245,11 @@ export class SimplePeer { // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. peer.destroy(); - if(!this.PeerScreenSharingConnectionArray.delete(userId)){ + + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + /*if(!this.PeerScreenSharingConnectionArray.delete(userId)){ throw 'Couln\'t delete peer screen sharing connexion'; - } + }*/ //console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size); } catch (err) { console.error("closeConnection", err) @@ -301,11 +303,13 @@ export class SimplePeer { peer.signal(data.signal); } else { console.error('Could not find peer whose ID is "'+data.userId+'" in receiveWebrtcScreenSharingSignal'); + console.info('tentative to create new peer connexion'); + this.sendLocalScreenSharingStreamToUser(data.userId); } } catch (e) { console.error(`receiveWebrtcSignal => ${data.userId}`, e); - //force delete and recreate peer connexion - this.PeerScreenSharingConnectionArray.delete(data.userId); + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + //this.PeerScreenSharingConnectionArray.delete(data.userId); this.receiveWebrtcScreenSharingSignal(data); } } @@ -416,8 +420,8 @@ export class SimplePeer { if (!PeerConnectionScreenSharing.isReceivingScreenSharingStream()) { PeerConnectionScreenSharing.destroy(); - - this.PeerScreenSharingConnectionArray.delete(userId); + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + //this.PeerScreenSharingConnectionArray.delete(userId); } } } From e8f1b2d048c64fc11a855d68a9fbf1135fc0a343 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 12:58:45 +0100 Subject: [PATCH 6/6] Add clear array peer connection sharing --- front/src/WebRtc/SimplePeer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 08ae99fe..90d260ee 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -229,6 +229,14 @@ export class SimplePeer { } catch (err) { console.error("closeConnection", err) } + + //if user left discussion, clear array peer connection of sharing + if(this.Users.length === 0) { + for (const userId of this.PeerScreenSharingConnectionArray.keys()) { + this.closeScreenSharingConnection(userId); + this.PeerScreenSharingConnectionArray.delete(userId); + } + } } /**