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

Misc fixes for group call widgets #2657

Merged
merged 4 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion src/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class RoomWidgetClient extends MatrixClient {
});
}) ?? [],
);
this.setSyncState(SyncState.Prepared);
this.setSyncState(SyncState.Syncing);
logger.info("Finished backfilling events");

// Watch for TURN servers, if requested
Expand All @@ -146,6 +146,11 @@ export class RoomWidgetClient extends MatrixClient {
this.lifecycle.abort(); // Signal to other async tasks that the client has stopped
}

public async joinRoom(roomIdOrAlias: string): Promise<Room> {
if (roomIdOrAlias === this.roomId) return this.room;
throw new Error(`Unknown room: ${roomIdOrAlias}`);
}

public async sendStateEvent(
roomId: string,
eventType: string,
Expand Down
20 changes: 13 additions & 7 deletions src/webrtc/groupCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export class GroupCall extends TypedEventEmitter<
private transmitTimer: ReturnType<typeof setTimeout> | null = null;
private memberStateExpirationTimers: Map<string, ReturnType<typeof setTimeout>> = new Map();
private resendMemberStateTimer: ReturnType<typeof setInterval> | null = null;
private initWithAudioMuted = false;
private initWithVideoMuted = false;

constructor(
private client: MatrixClient,
Expand Down Expand Up @@ -261,11 +263,6 @@ export class GroupCall extends TypedEventEmitter<
throw error;
}

// start muted on ptt calls
if (this.isPtt) {
setTracksEnabled(stream.getAudioTracks(), false);
}

const userId = this.client.getUserId();

const callFeed = new CallFeed({
Expand All @@ -274,10 +271,13 @@ export class GroupCall extends TypedEventEmitter<
userId,
stream,
purpose: SDPStreamMetadataPurpose.Usermedia,
audioMuted: stream.getAudioTracks().length === 0 || this.isPtt,
videoMuted: stream.getVideoTracks().length === 0,
audioMuted: this.initWithAudioMuted || stream.getAudioTracks().length === 0 || this.isPtt,
videoMuted: this.initWithVideoMuted || stream.getVideoTracks().length === 0,
});

setTracksEnabled(stream.getAudioTracks(), !callFeed.isAudioMuted());
setTracksEnabled(stream.getVideoTracks(), !callFeed.isVideoMuted());

this.localCallFeed = callFeed;
this.addUserMediaFeed(callFeed);

Expand Down Expand Up @@ -496,6 +496,9 @@ export class GroupCall extends TypedEventEmitter<
// given to any of the actual calls, so these tracks don't actually go
// anywhere. Let's do it anyway to avoid confusion.
setTracksEnabled(this.localCallFeed.stream.getAudioTracks(), !muted);
} else {
logger.log(`groupCall ${this.groupCallId} setMicrophoneMuted no stream muted ${muted}`);
this.initWithAudioMuted = muted;
}

for (const call of this.calls) {
Expand Down Expand Up @@ -532,6 +535,9 @@ export class GroupCall extends TypedEventEmitter<
this.localCallFeed.stream.id} muted ${muted}`);
this.localCallFeed.setAudioVideoMuted(null, muted);
setTracksEnabled(this.localCallFeed.stream.getVideoTracks(), !muted);
} else {
logger.log(`groupCall ${this.groupCallId} setLocalVideoMuted no stream muted ${muted}`);
this.initWithVideoMuted = muted;
}

for (const call of this.calls) {
Expand Down