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

Close all streams when a call ends #2992

Merged
merged 1 commit into from
Dec 19, 2022
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
18 changes: 10 additions & 8 deletions src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2475,18 +2475,20 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
}

private stopAllMedia(): void {
logger.debug(
!this.groupCallId
? `Call ${this.callId} stopping all media`
: `Call ${this.callId} stopping all media except local feeds`,
);
logger.debug(`Call ${this.callId} stopping all media`);

for (const feed of this.feeds) {
if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Usermedia && !this.groupCallId) {
// Slightly awkward as local feed need to go via the correct method on
// the mediahandler so they get removed from mediahandler (remote tracks
// don't)
// NB. We clone local streams when passing them to individual calls in a group
// call, so we can (and should) stop the clones once we no longer need them:
// the other clones will continue fine.
if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Usermedia) {
this.client.getMediaHandler().stopUserMediaStream(feed.stream);
} else if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Screenshare && !this.groupCallId) {
} else if (feed.isLocal() && feed.purpose === SDPStreamMetadataPurpose.Screenshare) {
this.client.getMediaHandler().stopScreensharingStream(feed.stream);
} else if (!feed.isLocal() || !this.groupCallId) {
} else if (!feed.isLocal()) {
logger.debug("Stopping remote stream", feed.stream.id);
for (const track of feed.stream.getTracks()) {
track.stop();
Expand Down