Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where switching media caused media in subsequent calls to fail #3489

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/webrtc/mediaHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,19 @@ export class MediaHandler extends TypedEventEmitter<
this.emit(MediaHandlerEvent.LocalStreamsChanged);

if (this.localUserMediaStream === mediaStream) {
// if we have this stream cahced, remove it, because we've stopped it
this.localUserMediaStream = undefined;
} else {
// If it's not the same stream. remove any tracks from the cached stream that
// we have just stopped, and if we do stop any, call the same method on the
// cached stream too in order to stop all its tracks (in case they are different)
// and un-cache it.
for (const track of mediaStream.getTracks()) {
if (this.localUserMediaStream?.getTrackById(track.id)) {
this.stopUserMediaStream(this.localUserMediaStream);
break;
}
}
}
}

Expand Down