From 590e9500c179b7d5238cdd60abfc7b9e24163716 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:33:16 +0100 Subject: [PATCH 1/2] clone localMedia,so we don't remove audio track from stream sent to peer --- src/matrix/calls/LocalMedia.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix/calls/LocalMedia.ts b/src/matrix/calls/LocalMedia.ts index 7a673ba9..adecfc18 100644 --- a/src/matrix/calls/LocalMedia.ts +++ b/src/matrix/calls/LocalMedia.ts @@ -43,7 +43,7 @@ export class LocalMedia { * Create an instance of LocalMedia without audio track (for user preview) */ asPreview(): LocalMedia { - const media = new LocalMedia(this.userMedia, this.screenShare, this.dataChannelOptions); + const media = this.clone(); const userMedia = media.userMedia; if (userMedia && userMedia.getVideoTracks().length > 0) { const audioTrack = getStreamAudioTrack(userMedia); From 2bd37970ba8a8267545378a407057c317fa6aa1a Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:34:15 +0100 Subject: [PATCH 2/2] each LocalMedia own their streams, so a copy should have their own clone --- src/matrix/calls/LocalMedia.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/matrix/calls/LocalMedia.ts b/src/matrix/calls/LocalMedia.ts index adecfc18..b7a14a9a 100644 --- a/src/matrix/calls/LocalMedia.ts +++ b/src/matrix/calls/LocalMedia.ts @@ -28,15 +28,15 @@ export class LocalMedia { ) {} withUserMedia(stream: Stream) { - return new LocalMedia(stream, this.screenShare, this.dataChannelOptions); + return new LocalMedia(stream, this.screenShare?.clone(), this.dataChannelOptions); } withScreenShare(stream: Stream) { - return new LocalMedia(this.userMedia, stream, this.dataChannelOptions); + return new LocalMedia(this.userMedia?.clone(), stream, this.dataChannelOptions); } withDataChannel(options: RTCDataChannelInit): LocalMedia { - return new LocalMedia(this.userMedia, this.screenShare, options); + return new LocalMedia(this.userMedia?.clone(), this.screenShare?.clone(), options); } /**