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 be01b253d..de3ff9c7c 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 @@ -36,8 +36,17 @@ public class BroadcastAction { for (String key : this.data.keySet()) { try { - // TODO add support for different types of objects - nativeMap.putString(key, this.data.get(key).toString()); + if (this.data.get(key) instanceof Boolean) { + nativeMap.putBoolean(key, (Boolean) this.data.get(key)); + } else if (this.data.get(key) instanceof Integer) { + nativeMap.putInt(key, (Integer) this.data.get(key)); + } else if (this.data.get(key) instanceof Double) { + nativeMap.putDouble(key, (Double) this.data.get(key)); + } else if (this.data.get(key) instanceof String) { + nativeMap.putString(key, (String) this.data.get(key)); + } else { + throw new Exception("Unsupported extra data type"); + } } catch (Exception e) { JitsiMeetLogger.w(TAG + " invalid extra data in event", e); } @@ -66,7 +75,8 @@ public class BroadcastAction { RETRIEVE_PARTICIPANTS_INFO("org.jitsi.meet.RETRIEVE_PARTICIPANTS_INFO"), OPEN_CHAT("org.jitsi.meet.OPEN_CHAT"), CLOSE_CHAT("org.jitsi.meet.CLOSE_CHAT"), - SEND_CHAT_MESSAGE("org.jitsi.meet.SEND_CHAT_MESSAGE"); + SEND_CHAT_MESSAGE("org.jitsi.meet.SEND_CHAT_MESSAGE"), + SET_VIDEO_MUTED("org.jitsi.meet.SET_VIDEO_MUTED"); private final String action; diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java index 05241d64d..3478a52c9 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java @@ -85,7 +85,9 @@ public class BroadcastEvent { SCREEN_SHARE_TOGGLED("org.jitsi.meet.SCREEN_SHARE_TOGGLED"), PARTICIPANTS_INFO_RETRIEVED("org.jitsi.meet.PARTICIPANTS_INFO_RETRIEVED"), CHAT_MESSAGE_RECEIVED("org.jitsi.meet.CHAT_MESSAGE_RECEIVED"), - CHAT_TOGGLED("org.jitsi.meet.CHAT_TOGGLED"); + CHAT_TOGGLED("org.jitsi.meet.CHAT_TOGGLED"), + VIDEO_MUTED_CHANGED("org.jitsi.meet.VIDEO_MUTED_CHANGED"); + private static final String CONFERENCE_WILL_JOIN_NAME = "CONFERENCE_WILL_JOIN"; private static final String CONFERENCE_JOINED_NAME = "CONFERENCE_JOINED"; @@ -98,6 +100,7 @@ public class BroadcastEvent { private static final String PARTICIPANTS_INFO_RETRIEVED_NAME = "PARTICIPANTS_INFO_RETRIEVED"; private static final String CHAT_MESSAGE_RECEIVED_NAME = "CHAT_MESSAGE_RECEIVED"; private static final String CHAT_TOGGLED_NAME = "CHAT_TOGGLED"; + private static final String VIDEO_MUTED_CHANGED_NAME = "VIDEO_MUTED_CHANGED"; private final String action; @@ -142,6 +145,8 @@ public class BroadcastEvent { return CHAT_MESSAGE_RECEIVED; case CHAT_TOGGLED_NAME: return CHAT_TOGGLED; + case VIDEO_MUTED_CHANGED_NAME: + return VIDEO_MUTED_CHANGED; } return null; 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 388a17c76..9b812b630 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 @@ -40,4 +40,10 @@ public class BroadcastIntentHelper { intent.putExtra("message", message); return intent; } + + public static Intent buildSetVideoMutedIntent(boolean muted) { + Intent intent = new Intent(BroadcastAction.Type.SET_VIDEO_MUTED.getAction()); + intent.putExtra("muted", muted); + return intent; + } } 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 3a149a6bf..d496fccac 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 @@ -85,6 +85,7 @@ class ExternalAPIModule constants.put("OPEN_CHAT", BroadcastAction.Type.OPEN_CHAT.getAction()); constants.put("CLOSE_CHAT", BroadcastAction.Type.CLOSE_CHAT.getAction()); constants.put("SEND_CHAT_MESSAGE", BroadcastAction.Type.SEND_CHAT_MESSAGE.getAction()); + constants.put("SET_VIDEO_MUTED", BroadcastAction.Type.SET_VIDEO_MUTED.getAction()); return constants; } diff --git a/ios/app/src/ViewController.m b/ios/app/src/ViewController.m index 9884f8c51..8e5358f8d 100644 --- a/ios/app/src/ViewController.m +++ b/ios/app/src/ViewController.m @@ -131,6 +131,10 @@ NSLog(@"%@%@", @"Chat toggled: ", data); } +- (void)videoMutedChanged:(NSDictionary *)data { + NSLog(@"%@%@", @"Video muted changed: ", data[@"muted"]); +} + #pragma mark - Helpers - (void)terminate { diff --git a/ios/sdk/src/ExternalAPI.h b/ios/sdk/src/ExternalAPI.h index e60572555..73ca0fc0d 100644 --- a/ios/sdk/src/ExternalAPI.h +++ b/ios/sdk/src/ExternalAPI.h @@ -26,5 +26,6 @@ - (void)openChat:(NSString*)to; - (void)closeChat; - (void)sendChatMessage:(NSString*)message :(NSString*)to ; +- (void)sendSetVideoMuted:(BOOL)muted; @end diff --git a/ios/sdk/src/ExternalAPI.m b/ios/sdk/src/ExternalAPI.m index c71aaadd7..19469feac 100644 --- a/ios/sdk/src/ExternalAPI.m +++ b/ios/sdk/src/ExternalAPI.m @@ -26,6 +26,7 @@ static NSString * const retrieveParticipantsInfoAction = @"org.jitsi.meet.RETRIE static NSString * const openChatAction = @"org.jitsi.meet.OPEN_CHAT"; 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"; @implementation ExternalAPI @@ -47,7 +48,8 @@ RCT_EXPORT_MODULE(); @"RETRIEVE_PARTICIPANTS_INFO": retrieveParticipantsInfoAction, @"OPEN_CHAT": openChatAction, @"CLOSE_CHAT": closeChatAction, - @"SEND_CHAT_MESSAGE": sendChatMessageAction + @"SEND_CHAT_MESSAGE": sendChatMessageAction, + @"SET_VIDEO_MUTED" : setVideoMutedAction }; }; @@ -70,7 +72,8 @@ RCT_EXPORT_MODULE(); retrieveParticipantsInfoAction, openChatAction, closeChatAction, - sendChatMessageAction + sendChatMessageAction, + setVideoMutedAction ]; } @@ -193,4 +196,11 @@ RCT_EXPORT_METHOD(sendEvent:(NSString *)name [self sendEventWithName:sendChatMessageAction body:data]; } +- (void)sendSetVideoMuted:(BOOL)muted { + NSDictionary *data = @{ @"muted": [NSNumber numberWithBool:muted]}; + + [self sendEventWithName:setVideoMutedAction body:data]; +} + + @end diff --git a/ios/sdk/src/JitsiMeetView.h b/ios/sdk/src/JitsiMeetView.h index 0c416c62b..34353d1b2 100644 --- a/ios/sdk/src/JitsiMeetView.h +++ b/ios/sdk/src/JitsiMeetView.h @@ -44,5 +44,6 @@ - (void)openChat:(NSString * _Nullable)to; - (void)closeChat; - (void)sendChatMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to; +- (void)setVideoMuted:(BOOL)muted; @end diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m index c8ed2eb7a..642e0fcf1 100644 --- a/ios/sdk/src/JitsiMeetView.m +++ b/ios/sdk/src/JitsiMeetView.m @@ -155,6 +155,11 @@ static void initializeViewsMap() { [externalAPI sendChatMessage:message :to]; } +- (void)setVideoMuted:(BOOL)muted { + ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI]; + [externalAPI sendSetVideoMuted:muted]; +} + #pragma mark Private methods /** diff --git a/ios/sdk/src/JitsiMeetViewDelegate.h b/ios/sdk/src/JitsiMeetViewDelegate.h index eb14e6f22..ad4adaa23 100644 --- a/ios/sdk/src/JitsiMeetViewDelegate.h +++ b/ios/sdk/src/JitsiMeetViewDelegate.h @@ -104,4 +104,11 @@ */ - (void)chatToggled:(NSDictionary *)data; +/** + * Called when videoMuted state changed. + * + * The `data` dictionary contains a `muted` key with state of the videoMuted for the localParticipant. + */ +- (void)videoMutedChanged:(NSDictionary *)data; + @end diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.js index d6774fad0..d5b46164f 100644 --- a/react/features/mobile/external-api/middleware.js +++ b/react/features/mobile/external-api/middleware.js @@ -27,7 +27,7 @@ import { } from '../../base/connection'; import { JitsiConferenceEvents } from '../../base/lib-jitsi-meet'; import { MEDIA_TYPE } from '../../base/media'; -import { SET_AUDIO_MUTED } from '../../base/media/actionTypes'; +import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes'; import { PARTICIPANT_JOINED, PARTICIPANT_LEFT, getParticipants, getParticipantById } from '../../base/participants'; import { MiddlewareRegistry, StateListenerRegistry } from '../../base/redux'; import { toggleScreensharing } from '../../base/tracks'; @@ -209,6 +209,15 @@ MiddlewareRegistry.register(store => next => action => { muted: action.muted }); break; + + case SET_VIDEO_MUTED: + sendEvent( + store, + 'VIDEO_MUTED_CHANGED', + /* data */ { + muted: action.muted + }); + break; } return result; @@ -271,7 +280,11 @@ function _registerForNativeEvents(store) { }); eventEmitter.addListener(ExternalAPI.SET_AUDIO_MUTED, ({ muted }) => { - dispatch(muteLocal(muted === 'true', MEDIA_TYPE.AUDIO)); + dispatch(muteLocal(muted, MEDIA_TYPE.AUDIO)); + }); + + eventEmitter.addListener(ExternalAPI.SET_VIDEO_MUTED, ({ muted }) => { + dispatch(muteLocal(muted, MEDIA_TYPE.VIDEO)); }); eventEmitter.addListener(ExternalAPI.SEND_ENDPOINT_TEXT_MESSAGE, ({ to, message }) => {