瀏覽代碼

ios,callkit: delay updating the muted state until conference starts

In iOS 13 if the call is not unmuted when we report it to the system as started,
an action to unmute it is dispatched automagically. Thanks, Apple.

So, delay synchronizing the muted state until the conference is started (after
the join action). This creates a small window for de-synchronization, but it's
very short and it seems unavoidable.

This change is only applied to operating systems built by the fruit company in
Cupertino.
master
Saúl Ibarra Corretgé 5 年之前
父節點
當前提交
6c4901a826
共有 1 個文件被更改,包括 30 次插入12 次删除
  1. 30
    12
      react/features/mobile/call-integration/middleware.js

+ 30
- 12
react/features/mobile/call-integration/middleware.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { Alert } from 'react-native';
3
+import { Alert, Platform } from 'react-native';
4
 import uuid from 'uuid';
4
 import uuid from 'uuid';
5
 
5
 
6
 import { createTrackMutedEvent, sendAnalytics } from '../../analytics';
6
 import { createTrackMutedEvent, sendAnalytics } from '../../analytics';
170
  * @private
170
  * @private
171
  * @returns {*} The value returned by {@code next(action)}.
171
  * @returns {*} The value returned by {@code next(action)}.
172
  */
172
  */
173
-function _conferenceJoined(store, next, action) {
173
+function _conferenceJoined({ getState }, next, action) {
174
     const result = next(action);
174
     const result = next(action);
175
 
175
 
176
     const { callUUID } = action.conference;
176
     const { callUUID } = action.conference;
177
 
177
 
178
     if (callUUID) {
178
     if (callUUID) {
179
-        CallIntegration.reportConnectedOutgoingCall(callUUID);
179
+        CallIntegration.reportConnectedOutgoingCall(callUUID).then(() => {
180
+            // iOS 13 doesn't like the mute state to be false before the call is started
181
+            // so we update it here in case the user selected startWithAudioMuted.
182
+            if (Platform.OS === 'ios') {
183
+                _updateCallIntegrationMuted(action.conference, getState());
184
+            }
185
+        });
180
     }
186
     }
181
 
187
 
182
     return result;
188
     return result;
238
     CallIntegration.startCall(conference.callUUID, handle, hasVideo)
244
     CallIntegration.startCall(conference.callUUID, handle, hasVideo)
239
         .then(() => {
245
         .then(() => {
240
             const displayName = getConferenceName(state);
246
             const displayName = getConferenceName(state);
241
-            const muted
242
-                = isLocalTrackMuted(
243
-                    state['features/base/tracks'],
244
-                    MEDIA_TYPE.AUDIO);
245
 
247
 
246
             CallIntegration.updateCall(
248
             CallIntegration.updateCall(
247
                 conference.callUUID,
249
                 conference.callUUID,
249
                     displayName,
251
                     displayName,
250
                     hasVideo
252
                     hasVideo
251
                 });
253
                 });
252
-            CallIntegration.setMuted(conference.callUUID, muted);
254
+
255
+            // iOS 13 doesn't like the mute state to be false before the call is started
256
+            // so delay it until the conference was joined.
257
+            if (Platform.OS !== 'ios') {
258
+                _updateCallIntegrationMuted(conference, state);
259
+            }
253
         })
260
         })
254
         .catch(error => {
261
         .catch(error => {
255
             // Currently this error code is emitted only by Android.
262
             // Currently this error code is emitted only by Android.
393
     if (jitsiTrack.isLocal() && conference && conference.callUUID) {
400
     if (jitsiTrack.isLocal() && conference && conference.callUUID) {
394
         switch (jitsiTrack.getType()) {
401
         switch (jitsiTrack.getType()) {
395
         case 'audio': {
402
         case 'audio': {
396
-            const tracks = state['features/base/tracks'];
397
-            const muted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
398
-
399
-            CallIntegration.setMuted(conference.callUUID, muted);
403
+            _updateCallIntegrationMuted(conference, state);
400
             break;
404
             break;
401
         }
405
         }
402
         case 'video': {
406
         case 'video': {
411
 
415
 
412
     return result;
416
     return result;
413
 }
417
 }
418
+
419
+/**
420
+ * Update the muted state in the native side.
421
+ *
422
+ * @param {Object} conference - The current active conference.
423
+ * @param {Object} state - The redux store state.
424
+ * @private
425
+ * @returns {void}
426
+ */
427
+function _updateCallIntegrationMuted(conference, state) {
428
+    const muted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO);
429
+
430
+    CallIntegration.setMuted(conference.callUUID, muted);
431
+}

Loading…
取消
儲存