diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java index 37eb89da5..e793a99b0 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java @@ -77,7 +77,8 @@ public class BroadcastAction { CLOSE_CHAT("org.jitsi.meet.CLOSE_CHAT"), SEND_CHAT_MESSAGE("org.jitsi.meet.SEND_CHAT_MESSAGE"), SET_VIDEO_MUTED("org.jitsi.meet.SET_VIDEO_MUTED"), - SET_CLOSED_CAPTIONS_ENABLED("org.jitsi.meet.SET_CLOSED_CAPTIONS_ENABLED"); + SET_CLOSED_CAPTIONS_ENABLED("org.jitsi.meet.SET_CLOSED_CAPTIONS_ENABLED"), + TOGGLE_CAMERA("org.jitsi.meet.TOGGLE_CAMERA"); private final String action; diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java index b70caea97..e842d0a8d 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java @@ -54,4 +54,8 @@ public class BroadcastIntentHelper { intent.putExtra("enabled", enabled); return intent; } + + public static Intent buildToggleCameraIntent() { + return new Intent(BroadcastAction.Type.TOGGLE_CAMERA.getAction()); + } } diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java index 325c2c822..02202c9c8 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java @@ -96,6 +96,7 @@ class ExternalAPIModule extends ReactContextBaseJavaModule { constants.put("SEND_CHAT_MESSAGE", BroadcastAction.Type.SEND_CHAT_MESSAGE.getAction()); constants.put("SET_VIDEO_MUTED", BroadcastAction.Type.SET_VIDEO_MUTED.getAction()); constants.put("SET_CLOSED_CAPTIONS_ENABLED", BroadcastAction.Type.SET_CLOSED_CAPTIONS_ENABLED.getAction()); + constants.put("TOGGLE_CAMERA", BroadcastAction.Type.TOGGLE_CAMERA.getAction()); return constants; } diff --git a/ios/sdk/src/ExternalAPI.h b/ios/sdk/src/ExternalAPI.h index b27d51dc8..e3c43a22e 100644 --- a/ios/sdk/src/ExternalAPI.h +++ b/ios/sdk/src/ExternalAPI.h @@ -30,5 +30,6 @@ static NSString * const sendEventNotificationName = @"org.jitsi.meet.SendEvent"; - (void)sendChatMessage:(NSString*)message :(NSString*)to ; - (void)sendSetVideoMuted:(BOOL)muted; - (void)sendSetClosedCaptionsEnabled:(BOOL)enabled; +- (void)toggleCamera; @end diff --git a/ios/sdk/src/ExternalAPI.m b/ios/sdk/src/ExternalAPI.m index 654312688..7437d43f8 100644 --- a/ios/sdk/src/ExternalAPI.m +++ b/ios/sdk/src/ExternalAPI.m @@ -27,6 +27,7 @@ static NSString * const closeChatAction = @"org.jitsi.meet.CLOSE_CHAT"; static NSString * const sendChatMessageAction = @"org.jitsi.meet.SEND_CHAT_MESSAGE"; static NSString * const setVideoMutedAction = @"org.jitsi.meet.SET_VIDEO_MUTED"; static NSString * const setClosedCaptionsEnabledAction = @"org.jitsi.meet.SET_CLOSED_CAPTIONS_ENABLED"; +static NSString * const toggleCameraAction = @"org.jitsi.meet.TOGGLE_CAMERA"; @implementation ExternalAPI @@ -50,7 +51,8 @@ RCT_EXPORT_MODULE(); @"CLOSE_CHAT": closeChatAction, @"SEND_CHAT_MESSAGE": sendChatMessageAction, @"SET_VIDEO_MUTED" : setVideoMutedAction, - @"SET_CLOSED_CAPTIONS_ENABLED": setClosedCaptionsEnabledAction + @"SET_CLOSED_CAPTIONS_ENABLED": setClosedCaptionsEnabledAction, + @"TOGGLE_CAMERA": toggleCameraAction }; }; @@ -75,7 +77,8 @@ RCT_EXPORT_MODULE(); closeChatAction, sendChatMessageAction, setVideoMutedAction, - setClosedCaptionsEnabledAction + setClosedCaptionsEnabledAction, + toggleCameraAction ]; } @@ -173,4 +176,8 @@ RCT_EXPORT_METHOD(sendEvent:(NSString *)name [self sendEventWithName:setClosedCaptionsEnabledAction body:data]; } +- (void)toggleCamera { + [self sendEventWithName:toggleCameraAction body:nil]; +} + @end diff --git a/ios/sdk/src/JitsiMeetView.h b/ios/sdk/src/JitsiMeetView.h index c81007872..3ab9cb4df 100644 --- a/ios/sdk/src/JitsiMeetView.h +++ b/ios/sdk/src/JitsiMeetView.h @@ -46,5 +46,6 @@ - (void)sendChatMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to; - (void)setVideoMuted:(BOOL)muted; - (void)setClosedCaptionsEnabled:(BOOL)enabled; +- (void)toggleCamera; @end diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m index 8ca3c6c0a..5691de1b0 100644 --- a/ios/sdk/src/JitsiMeetView.m +++ b/ios/sdk/src/JitsiMeetView.m @@ -138,6 +138,11 @@ static NSString *const PiPEnabledFeatureFlag = @"pip.enabled"; [externalAPI sendSetClosedCaptionsEnabled:enabled]; } +- (void)toggleCamera { + ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI]; + [externalAPI toggleCamera]; +} + #pragma mark Private methods - (void)registerObservers { diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.js index 83926aede..453cc8853 100644 --- a/react/features/mobile/external-api/middleware.js +++ b/react/features/mobile/external-api/middleware.js @@ -25,7 +25,7 @@ import { } from '../../base/connection'; import { JitsiConferenceEvents } from '../../base/lib-jitsi-meet'; -import { MEDIA_TYPE } from '../../base/media'; +import { MEDIA_TYPE, toggleCameraFacingMode } from '../../base/media'; import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes'; import { PARTICIPANT_JOINED, @@ -370,6 +370,10 @@ function _registerForNativeEvents(store) { eventEmitter.addListener(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED, ({ enabled }) => { dispatch(setRequestingSubtitles(enabled)); }); + + eventEmitter.addListener(ExternalAPI.TOGGLE_CAMERA, () => { + dispatch(toggleCameraFacingMode()); + }); } /** @@ -389,6 +393,7 @@ function _unregisterForNativeEvents() { eventEmitter.removeAllListeners(ExternalAPI.CLOSE_CHAT); eventEmitter.removeAllListeners(ExternalAPI.SEND_CHAT_MESSAGE); eventEmitter.removeAllListeners(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED); + eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_CAMERA); } /**