Skip to content

Commit cdd03e8

Browse files
Update Captions based on new sdk changes and add changeCaptionLanguage (#3385)
* api changes * captions ga * captions api change * api change * check if teams call * proxy changes * Enable set caption language for users (#3429) * set caption * show caption setting only when caption is on * fix bug * remove internal * adapter events * lint * lint * lint * string name change * string name change * string name change * Change files * Duplicate change files for beta release * Update packages/react-composites CallWithChatComposite browser test snapshots * build files * build files * build files * Update packages/react-composites CallComposite browser test snapshots --------- Signed-off-by: carocao-msft <96077406+carocao-msft@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent eeecb7c commit cdd03e8

49 files changed

Lines changed: 1104 additions & 356 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "feature",
4+
"workstream": "Update captions based on new sdk changes, allow changing caption language",
5+
"comment": "Update captions based on new sdk changes, allow changing caption language",
6+
"packageName": "@azure/communication-react",
7+
"email": "carolinecao@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "feature",
4+
"workstream": "Update captions based on new sdk changes, allow changing caption language",
5+
"comment": "Update captions based on new sdk changes, allow changing caption language",
6+
"packageName": "@azure/communication-react",
7+
"email": "carolinecao@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}

packages/calling-component-bindings/review/beta/calling-component-bindings.api.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,22 @@ export type _CaptionsBannerSelector = (state: CallClientState, props: CallingBas
124124
// @internal
125125
export const _captionsBannerSelector: _CaptionsBannerSelector;
126126

127-
// @beta
128-
export type CaptionsOptions = {
129-
spokenLanguage: string;
130-
};
131-
132127
// @internal
133-
export type _ChangeSpokenLanguageSelector = (state: CallClientState, props: CallingBaseSelectorProps) => {
128+
export type _CaptionSettingsSelector = (state: CallClientState, props: CallingBaseSelectorProps) => {
129+
supportedCaptionLanguages: string[];
130+
currentCaptionLanguage: string;
134131
supportedSpokenLanguages: string[];
135132
currentSpokenLanguage: string;
136133
isCaptionsFeatureActive: boolean;
137134
};
138135

139136
// @internal
140-
export const _changeSpokenLanguageSelector: _ChangeSpokenLanguageSelector;
137+
export const _captionSettingsSelector: _CaptionSettingsSelector;
138+
139+
// @beta
140+
export type CaptionsOptions = {
141+
spokenLanguage: string;
142+
};
141143

142144
// @public
143145
export interface CommonCallingHandlers {

packages/calling-component-bindings/src/captionsSelector.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* @conditional-compile-remove(close-captions) */
44
import { CallClientState, CaptionsInfo } from '@internal/calling-stateful-client';
55
/* @conditional-compile-remove(close-captions) */
6-
import { CallingBaseSelectorProps, getStartCaptionsInProgress } from './baseSelectors';
6+
import { CallingBaseSelectorProps, getStartCaptionsInProgress, getSupportedCaptionLanguages } from './baseSelectors';
77
/* @conditional-compile-remove(close-captions) */
88
import {
99
getCaptions,
@@ -44,35 +44,52 @@ export const _startCaptionsButtonSelector: _StartCaptionsButtonSelector = resele
4444
(isCaptionsFeatureActive, currentCaptionLanguage, currentSpokenLanguage) => {
4545
return {
4646
checked: isCaptionsFeatureActive ?? false,
47-
currentCaptionLanguage: currentCaptionLanguage ?? 'en-us',
47+
currentCaptionLanguage: currentCaptionLanguage ?? '',
4848
currentSpokenLanguage: currentSpokenLanguage ?? 'en-us'
4949
};
5050
}
5151
);
52+
5253
/* @conditional-compile-remove(close-captions) */
5354
/**
54-
* Selector type for components for Changing spoken language
55+
* Selector type for components for Changing caption language and spoken language
5556
* @internal
5657
*/
57-
export type _ChangeSpokenLanguageSelector = (
58+
export type _CaptionSettingsSelector = (
5859
state: CallClientState,
5960
props: CallingBaseSelectorProps
6061
) => {
62+
supportedCaptionLanguages: string[];
63+
currentCaptionLanguage: string;
6164
supportedSpokenLanguages: string[];
6265
currentSpokenLanguage: string;
6366
isCaptionsFeatureActive: boolean;
6467
};
6568

6669
/* @conditional-compile-remove(close-captions) */
6770
/**
68-
* Selector for {@link ChangeSpokenLanguageButton} component.
71+
* Selector for Changing caption language and spoken language
6972
*
7073
* @internal
7174
*/
72-
export const _changeSpokenLanguageSelector: _ChangeSpokenLanguageSelector = reselect.createSelector(
73-
[getSupportedSpokenLanguages, getCurrentSpokenLanguage, getCaptionsStatus],
74-
(supportedSpokenLanguages, currentSpokenLanguage, isCaptionsFeatureActive) => {
75+
export const _captionSettingsSelector: _CaptionSettingsSelector = reselect.createSelector(
76+
[
77+
getSupportedCaptionLanguages,
78+
getCurrentCaptionLanguage,
79+
getSupportedSpokenLanguages,
80+
getCurrentSpokenLanguage,
81+
getCaptionsStatus
82+
],
83+
(
84+
supportedCaptionLanguages,
85+
currentCaptionLanguage,
86+
supportedSpokenLanguages,
87+
currentSpokenLanguage,
88+
isCaptionsFeatureActive
89+
) => {
7590
return {
91+
supportedCaptionLanguages: supportedCaptionLanguages ?? [],
92+
currentCaptionLanguage: currentCaptionLanguage ?? '',
7693
supportedSpokenLanguages: supportedSpokenLanguages ?? ['en-us'],
7794
currentSpokenLanguage: currentSpokenLanguage ?? 'en-us',
7895
isCaptionsFeatureActive: isCaptionsFeatureActive ?? false

packages/calling-component-bindings/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ export type { HoldButtonSelector } from './callControlSelectors';
1616
/* @conditional-compile-remove(close-captions) */
1717
export type {
1818
_StartCaptionsButtonSelector,
19-
_ChangeSpokenLanguageSelector,
19+
_CaptionSettingsSelector,
2020
_CaptionsBannerSelector
2121
} from './captionsSelector';
2222

2323
/* @conditional-compile-remove(close-captions) */
24-
export {
25-
_captionsBannerSelector,
26-
_startCaptionsButtonSelector,
27-
_changeSpokenLanguageSelector
28-
} from './captionsSelector';
24+
export { _captionsBannerSelector, _startCaptionsButtonSelector, _captionSettingsSelector } from './captionsSelector';
2925

3026
export type { CallingHandlers, CreateDefaultCallingHandlers } from './handlers/createHandlers';
3127
/* @conditional-compile-remove(teams-identity-support) */

packages/calling-stateful-client/review/beta/calling-stateful-client.api.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ export const _isTeamsCall: (call: CallCommon) => call is TeamsCall_2;
226226
// @internal (undocumented)
227227
export const _isTeamsCallAgent: (callAgent: CallAgentCommon) => callAgent is TeamsCallAgent_2;
228228

229-
// @internal
230-
export const _isTeamsMeetingCall: (call: CallCommon) => boolean;
231-
232229
// @public
233230
export interface LocalVideoStreamState {
234231
mediaStreamType: MediaStreamType;

packages/calling-stateful-client/src/CallContext.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,14 @@ export class CallContext {
794794
this.modifyState((draft: CallClientState) => {
795795
const call = draft.calls[this._callIdHistory.latestCallId(callId)];
796796
if (call) {
797-
this.processNewCaption(call.captionsFeature.captions, convertFromSDKToCaptionInfoState(caption));
797+
const currentCaptionLanguage = call.captionsFeature.currentCaptionLanguage;
798+
if (
799+
caption.captionLanguage.toUpperCase() === currentCaptionLanguage.toUpperCase() ||
800+
currentCaptionLanguage === '' ||
801+
currentCaptionLanguage === undefined
802+
) {
803+
this.processNewCaption(call.captionsFeature.captions, convertFromSDKToCaptionInfoState(caption));
804+
}
798805
}
799806
});
800807
}

packages/calling-stateful-client/src/CaptionsSubscriber.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ export class CaptionsSubscriber {
4141
private subscribe = (): void => {
4242
this._captions.on('CaptionsActiveChanged', this.isCaptionsActiveChanged);
4343
this._captions.on('CaptionsReceived', this.onCaptionsReceived);
44+
this._captions.on('CaptionLanguageChanged', this.isCaptionLanguageChanged);
45+
this._captions.on('SpokenLanguageChanged', this.isSpokenLanguageChanged);
4446
};
4547

4648
public unsubscribe = (): void => {
4749
this._captions.off('CaptionsActiveChanged', this.isCaptionsActiveChanged);
4850
this._captions.off('CaptionsReceived', this.onCaptionsReceived);
51+
this._captions.off('CaptionLanguageChanged', this.isCaptionLanguageChanged);
52+
this._captions.off('SpokenLanguageChanged', this.isSpokenLanguageChanged);
4953
};
5054

5155
private onCaptionsReceived: TeamsCaptionsHandler = (caption: TeamsCaptionsInfo): void => {
@@ -55,6 +59,12 @@ export class CaptionsSubscriber {
5559
private isCaptionsActiveChanged: PropertyChangedEvent = (): void => {
5660
this._context.setIsCaptionActive(this._callIdRef.callId, this._captions.isCaptionsFeatureActive);
5761
};
62+
private isCaptionLanguageChanged: PropertyChangedEvent = (): void => {
63+
this._context.setSelectedCaptionLanguage(this._callIdRef.callId, this._captions.activeCaptionLanguage);
64+
};
65+
private isSpokenLanguageChanged: PropertyChangedEvent = (): void => {
66+
this._context.setSelectedSpokenLanguage(this._callIdRef.callId, this._captions.activeSpokenLanguage);
67+
};
5868
}
5969

6070
// This is a placeholder to bypass CC of "close-captions", remove when move the feature to stable

packages/calling-stateful-client/src/TypeGuards.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,3 @@ export const _isTeamsCallAgent = (callAgent: CallAgentCommon): callAgent is Team
3939
return callAgent.kind === 'TeamsCallAgent';
4040
return false;
4141
};
42-
43-
/* @conditional-compile-remove(close-captions) */
44-
/**
45-
* @internal
46-
* Determine whether a call is:
47-
* A TeamsCall
48-
* or a ACS Call joining the teams meeting
49-
*/
50-
export const _isTeamsMeetingCall = (call: CallCommon): boolean => {
51-
return _isTeamsCall(call) || (_isACSCall(call) && !call.info.groupId && !call.info.roomId); // there should be a better way to determine if a call is joining a teams meeting ideally should be a meetingID in the info object
52-
};

packages/calling-stateful-client/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@ export * from './index-public';
55

66
export { _isACSCall, _isACSCallAgent, _isTeamsCall, _isTeamsCallAgent } from './TypeGuards';
77

8-
/* @conditional-compile-remove(close-captions) */
9-
export { _isTeamsMeetingCall } from './TypeGuards';
10-
118
export type { CallAgentCommon, CallCommon, TeamsCall, TeamsCallAgent, IncomingCallCommon } from './BetaToStableTypes';

0 commit comments

Comments
 (0)