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

pull/8966/head jitsi-meet_5824
Alex Bumbu 4 years ago committed by Saúl Ibarra Corretgé
parent f187923233
commit cf37d34923
  1. 6
      android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java
  2. 2
      ios/sdk/sdk.xcodeproj/project.pbxproj
  3. 2
      ios/sdk/src/ExternalAPI.h
  4. 7
      ios/sdk/src/ExternalAPI.m
  5. 2
      ios/sdk/src/JitsiMeetView.h
  6. 4
      ios/sdk/src/JitsiMeetView.m
  7. 25
      ios/sdk/src/ScheenshareEventEmiter.m
  8. 15
      react/features/base/conference/middleware.native.js
  9. 5
      react/features/base/tracks/actions.js
  10. 4
      react/features/mobile/external-api/middleware.js
  11. 4
      react/features/toolbox/components/native/ScreenSharingAndroidButton.js
  12. 21
      react/features/toolbox/components/web/Toolbox.js

@ -20,8 +20,10 @@ public class BroadcastIntentHelper {
return intent; return intent;
} }
public static Intent buildToggleScreenShareIntent() { public static Intent buildToggleScreenShareIntent(boolean enabled) {
return new Intent(BroadcastAction.Type.TOGGLE_SCREEN_SHARE.getAction()); Intent intent = new Intent(BroadcastAction.Type.TOGGLE_SCREEN_SHARE.getAction());
intent.putExtra("enabled", enabled);
return intent;
} }
public static Intent buildOpenChatIntent(String participantId) { public static Intent buildOpenChatIntent(String participantId) {

@ -198,7 +198,6 @@
0BCA495C1EC4B6C600B793EE /* AudioMode.m */, 0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
C69EFA02209A0EFD0027712B /* callkit */, C69EFA02209A0EFD0027712B /* callkit */,
A4A934E7212F3AB8001E9388 /* dropbox */, A4A934E7212F3AB8001E9388 /* dropbox */,
0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
0BD906E91EC0C00300C8C18E /* Info.plist */, 0BD906E91EC0C00300C8C18E /* Info.plist */,
DE438CD82350934700DD541D /* JavaScriptSandbox.m */, DE438CD82350934700DD541D /* JavaScriptSandbox.m */,
0BD906E81EC0C00300C8C18E /* JitsiMeet.h */, 0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
@ -235,6 +234,7 @@
C8AFD27D2462C613000293D2 /* InfoPlistUtil.h */, C8AFD27D2462C613000293D2 /* InfoPlistUtil.h */,
C8AFD27E2462C613000293D2 /* InfoPlistUtil.m */, C8AFD27E2462C613000293D2 /* InfoPlistUtil.m */,
C81E9AB825AC5AD800B134D9 /* ExternalAPI.h */, C81E9AB825AC5AD800B134D9 /* ExternalAPI.h */,
0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */, 4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */,
4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */, 4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */,
); );

@ -21,7 +21,7 @@
- (void)sendHangUp; - (void)sendHangUp;
- (void)sendSetAudioMuted:(BOOL)muted; - (void)sendSetAudioMuted:(BOOL)muted;
- (void)sendEndpointTextMessage:(NSString*)message :(NSString*)to; - (void)sendEndpointTextMessage:(NSString*)message :(NSString*)to;
- (void)toggleScreenShare; - (void)toggleScreenShare:(BOOL)enabled;
- (void)retrieveParticipantsInfo:(void (^)(NSArray*))completion; - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completion;
- (void)openChat:(NSString*)to; - (void)openChat:(NSString*)to;
- (void)closeChat; - (void)closeChat;

@ -164,8 +164,11 @@ RCT_EXPORT_METHOD(sendEvent:(NSString *)name
[self sendEventWithName:sendEndpointTextMessageAction body:data]; [self sendEventWithName:sendEndpointTextMessageAction body:data];
} }
- (void)toggleScreenShare { - (void)toggleScreenShare:(BOOL)enabled {
[self sendEventWithName:toggleScreenShareAction body:nil]; NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
data[@"enabled"] = [NSNumber numberWithBool:enabled];
[self sendEventWithName:toggleScreenShareAction body:data];
} }
- (void)retrieveParticipantsInfo:(void (^)(NSArray*))completionHandler { - (void)retrieveParticipantsInfo:(void (^)(NSArray*))completionHandler {

@ -39,7 +39,7 @@
- (void)hangUp; - (void)hangUp;
- (void)setAudioMuted:(BOOL)muted; - (void)setAudioMuted:(BOOL)muted;
- (void)sendEndpointTextMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to; - (void)sendEndpointTextMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to;
- (void)toggleScreenShare; - (void)toggleScreenShare:(BOOL)enabled;
- (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler; - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler;
- (void)openChat:(NSString * _Nullable)to; - (void)openChat:(NSString * _Nullable)to;
- (void)closeChat; - (void)closeChat;

@ -130,9 +130,9 @@ static void initializeViewsMap() {
[externalAPI sendEndpointTextMessage:message :to]; [externalAPI sendEndpointTextMessage:message :to];
} }
- (void)toggleScreenShare { - (void)toggleScreenShare:(BOOL)enabled {
ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI]; ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
[externalAPI toggleScreenShare]; [externalAPI toggleScreenShare:enabled];
} }
- (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler { - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler {

@ -42,8 +42,8 @@ NSNotificationName const kBroadcastStoppedNotification = @"iOS_BroadcastStopped"
// MARK: Private Methods // MARK: Private Methods
- (void)setupObserver { - (void)setupObserver {
CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastToggleNotificationCallback, (__bridge CFStringRef)kBroadcastStartedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastStartedNotificationCallback, (__bridge CFStringRef)kBroadcastStartedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastToggleNotificationCallback, (__bridge CFStringRef)kBroadcastStoppedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(_notificationCenter, (__bridge const void *)(self), broadcastStoppedNotificationCallback, (__bridge CFStringRef)kBroadcastStoppedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
} }
- (void)clearObserver { - (void)clearObserver {
@ -51,13 +51,22 @@ NSNotificationName const kBroadcastStoppedNotification = @"iOS_BroadcastStopped"
CFNotificationCenterRemoveObserver(_notificationCenter, (__bridge const void *)(self), (__bridge CFStringRef)kBroadcastStoppedNotification, NULL); CFNotificationCenterRemoveObserver(_notificationCenter, (__bridge const void *)(self), (__bridge CFStringRef)kBroadcastStoppedNotification, NULL);
} }
void broadcastToggleNotificationCallback(CFNotificationCenterRef center, void broadcastStartedNotificationCallback(CFNotificationCenterRef center,
void *observer, void *observer,
CFStringRef name, CFStringRef name,
const void *object, const void *object,
CFDictionaryRef userInfo) { CFDictionaryRef userInfo) {
ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI]; ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
[externalAPI toggleScreenShare]; [externalAPI toggleScreenShare:true];
}
void broadcastStoppedNotificationCallback(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo) {
ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
[externalAPI toggleScreenShare:false];
} }
@end @end

@ -13,7 +13,7 @@ import './middleware.any';
MiddlewareRegistry.register(store => next => action => { MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case TOGGLE_SCREENSHARING: { case TOGGLE_SCREENSHARING: {
_toggleScreenSharing(store); _toggleScreenSharing(action.enabled, store);
break; break;
} }
} }
@ -25,19 +25,22 @@ MiddlewareRegistry.register(store => next => action => {
* Toggles screen sharing. * Toggles screen sharing.
* *
* @private * @private
* @param {boolean} enabled - The state to toggle screen sharing to.
* @param {Store} store - The redux. * @param {Store} store - The redux.
* @returns {void} * @returns {void}
*/ */
function _toggleScreenSharing(store) { function _toggleScreenSharing(enabled, store) {
const { dispatch, getState } = store; const { dispatch, getState } = store;
const state = getState(); const state = getState();
const isSharing = isLocalVideoTrackDesktop(state); if (enabled) {
const isSharing = isLocalVideoTrackDesktop(state);
if (isSharing) { if (!isSharing) {
dispatch(destroyLocalDesktopTrackIfExists()); _startScreenSharing(dispatch, state);
}
} else { } else {
_startScreenSharing(dispatch, state); dispatch(destroyLocalDesktopTrackIfExists());
} }
} }

@ -257,15 +257,18 @@ export function showNoDataFromSourceVideoError(jitsiTrack) {
* Signals that the local participant is ending screensharing or beginning the * Signals that the local participant is ending screensharing or beginning the
* screensharing flow. * screensharing flow.
* *
* @param {boolean} enabled - The state to toggle screen sharing to.
* @param {boolean} audioOnly - Only share system audio. * @param {boolean} audioOnly - Only share system audio.
* @returns {{ * @returns {{
* type: TOGGLE_SCREENSHARING, * type: TOGGLE_SCREENSHARING,
* on: boolean,
* audioOnly: boolean * audioOnly: boolean
* }} * }}
*/ */
export function toggleScreensharing(audioOnly = false) { export function toggleScreensharing(enabled, audioOnly = false) {
return { return {
type: TOGGLE_SCREENSHARING, type: TOGGLE_SCREENSHARING,
enabled,
audioOnly audioOnly
}; };
} }

@ -300,8 +300,8 @@ function _registerForNativeEvents(store) {
} }
}); });
eventEmitter.addListener(ExternalAPI.TOGGLE_SCREEN_SHARE, () => { eventEmitter.addListener(ExternalAPI.TOGGLE_SCREEN_SHARE, ({ enabled }) => {
dispatch(toggleScreensharing()); dispatch(toggleScreensharing(enabled));
}); });
eventEmitter.addListener(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO, ({ requestId }) => { eventEmitter.addListener(ExternalAPI.RETRIEVE_PARTICIPANTS_INFO, ({ requestId }) => {

@ -39,7 +39,9 @@ class ScreenSharingAndroidButton extends AbstractButton<Props, *> {
* @returns {void} * @returns {void}
*/ */
_handleClick() { _handleClick() {
this.props.dispatch(toggleScreensharing()); const enable = !this._isToggled();
this.props.dispatch(toggleScreensharing(enable));
} }
/** /**

@ -504,12 +504,13 @@ class Toolbox extends Component<Props> {
* Dispatches an action to toggle screensharing. * Dispatches an action to toggle screensharing.
* *
* @private * @private
* @param {boolean} enabled - The state to toggle screen sharing to.
* @param {boolean} audioOnly - Only share system audio. * @param {boolean} audioOnly - Only share system audio.
* @returns {void} * @returns {void}
*/ */
_doToggleScreenshare(audioOnly = false) { _doToggleScreenshare(enabled, audioOnly = false) {
if (this.props._desktopSharingEnabled) { if (this.props._desktopSharingEnabled) {
this.props.dispatch(toggleScreensharing(audioOnly)); this.props.dispatch(toggleScreensharing(enabled, audioOnly));
} }
} }
@ -690,13 +691,15 @@ class Toolbox extends Component<Props> {
* @returns {void} * @returns {void}
*/ */
_onShortcutToggleScreenshare() { _onShortcutToggleScreenshare() {
const enable = !this.props._screensharing;
sendAnalytics(createToolbarEvent( sendAnalytics(createToolbarEvent(
'screen.sharing', 'screen.sharing',
{ {
enable: !this.props._screensharing enable
})); }));
this._doToggleScreenshare(); this._doToggleScreenshare(enable);
} }
_onTabIn: () => void; _onTabIn: () => void;
@ -889,13 +892,15 @@ class Toolbox extends Component<Props> {
return; return;
} }
const enable = !this.props._screensharing;
sendAnalytics(createShortcutEvent( sendAnalytics(createShortcutEvent(
'toggle.screen.sharing', 'toggle.screen.sharing',
ACTION_SHORTCUT_TRIGGERED, ACTION_SHORTCUT_TRIGGERED,
{ enable: !this.props._screensharing })); { enable }));
this._closeOverflowMenuIfOpen(); this._closeOverflowMenuIfOpen();
this._doToggleScreenshare(); this._doToggleScreenshare(enable);
} }
_onToolbarToggleShareAudio: () => void; _onToolbarToggleShareAudio: () => void;
@ -906,8 +911,10 @@ class Toolbox extends Component<Props> {
* @returns {void} * @returns {void}
*/ */
_onToolbarToggleShareAudio() { _onToolbarToggleShareAudio() {
const enable = !this.props._screensharing;
this._closeOverflowMenuIfOpen(); this._closeOverflowMenuIfOpen();
this._doToggleScreenshare(true); this._doToggleScreenshare(enable, true);
} }
_onToolbarOpenLocalRecordingInfoDialog: () => void; _onToolbarOpenLocalRecordingInfoDialog: () => void;

Loading…
Cancel
Save