Put "is speaking?" threshold in remote config; lower default

This commit is contained in:
Evan Hahn 2022-03-01 17:39:09 -06:00 committed by GitHub
parent 2b0c98f943
commit cfa0711909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 6 deletions

View file

@ -15,7 +15,6 @@ import { getPlatform } from '../selectors/user';
import { isConversationTooBigToRing } from '../../conversations/isConversationTooBigToRing';
import { missingCaseError } from '../../util/missingCaseError';
import { calling } from '../../services/calling';
import { AUDIO_LEVEL_FOR_SPEAKING } from '../../calling/constants';
import type { StateType as RootStateType } from '../reducer';
import type {
ChangeIODevicePayloadType,
@ -464,6 +463,7 @@ type DeclineCallActionType = {
};
type GroupCallAudioLevelsChangeActionPayloadType = Readonly<{
audioLevelForSpeaking: number;
conversationId: string;
localAudioLevel: number;
remoteDeviceStates: ReadonlyArray<{ audioLevel: number; demuxId: number }>;
@ -1697,8 +1697,12 @@ export function reducer(
}
if (action.type === GROUP_CALL_AUDIO_LEVELS_CHANGE) {
const { conversationId, localAudioLevel, remoteDeviceStates } =
action.payload;
const {
audioLevelForSpeaking,
conversationId,
localAudioLevel,
remoteDeviceStates,
} = action.payload;
const { activeCallState } = state;
const existingCall = getGroupCall(conversationId, state);
@ -1709,14 +1713,14 @@ export function reducer(
return state;
}
const amISpeaking = localAudioLevel > AUDIO_LEVEL_FOR_SPEAKING;
const amISpeaking = localAudioLevel > audioLevelForSpeaking;
const speakingDemuxIds = new Set<number>();
remoteDeviceStates.forEach(({ audioLevel, demuxId }) => {
// We expect `audioLevel` to be a number but have this check just in case.
if (
typeof audioLevel === 'number' &&
audioLevel > AUDIO_LEVEL_FOR_SPEAKING
audioLevel > audioLevelForSpeaking
) {
speakingDemuxIds.add(demuxId);
}