You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Revert "Revert "Fix glare related regressions""
This reverts commit 4c552cc350.
This commit is contained in:
@@ -535,6 +535,7 @@ export class MatrixCall extends EventEmitter {
|
|||||||
this.emit(CallEvent.FeedsChanged, this.feeds);
|
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
|
// why do we enable audio (and only audio) tracks here? -- matthew
|
||||||
setTracksEnabled(stream.getAudioTracks(), true);
|
setTracksEnabled(stream.getAudioTracks(), true);
|
||||||
|
|
||||||
@@ -708,8 +709,6 @@ export class MatrixCall extends EventEmitter {
|
|||||||
this.getUserMediaFailed(e);
|
this.getUserMediaFailed(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (this.localUsermediaStream) {
|
|
||||||
this.gotUserMediaForAnswer(this.localUsermediaStream);
|
|
||||||
} else if (this.waitForLocalAVStream) {
|
} else if (this.waitForLocalAVStream) {
|
||||||
this.setState(CallState.WaitLocalMedia);
|
this.setState(CallState.WaitLocalMedia);
|
||||||
}
|
}
|
||||||
@@ -721,14 +720,10 @@ export class MatrixCall extends EventEmitter {
|
|||||||
* @param {MatrixCall} newCall The new call.
|
* @param {MatrixCall} newCall The new call.
|
||||||
*/
|
*/
|
||||||
replacedBy(newCall: MatrixCall) {
|
replacedBy(newCall: MatrixCall) {
|
||||||
logger.debug(this.callId + " being replaced by " + newCall.callId);
|
|
||||||
if (this.state === CallState.WaitLocalMedia) {
|
if (this.state === CallState.WaitLocalMedia) {
|
||||||
logger.debug("Telling new call to wait for local media");
|
logger.debug("Telling new call to wait for local media");
|
||||||
newCall.waitForLocalAVStream = true;
|
newCall.waitForLocalAVStream = true;
|
||||||
} else if (this.state === CallState.CreateOffer) {
|
} else if ([CallState.CreateOffer, CallState.InviteSent].includes(this.state)) {
|
||||||
logger.debug("Handing local stream to new call");
|
|
||||||
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
|
|
||||||
} else if (this.state === CallState.InviteSent) {
|
|
||||||
logger.debug("Handing local stream to new call");
|
logger.debug("Handing local stream to new call");
|
||||||
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
|
newCall.gotUserMediaForAnswer(this.localUsermediaStream);
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1024,6 @@ export class MatrixCall extends EventEmitter {
|
|||||||
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
|
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
|
||||||
this.setState(CallState.CreateOffer);
|
this.setState(CallState.CreateOffer);
|
||||||
|
|
||||||
logger.info("Got local AV stream with id " + this.localUsermediaStream.id);
|
|
||||||
logger.debug("gotUserMediaForInvite -> " + this.type);
|
logger.debug("gotUserMediaForInvite -> " + this.type);
|
||||||
// Now we wait for the negotiationneeded event
|
// Now we wait for the negotiationneeded event
|
||||||
};
|
};
|
||||||
@@ -1087,9 +1081,6 @@ export class MatrixCall extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
|
this.pushLocalFeed(stream, SDPStreamMetadataPurpose.Usermedia);
|
||||||
|
|
||||||
logger.info("Got local AV stream with id " + this.localUsermediaStream.id);
|
|
||||||
|
|
||||||
this.setState(CallState.CreateAnswer);
|
this.setState(CallState.CreateAnswer);
|
||||||
|
|
||||||
let myAnswer;
|
let myAnswer;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class CallEventHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.handleCallEvent(e);
|
await this.handleCallEvent(e);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("Caught exception handling call event", e);
|
logger.error("Caught exception handling call event", e);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ export class CallEventHandler {
|
|||||||
|
|
||||||
if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
|
if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
|
||||||
// add an event listener for once the event is decrypted.
|
// add an event listener for once the event is decrypted.
|
||||||
event.once("Event.decrypted", () => {
|
event.once("Event.decrypted", async () => {
|
||||||
if (!this.eventIsACall(event)) return;
|
if (!this.eventIsACall(event)) return;
|
||||||
|
|
||||||
if (this.callEventBuffer.includes(event)) {
|
if (this.callEventBuffer.includes(event)) {
|
||||||
@@ -110,7 +110,7 @@ export class CallEventHandler {
|
|||||||
// This one wasn't buffered so just run the event handler for it
|
// This one wasn't buffered so just run the event handler for it
|
||||||
// straight away
|
// straight away
|
||||||
try {
|
try {
|
||||||
this.handleCallEvent(event);
|
await this.handleCallEvent(event);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("Caught exception handling call event", e);
|
logger.error("Caught exception handling call event", e);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ export class CallEventHandler {
|
|||||||
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
|
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleCallEvent(event: MatrixEvent) {
|
private async handleCallEvent(event: MatrixEvent) {
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
const type = event.getType() as EventType;
|
const type = event.getType() as EventType;
|
||||||
const weSentTheEvent = event.getSender() === this.client.credentials.userId;
|
const weSentTheEvent = event.getSender() === this.client.credentials.userId;
|
||||||
@@ -169,7 +169,7 @@ export class CallEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call.callId = content.call_id;
|
call.callId = content.call_id;
|
||||||
call.initWithInvite(event);
|
await call.initWithInvite(event);
|
||||||
this.calls.set(call.callId, call);
|
this.calls.set(call.callId, call);
|
||||||
|
|
||||||
// if we stashed candidate events for that call ID, play them back now
|
// if we stashed candidate events for that call ID, play them back now
|
||||||
@@ -201,9 +201,11 @@ export class CallEventHandler {
|
|||||||
// we've got an invite, pick the incoming call because we know
|
// we've got an invite, pick the incoming call because we know
|
||||||
// we haven't sent our invite yet otherwise, pick whichever
|
// we haven't sent our invite yet otherwise, pick whichever
|
||||||
// call has the lowest call ID (by string comparison)
|
// call has the lowest call ID (by string comparison)
|
||||||
if (existingCall.state === CallState.WaitLocalMedia ||
|
if (
|
||||||
existingCall.state === CallState.CreateOffer ||
|
existingCall.state === CallState.WaitLocalMedia ||
|
||||||
existingCall.callId > call.callId) {
|
existingCall.state === CallState.CreateOffer ||
|
||||||
|
existingCall.callId > call.callId
|
||||||
|
) {
|
||||||
logger.log(
|
logger.log(
|
||||||
"Glare detected: answering incoming call " + call.callId +
|
"Glare detected: answering incoming call " + call.callId +
|
||||||
" and canceling outgoing call " + existingCall.callId,
|
" and canceling outgoing call " + existingCall.callId,
|
||||||
|
|||||||
Reference in New Issue
Block a user