|
|
@@ -19,13 +19,16 @@ import {
|
|
19
|
19
|
import { getInviteURL } from '../../base/connection';
|
|
20
|
20
|
import {
|
|
21
|
21
|
MEDIA_TYPE,
|
|
22
|
|
- SET_AUDIO_MUTED,
|
|
23
|
|
- SET_VIDEO_MUTED,
|
|
24
|
22
|
isVideoMutedByAudioOnly,
|
|
25
|
23
|
setAudioMuted
|
|
26
|
24
|
} from '../../base/media';
|
|
27
|
25
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
28
|
|
-import { TRACK_CREATE_ERROR, isLocalTrackMuted } from '../../base/tracks';
|
|
|
26
|
+import {
|
|
|
27
|
+ TRACK_ADDED,
|
|
|
28
|
+ TRACK_REMOVED,
|
|
|
29
|
+ TRACK_UPDATED,
|
|
|
30
|
+ isLocalTrackMuted
|
|
|
31
|
+} from '../../base/tracks';
|
|
29
|
32
|
|
|
30
|
33
|
import { _SET_CALLKIT_SUBSCRIPTIONS } from './actionTypes';
|
|
31
|
34
|
import CallKit from './CallKit';
|
|
|
@@ -63,14 +66,10 @@ CallKit && MiddlewareRegistry.register(store => next => action => {
|
|
63
|
66
|
case CONFERENCE_WILL_JOIN:
|
|
64
|
67
|
return _conferenceWillJoin(store, next, action);
|
|
65
|
68
|
|
|
66
|
|
- case SET_AUDIO_MUTED:
|
|
67
|
|
- return _setAudioMuted(store, next, action);
|
|
68
|
|
-
|
|
69
|
|
- case SET_VIDEO_MUTED:
|
|
70
|
|
- return _setVideoMuted(store, next, action);
|
|
71
|
|
-
|
|
72
|
|
- case TRACK_CREATE_ERROR:
|
|
73
|
|
- return _trackCreateError(store, next, action);
|
|
|
69
|
+ case TRACK_ADDED:
|
|
|
70
|
+ case TRACK_REMOVED:
|
|
|
71
|
+ case TRACK_UPDATED:
|
|
|
72
|
+ return _syncTrackState(store, next, action);
|
|
74
|
73
|
}
|
|
75
|
74
|
|
|
76
|
75
|
return next(action);
|
|
|
@@ -293,40 +292,15 @@ function _onPerformSetMutedCallAction({ callUUID, muted: newValue }) {
|
|
293
|
292
|
const tracks = getState()['features/base/tracks'];
|
|
294
|
293
|
const oldValue = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
|
|
295
|
294
|
|
|
296
|
|
- if (oldValue !== newValue) {
|
|
297
|
|
- const value = Boolean(newValue);
|
|
|
295
|
+ newValue = Boolean(newValue); // eslint-disable-line no-param-reassign
|
|
298
|
296
|
|
|
299
|
|
- sendAnalytics(createTrackMutedEvent('audio', 'callkit', value));
|
|
300
|
|
- dispatch(setAudioMuted(value, /* ensureTrack */ true));
|
|
|
297
|
+ if (oldValue !== newValue) {
|
|
|
298
|
+ sendAnalytics(createTrackMutedEvent('audio', 'callkit', newValue));
|
|
|
299
|
+ dispatch(setAudioMuted(newValue, /* ensureTrack */ true));
|
|
301
|
300
|
}
|
|
302
|
301
|
}
|
|
303
|
302
|
}
|
|
304
|
303
|
|
|
305
|
|
-/**
|
|
306
|
|
- * Notifies the feature callkit that the action {@link SET_AUDIO_MUTED} is being
|
|
307
|
|
- * dispatched within a specific redux {@code store}.
|
|
308
|
|
- *
|
|
309
|
|
- * @param {Store} store - The redux store in which the specified {@code action}
|
|
310
|
|
- * is being dispatched.
|
|
311
|
|
- * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
|
312
|
|
- * specified {@code action} in the specified {@code store}.
|
|
313
|
|
- * @param {Action} action - The redux action {@code SET_AUDIO_MUTED} which is
|
|
314
|
|
- * being dispatched in the specified {@code store}.
|
|
315
|
|
- * @private
|
|
316
|
|
- * @returns {*} The value returned by {@code next(action)}.
|
|
317
|
|
- */
|
|
318
|
|
-function _setAudioMuted({ getState }, next, action) {
|
|
319
|
|
- const result = next(action);
|
|
320
|
|
-
|
|
321
|
|
- const conference = getCurrentConference(getState);
|
|
322
|
|
-
|
|
323
|
|
- if (conference && conference.callUUID) {
|
|
324
|
|
- CallKit.setMuted(conference.callUUID, action.muted);
|
|
325
|
|
- }
|
|
326
|
|
-
|
|
327
|
|
- return result;
|
|
328
|
|
-}
|
|
329
|
|
-
|
|
330
|
304
|
/**
|
|
331
|
305
|
* Notifies the feature callkit that the action
|
|
332
|
306
|
* {@link _SET_CALLKIT_SUBSCRIPTIONS} is being dispatched within a specific
|
|
|
@@ -354,57 +328,31 @@ function _setCallKitSubscriptions({ getState }, next, action) {
|
|
354
|
328
|
}
|
|
355
|
329
|
|
|
356
|
330
|
/**
|
|
357
|
|
- * Notifies the feature callkit that the action {@link SET_VIDEO_MUTED} is being
|
|
358
|
|
- * dispatched within a specific redux {@code store}.
|
|
|
331
|
+ * Synchronize the muted state of tracks with CallKit.
|
|
359
|
332
|
*
|
|
360
|
333
|
* @param {Store} store - The redux store in which the specified {@code action}
|
|
361
|
334
|
* is being dispatched.
|
|
362
|
335
|
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
|
363
|
336
|
* specified {@code action} in the specified {@code store}.
|
|
364
|
|
- * @param {Action} action - The redux action {@code SET_VIDEO_MUTED} which is
|
|
365
|
|
- * being dispatched in the specified {@code store}.
|
|
|
337
|
+ * @param {Action} action - The redux action which is being dispatched in the
|
|
|
338
|
+ * specified {@code store}.
|
|
366
|
339
|
* @private
|
|
367
|
340
|
* @returns {*} The value returned by {@code next(action)}.
|
|
368
|
341
|
*/
|
|
369
|
|
-function _setVideoMuted({ getState }, next, action) {
|
|
370
|
|
- const result = next(action);
|
|
371
|
|
-
|
|
372
|
|
- const conference = getCurrentConference(getState);
|
|
373
|
|
-
|
|
374
|
|
- if (conference && conference.callUUID) {
|
|
375
|
|
- CallKit.updateCall(
|
|
376
|
|
- conference.callUUID,
|
|
377
|
|
- { hasVideo: !isVideoMutedByAudioOnly(getState) });
|
|
378
|
|
- }
|
|
379
|
|
-
|
|
380
|
|
- return result;
|
|
381
|
|
-}
|
|
382
|
|
-
|
|
383
|
|
-/**
|
|
384
|
|
- * Handles a track creation failure. This is relevant to us in the following
|
|
385
|
|
- * (corner) case: if the user never gave their permission to use the microphone
|
|
386
|
|
- * and try to unmute from the CallKit interface, this will fail, and we need to
|
|
387
|
|
- * sync back the CallKit button state.
|
|
388
|
|
- *
|
|
389
|
|
- * @param {Store} store - The redux store in which the specified {@code action}
|
|
390
|
|
- * is being dispatched.
|
|
391
|
|
- * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
|
|
392
|
|
- * specified {@code action} in the specified {@code store}.
|
|
393
|
|
- * @param {Action} action - The redux action {@code TRACK_CREARE_ERROR} which is
|
|
394
|
|
- * being dispatched in the specified {@code store}.
|
|
395
|
|
- * @private
|
|
396
|
|
- * @returns {*} The value returned by {@code next(action)}.
|
|
397
|
|
- */
|
|
398
|
|
-function _trackCreateError({ getState }, next, action) {
|
|
|
342
|
+function _syncTrackState({ getState }, next, action) {
|
|
399
|
343
|
const result = next(action);
|
|
|
344
|
+ const { track } = action;
|
|
400
|
345
|
const state = getState();
|
|
401
|
346
|
const conference = getCurrentConference(state);
|
|
402
|
347
|
|
|
403
|
|
- if (conference && conference.callUUID) {
|
|
|
348
|
+ if (track.local && conference && conference.callUUID) {
|
|
404
|
349
|
const tracks = state['features/base/tracks'];
|
|
405
|
350
|
const muted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
|
|
406
|
351
|
|
|
407
|
352
|
CallKit.setMuted(conference.callUUID, muted);
|
|
|
353
|
+ CallKit.updateCall(
|
|
|
354
|
+ conference.callUUID,
|
|
|
355
|
+ { hasVideo: !isVideoMutedByAudioOnly(state) });
|
|
408
|
356
|
}
|
|
409
|
357
|
|
|
410
|
358
|
return result;
|