You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Merge branch 'feed' into feed-audio
This commit is contained in:
@@ -479,6 +479,7 @@ export class MatrixCall extends EventEmitter {
|
||||
this.chooseOpponent(event);
|
||||
try {
|
||||
await this.peerConn.setRemoteDescription(invite.offer);
|
||||
await this.addBufferedIceCandidates();
|
||||
} catch (e) {
|
||||
logger.debug("Failed to set remote description", e);
|
||||
this.terminate(CallParty.Local, CallErrorCode.SetRemoteDescription, false);
|
||||
@@ -883,7 +884,7 @@ export class MatrixCall extends EventEmitter {
|
||||
private gotLocalIceCandidate = (event: RTCPeerConnectionIceEvent) => {
|
||||
if (event.candidate) {
|
||||
logger.debug(
|
||||
"Got local ICE " + event.candidate.sdpMid + " candidate: " +
|
||||
"Call " + this.callId + " got local ICE " + event.candidate.sdpMid + " candidate: " +
|
||||
event.candidate.candidate,
|
||||
);
|
||||
|
||||
@@ -917,7 +918,7 @@ export class MatrixCall extends EventEmitter {
|
||||
}
|
||||
};
|
||||
|
||||
onRemoteIceCandidatesReceived(ev: MatrixEvent) {
|
||||
async onRemoteIceCandidatesReceived(ev: MatrixEvent) {
|
||||
if (this.callHasEnded()) {
|
||||
//debuglog("Ignoring remote ICE candidate because call has ended");
|
||||
return;
|
||||
@@ -949,7 +950,7 @@ export class MatrixCall extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addIceCandidates(cands);
|
||||
await this.addIceCandidates(cands);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -957,7 +958,10 @@ export class MatrixCall extends EventEmitter {
|
||||
* @param {Object} msg
|
||||
*/
|
||||
async onAnswerReceived(event: MatrixEvent) {
|
||||
logger.debug(`Got answer for call ID ${this.callId} from party ID ${event.getContent().party_id}`);
|
||||
|
||||
if (this.callHasEnded()) {
|
||||
logger.debug(`Ignoring answer because call ID ${this.callId} has ended`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -970,6 +974,7 @@ export class MatrixCall extends EventEmitter {
|
||||
}
|
||||
|
||||
this.chooseOpponent(event);
|
||||
await this.addBufferedIceCandidates();
|
||||
|
||||
this.setState(CallState.Connecting);
|
||||
|
||||
@@ -1549,6 +1554,8 @@ export class MatrixCall extends EventEmitter {
|
||||
// I choo-choo-choose you
|
||||
const msg = ev.getContent();
|
||||
|
||||
logger.debug(`Choosing party ID ${msg.party_id} for call ID ${this.callId}`);
|
||||
|
||||
this.opponentVersion = msg.version;
|
||||
if (this.opponentVersion === 0) {
|
||||
// set to null to indicate that we've chosen an opponent, but because
|
||||
@@ -1562,30 +1569,32 @@ export class MatrixCall extends EventEmitter {
|
||||
}
|
||||
this.opponentCaps = msg.capabilities || {};
|
||||
this.opponentMember = ev.sender;
|
||||
}
|
||||
|
||||
private async addBufferedIceCandidates() {
|
||||
const bufferedCands = this.remoteCandidateBuffer.get(this.opponentPartyId);
|
||||
if (bufferedCands) {
|
||||
logger.info(`Adding ${bufferedCands.length} buffered candidates for opponent ${this.opponentPartyId}`);
|
||||
this.addIceCandidates(bufferedCands);
|
||||
await this.addIceCandidates(bufferedCands);
|
||||
}
|
||||
this.remoteCandidateBuffer = null;
|
||||
}
|
||||
|
||||
private addIceCandidates(cands: RTCIceCandidate[]) {
|
||||
private async addIceCandidates(cands: RTCIceCandidate[]) {
|
||||
for (const cand of cands) {
|
||||
if (
|
||||
(cand.sdpMid === null || cand.sdpMid === undefined) &&
|
||||
(cand.sdpMLineIndex === null || cand.sdpMLineIndex === undefined)
|
||||
) {
|
||||
logger.debug("Ignoring remote ICE candidate with no sdpMid or sdpMLineIndex");
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
logger.debug("Got remote ICE " + cand.sdpMid + " candidate: " + cand.candidate);
|
||||
logger.debug("Call " + this.callId + " got remote ICE " + cand.sdpMid + " candidate: " + cand.candidate);
|
||||
try {
|
||||
this.peerConn.addIceCandidate(cand);
|
||||
await this.peerConn.addIceCandidate(cand);
|
||||
} catch (err) {
|
||||
if (!this.ignoreOffer) {
|
||||
logger.info("Failed to add remore ICE candidate", err);
|
||||
logger.info("Failed to add remote ICE candidate", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user