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 'develop' into feed
This commit is contained in:
@@ -340,8 +340,8 @@ export class MatrixCall extends EventEmitter {
|
||||
logger.debug("placeVoiceCall");
|
||||
this.checkForErrorListener();
|
||||
const constraints = getUserMediaContraints(ConstraintsType.Audio);
|
||||
await this.placeCallWithConstraints(constraints);
|
||||
this.type = CallType.Voice;
|
||||
await this.placeCallWithConstraints(constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,8 +352,8 @@ export class MatrixCall extends EventEmitter {
|
||||
logger.debug("placeVideoCall");
|
||||
this.checkForErrorListener();
|
||||
const constraints = getUserMediaContraints(ConstraintsType.Video);
|
||||
await this.placeCallWithConstraints(constraints);
|
||||
this.type = CallType.Video;
|
||||
await this.placeCallWithConstraints(constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,6 +595,8 @@ export class MatrixCall extends EventEmitter {
|
||||
|
||||
logger.debug("Ending call " + this.callId);
|
||||
this.terminate(CallParty.Local, reason, !suppressEvent);
|
||||
// We don't want to send hangup here if we didn't even get to sending an invite
|
||||
if (this.state === CallState.WaitLocalMedia) return;
|
||||
const content = {};
|
||||
// Continue to send no reason for user hangups temporarily, until
|
||||
// clients understand the user_hangup reason (voip v1)
|
||||
@@ -1373,7 +1375,10 @@ export class MatrixCall extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
async transfer(targetUserId: string, targetRoomId?: string) {
|
||||
/*
|
||||
* Transfers this call to another user
|
||||
*/
|
||||
async transfer(targetUserId: string) {
|
||||
// Fetch the target user's global profile info: their room avatar / displayname
|
||||
// could be different in whatever room we shae with them.
|
||||
const profileInfo = await this.client.getProfileInfo(targetUserId);
|
||||
@@ -1390,9 +1395,49 @@ export class MatrixCall extends EventEmitter {
|
||||
create_call: replacementId,
|
||||
} as MCallReplacesEvent;
|
||||
|
||||
if (targetRoomId) body.target_room = targetRoomId;
|
||||
await this.sendVoipEvent(EventType.CallReplaces, body);
|
||||
|
||||
return this.sendVoipEvent(EventType.CallReplaces, body);
|
||||
await this.terminate(CallParty.Local, CallErrorCode.Replaced, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Transfers this call to the target call, effectively 'joining' the
|
||||
* two calls (so the remote parties on each call are connected together).
|
||||
*/
|
||||
async transferToCall(transferTargetCall?: MatrixCall) {
|
||||
const targetProfileInfo = await this.client.getProfileInfo(transferTargetCall.getOpponentMember().userId);
|
||||
const transfereeProfileInfo = await this.client.getProfileInfo(this.getOpponentMember().userId);
|
||||
|
||||
const newCallId = genCallID();
|
||||
|
||||
const bodyToTransferTarget = {
|
||||
// the replacements on each side have their own ID, and it's distinct from the
|
||||
// ID of the new call (but we can use the same function to generate it)
|
||||
replacement_id: genCallID(),
|
||||
target_user: {
|
||||
id: this.getOpponentMember().userId,
|
||||
display_name: transfereeProfileInfo.display_name,
|
||||
avatar_url: transfereeProfileInfo.avatar_url,
|
||||
},
|
||||
await_call: newCallId,
|
||||
} as MCallReplacesEvent;
|
||||
|
||||
await transferTargetCall.sendVoipEvent(EventType.CallReplaces, bodyToTransferTarget);
|
||||
|
||||
const bodyToTransferee = {
|
||||
replacement_id: genCallID(),
|
||||
target_user: {
|
||||
id: transferTargetCall.getOpponentMember().userId,
|
||||
display_name: targetProfileInfo.display_name,
|
||||
avatar_url: targetProfileInfo.avatar_url,
|
||||
},
|
||||
create_call: newCallId,
|
||||
} as MCallReplacesEvent;
|
||||
|
||||
await this.sendVoipEvent(EventType.CallReplaces, bodyToTransferee);
|
||||
|
||||
await this.terminate(CallParty.Local, CallErrorCode.Replaced, true);
|
||||
await transferTargetCall.terminate(CallParty.Local, CallErrorCode.Replaced, true);
|
||||
}
|
||||
|
||||
private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) {
|
||||
|
||||
Reference in New Issue
Block a user