send a pre offer to the PNServer for video calls

pull/2015/head
Audric Ackermann 3 years ago
parent 8618cf75e9
commit 8468598b3a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -26,6 +26,13 @@ export async function handleCallMessage(
return;
}
if (type === SignalService.CallMessage.Type.PRE_OFFER) {
await removeFromCache(envelope);
window.log.info('Skipping callMessage PRE_OFFER');
return;
}
if (type === SignalService.CallMessage.Type.OFFER) {
if (Math.max(sentTimestamp - (Date.now() - currentOffset)) > TTL_DEFAULT.CALL_MESSAGE) {
window?.log?.info('Dropping incoming OFFER callMessage sent a while ago: ', sentTimestamp);

@ -29,6 +29,7 @@ export class CallMessage extends ContentMessage {
// this does not make any sense
if (
this.type !== signalservice.CallMessage.Type.END_CALL &&
this.type !== signalservice.CallMessage.Type.PRE_OFFER &&
(!this.sdps || this.sdps.length === 0)
) {
throw new Error('sdps must be set unless this is a END_CALL type message');

@ -1,5 +1,5 @@
import _ from 'lodash';
import { ToastUtils } from '.';
import { MessageUtils, ToastUtils } from '.';
import { getCallMediaPermissionsSettings } from '../../components/session/settings/SessionSettings';
import { getConversationById } from '../../data/data';
import { ConversationModel } from '../../models/conversation';
@ -16,10 +16,11 @@ import {
import { getConversationController } from '../conversations';
import { CallMessage } from '../messages/outgoing/controlMessage/CallMessage';
import { ed25519Str } from '../onions/onionPath';
import { getMessageQueue } from '../sending';
import { getMessageQueue, MessageSender } from '../sending';
import { PubKey } from '../types';
import { v4 as uuidv4 } from 'uuid';
import { PnServer } from '../../pushnotification';
export type InputItem = { deviceId: string; label: string };
@ -373,6 +374,18 @@ export async function USER_callRecipient(recipient: string) {
}
currentCallUUID = uuidv4();
peerConnection = createOrGetPeerConnection(recipient, true);
// send a pre offer just to wake up the device on the remote side
const preOfferMsg = new CallMessage({
timestamp: Date.now(),
type: SignalService.CallMessage.Type.PRE_OFFER,
uuid: currentCallUUID,
});
window.log.info('Sending preOffer message to ', ed25519Str(recipient));
const rawMessage = await MessageUtils.toRawMessage(PubKey.cast(recipient), preOfferMsg);
const { wrappedEnvelope } = await MessageSender.send(rawMessage);
await PnServer.notifyPnServer(wrappedEnvelope, recipient);
await openMediaDevicesAndAddTracks();
}

Loading…
Cancel
Save