Explorar el Código

feat(external_api): add videoMuted event and action (#8862)

j8
tmoldovan8x8 hace 4 años
padre
commit
a1d3870634
No account linked to committer's email address

+ 13
- 3
android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastAction.java Ver fichero

@@ -36,8 +36,17 @@ public class BroadcastAction {
36 36
 
37 37
         for (String key : this.data.keySet()) {
38 38
             try {
39
-                // TODO add support for different types of objects
40
-                nativeMap.putString(key, this.data.get(key).toString());
39
+                if (this.data.get(key) instanceof Boolean) {
40
+                    nativeMap.putBoolean(key, (Boolean) this.data.get(key));
41
+                } else if (this.data.get(key) instanceof Integer) {
42
+                    nativeMap.putInt(key, (Integer) this.data.get(key));
43
+                } else if (this.data.get(key) instanceof Double) {
44
+                    nativeMap.putDouble(key, (Double) this.data.get(key));
45
+                } else if (this.data.get(key) instanceof String) {
46
+                    nativeMap.putString(key, (String) this.data.get(key));
47
+                } else {
48
+                    throw new Exception("Unsupported extra data type");
49
+                }
41 50
             } catch (Exception e) {
42 51
                 JitsiMeetLogger.w(TAG + " invalid extra data in event", e);
43 52
             }
@@ -66,7 +75,8 @@ public class BroadcastAction {
66 75
         RETRIEVE_PARTICIPANTS_INFO("org.jitsi.meet.RETRIEVE_PARTICIPANTS_INFO"),
67 76
         OPEN_CHAT("org.jitsi.meet.OPEN_CHAT"),
68 77
         CLOSE_CHAT("org.jitsi.meet.CLOSE_CHAT"),
69
-        SEND_CHAT_MESSAGE("org.jitsi.meet.SEND_CHAT_MESSAGE");
78
+        SEND_CHAT_MESSAGE("org.jitsi.meet.SEND_CHAT_MESSAGE"),
79
+        SET_VIDEO_MUTED("org.jitsi.meet.SET_VIDEO_MUTED");
70 80
 
71 81
         private final String action;
72 82
 

+ 6
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastEvent.java Ver fichero

@@ -85,7 +85,9 @@ public class BroadcastEvent {
85 85
         SCREEN_SHARE_TOGGLED("org.jitsi.meet.SCREEN_SHARE_TOGGLED"),
86 86
         PARTICIPANTS_INFO_RETRIEVED("org.jitsi.meet.PARTICIPANTS_INFO_RETRIEVED"),
87 87
         CHAT_MESSAGE_RECEIVED("org.jitsi.meet.CHAT_MESSAGE_RECEIVED"),
88
-        CHAT_TOGGLED("org.jitsi.meet.CHAT_TOGGLED");
88
+        CHAT_TOGGLED("org.jitsi.meet.CHAT_TOGGLED"),
89
+        VIDEO_MUTED_CHANGED("org.jitsi.meet.VIDEO_MUTED_CHANGED");
90
+
89 91
 
90 92
         private static final String CONFERENCE_WILL_JOIN_NAME = "CONFERENCE_WILL_JOIN";
91 93
         private static final String CONFERENCE_JOINED_NAME = "CONFERENCE_JOINED";
@@ -98,6 +100,7 @@ public class BroadcastEvent {
98 100
         private static final String PARTICIPANTS_INFO_RETRIEVED_NAME = "PARTICIPANTS_INFO_RETRIEVED";
99 101
         private static final String CHAT_MESSAGE_RECEIVED_NAME = "CHAT_MESSAGE_RECEIVED";
100 102
         private static final String CHAT_TOGGLED_NAME = "CHAT_TOGGLED";
103
+        private static final String VIDEO_MUTED_CHANGED_NAME = "VIDEO_MUTED_CHANGED";
101 104
 
102 105
         private final String action;
103 106
 
@@ -142,6 +145,8 @@ public class BroadcastEvent {
142 145
                     return CHAT_MESSAGE_RECEIVED;
143 146
                 case CHAT_TOGGLED_NAME:
144 147
                     return CHAT_TOGGLED;
148
+                case VIDEO_MUTED_CHANGED_NAME:
149
+                    return VIDEO_MUTED_CHANGED;
145 150
             }
146 151
 
147 152
             return null;

+ 6
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/BroadcastIntentHelper.java Ver fichero

@@ -40,4 +40,10 @@ public class BroadcastIntentHelper {
40 40
         intent.putExtra("message", message);
41 41
         return intent;
42 42
     }
43
+
44
+    public static Intent buildSetVideoMutedIntent(boolean muted) {
45
+        Intent intent = new Intent(BroadcastAction.Type.SET_VIDEO_MUTED.getAction());
46
+        intent.putExtra("muted", muted);
47
+        return intent;
48
+    }
43 49
 }

+ 1
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java Ver fichero

@@ -85,6 +85,7 @@ class ExternalAPIModule
85 85
         constants.put("OPEN_CHAT", BroadcastAction.Type.OPEN_CHAT.getAction());
86 86
         constants.put("CLOSE_CHAT", BroadcastAction.Type.CLOSE_CHAT.getAction());
87 87
         constants.put("SEND_CHAT_MESSAGE", BroadcastAction.Type.SEND_CHAT_MESSAGE.getAction());
88
+        constants.put("SET_VIDEO_MUTED", BroadcastAction.Type.SET_VIDEO_MUTED.getAction());
88 89
 
89 90
         return constants;
90 91
     }

+ 4
- 0
ios/app/src/ViewController.m Ver fichero

@@ -131,6 +131,10 @@
131 131
   NSLog(@"%@%@", @"Chat toggled: ", data);
132 132
 }
133 133
 
134
+- (void)videoMutedChanged:(NSDictionary *)data {
135
+  NSLog(@"%@%@", @"Video muted changed: ", data[@"muted"]);
136
+}
137
+
134 138
 #pragma mark - Helpers
135 139
 
136 140
 - (void)terminate {

+ 1
- 0
ios/sdk/src/ExternalAPI.h Ver fichero

@@ -26,5 +26,6 @@
26 26
 - (void)openChat:(NSString*)to;
27 27
 - (void)closeChat;
28 28
 - (void)sendChatMessage:(NSString*)message :(NSString*)to ;
29
+- (void)sendSetVideoMuted:(BOOL)muted;
29 30
 
30 31
 @end

+ 12
- 2
ios/sdk/src/ExternalAPI.m Ver fichero

@@ -26,6 +26,7 @@ static NSString * const retrieveParticipantsInfoAction = @"org.jitsi.meet.RETRIE
26 26
 static NSString * const openChatAction = @"org.jitsi.meet.OPEN_CHAT";
27 27
 static NSString * const closeChatAction = @"org.jitsi.meet.CLOSE_CHAT";
28 28
 static NSString * const sendChatMessageAction = @"org.jitsi.meet.SEND_CHAT_MESSAGE";
29
+static NSString * const setVideoMutedAction = @"org.jitsi.meet.SET_VIDEO_MUTED";
29 30
 
30 31
 @implementation ExternalAPI
31 32
 
@@ -47,7 +48,8 @@ RCT_EXPORT_MODULE();
47 48
         @"RETRIEVE_PARTICIPANTS_INFO": retrieveParticipantsInfoAction,
48 49
         @"OPEN_CHAT": openChatAction,
49 50
         @"CLOSE_CHAT": closeChatAction,
50
-        @"SEND_CHAT_MESSAGE": sendChatMessageAction
51
+        @"SEND_CHAT_MESSAGE": sendChatMessageAction,
52
+        @"SET_VIDEO_MUTED" : setVideoMutedAction
51 53
     };
52 54
 };
53 55
 
@@ -70,7 +72,8 @@ RCT_EXPORT_MODULE();
70 72
               retrieveParticipantsInfoAction,
71 73
               openChatAction,
72 74
               closeChatAction,
73
-              sendChatMessageAction
75
+              sendChatMessageAction,
76
+              setVideoMutedAction
74 77
     ];
75 78
 }
76 79
 
@@ -193,4 +196,11 @@ RCT_EXPORT_METHOD(sendEvent:(NSString *)name
193 196
     [self sendEventWithName:sendChatMessageAction body:data];
194 197
 }
195 198
 
199
+- (void)sendSetVideoMuted:(BOOL)muted {
200
+    NSDictionary *data = @{ @"muted": [NSNumber numberWithBool:muted]};
201
+
202
+    [self sendEventWithName:setVideoMutedAction body:data];
203
+}
204
+
205
+
196 206
 @end

+ 1
- 0
ios/sdk/src/JitsiMeetView.h Ver fichero

@@ -44,5 +44,6 @@
44 44
 - (void)openChat:(NSString * _Nullable)to;
45 45
 - (void)closeChat;
46 46
 - (void)sendChatMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to;
47
+- (void)setVideoMuted:(BOOL)muted;
47 48
 
48 49
 @end

+ 5
- 0
ios/sdk/src/JitsiMeetView.m Ver fichero

@@ -155,6 +155,11 @@ static void initializeViewsMap() {
155 155
     [externalAPI sendChatMessage:message :to];
156 156
 }
157 157
 
158
+- (void)setVideoMuted:(BOOL)muted {
159
+    ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
160
+    [externalAPI sendSetVideoMuted:muted];
161
+}
162
+
158 163
 #pragma mark Private methods
159 164
 
160 165
 /**

+ 7
- 0
ios/sdk/src/JitsiMeetViewDelegate.h Ver fichero

@@ -104,4 +104,11 @@
104 104
  */
105 105
 - (void)chatToggled:(NSDictionary *)data;
106 106
 
107
+/**
108
+ * Called when videoMuted state changed.
109
+ *
110
+ * The `data` dictionary contains a `muted` key with state of the videoMuted for the localParticipant.
111
+ */
112
+- (void)videoMutedChanged:(NSDictionary *)data;
113
+
107 114
 @end

+ 15
- 2
react/features/mobile/external-api/middleware.js Ver fichero

@@ -27,7 +27,7 @@ import {
27 27
 } from '../../base/connection';
28 28
 import { JitsiConferenceEvents } from '../../base/lib-jitsi-meet';
29 29
 import { MEDIA_TYPE } from '../../base/media';
30
-import { SET_AUDIO_MUTED } from '../../base/media/actionTypes';
30
+import { SET_AUDIO_MUTED, SET_VIDEO_MUTED } from '../../base/media/actionTypes';
31 31
 import { PARTICIPANT_JOINED, PARTICIPANT_LEFT, getParticipants, getParticipantById } from '../../base/participants';
32 32
 import { MiddlewareRegistry, StateListenerRegistry } from '../../base/redux';
33 33
 import { toggleScreensharing } from '../../base/tracks';
@@ -209,6 +209,15 @@ MiddlewareRegistry.register(store => next => action => {
209 209
                 muted: action.muted
210 210
             });
211 211
         break;
212
+
213
+    case SET_VIDEO_MUTED:
214
+        sendEvent(
215
+            store,
216
+            'VIDEO_MUTED_CHANGED',
217
+            /* data */ {
218
+                muted: action.muted
219
+            });
220
+        break;
212 221
     }
213 222
 
214 223
     return result;
@@ -271,7 +280,11 @@ function _registerForNativeEvents(store) {
271 280
     });
272 281
 
273 282
     eventEmitter.addListener(ExternalAPI.SET_AUDIO_MUTED, ({ muted }) => {
274
-        dispatch(muteLocal(muted === 'true', MEDIA_TYPE.AUDIO));
283
+        dispatch(muteLocal(muted, MEDIA_TYPE.AUDIO));
284
+    });
285
+
286
+    eventEmitter.addListener(ExternalAPI.SET_VIDEO_MUTED, ({ muted }) => {
287
+        dispatch(muteLocal(muted, MEDIA_TYPE.VIDEO));
275 288
     });
276 289
 
277 290
     eventEmitter.addListener(ExternalAPI.SEND_ENDPOINT_TEXT_MESSAGE, ({ to, message }) => {

Loading…
Cancelar
Guardar