From e9649ec7c2dbc0f69ef3719f0b77ede611feb31b Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Thu, 7 Jul 2022 15:47:09 +0200 Subject: [PATCH] different streams never have the same id, even for same devices --- src/matrix/calls/LocalMedia.ts | 16 +++------------- src/matrix/calls/group/GroupCall.ts | 3 +-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/matrix/calls/LocalMedia.ts b/src/matrix/calls/LocalMedia.ts index 90a257fb..f02cd11b 100644 --- a/src/matrix/calls/LocalMedia.ts +++ b/src/matrix/calls/LocalMedia.ts @@ -40,8 +40,6 @@ export class LocalMedia { /** @internal */ replaceClone(oldClone: LocalMedia | undefined, oldOriginal: LocalMedia | undefined): LocalMedia { - let userMedia; - let screenShare; const cloneOrAdoptStream = (oldOriginalStream: Stream | undefined, oldCloneStream: Stream | undefined, newStream: Stream | undefined): Stream | undefined => { let stream; if (oldOriginalStream?.id === newStream?.id) { @@ -63,16 +61,8 @@ export class LocalMedia { } dispose() { - this.stopExcept(undefined); - } - - stopExcept(newMedia: LocalMedia | undefined) { - if(newMedia?.userMedia?.id !== this.userMedia?.id) { - getStreamAudioTrack(this.userMedia)?.stop(); - getStreamVideoTrack(this.userMedia)?.stop(); - } - if(newMedia?.screenShare?.id !== this.screenShare?.id) { - getStreamVideoTrack(this.screenShare)?.stop(); - } + getStreamAudioTrack(this.userMedia)?.stop(); + getStreamVideoTrack(this.userMedia)?.stop(); + getStreamVideoTrack(this.screenShare)?.stop(); } } diff --git a/src/matrix/calls/group/GroupCall.ts b/src/matrix/calls/group/GroupCall.ts index 32052cc3..07aa2a08 100644 --- a/src/matrix/calls/group/GroupCall.ts +++ b/src/matrix/calls/group/GroupCall.ts @@ -175,8 +175,7 @@ export class GroupCall extends EventEmitter<{change: never}> { await Promise.all(Array.from(this._members.values()).map(m => { return m.setMedia(localMedia, oldMedia); })); - - oldMedia?.stopExcept(localMedia); + oldMedia?.dispose(); } }