Browse Source

fix(ios) fix leaving the meeting when screen-sharing

master
Alex Bumbu 4 years ago
parent
commit
cf37d34923

+ 4
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java View File

20
         return intent;
20
         return intent;
21
     }
21
     }
22
 
22
 
23
-    public static Intent buildToggleScreenShareIntent() {
24
-        return new Intent(BroadcastAction.Type.TOGGLE_SCREEN_SHARE.getAction());
23
+    public static Intent buildToggleScreenShareIntent(boolean enabled) {
24
+        Intent intent = new Intent(BroadcastAction.Type.TOGGLE_SCREEN_SHARE.getAction());
25
+        intent.putExtra("enabled", enabled);
26
+        return intent;
25
     }
27
     }
26
 
28
 
27
     public static Intent buildOpenChatIntent(String participantId) {
29
     public static Intent buildOpenChatIntent(String participantId) {

+ 1
- 1
ios/sdk/sdk.xcodeproj/project.pbxproj View File

198
 				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
198
 				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
199
 				C69EFA02209A0EFD0027712B /* callkit */,
199
 				C69EFA02209A0EFD0027712B /* callkit */,
200
 				A4A934E7212F3AB8001E9388 /* dropbox */,
200
 				A4A934E7212F3AB8001E9388 /* dropbox */,
201
-				0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
202
 				0BD906E91EC0C00300C8C18E /* Info.plist */,
201
 				0BD906E91EC0C00300C8C18E /* Info.plist */,
203
 				DE438CD82350934700DD541D /* JavaScriptSandbox.m */,
202
 				DE438CD82350934700DD541D /* JavaScriptSandbox.m */,
204
 				0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
203
 				0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
235
 				C8AFD27D2462C613000293D2 /* InfoPlistUtil.h */,
234
 				C8AFD27D2462C613000293D2 /* InfoPlistUtil.h */,
236
 				C8AFD27E2462C613000293D2 /* InfoPlistUtil.m */,
235
 				C8AFD27E2462C613000293D2 /* InfoPlistUtil.m */,
237
 				C81E9AB825AC5AD800B134D9 /* ExternalAPI.h */,
236
 				C81E9AB825AC5AD800B134D9 /* ExternalAPI.h */,
237
+				0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
238
 				4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */,
238
 				4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */,
239
 				4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */,
239
 				4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */,
240
 			);
240
 			);

+ 1
- 1
ios/sdk/src/ExternalAPI.h View File

21
 - (void)sendHangUp;
21
 - (void)sendHangUp;
22
 - (void)sendSetAudioMuted:(BOOL)muted;
22
 - (void)sendSetAudioMuted:(BOOL)muted;
23
 - (void)sendEndpointTextMessage:(NSString*)message :(NSString*)to;
23
 - (void)sendEndpointTextMessage:(NSString*)message :(NSString*)to;
24
-- (void)toggleScreenShare;
24
+- (void)toggleScreenShare:(BOOL)enabled;
25
 - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completion;
25
 - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completion;
26
 - (void)openChat:(NSString*)to;
26
 - (void)openChat:(NSString*)to;
27
 - (void)closeChat;
27
 - (void)closeChat;

+ 5
- 2
ios/sdk/src/ExternalAPI.m View File

164
     [self sendEventWithName:sendEndpointTextMessageAction body:data];
164
     [self sendEventWithName:sendEndpointTextMessageAction body:data];
165
 }
165
 }
166
 
166
 
167
-- (void)toggleScreenShare {
168
-    [self sendEventWithName:toggleScreenShareAction body:nil];
167
+- (void)toggleScreenShare:(BOOL)enabled {
168
+    NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
169
+    data[@"enabled"] = [NSNumber numberWithBool:enabled];
170
+    
171
+    [self sendEventWithName:toggleScreenShareAction body:data];
169
 }
172
 }
170
 
173
 
171
 - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completionHandler {
174
 - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completionHandler {

+ 1
- 1
ios/sdk/src/JitsiMeetView.h View File

39
 - (void)hangUp;
39
 - (void)hangUp;
40
 - (void)setAudioMuted:(BOOL)muted;
40
 - (void)setAudioMuted:(BOOL)muted;
41
 - (void)sendEndpointTextMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to;
41
 - (void)sendEndpointTextMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to;
42
-- (void)toggleScreenShare;
42
+- (void)toggleScreenShare:(BOOL)enabled;
43
 - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler;
43
 - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler;
44
 - (void)openChat:(NSString * _Nullable)to;
44
 - (void)openChat:(NSString * _Nullable)to;
45
 - (void)closeChat;
45
 - (void)closeChat;

+ 2
- 2
ios/sdk/src/JitsiMeetView.m View File

130
     [externalAPI sendEndpointTextMessage:message :to];
130
     [externalAPI sendEndpointTextMessage:message :to];
131
 }
131
 }
132
 
132
 
133
-- (void)toggleScreenShare {
133
+- (void)toggleScreenShare:(BOOL)enabled {
134
     ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
134
     ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
135
-    [externalAPI toggleScreenShare];
135
+    [externalAPI toggleScreenShare:enabled];
136
 }
136
 }
137
 
137
 
138
 - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler {
138
 - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler {

+ 17
- 8
ios/sdk/src/ScheenshareEventEmiter.m View File

42
 // MARK: Private Methods
42
 // MARK: Private Methods
43
 
43
 
44
 - (void)setupObserver {
44
 - (void)setupObserver {
45
-    CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastToggleNotificationCallback, (__bridge CFStringRef)kBroadcastStartedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
46
-    CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastToggleNotificationCallback, (__bridge CFStringRef)kBroadcastStoppedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
45
+    CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastStartedNotificationCallback, (__bridge CFStringRef)kBroadcastStartedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
46
+    CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastStoppedNotificationCallback, (__bridge CFStringRef)kBroadcastStoppedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
47
 }
47
 }
48
 
48
 
49
 - (void)clearObserver {
49
 - (void)clearObserver {
51
     CFNotificationCenterRemoveObserver(_notificationCenter, (__bridge const void *)(self), (__bridge CFStringRef)kBroadcastStoppedNotification, NULL);
51
     CFNotificationCenterRemoveObserver(_notificationCenter, (__bridge const void *)(self), (__bridge CFStringRef)kBroadcastStoppedNotification, NULL);
52
 }
52
 }
53
 
53
 
54
-void broadcastToggleNotificationCallback(CFNotificationCenterRef center,
55
-                                         void *observer,
56
-                                         CFStringRef name,
57
-                                         const void *object,
58
-                                         CFDictionaryRef userInfo) {
54
+void broadcastStartedNotificationCallback(CFNotificationCenterRef center,
55
+                                          void *observer,
56
+                                          CFStringRef name,
57
+                                          const void *object,
58
+                                          CFDictionaryRef userInfo) {
59
     ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
59
     ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
60
-    [externalAPI toggleScreenShare];
60
+    [externalAPI toggleScreenShare:true];
61
+}
62
+
63
+void broadcastStoppedNotificationCallback(CFNotificationCenterRef center,
64
+                                          void *observer,
65
+                                          CFStringRef name,
66
+                                          const void *object,
67
+                                          CFDictionaryRef userInfo) {
68
+    ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
69
+    [externalAPI toggleScreenShare:false];
61
 }
70
 }
62
 
71
 
63
 @end
72
 @end

+ 9
- 6
react/features/base/conference/middleware.native.js View File

13
 MiddlewareRegistry.register(store => next => action => {
13
 MiddlewareRegistry.register(store => next => action => {
14
     switch (action.type) {
14
     switch (action.type) {
15
     case TOGGLE_SCREENSHARING: {
15
     case TOGGLE_SCREENSHARING: {
16
-        _toggleScreenSharing(store);
16
+        _toggleScreenSharing(action.enabled, store);
17
         break;
17
         break;
18
     }
18
     }
19
     }
19
     }
25
  * Toggles screen sharing.
25
  * Toggles screen sharing.
26
  *
26
  *
27
  * @private
27
  * @private
28
+ * @param {boolean} enabled - The state to toggle screen sharing to.
28
  * @param {Store} store - The redux.
29
  * @param {Store} store - The redux.
29
  * @returns {void}
30
  * @returns {void}
30
  */
31
  */
31
-function _toggleScreenSharing(store) {
32
+function _toggleScreenSharing(enabled, store) {
32
     const { dispatch, getState } = store;
33
     const { dispatch, getState } = store;
33
     const state = getState();
34
     const state = getState();
34
 
35
 
35
-    const isSharing = isLocalVideoTrackDesktop(state);
36
+    if (enabled) {
37
+        const isSharing = isLocalVideoTrackDesktop(state);
36
 
38
 
37
-    if (isSharing) {
38
-        dispatch(destroyLocalDesktopTrackIfExists());
39
+        if (!isSharing) {
40
+            _startScreenSharing(dispatch, state);
41
+        }
39
     } else {
42
     } else {
40
-        _startScreenSharing(dispatch, state);
43
+        dispatch(destroyLocalDesktopTrackIfExists());
41
     }
44
     }
42
 }
45
 }
43
 
46
 

+ 4
- 1
react/features/base/tracks/actions.js View File

257
  * Signals that the local participant is ending screensharing or beginning the
257
  * Signals that the local participant is ending screensharing or beginning the
258
  * screensharing flow.
258
  * screensharing flow.
259
  *
259
  *
260
+ * @param {boolean} enabled - The state to toggle screen sharing to.
260
  * @param {boolean} audioOnly - Only share system audio.
261
  * @param {boolean} audioOnly - Only share system audio.
261
  * @returns {{
262
  * @returns {{
262
  *     type: TOGGLE_SCREENSHARING,
263
  *     type: TOGGLE_SCREENSHARING,
264
+ *     on: boolean,
263
  *     audioOnly: boolean
265
  *     audioOnly: boolean
264
  * }}
266
  * }}
265
  */
267
  */
266
-export function toggleScreensharing(audioOnly = false) {
268
+export function toggleScreensharing(enabled, audioOnly = false) {
267
     return {
269
     return {
268
         type: TOGGLE_SCREENSHARING,
270
         type: TOGGLE_SCREENSHARING,
271
+        enabled,
269
         audioOnly
272
         audioOnly
270
     };
273
     };
271
 }
274
 }

+ 2
- 2
react/features/mobile/external-api/middleware.js View File

300
         }
300
         }
301
     });
301
     });
302
 
302
 
303
-    eventEmitter.addListener(ExternalAPI.TOGGLE_SCREEN_SHARE, () => {
304
-        dispatch(toggleScreensharing());
303
+    eventEmitter.addListener(ExternalAPI.TOGGLE_SCREEN_SHARE, ({ enabled }) => {
304
+        dispatch(toggleScreensharing(enabled));
305
     });
305
     });
306
 
306
 
307
     eventEmitter.addListener(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO, ({ requestId }) => {
307
     eventEmitter.addListener(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO, ({ requestId }) => {

+ 3
- 1
react/features/toolbox/components/native/ScreenSharingAndroidButton.js View File

39
      * @returns {void}
39
      * @returns {void}
40
      */
40
      */
41
     _handleClick() {
41
     _handleClick() {
42
-        this.props.dispatch(toggleScreensharing());
42
+        const enable = !this._isToggled();
43
+
44
+        this.props.dispatch(toggleScreensharing(enable));
43
     }
45
     }
44
 
46
 
45
     /**
47
     /**

+ 14
- 7
react/features/toolbox/components/web/Toolbox.js View File

504
      * Dispatches an action to toggle screensharing.
504
      * Dispatches an action to toggle screensharing.
505
      *
505
      *
506
      * @private
506
      * @private
507
+     * @param {boolean} enabled - The state to toggle screen sharing to.
507
      * @param {boolean} audioOnly - Only share system audio.
508
      * @param {boolean} audioOnly - Only share system audio.
508
      * @returns {void}
509
      * @returns {void}
509
      */
510
      */
510
-    _doToggleScreenshare(audioOnly = false) {
511
+    _doToggleScreenshare(enabled, audioOnly = false) {
511
         if (this.props._desktopSharingEnabled) {
512
         if (this.props._desktopSharingEnabled) {
512
-            this.props.dispatch(toggleScreensharing(audioOnly));
513
+            this.props.dispatch(toggleScreensharing(enabled, audioOnly));
513
         }
514
         }
514
     }
515
     }
515
 
516
 
690
      * @returns {void}
691
      * @returns {void}
691
      */
692
      */
692
     _onShortcutToggleScreenshare() {
693
     _onShortcutToggleScreenshare() {
694
+        const enable = !this.props._screensharing;
695
+
693
         sendAnalytics(createToolbarEvent(
696
         sendAnalytics(createToolbarEvent(
694
             'screen.sharing',
697
             'screen.sharing',
695
             {
698
             {
696
-                enable: !this.props._screensharing
699
+                enable
697
             }));
700
             }));
698
 
701
 
699
-        this._doToggleScreenshare();
702
+        this._doToggleScreenshare(enable);
700
     }
703
     }
701
 
704
 
702
     _onTabIn: () => void;
705
     _onTabIn: () => void;
889
             return;
892
             return;
890
         }
893
         }
891
 
894
 
895
+        const enable = !this.props._screensharing;
896
+
892
         sendAnalytics(createShortcutEvent(
897
         sendAnalytics(createShortcutEvent(
893
             'toggle.screen.sharing',
898
             'toggle.screen.sharing',
894
             ACTION_SHORTCUT_TRIGGERED,
899
             ACTION_SHORTCUT_TRIGGERED,
895
-            { enable: !this.props._screensharing }));
900
+            { enable }));
896
 
901
 
897
         this._closeOverflowMenuIfOpen();
902
         this._closeOverflowMenuIfOpen();
898
-        this._doToggleScreenshare();
903
+        this._doToggleScreenshare(enable);
899
     }
904
     }
900
 
905
 
901
     _onToolbarToggleShareAudio: () => void;
906
     _onToolbarToggleShareAudio: () => void;
906
      * @returns {void}
911
      * @returns {void}
907
      */
912
      */
908
     _onToolbarToggleShareAudio() {
913
     _onToolbarToggleShareAudio() {
914
+        const enable = !this.props._screensharing;
915
+
909
         this._closeOverflowMenuIfOpen();
916
         this._closeOverflowMenuIfOpen();
910
-        this._doToggleScreenshare(true);
917
+        this._doToggleScreenshare(enable, true);
911
     }
918
     }
912
 
919
 
913
     _onToolbarOpenLocalRecordingInfoDialog: () => void;
920
     _onToolbarOpenLocalRecordingInfoDialog: () => void;

Loading…
Cancel
Save