|
@@ -2,9 +2,10 @@
|
2
|
2
|
|
3
|
3
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
|
4
|
4
|
import {
|
5
|
|
- getParticipantById,
|
6
|
|
- PARTICIPANT_UPDATED,
|
7
|
|
- PARTICIPANT_LEFT
|
|
5
|
+ getParticipantPresenceStatus,
|
|
6
|
+ PARTICIPANT_JOINED_SOUND_ID,
|
|
7
|
+ PARTICIPANT_LEFT,
|
|
8
|
+ PARTICIPANT_UPDATED
|
8
|
9
|
} from '../base/participants';
|
9
|
10
|
import { MiddlewareRegistry } from '../base/redux';
|
10
|
11
|
import {
|
|
@@ -15,24 +16,39 @@ import {
|
15
|
16
|
} from '../base/sounds';
|
16
|
17
|
import {
|
17
|
18
|
CALLING,
|
|
19
|
+ CONNECTED_USER,
|
|
20
|
+ EXPIRED,
|
18
|
21
|
INVITED,
|
|
22
|
+ REJECTED,
|
19
|
23
|
RINGING
|
20
|
24
|
} from '../presence-status';
|
21
|
25
|
|
22
|
26
|
import { UPDATE_DIAL_IN_NUMBERS_FAILED } from './actionTypes';
|
23
|
27
|
import {
|
24
|
|
- OUTGOING_CALL_START_SOUND_ID,
|
25
|
|
- OUTGOING_CALL_RINGING_SOUND_ID
|
|
28
|
+ OUTGOING_CALL_EXPIRED_SOUND_ID,
|
|
29
|
+ OUTGOING_CALL_REJECTED_SOUND_ID,
|
|
30
|
+ OUTGOING_CALL_RINGING_SOUND_ID,
|
|
31
|
+ OUTGOING_CALL_START_SOUND_ID
|
26
|
32
|
} from './constants';
|
27
|
|
-import {
|
28
|
|
- OUTGOING_CALL_START_FILE,
|
29
|
|
- OUTGOING_CALL_RINGING_FILE
|
30
|
|
-} from './sounds';
|
|
33
|
+import { sounds } from './sounds';
|
31
|
34
|
|
32
|
35
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
33
|
36
|
|
34
|
37
|
declare var interfaceConfig: Object;
|
35
|
38
|
|
|
39
|
+/**
|
|
40
|
+ * Maps the presence status with the ID of the sound that will be played when
|
|
41
|
+ * the status is received.
|
|
42
|
+ */
|
|
43
|
+const statusToRingtone = {
|
|
44
|
+ [CALLING]: OUTGOING_CALL_START_SOUND_ID,
|
|
45
|
+ [CONNECTED_USER]: PARTICIPANT_JOINED_SOUND_ID,
|
|
46
|
+ [EXPIRED]: OUTGOING_CALL_EXPIRED_SOUND_ID,
|
|
47
|
+ [INVITED]: OUTGOING_CALL_START_SOUND_ID,
|
|
48
|
+ [REJECTED]: OUTGOING_CALL_REJECTED_SOUND_ID,
|
|
49
|
+ [RINGING]: OUTGOING_CALL_RINGING_SOUND_ID
|
|
50
|
+};
|
|
51
|
+
|
36
|
52
|
/**
|
37
|
53
|
* The middleware of the feature invite common to mobile/react-native and
|
38
|
54
|
* Web/React.
|
|
@@ -46,56 +62,55 @@ MiddlewareRegistry.register(store => next => action => {
|
46
|
62
|
if (action.type === PARTICIPANT_UPDATED
|
47
|
63
|
|| action.type === PARTICIPANT_LEFT) {
|
48
|
64
|
oldParticipantPresence
|
49
|
|
- = _getParticipantPresence(store.getState(), action.participant.id);
|
|
65
|
+ = getParticipantPresenceStatus(
|
|
66
|
+ store.getState(),
|
|
67
|
+ action.participant.id);
|
50
|
68
|
}
|
51
|
69
|
|
52
|
70
|
const result = next(action);
|
53
|
71
|
|
54
|
72
|
switch (action.type) {
|
55
|
73
|
case APP_WILL_MOUNT:
|
56
|
|
- store.dispatch(
|
57
|
|
- registerSound(
|
58
|
|
- OUTGOING_CALL_START_SOUND_ID,
|
59
|
|
- OUTGOING_CALL_START_FILE));
|
60
|
|
-
|
61
|
|
- store.dispatch(
|
62
|
|
- registerSound(
|
63
|
|
- OUTGOING_CALL_RINGING_SOUND_ID,
|
64
|
|
- OUTGOING_CALL_RINGING_FILE,
|
65
|
|
- { loop: true }));
|
|
74
|
+ for (const [ soundId, sound ] of sounds.entries()) {
|
|
75
|
+ store.dispatch(registerSound(soundId, sound.file, sound.options));
|
|
76
|
+ }
|
66
|
77
|
break;
|
67
|
78
|
|
68
|
79
|
case APP_WILL_UNMOUNT:
|
69
|
|
- store.dispatch(unregisterSound(OUTGOING_CALL_START_SOUND_ID));
|
70
|
|
- store.dispatch(unregisterSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
|
80
|
+ for (const soundId of sounds.keys()) {
|
|
81
|
+ store.dispatch(unregisterSound(soundId));
|
|
82
|
+ }
|
71
|
83
|
break;
|
72
|
84
|
|
73
|
85
|
case PARTICIPANT_LEFT:
|
74
|
86
|
case PARTICIPANT_UPDATED: {
|
75
|
87
|
const newParticipantPresence
|
76
|
|
- = _getParticipantPresence(store.getState(), action.participant.id);
|
|
88
|
+ = getParticipantPresenceStatus(
|
|
89
|
+ store.getState(),
|
|
90
|
+ action.participant.id);
|
77
|
91
|
|
78
|
92
|
if (oldParticipantPresence === newParticipantPresence) {
|
79
|
93
|
break;
|
80
|
94
|
}
|
81
|
95
|
|
82
|
|
- switch (oldParticipantPresence) {
|
83
|
|
- case CALLING:
|
84
|
|
- case INVITED:
|
85
|
|
- store.dispatch(stopSound(OUTGOING_CALL_START_SOUND_ID));
|
86
|
|
- break;
|
87
|
|
- case RINGING:
|
88
|
|
- store.dispatch(stopSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
|
96
|
+ const oldSoundId
|
|
97
|
+ = oldParticipantPresence
|
|
98
|
+ && statusToRingtone[oldParticipantPresence];
|
|
99
|
+ const newSoundId
|
|
100
|
+ = newParticipantPresence
|
|
101
|
+ && statusToRingtone[newParticipantPresence];
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+ if (oldSoundId === newSoundId) {
|
89
|
105
|
break;
|
90
|
106
|
}
|
91
|
107
|
|
92
|
|
- switch (newParticipantPresence) {
|
93
|
|
- case CALLING:
|
94
|
|
- case INVITED:
|
95
|
|
- store.dispatch(playSound(OUTGOING_CALL_START_SOUND_ID));
|
96
|
|
- break;
|
97
|
|
- case RINGING:
|
98
|
|
- store.dispatch(playSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
|
108
|
+ if (oldSoundId) {
|
|
109
|
+ store.dispatch(stopSound(oldSoundId));
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ if (newSoundId) {
|
|
113
|
+ store.dispatch(playSound(newSoundId));
|
99
|
114
|
}
|
100
|
115
|
|
101
|
116
|
break;
|
|
@@ -109,22 +124,3 @@ MiddlewareRegistry.register(store => next => action => {
|
109
|
124
|
|
110
|
125
|
return result;
|
111
|
126
|
});
|
112
|
|
-
|
113
|
|
-/**
|
114
|
|
- * Returns the presence status of a participant associated with the passed id.
|
115
|
|
- *
|
116
|
|
- * @param {Object} state - The redux state.
|
117
|
|
- * @param {string} id - The id of the participant.
|
118
|
|
- * @returns {string} - The presence status.
|
119
|
|
- */
|
120
|
|
-function _getParticipantPresence(state, id) {
|
121
|
|
- if (id) {
|
122
|
|
- const participantById = getParticipantById(state, id);
|
123
|
|
-
|
124
|
|
- if (participantById) {
|
125
|
|
- return participantById.presence;
|
126
|
|
- }
|
127
|
|
- }
|
128
|
|
-
|
129
|
|
- return undefined;
|
130
|
|
-}
|