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);