From 3e2c5049f2e633ce6357da46df629d379e9b3da6 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 8 Jun 2020 09:36:07 +0200 Subject: [PATCH] Fix to add special screen sharing --- front/src/WebRtc/MediaManager.ts | 6 +++++- front/src/WebRtc/SimplePeer.ts | 20 +++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index cfe4843a..4341c52e 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -298,7 +298,11 @@ export class MediaManager { `); - this.remoteVideo.set(userId, document.getElementById(userId)); + let activeHTMLVideoElement : HTMLElement|null = document.getElementById(userId); + if(!activeHTMLVideoElement){ + return; + } + this.remoteVideo.set(userId, (activeHTMLVideoElement as HTMLVideoElement)); } /** diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 6d39444e..f24cc31d 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -122,9 +122,11 @@ export class SimplePeer { } let screenSharing : boolean = name !== undefined && name.indexOf("screenSharing") > -1; + mediaManager.removeActiveVideo(user.userId); if(!screenSharing) { - mediaManager.removeActiveVideo(user.userId); mediaManager.addActiveVideo(user.userId, name); + }else{ + mediaManager.addScreenSharingActiveVideo(user.userId, name); } const peer : SimplePeerNamespace.Instance = new Peer({ @@ -151,22 +153,6 @@ export class SimplePeer { }); peer.on('stream', (stream: MediaStream) => { - if(screenSharing){ - //add stream video on - return; - } - - let videoActive = false; - let microphoneActive = false; - stream.getTracks().forEach((track : MediaStreamTrack) => { - if(track.kind === "audio"){ - microphoneActive = true; - } - if(track.kind === "video"){ - videoActive = true; - } - }); - this.stream(user.userId, stream); });