You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
Allow answering calls without audio/video
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@@ -696,13 +696,34 @@ export class MatrixCall extends EventEmitter {
|
|||||||
this.setState(CallState.Ended);
|
this.setState(CallState.Ended);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private shouldAnswerWithMediaType(
|
||||||
|
wantedValue: boolean, valueOfTheOtherSide: boolean, type: "audio" | "video",
|
||||||
|
): boolean {
|
||||||
|
if (wantedValue && !valueOfTheOtherSide) {
|
||||||
|
// TODO: Figure out how to do this
|
||||||
|
logger.warn(`Unable to answer with ${type} because the other side isn't sending it either.`);
|
||||||
|
return false;
|
||||||
|
} else if (
|
||||||
|
!utils.isNullOrUndefined(wantedValue) &&
|
||||||
|
wantedValue !== valueOfTheOtherSide &&
|
||||||
|
!this.opponentSupportsSDPStreamMetadata()
|
||||||
|
) {
|
||||||
|
logger.warn(
|
||||||
|
`Unable to answer with ${type}=${wantedValue} because the other side doesn't support it. ` +
|
||||||
|
`Answering with ${type}=${valueOfTheOtherSide}.`,
|
||||||
|
);
|
||||||
|
return valueOfTheOtherSide;
|
||||||
|
}
|
||||||
|
return wantedValue ?? valueOfTheOtherSide;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answer a call.
|
* Answer a call.
|
||||||
*/
|
*/
|
||||||
public async answer(): Promise<void> {
|
public async answer(audio?: boolean, video?: boolean): Promise<void> {
|
||||||
if (this.inviteOrAnswerSent) {
|
if (this.inviteOrAnswerSent) return;
|
||||||
return;
|
// TODO: Figure out how to do this
|
||||||
}
|
if (audio === false && video === false) throw new Error("You CANNOT answer a call without media");
|
||||||
|
|
||||||
logger.debug(`Answering call ${this.callId}`);
|
logger.debug(`Answering call ${this.callId}`);
|
||||||
|
|
||||||
@@ -712,8 +733,8 @@ export class MatrixCall extends EventEmitter {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const mediaStream = await this.client.getMediaHandler().getUserMediaStream(
|
const mediaStream = await this.client.getMediaHandler().getUserMediaStream(
|
||||||
true,
|
this.shouldAnswerWithMediaType(audio, this.hasRemoteUserMediaAudioTrack, "audio"),
|
||||||
this.hasRemoteUserMediaVideoTrack,
|
this.shouldAnswerWithMediaType(video, this.hasRemoteUserMediaVideoTrack, "video"),
|
||||||
);
|
);
|
||||||
this.waitForLocalAVStream = false;
|
this.waitForLocalAVStream = false;
|
||||||
this.gotUserMediaForAnswer(mediaStream);
|
this.gotUserMediaForAnswer(mediaStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user