Dynamic audio level indicator
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Copyright 2020-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export const AUDIO_LEVEL_INTERVAL_MS = 250;
|
||||
export const DEFAULT_AUDIO_LEVEL_FOR_SPEAKING = 0.15;
|
||||
// See `TICK_INTERVAL` in group_call.rs in RingRTC
|
||||
export const AUDIO_LEVEL_INTERVAL_MS = 200;
|
||||
|
||||
export const REQUESTED_VIDEO_WIDTH = 640;
|
||||
export const REQUESTED_VIDEO_HEIGHT = 480;
|
||||
|
@@ -1,20 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type * as RemoteConfig from '../RemoteConfig';
|
||||
import { DEFAULT_AUDIO_LEVEL_FOR_SPEAKING } from './constants';
|
||||
|
||||
export function getAudioLevelForSpeaking(
|
||||
getValueFromRemoteConfig: typeof RemoteConfig.getValue
|
||||
): number {
|
||||
const configValue = getValueFromRemoteConfig(
|
||||
'desktop.calling.audioLevelForSpeaking'
|
||||
);
|
||||
if (typeof configValue !== 'string') {
|
||||
return DEFAULT_AUDIO_LEVEL_FOR_SPEAKING;
|
||||
}
|
||||
|
||||
const result = parseFloat(configValue);
|
||||
const isResultValid = result > 0 && result <= 1;
|
||||
return isResultValid ? result : DEFAULT_AUDIO_LEVEL_FOR_SPEAKING;
|
||||
}
|
24
ts/calling/truncateAudioLevel.ts
Normal file
24
ts/calling/truncateAudioLevel.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// See https://github.com/signalapp/Signal-Android/blob/b527b2ffb94fb82a7508c3b33ddbffef28085349/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt#L87-L100
|
||||
const LOWEST = 500 / 32767;
|
||||
const LOW = 1000 / 32767;
|
||||
const MEDIUM = 5000 / 32767;
|
||||
const HIGH = 16000 / 32767;
|
||||
|
||||
export function truncateAudioLevel(audioLevel: number): number {
|
||||
if (audioLevel < LOWEST) {
|
||||
return 0;
|
||||
}
|
||||
if (audioLevel < LOW) {
|
||||
return 0.25;
|
||||
}
|
||||
if (audioLevel < MEDIUM) {
|
||||
return 0.5;
|
||||
}
|
||||
if (audioLevel < HIGH) {
|
||||
return 0.75;
|
||||
}
|
||||
return 1;
|
||||
}
|
Reference in New Issue
Block a user