Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support joining an existing call in the CallComposite & CallWithChatComposite #5148

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "feature",
"workstream": "",
"comment": "Support Composites joining existing calls by updating CallAdapter and CallWithChatAdapters to take an existing call as a contruction parameter instead of a locator.",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "feature",
"workstream": "",
"comment": "Support Composites joining existing calls by updating CallAdapter and CallWithChatAdapters to take an existing call as a contruction parameter instead of a locator.",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2549,11 +2549,24 @@ export function createAzureCommunicationCallAdapterFromClient(callClient: Statef
// @public
export function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, locator: CallAdapterLocator, options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;

// @public
export function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, call: Call, options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;

// @public
export const createAzureCommunicationCallWithChatAdapter: ({ userId, displayName, credential, endpoint, locator, alternateCallerId, callAdapterOptions }: AzureCommunicationCallWithChatAdapterArgs) => Promise<CallWithChatAdapter>;

// @public
export const createAzureCommunicationCallWithChatAdapterFromClients: ({ callClient, callAgent, callLocator, chatClient, chatThreadClient, callAdapterOptions }: AzureCommunicationCallWithChatAdapterFromClientArgs) => Promise<CallWithChatAdapter>;
export function createAzureCommunicationCallWithChatAdapterFromClients(args: AzureCommunicationCallWithChatAdapterFromClientArgs): Promise<CallWithChatAdapter>;

// @public
export function createAzureCommunicationCallWithChatAdapterFromClients(args: {
callClient: StatefulCallClient;
callAgent: CallAgent;
call: Call;
chatClient: StatefulChatClient;
chatThreadClient: ChatThreadClient;
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
}): Promise<CallWithChatAdapter>;

// @public
export const createAzureCommunicationChatAdapter: ({ endpoint: endpointUrl, userId, displayName, credential, threadId }: AzureCommunicationChatAdapterArgs) => Promise<ChatAdapter>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2159,11 +2159,24 @@ export function createAzureCommunicationCallAdapterFromClient(callClient: Statef
// @public
export function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, locator: CallAdapterLocator, options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;

// @public
export function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, call: Call, options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;

// @public
export const createAzureCommunicationCallWithChatAdapter: ({ userId, displayName, credential, endpoint, locator, alternateCallerId, callAdapterOptions }: AzureCommunicationCallWithChatAdapterArgs) => Promise<CallWithChatAdapter>;

// @public
export const createAzureCommunicationCallWithChatAdapterFromClients: ({ callClient, callAgent, callLocator, chatClient, chatThreadClient, callAdapterOptions }: AzureCommunicationCallWithChatAdapterFromClientArgs) => Promise<CallWithChatAdapter>;
export function createAzureCommunicationCallWithChatAdapterFromClients(args: AzureCommunicationCallWithChatAdapterFromClientArgs): Promise<CallWithChatAdapter>;

// @public
export function createAzureCommunicationCallWithChatAdapterFromClients(args: {
callClient: StatefulCallClient;
callAgent: CallAgent;
call: Call;
chatClient: StatefulChatClient;
chatThreadClient: ChatThreadClient;
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
}): Promise<CallWithChatAdapter>;

// @public
export const createAzureCommunicationChatAdapter: ({ endpoint: endpointUrl, userId, displayName, credential, threadId }: AzureCommunicationChatAdapterArgs) => Promise<ChatAdapter>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import {
} from './CallAdapter';
/* @conditional-compile-remove(teams-identity-support) */
import { TeamsCallAdapter } from './CallAdapter';
import { getCallCompositePage, getLocatorOrTargetCallees, IsCallEndedPage, isCameraOn } from '../utils';
import { getCallCompositePage, isCall, IsCallEndedPage, isCameraOn, isTargetCallees } from '../utils';
import { CreateVideoStreamViewResult, VideoStreamOptions } from '@internal/react-components';
import { toFlatCommunicationIdentifier, _toCommunicationIdentifier, _isValidIdentifier } from '@internal/acs-ui-common';
import {
Expand Down Expand Up @@ -436,32 +436,49 @@ export class AzureCommunicationCallAdapter<AgentType extends CallAgent | TeamsCa
);
constructor(
callClient: StatefulCallClient,
locatorOrTargetCalless: CallAdapterLocator | StartCallIdentifier[],
call: Call,
callAgent: AgentType,
deviceManager: StatefulDeviceManager,
options?: AzureCommunicationCallAdapterOptions | TeamsAdapterOptions
);
constructor(
callClient: StatefulCallClient,
overloadedParam: CallAdapterLocator | StartCallIdentifier[] | Call,
callAgent: AgentType,
deviceManager: StatefulDeviceManager,
options?: AzureCommunicationCallAdapterOptions | TeamsAdapterOptions
) {
this.bindPublicMethods();
this.callClient = callClient;
this.callAgent = callAgent;
this.targetCallees =
getLocatorOrTargetCallees(locatorOrTargetCalless) === true
? (locatorOrTargetCalless as StartCallIdentifier[])
: undefined;
this.locator =
getLocatorOrTargetCallees(locatorOrTargetCalless) === false
? (locatorOrTargetCalless as CallAdapterLocator)
: undefined;

let overloadedParamAsCall: Call | undefined = undefined;
if (isTargetCallees(overloadedParam)) {
this.targetCallees = overloadedParam;
} else if (isCall(overloadedParam)) {
overloadedParamAsCall = overloadedParam;
} else {
this.locator = overloadedParam;
}

this.deviceManager = deviceManager;
const isTeamsMeeting = this.locator ? 'meetingLink' in this.locator || 'meetingId' in this.locator : false;

const isTeamsMeeting = this.locator
? 'meetingLink' in this.locator || 'meetingId' in this.locator
: !!overloadedParamAsCall?.info.threadId;
JamesBurnside marked this conversation as resolved.
Show resolved Hide resolved
let isTeamsCall: boolean | undefined;
this.targetCallees?.forEach((callee) => {
if (isMicrosoftTeamsUserIdentifier(callee) || isMicrosoftTeamsAppIdentifier(callee)) {
isTeamsCall = true;
}
});

const isRoomsCall = this.locator ? 'roomId' in this.locator : false;
const isOverloadedParamARoomsCallTrampoline = (): boolean => {
/* @conditional-compile-remove(calling-beta-sdk) */
return !!overloadedParamAsCall?.info.roomId;
return false;
};
const isRoomsCall = this.locator ? 'roomId' in this.locator : isOverloadedParamARoomsCallTrampoline();

this.onResolveVideoBackgroundEffectsDependency = options?.videoBackgroundOptions?.onResolveDependency;
/* @conditional-compile-remove(DNS) */
Expand Down Expand Up @@ -558,6 +575,10 @@ export class AzureCommunicationCallAdapter<AgentType extends CallAgent | TeamsCa
};
(this.callAgent as TeamsCallAgent).on('callsUpdated', onTeamsCallsUpdated);
}

if (overloadedParamAsCall) {
this.processNewCall(overloadedParamAsCall);
}
}

// TODO: update this to include the 'selectedCameraChanged' when calling adds it to the device manager
Expand Down Expand Up @@ -2177,7 +2198,18 @@ export async function createAzureCommunicationCallAdapterFromClient(
export async function createAzureCommunicationCallAdapterFromClient(
callClient: StatefulCallClient,
callAgent: CallAgent,
locatorOrtargetCallees: CallAdapterLocator | StartCallIdentifier[],
call: Call,
options?: AzureCommunicationCallAdapterOptions
): Promise<CallAdapter>;
/**
* Implementation of overloads for {@link createAzureCommunicationCallAdapterFromClient}.
*
* @private
*/
export async function createAzureCommunicationCallAdapterFromClient(
callClient: StatefulCallClient,
callAgent: CallAgent,
overloadedParam: CallAdapterLocator | StartCallIdentifier[] | Call,
options?: AzureCommunicationCallAdapterOptions
): Promise<CallAdapter> {
const deviceManager = (await callClient.getDeviceManager()) as StatefulDeviceManager;
Expand All @@ -2187,22 +2219,12 @@ export async function createAzureCommunicationCallAdapterFromClient(
}
/* @conditional-compile-remove(unsupported-browser) */
await callClient.feature(Features.DebugInfo).getEnvironmentInfo();
if (getLocatorOrTargetCallees(locatorOrtargetCallees)) {
return new AzureCommunicationCallAdapter(
callClient,
locatorOrtargetCallees as StartCallIdentifier[],
callAgent,
deviceManager,
options
);
if (isTargetCallees(overloadedParam)) {
return new AzureCommunicationCallAdapter(callClient, overloadedParam, callAgent, deviceManager, options);
} else if (isCall(overloadedParam)) {
return new AzureCommunicationCallAdapter(callClient, overloadedParam, callAgent, deviceManager, options);
} else {
return new AzureCommunicationCallAdapter(
callClient,
locatorOrtargetCallees as CallAdapterLocator,
callAgent,
deviceManager,
options
);
return new AzureCommunicationCallAdapter(callClient, overloadedParam, callAgent, deviceManager, options);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VideoBackgroundEffectsDependency } from '@internal/calling-component-bi
import { VideoBackgroundEffect } from '../adapter/CallAdapter';
import { VideoDeviceInfo } from '@azure/communication-calling';

import { VideoEffectProcessor } from '@azure/communication-calling';
import { Call, VideoEffectProcessor } from '@azure/communication-calling';
import { CompositeLocale } from '../../localization';
import { CallCompositeIcons } from '../../common/icons';

Expand Down Expand Up @@ -587,14 +587,18 @@ export const getSelectedCameraFromAdapterState = (state: CallAdapterState): Vide

/**
* Helper to determine if the adapter has a locator or targetCallees
* @param locatorOrTargetCallees
* @returns boolean to determine if the adapter has a locator or targetCallees, true is locator, false is targetCallees
* @private
*/
export const getLocatorOrTargetCallees = (
locatorOrTargetCallees: CallAdapterLocator | StartCallIdentifier[]
): locatorOrTargetCallees is StartCallIdentifier[] => {
return !!Array.isArray(locatorOrTargetCallees);
export const isTargetCallees = (
overloadedParam: CallAdapterLocator | StartCallIdentifier[] | Call
): overloadedParam is StartCallIdentifier[] => {
return !!Array.isArray(overloadedParam);
};

/** @private */
export const isCall = (overloadedParam: CallAdapterLocator | StartCallIdentifier[] | Call): overloadedParam is Call => {
return 'kind' in overloadedParam && overloadedParam.kind === 'Call';
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,6 @@ export type AzureCommunicationCallWithChatAdapterFromClientArgs = {
callClient: StatefulCallClient;
chatClient: StatefulChatClient;
chatThreadClient: ChatThreadClient;

callAdapterOptions?: AzureCommunicationCallAdapterOptions;
};

Expand All @@ -1407,24 +1406,59 @@ export type AzureCommunicationCallWithChatAdapterFromClientArgs = {
*
* @public
*/
export const createAzureCommunicationCallWithChatAdapterFromClients = async ({
callClient,
callAgent,
callLocator,
chatClient,
chatThreadClient,
callAdapterOptions
}: AzureCommunicationCallWithChatAdapterFromClientArgs): Promise<CallWithChatAdapter> => {
const callAdapter = await createAzureCommunicationCallAdapterFromClient(
callClient,
callAgent,
callLocator,
export async function createAzureCommunicationCallWithChatAdapterFromClients(
args: AzureCommunicationCallWithChatAdapterFromClientArgs
): Promise<CallWithChatAdapter>;

/**
* Create a {@link CallWithChatAdapter} using the provided {@link StatefulChatClient} and {@link StatefulCallClient} and {@link Call}.
*
* Useful if you want to keep a reference to {@link StatefulChatClient} and {@link StatefulCallClient}.
* Please note that chatThreadClient has to be created by StatefulChatClient via chatClient.getChatThreadClient(chatThreadId) API.
* Consider using {@link createAzureCommunicationCallWithChatAdapter} for a simpler API.
*
* @public
*/
export async function createAzureCommunicationCallWithChatAdapterFromClients(args: {
callClient: StatefulCallClient;
callAgent: CallAgent;
call: Call;
chatClient: StatefulChatClient;
chatThreadClient: ChatThreadClient;
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
}): Promise<CallWithChatAdapter>;

/**
* Implementation of {@link createAzureCommunicationCallWithChatAdapterFromClients} overloads.
* @private
*/
export async function createAzureCommunicationCallWithChatAdapterFromClients(
args:
| AzureCommunicationCallWithChatAdapterFromClientArgs
| {
call: Call;
callAgent: CallAgent;
callClient: StatefulCallClient;
chatClient: StatefulChatClient;
chatThreadClient: ChatThreadClient;
callAdapterOptions?: AzureCommunicationCallAdapterOptions;
}
): Promise<CallWithChatAdapter> {
const { callAgent, callClient, chatClient, chatThreadClient, callAdapterOptions } = args;

const callAdapter =
'call' in args
? await createAzureCommunicationCallAdapterFromClient(callClient, callAgent, args.call, callAdapterOptions)
: await createAzureCommunicationCallAdapterFromClient(
callClient,
callAgent,
args.callLocator,
callAdapterOptions
);

callAdapterOptions
);
const chatAdapter = await createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);
return new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapter);
};
}

/**
* Create a {@link CallWithChatAdapter} from the underlying adapters.
Expand Down
Loading