Skip to content

Commit 5993901

Browse files
dmceachernmsftpull[bot]
authored andcommitted
[BugFix] Add isCameraOn to CallAdapter state (#2641)
* add isCameraOn to CallAdapter state * Change files * Duplicate change files for beta release * rework logic to remove getState * Fix up boolean check * remove console * add new camera state type * rename variable
1 parent 1cca2b2 commit 5993901

9 files changed

Lines changed: 32 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add isCameraOn state to help track camera state in the CallAdapter.",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add isCameraOn state to help track camera state in the CallAdapter.",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/communication-react/review/beta/communication-react.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export type CallAdapterClientState = {
303303
alternateCallerId?: string;
304304
environmentInfo?: EnvironmentInfo;
305305
roleHint?: Role;
306+
cameraStatus?: 'On' | 'Off';
306307
};
307308

308309
// @public

packages/communication-react/review/stable/communication-react.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export type CallAdapterClientState = {
208208
endedCall?: CallState;
209209
isTeamsCall: boolean;
210210
latestErrors: AdapterErrors;
211+
cameraStatus?: 'On' | 'Off';
211212
};
212213

213214
// @public

packages/react-composites/review/beta/react-composites.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export type CallAdapterClientState = {
202202
alternateCallerId?: string;
203203
environmentInfo?: EnvironmentInfo;
204204
roleHint?: Role;
205+
cameraStatus?: 'On' | 'Off';
205206
};
206207

207208
// @public

packages/react-composites/review/stable/react-composites.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export type CallAdapterClientState = {
158158
endedCall?: CallState;
159159
isTeamsCall: boolean;
160160
latestErrors: AdapterErrors;
161+
cameraStatus?: 'On' | 'Off';
161162
};
162163

163164
// @public

packages/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ class CallContext {
105105
/* @conditional-compile-remove(PSTN-calls) */ alternateCallerId: clientState.alternateCallerId,
106106
/* @conditional-compile-remove(unsupported-browser) */ environmentInfo: clientState.environmentInfo,
107107
/* @conditional-compile-remove(unsupported-browser) */ unsupportedBrowserVersionsAllowed: false,
108-
/* @conditional-compile-remove(rooms) */ roleHint: options?.roleHint
108+
/* @conditional-compile-remove(rooms) */ roleHint: options?.roleHint,
109+
cameraStatus: undefined
109110
};
110111
this.emitter.setMaxListeners(options?.maxListeners ?? 50);
111112
this.bindPublicMethods();
@@ -182,7 +183,12 @@ class CallContext {
182183
page: newPage,
183184
endedCall: latestEndedCall,
184185
devices: clientState.deviceManager,
185-
latestErrors: clientState.latestErrors
186+
latestErrors: clientState.latestErrors,
187+
cameraStatus:
188+
call?.localVideoStreams.find((s) => s.mediaStreamType === 'Video') ||
189+
clientState.deviceManager.unparentedViews.find((s) => s.mediaStreamType === 'Video')
190+
? 'On'
191+
: 'Off'
186192
});
187193
}
188194
}

packages/react-composites/src/composites/CallComposite/adapter/CallAdapter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ export type CallAdapterClientState = {
107107
* {@link CallComposite}. The true role of the user will be synced with ACS services when a Rooms call starts.
108108
*/
109109
roleHint?: Role;
110+
/**
111+
* State to track whether the local participant's camera is on. To be used when creating a custom
112+
* control bar with the CallComposite.
113+
*/
114+
cameraStatus?: 'On' | 'Off';
110115
};
111116

112117
/**

packages/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatTypeAssertions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type CallWithChatClientStateInternal = Omit<
9191
| /* @conditional-compile-remove(PSTN-calls) */ 'alternateCallerId'
9292
| /* @conditional-compile-remove(unsupported-browser) */ 'features'
9393
| /* @conditional-compile-remove(rooms) */ 'roleHint'
94+
| 'cameraStatus'
9495
>;
9596

9697
const CallWithChatClientStateTypeAssertion = (value: CallWithChatClientState): CallWithChatClientStateInternal => value;

0 commit comments

Comments
 (0)