different streams never have the same id, even for same devices

This commit is contained in:
Bruno Windels 2022-07-07 15:47:09 +02:00
parent 2f08cd8984
commit e9649ec7c2
2 changed files with 4 additions and 15 deletions

View file

@ -40,8 +40,6 @@ export class LocalMedia {
/** @internal */ /** @internal */
replaceClone(oldClone: LocalMedia | undefined, oldOriginal: LocalMedia | undefined): LocalMedia { 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 => { const cloneOrAdoptStream = (oldOriginalStream: Stream | undefined, oldCloneStream: Stream | undefined, newStream: Stream | undefined): Stream | undefined => {
let stream; let stream;
if (oldOriginalStream?.id === newStream?.id) { if (oldOriginalStream?.id === newStream?.id) {
@ -63,16 +61,8 @@ export class LocalMedia {
} }
dispose() { dispose() {
this.stopExcept(undefined); getStreamAudioTrack(this.userMedia)?.stop();
} getStreamVideoTrack(this.userMedia)?.stop();
getStreamVideoTrack(this.screenShare)?.stop();
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();
}
} }
} }

View file

@ -175,8 +175,7 @@ export class GroupCall extends EventEmitter<{change: never}> {
await Promise.all(Array.from(this._members.values()).map(m => { await Promise.all(Array.from(this._members.values()).map(m => {
return m.setMedia(localMedia, oldMedia); return m.setMedia(localMedia, oldMedia);
})); }));
oldMedia?.dispose();
oldMedia?.stopExcept(localMedia);
} }
} }