Calls: Fix phone calls (#4406)
This commit is contained in:
parent
13ca4d74aa
commit
3dbef9802f
@ -5,8 +5,8 @@ import type { MediaContent, MediaStateMessage, P2pMessage } from './p2pMessage';
|
|||||||
import {
|
import {
|
||||||
fromTelegramSource,
|
fromTelegramSource,
|
||||||
IS_ECHO_CANCELLATION_SUPPORTED,
|
IS_ECHO_CANCELLATION_SUPPORTED,
|
||||||
IS_NOISE_SUPPRESSION_SUPPORTED, isRelayAddress,
|
IS_NOISE_SUPPRESSION_SUPPORTED,
|
||||||
p2pPayloadTypeToConference, removeRelatedAddress,
|
p2pPayloadTypeToConference,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import buildSdp, { Conference } from './buildSdp';
|
import buildSdp, { Conference } from './buildSdp';
|
||||||
import { StreamType } from './secretsauce';
|
import { StreamType } from './secretsauce';
|
||||||
@ -38,6 +38,8 @@ type P2pState = {
|
|||||||
|
|
||||||
let state: P2pState | undefined;
|
let state: P2pState | undefined;
|
||||||
|
|
||||||
|
const ICE_CANDIDATE_POOL_SIZE = 10;
|
||||||
|
|
||||||
export function getStreams() {
|
export function getStreams() {
|
||||||
return state?.streams;
|
return state?.streams;
|
||||||
}
|
}
|
||||||
@ -189,7 +191,8 @@ export async function joinPhoneCall(
|
|||||||
}
|
}
|
||||||
)),
|
)),
|
||||||
iceTransportPolicy: isP2p ? 'all' : 'relay',
|
iceTransportPolicy: isP2p ? 'all' : 'relay',
|
||||||
bundlePolicy: 'max-bundle'
|
bundlePolicy: 'max-bundle',
|
||||||
|
iceCandidatePoolSize: ICE_CANDIDATE_POOL_SIZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
conn.onicecandidate = (e) => {
|
conn.onicecandidate = (e) => {
|
||||||
@ -463,9 +466,8 @@ export async function processSignalingMessage(message: P2pMessage) {
|
|||||||
|
|
||||||
if (!isOutgoing) {
|
if (!isOutgoing) {
|
||||||
const answer = await connection.createAnswer();
|
const answer = await connection.createAnswer();
|
||||||
if (!answer) return;
|
|
||||||
await connection.setLocalDescription(answer);
|
await connection.setLocalDescription(answer);
|
||||||
sendInitialSetup(parseSdp(answer, true) as P2pParsedSdp);
|
sendInitialSetup(parseSdp(connection.localDescription!, true) as P2pParsedSdp);
|
||||||
}
|
}
|
||||||
state.gotInitialSetup = true;
|
state.gotInitialSetup = true;
|
||||||
await commitPendingIceCandidates();
|
await commitPendingIceCandidates();
|
||||||
@ -497,8 +499,8 @@ async function tryAddCandidate(connection: RTCPeerConnection, candidate: string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createOffer(pc: RTCPeerConnection, params: RTCOfferOptions) {
|
async function createOffer(conn: RTCPeerConnection, params: RTCOfferOptions) {
|
||||||
const offer = await pc.createOffer(params);
|
const offer = await conn.createOffer(params);
|
||||||
sendInitialSetup(parseSdp(offer, true) as P2pParsedSdp);
|
await conn.setLocalDescription(offer);
|
||||||
await pc.setLocalDescription(offer);
|
sendInitialSetup(parseSdp(conn.localDescription!, true) as P2pParsedSdp);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user