Dynamic audio level indicator
This commit is contained in:
parent
ac59dec5aa
commit
e6223b6a11
24 changed files with 323 additions and 123 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
isAnybodyElseInGroupCall,
|
||||
reducer,
|
||||
} from '../../../state/ducks/calling';
|
||||
import { truncateAudioLevel } from '../../../calling/truncateAudioLevel';
|
||||
import { calling as callingService } from '../../../services/calling';
|
||||
import {
|
||||
CallMode,
|
||||
|
@ -50,7 +51,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-direct-call-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: false,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -129,7 +130,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-group-call-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: false,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -435,7 +436,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-direct-call-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: true,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -528,7 +529,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-group-call-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: true,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -763,9 +764,16 @@ describe('calling duck', () => {
|
|||
{ audioLevel: 0, demuxId: 9 },
|
||||
];
|
||||
|
||||
const remoteAudioLevels = new Map<number, number>([
|
||||
[1, truncateAudioLevel(0.3)],
|
||||
[2, truncateAudioLevel(0.4)],
|
||||
[3, truncateAudioLevel(0.5)],
|
||||
[7, truncateAudioLevel(0.2)],
|
||||
[8, truncateAudioLevel(0.1)],
|
||||
]);
|
||||
|
||||
it("does nothing if there's no relevant call", () => {
|
||||
const action = groupCallAudioLevelsChange({
|
||||
audioLevelForSpeaking: 0.25,
|
||||
conversationId: 'garbage',
|
||||
localAudioLevel: 1,
|
||||
remoteDeviceStates,
|
||||
|
@ -784,14 +792,13 @@ describe('calling duck', () => {
|
|||
...stateWithActiveGroupCall.callsByConversation[
|
||||
'fake-group-call-conversation-id'
|
||||
],
|
||||
speakingDemuxIds: new Set([3, 2, 1]),
|
||||
remoteAudioLevels,
|
||||
},
|
||||
},
|
||||
};
|
||||
const action = groupCallAudioLevelsChange({
|
||||
audioLevelForSpeaking: 0.25,
|
||||
conversationId: 'fake-group-call-conversation-id',
|
||||
localAudioLevel: 0.1,
|
||||
localAudioLevel: 0.001,
|
||||
remoteDeviceStates,
|
||||
});
|
||||
|
||||
|
@ -802,21 +809,23 @@ describe('calling duck', () => {
|
|||
|
||||
it('updates the set of speaking participants, including yourself', () => {
|
||||
const action = groupCallAudioLevelsChange({
|
||||
audioLevelForSpeaking: 0.25,
|
||||
conversationId: 'fake-group-call-conversation-id',
|
||||
localAudioLevel: 0.8,
|
||||
remoteDeviceStates,
|
||||
});
|
||||
const result = reducer(stateWithActiveGroupCall, action);
|
||||
|
||||
assert.isTrue(result.activeCallState?.amISpeaking);
|
||||
assert.strictEqual(
|
||||
result.activeCallState?.localAudioLevel,
|
||||
truncateAudioLevel(0.8)
|
||||
);
|
||||
|
||||
const call =
|
||||
result.callsByConversation['fake-group-call-conversation-id'];
|
||||
if (call?.callMode !== CallMode.Group) {
|
||||
throw new Error('Expected a group call to be found');
|
||||
}
|
||||
assert.deepStrictEqual(call.speakingDemuxIds, new Set([1, 2, 3]));
|
||||
assert.deepStrictEqual(call.remoteAudioLevels, remoteAudioLevels);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1112,7 +1121,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-group-call-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: false,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -1641,7 +1650,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: true,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
@ -1927,7 +1936,7 @@ describe('calling duck', () => {
|
|||
conversationId: 'fake-conversation-id',
|
||||
hasLocalAudio: true,
|
||||
hasLocalVideo: false,
|
||||
amISpeaking: false,
|
||||
localAudioLevel: 0,
|
||||
isInSpeakerView: false,
|
||||
showParticipantsList: false,
|
||||
safetyNumberChangedUuids: [],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue