зеркало из
1
0
Форкнуть 0

Add toggle for DNS on by default and hide DNS button in adapter options (#5095)

* Add toggle for DNS on by default and hide DNS button in adapter options

* Change files

* minor
This commit is contained in:
prabhjot-msft 2024-08-29 17:19:51 -07:00 коммит произвёл GitHub
Родитель b11bc8a535
Коммит 5680829e1f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
11 изменённых файлов: 153 добавлений и 47 удалений

Просмотреть файл

@ -0,0 +1,9 @@
{
"type": "prerelease",
"area": "feature",
"workstream": "DNS",
"comment": "Add toggle for DNS on by default and hide DNS button in adapter options",
"packageName": "@azure/communication-react",
"email": "97124699+prabhjot-msft@users.noreply.github.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,9 @@
{
"type": "prerelease",
"area": "feature",
"workstream": "DNS",
"comment": "Add toggle for DNS on by default and hide DNS button in adapter options",
"packageName": "@azure/communication-react",
"email": "97124699+prabhjot-msft@users.noreply.github.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -506,6 +506,8 @@ export type CallAdapterClientState = {
videoBackgroundImages?: VideoBackgroundImage[]; videoBackgroundImages?: VideoBackgroundImage[];
onResolveVideoEffectDependency?: () => Promise<VideoBackgroundEffectsDependency>; onResolveVideoEffectDependency?: () => Promise<VideoBackgroundEffectsDependency>;
onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>; onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>;
deepNoiseSuppressionOnByDefault?: boolean;
hideNoiseSuppressionButton?: boolean;
selectedVideoBackgroundEffect?: VideoBackgroundEffect; selectedVideoBackgroundEffect?: VideoBackgroundEffect;
acceptedTransferCallState?: CallState; acceptedTransferCallState?: CallState;
hideAttendeeNames?: boolean; hideAttendeeNames?: boolean;
@ -1391,10 +1393,12 @@ export interface CallWithChatClientState {
alternateCallerId?: string | undefined; alternateCallerId?: string | undefined;
call?: CallState; call?: CallState;
chat?: ChatThreadClientState; chat?: ChatThreadClientState;
deepNoiseSuppressionOnByDefault?: boolean;
devices: DeviceManagerState; devices: DeviceManagerState;
displayName: string | undefined; displayName: string | undefined;
environmentInfo?: EnvironmentInfo; environmentInfo?: EnvironmentInfo;
hideAttendeeNames?: boolean; hideAttendeeNames?: boolean;
hideNoiseSuppressionButton?: boolean;
isTeamsCall: boolean; isTeamsCall: boolean;
isTeamsMeeting: boolean; isTeamsMeeting: boolean;
latestCallErrors: AdapterErrors; latestCallErrors: AdapterErrors;
@ -3786,6 +3790,7 @@ export interface MicrophoneButtonProps extends ControlBarButtonProps {
onToggleMicrophone?: () => Promise<void>; onToggleMicrophone?: () => Promise<void>;
selectedMicrophone?: OptionsDevice; selectedMicrophone?: OptionsDevice;
selectedSpeaker?: OptionsDevice; selectedSpeaker?: OptionsDevice;
showNoiseSuppressionButton?: boolean;
speakers?: OptionsDevice[]; speakers?: OptionsDevice[];
strings?: Partial<MicrophoneButtonStrings>; strings?: Partial<MicrophoneButtonStrings>;
styles?: Partial<MicrophoneButtonStyles>; styles?: Partial<MicrophoneButtonStyles>;

Просмотреть файл

@ -191,6 +191,11 @@ export interface MicrophoneButtonProps extends ControlBarButtonProps {
* Callback when noise suppression is clicked * Callback when noise suppression is clicked
*/ */
onClickNoiseSuppression?: () => void; onClickNoiseSuppression?: () => void;
/* @conditional-compile-remove(DNS) */
/**
* Show/Hide the deep noise suppression button
*/
showNoiseSuppressionButton?: boolean;
} }
/** /**
@ -260,6 +265,51 @@ export const MicrophoneButton = (props: MicrophoneButtonProps): JSX.Element => {
label: { fontWeight: 400 } label: { fontWeight: 400 }
}; };
const splitButtonMenuItems: IContextualMenuItem[] = [];
splitButtonMenuItems.push({
key: 'microphonePrimaryAction',
text: props.checked ? strings.onSplitButtonMicrophonePrimaryAction : strings.offSplitButtonMicrophonePrimaryAction,
onClick: () => {
onToggleClick();
},
iconProps: {
iconName: props.checked ? 'SplitButtonPrimaryActionMicUnmuted' : 'SplitButtonPrimaryActionMicMuted',
styles: { root: { lineHeight: 0 } }
}
});
/* @conditional-compile-remove(DNS) */
if (props.showNoiseSuppressionButton) {
splitButtonMenuItems.push({
key: 'microphoneDNSToggle',
onRender: () => {
return (
<Stack
onClick={async () => {
await props.onClickNoiseSuppression?.();
setAnnouncerString(
props.isDeepNoiseSuppressionOn
? strings.deepNoiseSuppresionOnAnnouncement
: strings.deepNoiseSuppresionOffAnnouncement
);
}}
>
<Toggle
label={
props.isDeepNoiseSuppressionOn
? strings.deepNoiseSuppresionOnTitle
: strings.deepNoiseSuppresionOffTitle
}
checked={props.isDeepNoiseSuppressionOn}
inlineLabel
styles={deepNoiseSuppressionToggleStyles}
/>
</Stack>
);
}
});
}
/** /**
* We need to also include the primary action of the button to the * We need to also include the primary action of the button to the
* split button for mobile devices. * split button for mobile devices.
@ -270,50 +320,7 @@ export const MicrophoneButton = (props: MicrophoneButtonProps): JSX.Element => {
itemType: ContextualMenuItemType.Section, itemType: ContextualMenuItemType.Section,
sectionProps: { sectionProps: {
topDivider: true, topDivider: true,
items: [ items: splitButtonMenuItems
{
key: 'microphonePrimaryAction',
text: props.checked
? strings.onSplitButtonMicrophonePrimaryAction
: strings.offSplitButtonMicrophonePrimaryAction,
onClick: () => {
onToggleClick();
},
iconProps: {
iconName: props.checked ? 'SplitButtonPrimaryActionMicUnmuted' : 'SplitButtonPrimaryActionMicMuted',
styles: { root: { lineHeight: 0 } }
}
},
/* @conditional-compile-remove(DNS) */
{
key: 'microphoneDNSToggle',
onRender: () => {
return (
<Stack
onClick={async () => {
await props.onClickNoiseSuppression?.();
setAnnouncerString(
props.isDeepNoiseSuppressionOn
? strings.deepNoiseSuppresionOnAnnouncement
: strings.deepNoiseSuppresionOffAnnouncement
);
}}
>
<Toggle
label={
props.isDeepNoiseSuppressionOn
? strings.deepNoiseSuppresionOnTitle
: strings.deepNoiseSuppresionOffTitle
}
checked={props.isDeepNoiseSuppressionOn}
inlineLabel
styles={deepNoiseSuppressionToggleStyles}
/>
</Stack>
);
}
}
]
} }
}; };

Просмотреть файл

@ -164,6 +164,8 @@ class CallContext {
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
deepNoiseSuppressionOptions?: { deepNoiseSuppressionOptions?: {
onResolveDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>; onResolveDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>;
deepNoiseSuppressionOnByDefault?: boolean;
hideNoiseSuppressionButton?: boolean;
}; };
callingSounds?: CallingSounds; callingSounds?: CallingSounds;
reactionResources?: ReactionResources; reactionResources?: ReactionResources;
@ -193,6 +195,10 @@ class CallContext {
onResolveVideoEffectDependency: options?.videoBackgroundOptions?.onResolveDependency, onResolveVideoEffectDependency: options?.videoBackgroundOptions?.onResolveDependency,
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
onResolveDeepNoiseSuppressionDependency: options?.deepNoiseSuppressionOptions?.onResolveDependency, onResolveDeepNoiseSuppressionDependency: options?.deepNoiseSuppressionOptions?.onResolveDependency,
/* @conditional-compile-remove(DNS) */
deepNoiseSuppressionOnByDefault: options?.deepNoiseSuppressionOptions?.deepNoiseSuppressionOnByDefault ?? false,
/* @conditional-compile-remove(DNS) */
hideNoiseSuppressionButton: options?.deepNoiseSuppressionOptions?.hideNoiseSuppressionButton ?? false,
selectedVideoBackgroundEffect: undefined, selectedVideoBackgroundEffect: undefined,
cameraStatus: undefined, cameraStatus: undefined,
sounds: options?.callingSounds, sounds: options?.callingSounds,

Просмотреть файл

@ -176,7 +176,20 @@ export type CallAdapterClientState = {
* @beta * @beta
*/ */
onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>; onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>;
/* @conditional-compile-remove(DNS) */
/**
* State to track whether the noise suppression should be on by default.
* @beta
* @default false
*/
deepNoiseSuppressionOnByDefault?: boolean;
/* @conditional-compile-remove(DNS) */
/**
* State to track whether to hide the noise suppression button.
* @beta
* @default false
*/
hideNoiseSuppressionButton?: boolean;
/** /**
* State to track the selected video background effect. * State to track the selected video background effect.
*/ */

Просмотреть файл

@ -9,7 +9,7 @@ import { ControlBar, DevicesButton, ParticipantMenuItemsCallback } from '@intern
import { HoldButton } from '@internal/react-components'; import { HoldButton } from '@internal/react-components';
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
import { useCallback, useState } from 'react'; import { useCallback, useState, useEffect } from 'react';
import { CallControlOptions } from '../types/CallControlOptions'; import { CallControlOptions } from '../types/CallControlOptions';
import { Camera } from './buttons/Camera'; import { Camera } from './buttons/Camera';
import { Devices } from './buttons/Devices'; import { Devices } from './buttons/Devices';
@ -96,6 +96,27 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
const [isDeepNoiseSuppressionOn, setDeepNoiseSuppressionOn] = useState<boolean>(false); const [isDeepNoiseSuppressionOn, setDeepNoiseSuppressionOn] = useState<boolean>(false);
/* @conditional-compile-remove(DNS) */
const startDeepNoiseSuppression = useCallback(async () => {
await adapter.startNoiseSuppressionEffect();
}, [adapter]);
/* @conditional-compile-remove(DNS) */
useEffect(() => {
if (
adapter.getState().onResolveDeepNoiseSuppressionDependency &&
adapter.getState().deepNoiseSuppressionOnByDefault
) {
startDeepNoiseSuppression();
setDeepNoiseSuppressionOn(true);
}
}, [adapter, startDeepNoiseSuppression]);
/* @conditional-compile-remove(DNS) */
const showNoiseSuppressionButton =
adapter.getState().onResolveDeepNoiseSuppressionDependency && !adapter.getState().hideNoiseSuppressionButton
? true
: false;
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
const onClickNoiseSuppression = useCallback(async () => { const onClickNoiseSuppression = useCallback(async () => {
if (isDeepNoiseSuppressionOn) { if (isDeepNoiseSuppressionOn) {
@ -363,6 +384,8 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
onClickNoiseSuppression={onClickNoiseSuppression} onClickNoiseSuppression={onClickNoiseSuppression}
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
isDeepNoiseSuppressionOn={isDeepNoiseSuppressionOn} isDeepNoiseSuppressionOn={isDeepNoiseSuppressionOn}
/* @conditional-compile-remove(DNS) */
showNoiseSuppressionButton={showNoiseSuppressionButton}
/> />
)} )}
{cameraButtonIsEnabled && ( {cameraButtonIsEnabled && (

Просмотреть файл

@ -26,6 +26,8 @@ export const Microphone = (props: {
isDeepNoiseSuppressionOn?: boolean; isDeepNoiseSuppressionOn?: boolean;
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
onClickNoiseSuppression?: () => void; onClickNoiseSuppression?: () => void;
/* @conditional-compile-remove(DNS) */
showNoiseSuppressionButton?: boolean;
}): JSX.Element => { }): JSX.Element => {
const microphoneButtonProps = usePropsFor(MicrophoneButton); const microphoneButtonProps = usePropsFor(MicrophoneButton);
const callStatus = useSelector(getCallStatus); const callStatus = useSelector(getCallStatus);
@ -54,6 +56,8 @@ export const Microphone = (props: {
isDeepNoiseSuppressionOn={props.isDeepNoiseSuppressionOn} isDeepNoiseSuppressionOn={props.isDeepNoiseSuppressionOn}
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
onClickNoiseSuppression={props.onClickNoiseSuppression} onClickNoiseSuppression={props.onClickNoiseSuppression}
/* @conditional-compile-remove(DNS) */
showNoiseSuppressionButton={props.showNoiseSuppressionButton}
showLabel={props.displayType !== 'compact'} showLabel={props.displayType !== 'compact'}
disableTooltip={props.disableTooltip} disableTooltip={props.disableTooltip}
styles={styles} styles={styles}

Просмотреть файл

@ -90,6 +90,12 @@ export interface CallWithChatClientState {
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
/** Dependency to be injected for deep noise suppression effect. */ /** Dependency to be injected for deep noise suppression effect. */
onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>; onResolveDeepNoiseSuppressionDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>;
/* @conditional-compile-remove(DNS) */
/** State to track whether the noise suppression should be on by default. */
deepNoiseSuppressionOnByDefault?: boolean;
/* @conditional-compile-remove(DNS) */
/** State to track whether to hide the noise suppression button. */
hideNoiseSuppressionButton?: boolean;
/** State to track the selected video background effect */ /** State to track the selected video background effect */
selectedVideoBackgroundEffect?: VideoBackgroundEffect; selectedVideoBackgroundEffect?: VideoBackgroundEffect;

Просмотреть файл

@ -228,6 +228,27 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
const [isDeepNoiseSuppressionOn, setDeepNoiseSuppressionOn] = useState<boolean>(false); const [isDeepNoiseSuppressionOn, setDeepNoiseSuppressionOn] = useState<boolean>(false);
/* @conditional-compile-remove(DNS) */
const startDeepNoiseSuppression = useCallback(async () => {
await props.callAdapter.startNoiseSuppressionEffect();
}, [props.callAdapter]);
/* @conditional-compile-remove(DNS) */
useEffect(() => {
if (
props.callAdapter.getState().onResolveDeepNoiseSuppressionDependency &&
props.callAdapter.getState().deepNoiseSuppressionOnByDefault
) {
startDeepNoiseSuppression();
setDeepNoiseSuppressionOn(true);
}
}, [props.callAdapter, startDeepNoiseSuppression]);
/* @conditional-compile-remove(DNS) */
const showNoiseSuppressionButton =
props.callAdapter.getState().onResolveDeepNoiseSuppressionDependency &&
!props.callAdapter.getState().hideNoiseSuppressionButton
? true
: false;
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
const onClickNoiseSuppression = useCallback(async () => { const onClickNoiseSuppression = useCallback(async () => {
if (isDeepNoiseSuppressionOn) { if (isDeepNoiseSuppressionOn) {
@ -417,6 +438,8 @@ export const CommonCallControlBar = (props: CommonCallControlBarProps & Containe
onClickNoiseSuppression={onClickNoiseSuppression} onClickNoiseSuppression={onClickNoiseSuppression}
/* @conditional-compile-remove(DNS) */ /* @conditional-compile-remove(DNS) */
isDeepNoiseSuppressionOn={isDeepNoiseSuppressionOn} isDeepNoiseSuppressionOn={isDeepNoiseSuppressionOn}
/* @conditional-compile-remove(DNS) */
showNoiseSuppressionButton={showNoiseSuppressionButton}
/> />
)} )}
{cameraButtonIsEnabled && ( {cameraButtonIsEnabled && (

Просмотреть файл

@ -161,7 +161,8 @@ const AzureCommunicationCallScreen = (props: AzureCommunicationCallScreenProps):
}, },
// /* @conditional-compile-remove(DNS) */ // /* @conditional-compile-remove(DNS) */
deepNoiseSuppressionOptions: { deepNoiseSuppressionOptions: {
onResolveDependency: onResolveDeepNoiseSuppressionDependencyLazy onResolveDependency: onResolveDeepNoiseSuppressionDependencyLazy,
deepNoiseSuppressionOnByDefault: true
}, },
callingSounds: { callingSounds: {
callEnded: { url: '/assets/sounds/callEnded.mp3' }, callEnded: { url: '/assets/sounds/callEnded.mp3' },