Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions apps/meteor/server/services/media-call/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall

public async processSignal(uid: IUser['_id'], signal: ClientMediaSignal): Promise<void> {
try {
logger.debug({ msg: 'new client signal', type: signal.type, uid });
callServer.receiveSignal(uid, signal);
} catch (err) {
logger.error({ msg: 'failed to process client signal', err, signal, uid });
Expand All @@ -50,8 +49,6 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall

public async processSerializedSignal(uid: IUser['_id'], signal: string): Promise<void> {
try {
logger.debug({ msg: 'new client signal', uid });

const deserialized = await this.deserializeClientSignal(signal);

callServer.receiveSignal(uid, deserialized);
Expand Down
5 changes: 5 additions & 0 deletions ee/packages/media-calls/src/internal/InternalCallProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export class InternalCallProvider extends BaseCallProvider {
await mediaCallDirector.runOnCallCreatedForAgent(call, calleeAgent, callerAgent);

if (params.parentCallId) {
logger.info({
msg: 'Transferred call was created, so the old one will be terminated',
newCallId: call._id,
oldCallId: params.parentCallId,
});
mediaCallDirector.hangupTransferredCallById(params.parentCallId).catch(() => null);
}

Expand Down
7 changes: 3 additions & 4 deletions ee/packages/media-calls/src/internal/SignalProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export class GlobalSignalProcessor {
}

public async processSignal(uid: IUser['_id'], signal: ClientMediaSignal): Promise<void> {
logger.debug({ msg: 'GlobalSignalProcessor.processSignal', signal: stripSensitiveDataFromSignal(signal), uid });

switch (signal.type) {
case 'register':
return this.processRegisterSignal(uid, signal);
Expand Down Expand Up @@ -112,6 +110,8 @@ export class GlobalSignalProcessor {
}

private async processRegisterSignal(uid: IUser['_id'], signal: ClientMediaSignalRegister): Promise<void> {
logger.debug({ msg: 'GlobalSignalProcessor.processRegisterSignal', signal: stripSensitiveDataFromSignal(signal), uid });

const calls = await MediaCalls.findAllNotOverByUid(uid).toArray();
if (!calls.length) {
return;
Expand Down Expand Up @@ -140,6 +140,7 @@ export class GlobalSignalProcessor {
// If it's signed to the same session that is now registering
// Or it was signed by a session that the current session is replacing (as in a browser refresh)
if (actor.contractId === signal.contractId || actor.contractId === signal.oldContractId) {
logger.info({ msg: 'Server detected a client refresh for a session with an active call.', callId: call._id });
await mediaCallDirector.hangupDetachedCall(call, { endedBy: { ...actor, contractId: signal.contractId }, reason: 'unknown' });
return;
}
Expand Down Expand Up @@ -207,8 +208,6 @@ export class GlobalSignalProcessor {
return null;
}

logger.debug({ msg: 'GlobalSignalProcessor.getExistingRequestedCall', uid, signal });

const caller = { type: 'user', id: uid } as const;
const rejection = { callId: requestedCallId, toContractId: signal.contractId, reason: 'invalid-call-id' } as const;

Expand Down
31 changes: 18 additions & 13 deletions ee/packages/media-calls/src/internal/agents/CallSignalProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { IMediaCallAgent } from '../../definition/IMediaCallAgent';
import { logger } from '../../logger';
import { mediaCallDirector } from '../../server/CallDirector';
import { getMediaCallServer } from '../../server/injection';
import { stripSensitiveDataFromSignal, stripSensitiveDataFromSdp } from '../../server/stripSensitiveData';
import { stripSensitiveDataFromSignal } from '../../server/stripSensitiveData';

export class UserActorSignalProcessor {
public get contractId(): string {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class UserActorSignalProcessor {
}

public async requestWebRTCOffer(params: { negotiationId: string }): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.requestWebRTCOffer', actor: this.actor });
logger.debug({ msg: 'UserActorSignalProcessor.requestWebRTCOffer', params });

await this.sendSignal({
callId: this.callId,
Expand All @@ -80,7 +80,14 @@ export class UserActorSignalProcessor {
}

public async processSignal(signal: ClientMediaSignal): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.processSignal', signal: stripSensitiveDataFromSignal(signal) });
if (signal.type !== 'local-state') {
logger.debug({
msg: 'UserActorSignalProcessor.processSignal',
signal: stripSensitiveDataFromSignal(signal),
role: this.role,
signed: this.signed,
});
}

// The code will only reach this point if one of the following conditions are true:
// 1. the signal came from the exact user session where the caller initiated the call
Expand Down Expand Up @@ -112,8 +119,6 @@ export class UserActorSignalProcessor {
}

protected async saveLocalDescription(sdp: RTCSessionDescriptionInit, negotiationId: string): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.saveLocalDescription', sdp: stripSensitiveDataFromSdp(sdp), signed: this.signed });

if (!this.signed) {
return;
}
Expand All @@ -122,8 +127,6 @@ export class UserActorSignalProcessor {
}

private async processAnswer(answer: CallAnswer): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.processAnswer', answer });

switch (answer) {
case 'ack':
return this.clientIsReachable();
Expand Down Expand Up @@ -267,8 +270,6 @@ export class UserActorSignalProcessor {
}

protected async clientIsReachable(): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.clientIsReachable', role: this.role, uid: this.actorId });

if (this.role === 'callee' && this.call.state === 'none') {
// Change the call state from 'none' to 'ringing' when any callee session is found
const ringUpdateResult = await MediaCalls.startRingingById(this.callId, mediaCallDirector.getNewExpirationTime());
Expand All @@ -288,7 +289,6 @@ export class UserActorSignalProcessor {
}

protected async clientHasRejected(): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.clientHasRejected', role: this.role, uid: this.actorId });
if (!this.isCallPending()) {
return;
}
Expand All @@ -299,7 +299,6 @@ export class UserActorSignalProcessor {
}

protected async clientIsUnavailable(): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.clientIsUnavailable', role: this.role, uid: this.actorId });
// Ignore 'unavailable' responses from unsigned clients as some other client session may have a different answer
if (!this.signed) {
return;
Expand All @@ -309,7 +308,6 @@ export class UserActorSignalProcessor {
}

protected async clientHasAccepted(): Promise<void> {
logger.debug({ msg: 'UserActorSignalProcessor.clientHasAccepted', role: this.role, uid: this.actorId });
if (!this.isCallPending()) {
return;
}
Expand All @@ -322,6 +320,7 @@ export class UserActorSignalProcessor {
protected async clientIsActive(): Promise<void> {
const result = await MediaCallChannels.setActiveById(this.channel._id);
if (result.modifiedCount) {
logger.info({ msg: 'Call Channel was flagged as active', callId: this.callId, role: this.role });
await mediaCallDirector.activate(this.call, this.agent);
}
}
Expand All @@ -345,7 +344,13 @@ export class UserActorSignalProcessor {

if (signal.clientState === 'active') {
if (signal.negotiationId) {
void MediaCallNegotiations.setStableById(signal.negotiationId).catch(() => null);
void MediaCallNegotiations.setStableById(signal.negotiationId)
.then((result) => {
if (result.modifiedCount) {
logger.info({ msg: 'Negotiation is stable', callId: signal.callId, role: this.role });
}
})
.catch(() => null);
}

if (this.channel.state === 'active' || this.channel.activeAt) {
Expand Down
14 changes: 1 addition & 13 deletions ee/packages/media-calls/src/internal/agents/UserActorAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onCallAccepted(callId: string, signedContractId: string): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onCallAccepted', callId });

await this.sendSignal({
callId,
type: 'notification',
Expand Down Expand Up @@ -50,8 +48,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onCallEnded(callId: string): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onCallEnded', callId });

return this.sendSignal({
callId,
type: 'notification',
Expand All @@ -60,8 +56,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onCallActive(callId: string): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onCallActive', callId });

return this.sendSignal({
callId,
type: 'notification',
Expand All @@ -70,8 +64,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onCallCreated(call: IMediaCall): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onCallCreated', call });

if (this.role === 'caller' && call.caller.contractId) {
// Pre-create the channel for the contractId that requested the call
await this.getOrCreateChannel(call, call.caller.contractId);
Expand All @@ -81,8 +73,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onRemoteDescriptionChanged(callId: string, negotiationId: string): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onRemoteDescriptionChanged', callId, negotiationId });

const call = await MediaCalls.findOneById(callId);
if (!call || !isBusyState(call.state)) {
return;
Expand Down Expand Up @@ -140,8 +130,6 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onCallTransferred(callId: string): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onCallTransferred', callId });

const call = await MediaCalls.findOneById(callId);
if (!call?.transferredBy || !call?.transferredTo) {
return;
Expand All @@ -163,7 +151,7 @@ export class UserActorAgent extends BaseMediaCallAgent {
}

public async onDTMF(callId: string, dtmf: string, duration: number): Promise<void> {
logger.debug({ msg: 'UserActorAgent.onDTMF', callId, dtmf, duration });
logger.debug({ msg: 'UserActorAgent.onDTMF', callId, dtmf, duration, role: this.role });
// internal calls have nothing to do with DTMFs
}
}
15 changes: 2 additions & 13 deletions ee/packages/media-calls/src/server/BroadcastAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,31 @@ export class BroadcastActorAgent extends BaseMediaCallAgent {
public provider: BaseCallProvider | null = null;

public async onCallAccepted(callId: string, _signedContractId: string): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onCallAccepted', callId });

this.reportCallUpdated({ callId });
}

public async onCallEnded(callId: string): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onCallEnded', callId });

this.reportCallUpdated({ callId });
}

public async onCallActive(callId: string): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onCallActive', callId });

this.reportCallUpdated({ callId });
}

public async onCallCreated(call: IMediaCall): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onCallCreated', call });
logger.debug({ msg: 'BroadcastActorAgent.onCallCreated', call, role: this.role });
// there's no point in broadcasting onCallCreated as it can only be called from within the call provider
}

public async onRemoteDescriptionChanged(callId: string, negotiationId: string): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onRemoteDescriptionChanged', callId, negotiationId });

public async onRemoteDescriptionChanged(callId: string, _negotiationId: string): Promise<void> {
this.reportCallUpdated({ callId });
}

public async onCallTransferred(callId: string): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onCallTransferred', callId });

this.reportCallUpdated({ callId });
}

public async onDTMF(callId: string, dtmf: string, duration: number): Promise<void> {
logger.debug({ msg: 'BroadcastActorAgent.onDTMF', callId, dtmf, duration });
this.reportCallUpdated({ callId, dtmf: { dtmf, duration } });
}

Expand Down
Loading
Loading