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 glare related regressions #1851

Merged
merged 7 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 2 additions & 11 deletions src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ export class MatrixCall extends EventEmitter {
this.emit(CallEvent.FeedsChanged, this.feeds);
}

// TODO: Find out what is going on here
// why do we enable audio (and only audio) tracks here? -- matthew
setTracksEnabled(stream.getAudioTracks(), true);

Expand Down Expand Up @@ -708,8 +709,6 @@ export class MatrixCall extends EventEmitter {
this.getUserMediaFailed(e);
return;
}
} else if (this.localUsermediaStream) {
this.gotUserMediaForAnswer(this.localUsermediaStream);
} else if (this.waitForLocalAVStream) {
this.setState(CallState.WaitLocalMedia);
}
Expand All @@ -721,14 +720,10 @@ export class MatrixCall extends EventEmitter {
* @param {MatrixCall} newCall The new call.
*/
replacedBy(newCall: MatrixCall) {
logger.debug(this.callId + " being replaced by " + newCall.callId);
if (this.state === CallState.WaitLocalMedia) {
logger.debug("Telling new call to wait for local media");
newCall.waitForLocalAVStream = true;
} else if (this.state === CallState.CreateOffer) {
logger.debug("Handing local stream to new call");
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
} else if (this.state === CallState.InviteSent) {
} else if ([CallState.CreateOffer, CallState.InviteSent].includes(this.state)) {
logger.debug("Handing local stream to new call");
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
}
Expand Down Expand Up @@ -1029,7 +1024,6 @@ export class MatrixCall extends EventEmitter {
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
this.setState(CallState.CreateOffer);

logger.info("Got local AV stream with id " + this.localUsermediaStream.id);
logger.debug("gotUserMediaForInvite -> " + this.type);
// Now we wait for the negotiationneeded event
};
Expand Down Expand Up @@ -1087,9 +1081,6 @@ export class MatrixCall extends EventEmitter {
}

this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);

logger.info("Got local AV stream with id " + this.localUsermediaStream.id);

this.setState(CallState.CreateAnswer);

let myAnswer;
Expand Down
12 changes: 7 additions & 5 deletions src/webrtc/callEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class CallEventHandler {
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
}

private handleCallEvent(event: MatrixEvent) {
private async handleCallEvent(event: MatrixEvent) {
const content = event.getContent();
const type = event.getType() as EventType;
const weSentTheEvent = event.getSender() === this.client.credentials.userId;
Expand Down Expand Up @@ -169,7 +169,7 @@ export class CallEventHandler {
}

call.callId = content.call_id;
call.initWithInvite(event);
await call.initWithInvite(event);
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
this.calls.set(call.callId, call);

// if we stashed candidate events for that call ID, play them back now
Expand Down Expand Up @@ -201,9 +201,11 @@ export class CallEventHandler {
// we've got an invite, pick the incoming call because we know
// we haven't sent our invite yet otherwise, pick whichever
// call has the lowest call ID (by string comparison)
if (existingCall.state === CallState.WaitLocalMedia ||
existingCall.state === CallState.CreateOffer ||
existingCall.callId > call.callId) {
if (
existingCall.state === CallState.WaitLocalMedia ||
existingCall.state === CallState.CreateOffer ||
existingCall.callId > call.callId
) {
logger.log(
"Glare detected: answering incoming call " + call.callId +
" and canceling outgoing call " + existingCall.callId,
Expand Down