From f187a51c97ea09c8c8af90136eb8fe64b6f14337 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Thu, 7 Jul 2022 15:36:30 +0200 Subject: [PATCH] stop replaced track in PeerCall --- src/matrix/calls/LocalMedia.ts | 11 +---------- src/matrix/calls/PeerCall.ts | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/matrix/calls/LocalMedia.ts b/src/matrix/calls/LocalMedia.ts index 922e6861..90a257fb 100644 --- a/src/matrix/calls/LocalMedia.ts +++ b/src/matrix/calls/LocalMedia.ts @@ -47,16 +47,7 @@ export class LocalMedia { if (oldOriginalStream?.id === newStream?.id) { return oldCloneStream; } else { - const clonedStream = newStream?.clone(); - // clonedStream.addEventListener("removetrack", evt => { - // console.log(`removing track ${evt.track.id} (${evt.track.kind}) from clonedStream ${clonedStream.id}`); - // }); - // console.log("got cloned tracks", Array.from(clonedStream.getTracks()).map((t: MediaStreamTrack) => { return {kind: t.kind, id: t.id};}), "from new stream", Array.from(newStream.getTracks()).map((t: MediaStreamTrack) => { return {kind: t.kind, id: t.id};})); - // console.log("stopping old audio stream", getStreamAudioTrack(oldCloneStream)?.id); - // console.log("stopping old video stream", getStreamVideoTrack(oldCloneStream)?.id); - getStreamAudioTrack(oldCloneStream)?.stop(); - getStreamVideoTrack(oldCloneStream)?.stop(); - return clonedStream; + return newStream?.clone(); } } return new LocalMedia( diff --git a/src/matrix/calls/PeerCall.ts b/src/matrix/calls/PeerCall.ts index 29eccf2c..118e5de4 100644 --- a/src/matrix/calls/PeerCall.ts +++ b/src/matrix/calls/PeerCall.ts @@ -1007,6 +1007,7 @@ export class PeerCall implements IDisposable { if (streamToKeep !== stream) { if (oldTrack) { streamToKeep.removeTrack(oldTrack); + oldTrack.stop(); } if (newTrack) { streamToKeep.addTrack(newTrack);