calling: add support for multiple ice server groups in GetIceServers
Co-authored-by: adel-signal <adel@signal.org>
This commit is contained in:
parent
80d7b0bf29
commit
9da1685dba
2 changed files with 39 additions and 15 deletions
|
@ -88,7 +88,10 @@ import * as durations from '../util/durations';
|
||||||
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
|
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
|
||||||
import { fetchMembershipProof, getMembershipList } from '../groups';
|
import { fetchMembershipProof, getMembershipList } from '../groups';
|
||||||
import type { ProcessedEnvelope } from '../textsecure/Types.d';
|
import type { ProcessedEnvelope } from '../textsecure/Types.d';
|
||||||
import type { GetIceServersResultType } from '../textsecure/WebAPI';
|
import type {
|
||||||
|
GetIceServersResultType,
|
||||||
|
IceServerGroupType,
|
||||||
|
} from '../textsecure/WebAPI';
|
||||||
import { missingCaseError } from '../util/missingCaseError';
|
import { missingCaseError } from '../util/missingCaseError';
|
||||||
import { normalizeGroupCallTimestamp } from '../util/ringrtc/normalizeGroupCallTimestamp';
|
import { normalizeGroupCallTimestamp } from '../util/ringrtc/normalizeGroupCallTimestamp';
|
||||||
import {
|
import {
|
||||||
|
@ -3144,20 +3147,32 @@ export class CallingClass {
|
||||||
function iceServerConfigToList(
|
function iceServerConfigToList(
|
||||||
iceServerConfig: GetIceServersResultType
|
iceServerConfig: GetIceServersResultType
|
||||||
): Array<IceServer> {
|
): Array<IceServer> {
|
||||||
return [
|
function mapConfig(
|
||||||
{
|
iceServerGroup: GetIceServersResultType | IceServerGroupType
|
||||||
hostname: iceServerConfig.hostname ?? '',
|
): Array<IceServer> {
|
||||||
username: iceServerConfig.username,
|
if (!iceServerGroup.username || !iceServerGroup.password) {
|
||||||
password: iceServerConfig.password,
|
return [];
|
||||||
urls: (iceServerConfig.urlsWithIps ?? []).slice(),
|
}
|
||||||
},
|
|
||||||
{
|
return [
|
||||||
hostname: '',
|
{
|
||||||
username: iceServerConfig.username,
|
hostname: iceServerGroup.hostname ?? '',
|
||||||
password: iceServerConfig.password,
|
username: iceServerGroup.username,
|
||||||
urls: (iceServerConfig.urls ?? []).slice(),
|
password: iceServerGroup.password,
|
||||||
},
|
urls: (iceServerGroup.urlsWithIps ?? []).slice(),
|
||||||
];
|
},
|
||||||
|
{
|
||||||
|
hostname: '',
|
||||||
|
username: iceServerGroup.username,
|
||||||
|
password: iceServerGroup.password,
|
||||||
|
urls: (iceServerGroup.urls ?? []).slice(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [iceServerConfig]
|
||||||
|
.concat(iceServerConfig.iceServers ?? [])
|
||||||
|
.flatMap(mapConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.textsecure.messaging) {
|
if (!window.textsecure.messaging) {
|
||||||
|
|
|
@ -857,6 +857,15 @@ export type GetAccountForUsernameResultType = z.infer<
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type GetIceServersResultType = Readonly<{
|
export type GetIceServersResultType = Readonly<{
|
||||||
|
username?: string;
|
||||||
|
password?: string;
|
||||||
|
urls?: ReadonlyArray<string>;
|
||||||
|
urlsWithIps?: ReadonlyArray<string>;
|
||||||
|
hostname?: string;
|
||||||
|
iceServers?: ReadonlyArray<IceServerGroupType>;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export type IceServerGroupType = Readonly<{
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
urls?: ReadonlyArray<string>;
|
urls?: ReadonlyArray<string>;
|
||||||
|
|
Loading…
Reference in a new issue