Просмотр исходного кода

fix. negative number for android platform

refactor. setLiveTranscoding
improve api doc
matrixbirds 5 лет назад
Родитель
Сommit
a302755b2d

+ 5
- 0
CHANGELOG Просмотреть файл

@@ -1,5 +1,10 @@
1 1
 ## THE CHANGELOG
2 2
 
3
+#### 2.4.1-alpha.3
4
+- refactor setLiveTranscoding: rename ios & android native parameters. export enum for javascript/typescript api.
5
+- fix negative number case in android platform.
6
+- improve api doc.
7
+
3 8
 #### 2.4.1-alpha.2
4 9
 - deprecated `sendMessage` & `createDataStream` & `removeAllListeners` & `off`
5 10
 - refactor event system

+ 53
- 43
android/src/main/java/com/syan/agora/AgoraModule.java Просмотреть файл

@@ -1927,6 +1927,19 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1927 1927
         return type;
1928 1928
     }
1929 1929
 
1930
+    public LiveTranscoding.AudioCodecProfileType getLiveTranscodingAudioCodecProfileEnum (int val) {
1931
+        LiveTranscoding.AudioCodecProfileType type = LiveTranscoding.AudioCodecProfileType.LC_AAC;
1932
+        switch (Integer.valueOf(val)) {
1933
+            case 0:
1934
+                type = LiveTranscoding.AudioCodecProfileType.LC_AAC;
1935
+                break;
1936
+            case 1:
1937
+                type = LiveTranscoding.AudioCodecProfileType.HE_AAC;
1938
+                break;
1939
+        }
1940
+        return type;
1941
+    }
1942
+
1930 1943
 
1931 1944
 
1932 1945
     @ReactMethod
@@ -1994,7 +2007,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1994 2007
     @ReactMethod
1995 2008
     public void setLiveTranscoding(ReadableMap options, Promise promise) {
1996 2009
         LiveTranscoding transcoding = new LiveTranscoding();
1997
-        if (options.hasKey("size") && null != options.getMap("size")) {
2010
+        if (options.hasKey("size")) {
1998 2011
             ReadableMap size = options.getMap("size");
1999 2012
             transcoding.width = size.getInt("width");
2000 2013
             transcoding.height = size.getInt("height");
@@ -2014,64 +2027,61 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2014 2027
         if (options.hasKey("videoCodecProfile")) {
2015 2028
             transcoding.videoCodecProfile = getLiveTranscodingVideoCodecProfileEnum(options.getInt("videoCodecProfile"));
2016 2029
         }
2017
-        if (options.hasKey("transcodingUsers")) {
2018
-            ArrayList<LiveTranscoding.TranscodingUser> users = new ArrayList<LiveTranscoding.TranscodingUser>();
2019
-            ReadableArray transcodingUsers = options.getArray("transcodingUsers");
2020
-            for (int i = 0; i < transcodingUsers.size(); i++) {
2021
-                ReadableMap _map = transcodingUsers.getMap(i);
2022
-                LiveTranscoding.TranscodingUser user = new LiveTranscoding.TranscodingUser();
2023
-                user.uid = _map.getInt("uid");
2024
-                ReadableMap backgroundColor = _map.getMap("backgroundColor");
2025
-                user.x = backgroundColor.getInt("x");
2026
-                user.y = backgroundColor.getInt("y");
2027
-                user.width = backgroundColor.getInt("width");
2028
-                user.height = backgroundColor.getInt("height");
2029
-                user.zOrder = _map.getInt("zOrder");
2030
-                user.alpha = _map.getInt("alpha");
2031
-                user.audioChannel = _map.getInt("audioChannel");
2032
-                users.add(user);
2033
-            }
2034
-            transcoding.setUsers(users);
2030
+        if (options.hasKey("audioCodecProfile")) {
2031
+            transcoding.audioCodecProfile = getLiveTranscodingAudioCodecProfileEnum(options.getInt("audioCodecProfile"));
2035 2032
         }
2036
-        if (options.hasKey("transcodingExtraInfo")) {
2037
-            transcoding.userConfigExtraInfo = options.getString("transcodingExtraInfo");
2033
+        if (options.hasKey("audioSampleRate")) {
2034
+            transcoding.audioSampleRate = getLiveTranscodingAudioSampleRateEnum(options.getInt("audioSampleRate"));
2038 2035
         }
2039 2036
         if (options.hasKey("watermark")) {
2040 2037
             ReadableMap watermark = options.getMap("watermark");
2041 2038
             WritableMap map = Arguments.createMap();
2042 2039
             map.putString("url", watermark.getString("url"));
2043
-            map.putString("x", watermark.getString("x"));
2044
-            map.putString("y", watermark.getString("y"));
2045
-            map.putString("width", watermark.getString("width"));
2046
-            map.putString("height", watermark.getString("height"));
2040
+            map.putInt("x", watermark.getInt("x"));
2041
+            map.putInt("y", watermark.getInt("y"));
2042
+            map.putInt("width", watermark.getInt("width"));
2043
+            map.putInt("height", watermark.getInt("height"));
2047 2044
             transcoding.watermark = createAgoraImage(map);
2048 2045
         }
2049 2046
         if (options.hasKey("backgroundImage")) {
2050
-            ReadableMap watermark = options.getMap("backgroundImage");
2047
+            ReadableMap image = options.getMap("backgroundImage");
2051 2048
             WritableMap map = Arguments.createMap();
2052
-            map.putString("url", watermark.getString("url"));
2053
-            map.putString("x", watermark.getString("x"));
2054
-            map.putString("y", watermark.getString("y"));
2055
-            map.putString("width", watermark.getString("width"));
2056
-            map.putString("height", watermark.getString("height"));
2049
+            map.putString("url", image.getString("url"));
2050
+            map.putInt("x", image.getInt("x"));
2051
+            map.putInt("y", image.getInt("y"));
2052
+            map.putInt("width", image.getInt("width"));
2053
+            map.putInt("height", image.getInt("height"));
2057 2054
             transcoding.backgroundImage = createAgoraImage(map);
2058 2055
         }
2059 2056
         if (options.hasKey("backgroundColor")) {
2060
-            ReadableMap backgroundColor = options.getMap("backgroundColor");
2061
-            transcoding.setBackgroundColor(
2062
-                    backgroundColor.getInt("red"),
2063
-                    backgroundColor.getInt("green"),
2064
-                    backgroundColor.getInt("blue")
2065
-            );
2066
-        }
2067
-        if (options.hasKey("audioSampleRate")) {
2068
-            transcoding.audioSampleRate = getLiveTranscodingAudioSampleRateEnum(options.getInt("audioSampleRate"));
2057
+            transcoding.setBackgroundColor(options.getInt("backgroundColor"));
2069 2058
         }
2070 2059
         if (options.hasKey("audioBitrate")) {
2071
-            transcoding.audioChannels = options.getInt("audioBitrate");
2060
+            transcoding.audioBitrate = options.getInt("audioBitrate");
2072 2061
         }
2073 2062
         if (options.hasKey("audioChannels")) {
2074
-            transcoding.audioChannels = options.getInt("audioChannel");
2063
+            transcoding.audioChannels = options.getInt("audioChannels");
2064
+        }
2065
+        if (options.hasKey("transcodingUsers")) {
2066
+            ArrayList<LiveTranscoding.TranscodingUser> users = new ArrayList<LiveTranscoding.TranscodingUser>();
2067
+            ReadableArray transcodingUsers = options.getArray("transcodingUsers");
2068
+            for (int i = 0; i < transcodingUsers.size(); i++) {
2069
+                ReadableMap optionUser = transcodingUsers.getMap(i);
2070
+                LiveTranscoding.TranscodingUser user = new LiveTranscoding.TranscodingUser();
2071
+                user.uid = optionUser.getInt("uid");
2072
+                user.x = optionUser.getInt("x");
2073
+                user.y = optionUser.getInt("y");
2074
+                user.width = optionUser.getInt("width");
2075
+                user.height = optionUser.getInt("height");
2076
+                user.zOrder = optionUser.getInt("zOrder");
2077
+                user.alpha = (float) optionUser.getDouble("alpha");
2078
+                user.audioChannel = optionUser.getInt("audioChannel");
2079
+                users.add(user);
2080
+            }
2081
+            transcoding.setUsers(users);
2082
+        }
2083
+        if (options.hasKey("transcodingExtraInfo")) {
2084
+            transcoding.userConfigExtraInfo = options.getString("transcodingExtraInfo");
2075 2085
         }
2076 2086
         Integer res = AgoraManager.getInstance().mRtcEngine.setLiveTranscoding(transcoding);
2077 2087
         if (res == 0) {
@@ -2405,4 +2415,4 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2405 2415
                 .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
2406 2416
                 .emit(agoraEvtName.toString(), params);
2407 2417
     }
2408
-}
2418
+}

+ 1
- 1
android/src/main/java/com/syan/agora/AgoraViewManager.java Просмотреть файл

@@ -50,7 +50,7 @@ public class AgoraViewManager extends SimpleViewManager<AgoraVideoView> {
50 50
     @ReactProp(name = "remoteUid")
51 51
     public void setRemoteUid(final AgoraVideoView agoraVideoView, final int remoteUid) {
52 52
         agoraVideoView.setRemoteUid(remoteUid);
53
-        if (remoteUid > 0) {
53
+        if (remoteUid != 0) {
54 54
             AgoraManager.getInstance().setupRemoteVideo(remoteUid, agoraVideoView.getRenderMode());
55 55
             surfaceView = AgoraManager.getInstance().getSurfaceView(remoteUid);
56 56
             surfaceView.setZOrderMediaOverlay(agoraVideoView.getZOrderMediaOverlay());

+ 0
- 298
android/src/main/java/com/syan/agora/ConvertUtils.java Просмотреть файл

@@ -1,298 +0,0 @@
1
-package com.syan.agora;
2
-
3
-import android.support.annotation.Nullable;
4
-
5
-import com.facebook.react.bridge.Arguments;
6
-import com.facebook.react.bridge.ReadableArray;
7
-import com.facebook.react.bridge.ReadableMap;
8
-import com.facebook.react.bridge.ReadableMapKeySetIterator;
9
-import com.facebook.react.bridge.ReadableType;
10
-import com.facebook.react.bridge.WritableArray;
11
-import com.facebook.react.bridge.WritableMap;
12
-import com.facebook.react.bridge.WritableNativeArray;
13
-import com.facebook.react.bridge.WritableNativeMap;
14
-
15
-import org.json.JSONArray;
16
-import org.json.JSONException;
17
-import org.json.JSONObject;
18
-
19
-import java.util.ArrayList;
20
-import java.util.HashMap;
21
-import java.util.Iterator;
22
-import java.util.List;
23
-import java.util.Map;
24
-
25
-public class ConvertUtils {
26
-    public static Map<String, Object> readableMapToMap(final @Nullable ReadableMap readableMap) {
27
-        if (readableMap == null) {
28
-            return new HashMap<>();
29
-        }
30
-
31
-        final ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
32
-        if (!iterator.hasNextKey()) {
33
-            return new HashMap<>();
34
-        }
35
-
36
-        final Map<String, Object> result = new HashMap<>();
37
-        while (iterator.hasNextKey()) {
38
-            final String key = iterator.nextKey();
39
-            result.put(key, toObject(readableMap, key));
40
-        }
41
-
42
-        return result;
43
-    }
44
-
45
-    public static Object toObject(@Nullable ReadableMap readableMap, String key) {
46
-        if (readableMap == null) {
47
-            return null;
48
-        }
49
-
50
-        Object result;
51
-
52
-        final ReadableType readableType = readableMap.getType(key);
53
-        switch (readableType) {
54
-            case Null:
55
-                result = key;
56
-                break;
57
-            case Boolean:
58
-                result = readableMap.getBoolean(key);
59
-                break;
60
-            case Number:
61
-                // Can be int or double.
62
-                double tmp = readableMap.getDouble(key);
63
-                if (tmp == (int) tmp) {
64
-                    result = (int) tmp;
65
-                } else {
66
-                    result = tmp;
67
-                }
68
-                break;
69
-            case String:
70
-                result = readableMap.getString(key);
71
-                break;
72
-            case Map:
73
-                result = readableMapToMap(readableMap.getMap(key));
74
-                break;
75
-            case Array:
76
-                result = readableArrayToList(readableMap.getArray(key));
77
-                break;
78
-            default:
79
-                throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
80
-        }
81
-
82
-        return result;
83
-    }
84
-
85
-    /**
86
-     * toList converts a {@link ReadableArray} into an ArrayList.
87
-     *
88
-     * @param readableArray The ReadableArray to be conveted.
89
-     * @return An ArrayList containing the data that was in the ReadableArray.
90
-     */
91
-    public static List<Object> readableArrayToList(final @Nullable ReadableArray readableArray) {
92
-        if (readableArray == null) {
93
-            return null;
94
-        }
95
-
96
-        List<Object> result = new ArrayList<>(readableArray.size());
97
-        for (int index = 0; index < readableArray.size(); index++) {
98
-            final ReadableType readableType = readableArray.getType(index);
99
-            switch (readableType) {
100
-                case Null:
101
-                    result.add(String.valueOf(index));
102
-                    break;
103
-                case Boolean:
104
-                    result.add(readableArray.getBoolean(index));
105
-                    break;
106
-                case Number:
107
-                    // Can be int or double.
108
-                    double tmp = readableArray.getDouble(index);
109
-                    if (tmp == (int) tmp) {
110
-                        result.add((int) tmp);
111
-                    } else {
112
-                        result.add(tmp);
113
-                    }
114
-                    break;
115
-                case String:
116
-                    result.add(readableArray.getString(index));
117
-                    break;
118
-                case Map:
119
-                    result.add(readableMapToMap(readableArray.getMap(index)));
120
-                    break;
121
-                case Array:
122
-                    result = readableArrayToList(readableArray.getArray(index));
123
-                    break;
124
-                default:
125
-                    throw new IllegalArgumentException("Could not convert object with index: " + index + ".");
126
-            }
127
-        }
128
-
129
-        return result;
130
-    }
131
-
132
-    /**
133
-     * better
134
-     *
135
-     * @param jsonArray
136
-     * @return
137
-     * @throws JSONException
138
-     */
139
-    public static WritableArray jsonToReact(final JSONArray jsonArray) throws JSONException {
140
-        final WritableArray writableArray = Arguments.createArray();
141
-        for (int i = 0; i < jsonArray.length(); i++) {
142
-            final Object value = jsonArray.get(i);
143
-            if (value instanceof Float || value instanceof Double) {
144
-                writableArray.pushDouble(jsonArray.getDouble(i));
145
-            } else if (value instanceof Number) {
146
-                writableArray.pushInt(jsonArray.getInt(i));
147
-            } else if (value instanceof String) {
148
-                writableArray.pushString(jsonArray.getString(i));
149
-            } else if (value instanceof Boolean) {
150
-                writableArray.pushBoolean(jsonArray.getBoolean(i));
151
-            } else if (value instanceof JSONObject) {
152
-                writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)));
153
-            } else if (value instanceof JSONArray) {
154
-                writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)));
155
-            } else if (value == JSONObject.NULL) {
156
-                writableArray.pushNull();
157
-            }
158
-        }
159
-        return writableArray;
160
-    }
161
-
162
-    /**
163
-     * better
164
-     *
165
-     * @param jsonObject
166
-     * @return
167
-     * @throws JSONException
168
-     */
169
-    public static WritableMap jsonToReact(final JSONObject jsonObject) throws JSONException {
170
-        final WritableMap writableMap = Arguments.createMap();
171
-        final Iterator iterator = jsonObject.keys();
172
-        while (iterator.hasNext()) {
173
-            final String key = (String) iterator.next();
174
-            final Object value = jsonObject.get(key);
175
-            if (value instanceof Float || value instanceof Double) {
176
-                writableMap.putDouble(key, jsonObject.getDouble(key));
177
-            } else if (value instanceof Number) {
178
-                writableMap.putInt(key, jsonObject.getInt(key));
179
-            } else if (value instanceof String) {
180
-                writableMap.putString(key, jsonObject.getString(key));
181
-            } else if (value instanceof JSONObject) {
182
-                writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key)));
183
-            } else if (value instanceof JSONArray) {
184
-                writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
185
-            } else if (value instanceof Boolean) {
186
-                writableMap.putBoolean(key, jsonObject.getBoolean(key));
187
-            } else if (value == JSONObject.NULL) {
188
-                writableMap.putNull(key);
189
-            }
190
-        }
191
-        return writableMap;
192
-    }
193
-
194
-    public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
195
-        WritableMap map = new WritableNativeMap();
196
-
197
-        Iterator<String> iterator = jsonObject.keys();
198
-        while (iterator.hasNext()) {
199
-            String key = iterator.next();
200
-            Object value = jsonObject.get(key);
201
-            if (value instanceof JSONObject) {
202
-                map.putMap(key, convertJsonToMap((JSONObject) value));
203
-            } else if (value instanceof JSONArray) {
204
-                map.putArray(key, convertJsonToArray((JSONArray) value));
205
-            } else if (value instanceof Boolean) {
206
-                map.putBoolean(key, (Boolean) value);
207
-            } else if (value instanceof Integer) {
208
-                map.putInt(key, (Integer) value);
209
-            } else if (value instanceof Double) {
210
-                map.putDouble(key, (Double) value);
211
-            } else if (value instanceof String) {
212
-                map.putString(key, (String) value);
213
-            } else {
214
-                map.putString(key, value.toString());
215
-            }
216
-        }
217
-        return map;
218
-    }
219
-
220
-    public static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
221
-        WritableArray array = new WritableNativeArray();
222
-
223
-        for (int i = 0; i < jsonArray.length(); i++) {
224
-            Object value = jsonArray.get(i);
225
-            if (value instanceof JSONObject) {
226
-                array.pushMap(convertJsonToMap((JSONObject) value));
227
-            } else if (value instanceof JSONArray) {
228
-                array.pushArray(convertJsonToArray((JSONArray) value));
229
-            } else if (value instanceof Boolean) {
230
-                array.pushBoolean((Boolean) value);
231
-            } else if (value instanceof Integer) {
232
-                array.pushInt((Integer) value);
233
-            } else if (value instanceof Double) {
234
-                array.pushDouble((Double) value);
235
-            } else if (value instanceof String) {
236
-                array.pushString((String) value);
237
-            } else {
238
-                array.pushString(value.toString());
239
-            }
240
-        }
241
-        return array;
242
-    }
243
-
244
-    public static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException {
245
-        JSONObject object = new JSONObject();
246
-        ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
247
-        while (iterator.hasNextKey()) {
248
-            String key = iterator.nextKey();
249
-            switch (readableMap.getType(key)) {
250
-                case Null:
251
-                    object.put(key, JSONObject.NULL);
252
-                    break;
253
-                case Boolean:
254
-                    object.put(key, readableMap.getBoolean(key));
255
-                    break;
256
-                case Number:
257
-                    object.put(key, readableMap.getDouble(key));
258
-                    break;
259
-                case String:
260
-                    object.put(key, readableMap.getString(key));
261
-                    break;
262
-                case Map:
263
-                    object.put(key, convertMapToJson(readableMap.getMap(key)));
264
-                    break;
265
-                case Array:
266
-                    object.put(key, convertArrayToJson(readableMap.getArray(key)));
267
-                    break;
268
-            }
269
-        }
270
-        return object;
271
-    }
272
-
273
-    public static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
274
-        JSONArray array = new JSONArray();
275
-        for (int i = 0; i < readableArray.size(); i++) {
276
-            switch (readableArray.getType(i)) {
277
-                case Null:
278
-                    break;
279
-                case Boolean:
280
-                    array.put(readableArray.getBoolean(i));
281
-                    break;
282
-                case Number:
283
-                    array.put(readableArray.getDouble(i));
284
-                    break;
285
-                case String:
286
-                    array.put(readableArray.getString(i));
287
-                    break;
288
-                case Map:
289
-                    array.put(convertMapToJson(readableArray.getMap(i)));
290
-                    break;
291
-                case Array:
292
-                    array.put(convertArrayToJson(readableArray.getArray(i)));
293
-                    break;
294
-            }
295
-        }
296
-        return array;
297
-    }
298
-}

+ 292
- 281
ios/RCTAgora/RCTAgora.m Просмотреть файл

@@ -47,21 +47,25 @@
47 47
   return toSend;
48 48
 }
49 49
 
50
-- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSInteger)uid atTimestamp:(NSTimeInterval)timestamp {
50
+- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSUInteger)uid atTimestamp:(NSTimeInterval)timestamp {
51 51
   NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
52 52
   [self sendEvent:AGMediaMetaDataReceived params:@{
53
-                                               @"uid": @(uid),
54
-                                               @"data": dataStr,
55
-                                               @"ts": @(timestamp)
56
-                                               }];
53
+                                                   @"uid": @(uid),
54
+                                                   @"data": dataStr,
55
+                                                   @"ts": @(timestamp)
56
+                                                   }];
57 57
 }
58 58
 
59 59
 
60 60
 RCT_EXPORT_MODULE();
61 61
 
62
+- (UIColor *) UIColorFromRGB:(NSUInteger)rgbValue {
63
+  return [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0];
64
+}
65
+
62 66
 - (AgoraImage *) makeAgoraImage:(NSDictionary *)options {
63 67
   AgoraImage *img = [AgoraImage new];
64
-  img.url = [NSURL URLWithString:[options[@"url"] stringValue]];
68
+  img.url = [NSURL URLWithString:options[@"url"]];
65 69
   
66 70
   img.rect = CGRectMake((CGFloat)[options[@"x"] floatValue],
67 71
                         (CGFloat)[options[@"y"] floatValue],
@@ -163,7 +167,7 @@ RCT_EXPORT_MODULE();
163 167
            @"ChannelProfileGame": @(AgoraChannelProfileGame),
164 168
            @"AudioMode": @(AgoraAudioMode),
165 169
            @"VideoMode": @(AgoraVideoMode),
166
-         };
170
+           };
167 171
 }
168 172
 
169 173
 // init
@@ -187,21 +191,21 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
187 191
   });
188 192
   if ([options objectForKey:@"mode"]) {
189 193
     switch([options[@"mode"] integerValue]) {
190
-       case AgoraAudioMode: {
191
-         [self.rtcEngine enableLocalAudio:true];
192
-         [self.rtcEngine enableLocalVideo:false];
193
-         break;
194
-       }
195
-       case AgoraVideoMode: {
196
-         [self.rtcEngine enableLocalVideo:true];
197
-         [self.rtcEngine enableLocalAudio:false];
198
-         break;
199
-       }
194
+      case AgoraAudioMode: {
195
+        [self.rtcEngine enableLocalAudio:true];
196
+        [self.rtcEngine enableLocalVideo:false];
197
+        break;
198
+      }
199
+      case AgoraVideoMode: {
200
+        [self.rtcEngine enableLocalVideo:true];
201
+        [self.rtcEngine enableLocalAudio:false];
202
+        break;
203
+      }
200 204
     }
201
-   } else {
202
-     [self.rtcEngine enableLocalVideo:true];
203
-     [self.rtcEngine enableLocalAudio:true];
204
-   }
205
+  } else {
206
+    [self.rtcEngine enableLocalVideo:true];
207
+    [self.rtcEngine enableLocalAudio:true];
208
+  }
205 209
   
206 210
   if ([options objectForKey:@"beauty"]) {
207 211
     AgoraBeautyOptions *beautyOption = [[AgoraBeautyOptions alloc] init];
@@ -209,7 +213,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
209 213
     beautyOption.lighteningLevel = [options[@"beauty"][@"lighteningLevel"] floatValue];
210 214
     beautyOption.smoothnessLevel = [options[@"beauty"][@"smoothnessLevel"] floatValue];
211 215
     beautyOption.rednessLevel = [options[@"beauty"][@"rednessLevel"] floatValue];
212
-      [self.rtcEngine setBeautyEffectOptions:true options:beautyOption];
216
+    [self.rtcEngine setBeautyEffectOptions:true options:beautyOption];
213 217
   }
214 218
   if ([options objectForKey:@"voice"]) {
215 219
     NSInteger voiceValue = [options[@"voice"][@"value"] integerValue];
@@ -221,22 +225,22 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
221 225
       [self.rtcEngine setLocalVoiceReverbPreset:(AgoraAudioReverbPreset)voiceValue];
222 226
     }
223 227
   }
224
-   if (options[@"secret"] != nil) {
225
-     [self.rtcEngine setEncryptionSecret:[options[@"secret"] stringValue]];
226
-     if (options[@"secretMode"] != nil) {
227
-       [self.rtcEngine setEncryptionMode:[options[@"secretMode"] stringValue]];
228
-     }
229
-   }
230
-     
231
-   AgoraVideoEncoderConfiguration *video_encoder_config = [[AgoraVideoEncoderConfiguration new] initWithWidth:[options[@"videoEncoderConfig"][@"width"] integerValue] height:[options[@"videoEncoderConfig"][@"height"] integerValue] frameRate:[options[@"videoEncoderConfig"][@"frameRate"] integerValue] bitrate:[options[@"videoEncoderConfig"][@"bitrate"] integerValue] orientationMode: (AgoraVideoOutputOrientationMode)[options[@"videoEncoderConfig"][@"orientationMode"] integerValue]];
232
-   [self.rtcEngine setVideoEncoderConfiguration:video_encoder_config];
233
-   [self.rtcEngine setClientRole:(AgoraClientRole)[options[@"clientRole"] integerValue]];
234
-   [self.rtcEngine setAudioProfile:(AgoraAudioProfile)[options[@"audioProfile"] integerValue]
235
-                          scenario:(AgoraAudioScenario)[options[@"audioScenario"] integerValue]];
236
-     
237
-     //Enable Agora Native SDK be Interoperable with Agora Web SDK
238
-   [self.rtcEngine enableWebSdkInteroperability:YES];
239
- }
228
+  if (options[@"secret"] != nil) {
229
+    [self.rtcEngine setEncryptionSecret:[options[@"secret"] stringValue]];
230
+    if (options[@"secretMode"] != nil) {
231
+      [self.rtcEngine setEncryptionMode:[options[@"secretMode"] stringValue]];
232
+    }
233
+  }
234
+  
235
+  AgoraVideoEncoderConfiguration *video_encoder_config = [[AgoraVideoEncoderConfiguration new] initWithWidth:[options[@"videoEncoderConfig"][@"width"] integerValue] height:[options[@"videoEncoderConfig"][@"height"] integerValue] frameRate:[options[@"videoEncoderConfig"][@"frameRate"] integerValue] bitrate:[options[@"videoEncoderConfig"][@"bitrate"] integerValue] orientationMode: (AgoraVideoOutputOrientationMode)[options[@"videoEncoderConfig"][@"orientationMode"] integerValue]];
236
+  [self.rtcEngine setVideoEncoderConfiguration:video_encoder_config];
237
+  [self.rtcEngine setClientRole:(AgoraClientRole)[options[@"clientRole"] integerValue]];
238
+  [self.rtcEngine setAudioProfile:(AgoraAudioProfile)[options[@"audioProfile"] integerValue]
239
+                         scenario:(AgoraAudioScenario)[options[@"audioScenario"] integerValue]];
240
+  
241
+  //Enable Agora Native SDK be Interoperable with Agora Web SDK
242
+  [self.rtcEngine enableWebSdkInteroperability:YES];
243
+}
240 244
 
241 245
 // renew token
242 246
 RCT_EXPORT_METHOD(renewToken
@@ -286,7 +290,7 @@ RCT_EXPORT_METHOD(setClientRole:(NSInteger)role
286 290
 RCT_EXPORT_METHOD(joinChannel:(NSDictionary *)options
287 291
                   resolve:(RCTPromiseResolveBlock)resolve
288 292
                   reject:(RCTPromiseRejectBlock)reject) {
289
-  [AgoraConst share].localUid = [options[@"uid"] integerValue];
293
+  [AgoraConst share].localUid = (NSUInteger)[options[@"uid"] integerValue];
290 294
   NSInteger res = [self.rtcEngine joinChannelByToken:options[@"token"] channelId:options[@"channelName"] info:options[@"info"] uid:[AgoraConst share].localUid joinSuccess:nil];
291 295
   if (res == 0) {
292 296
     resolve(nil);
@@ -301,19 +305,19 @@ RCT_EXPORT_METHOD(leaveChannel
301 305
                   reject:(RCTPromiseRejectBlock) reject) {
302 306
   NSInteger res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stat) {
303 307
     [self sendEvent:AGLeaveChannel params:@{
304
-                                             @"message": @"leaveChannel",
305
-                                             @"duration": @(stat.duration),
306
-                                             @"txBytes": @(stat.txBytes),
307
-                                             @"rxBytes": @(stat.rxBytes),
308
-                                             @"txAudioKBitrate": @(stat.txAudioKBitrate),
309
-                                             @"rxAudioKBitrate": @(stat.rxAudioKBitrate),
310
-                                             @"txVideoKBitrate": @(stat.txVideoKBitrate),
311
-                                             @"rxVideoKBitrate": @(stat.rxVideoKBitrate),
312
-                                             @"lastmileDelay": @(stat.lastmileDelay),
313
-                                             @"userCount": @(stat.userCount),
314
-                                             @"cpuAppUsage": @(stat.cpuAppUsage),
315
-                                             @"cpuTotalUsage": @(stat.cpuTotalUsage)
316
-                                             }];
308
+                                            @"message": @"leaveChannel",
309
+                                            @"duration": @(stat.duration),
310
+                                            @"txBytes": @(stat.txBytes),
311
+                                            @"rxBytes": @(stat.rxBytes),
312
+                                            @"txAudioKBitrate": @(stat.txAudioKBitrate),
313
+                                            @"rxAudioKBitrate": @(stat.rxAudioKBitrate),
314
+                                            @"txVideoKBitrate": @(stat.txVideoKBitrate),
315
+                                            @"rxVideoKBitrate": @(stat.rxVideoKBitrate),
316
+                                            @"lastmileDelay": @(stat.lastmileDelay),
317
+                                            @"userCount": @(stat.userCount),
318
+                                            @"cpuAppUsage": @(stat.cpuAppUsage),
319
+                                            @"cpuTotalUsage": @(stat.cpuTotalUsage)
320
+                                            }];
317 321
   }];
318 322
   if (res == 0) {
319 323
     resolve(nil);
@@ -341,7 +345,7 @@ RCT_EXPORT_METHOD(setLocalRenderMode:(NSInteger) mode
341 345
 }
342 346
 
343 347
 // set remote video render mode
344
-RCT_EXPORT_METHOD(setRemoteRenderMode:(NSInteger) uid
348
+RCT_EXPORT_METHOD(setRemoteRenderMode:(NSUInteger) uid
345 349
                   mode:(NSInteger) mode
346 350
                   resolve:(RCTPromiseResolveBlock) resolve
347 351
                   reject:(RCTPromiseRejectBlock) reject) {
@@ -597,8 +601,8 @@ RCT_EXPORT_METHOD(adjustPlaybackSignalVolume: (NSInteger) volume
597 601
 
598 602
 // enable audio volume indication
599 603
 RCT_EXPORT_METHOD(enableAudioVolumeIndication: (NSInteger) interval smooth:(NSInteger)smooth
600
-    resolve:(RCTPromiseResolveBlock)resolve
601
-    reject:(RCTPromiseRejectBlock)reject) {
604
+                  resolve:(RCTPromiseResolveBlock)resolve
605
+                  reject:(RCTPromiseRejectBlock)reject) {
602 606
   NSInteger res = [self.rtcEngine enableAudioVolumeIndication:interval smooth:smooth];
603 607
   if (res == 0) {
604 608
     resolve(nil);
@@ -678,9 +682,9 @@ RCT_EXPORT_METHOD(startAudioMixing:(NSDictionary *) options
678 682
                   resolve:(RCTPromiseResolveBlock)resolve
679 683
                   reject:(RCTPromiseRejectBlock)reject) {
680 684
   NSInteger res = [self.rtcEngine startAudioMixing:[options[@"filepath"] stringValue]
681
-                          loopback:[options[@"loopback"] boolValue]
682
-                           replace:[options[@"replace"] boolValue]
683
-                             cycle:[options[@"cycle"] integerValue]];
685
+                                          loopback:[options[@"loopback"] boolValue]
686
+                                           replace:[options[@"replace"] boolValue]
687
+                                             cycle:[options[@"cycle"] integerValue]];
684 688
   if (res == 0) {
685 689
     resolve(nil);
686 690
   } else {
@@ -1259,7 +1263,7 @@ RCT_EXPORT_METHOD(getCameraInfo
1259 1263
                 @"focusPositionInPreview": @([self.rtcEngine isCameraFocusPositionInPreviewSupported]),
1260 1264
                 @"exposurePosition": @([self.rtcEngine isCameraExposurePositionSupported]),
1261 1265
                 @"autoFocusFaceMode": @([self.rtcEngine isCameraAutoFocusFaceModeSupported])
1262
-            }
1266
+                }
1263 1267
             });
1264 1268
 }
1265 1269
 
@@ -1387,44 +1391,31 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options
1387 1391
                   resolve:(RCTPromiseResolveBlock) resolve
1388 1392
                   reject:(RCTPromiseRejectBlock) reject) {
1389 1393
   AgoraLiveTranscoding *transcoding = AgoraLiveTranscoding.defaultTranscoding;
1390
-  if (options[@"size"] != nil) {
1394
+  if ([options objectForKey:@"size"]) {
1391 1395
     transcoding.size = CGSizeMake([options[@"size"][@"width"] doubleValue], [options[@"size"][@"height"] doubleValue]);
1392 1396
   }
1393
-  if (options[@"videoBitrate"] != nil) {
1397
+  if ([options objectForKey:@"videoBitrate"]) {
1394 1398
     transcoding.videoBitrate = [options[@"videoBitrate"] integerValue];
1395 1399
   }
1396
-  if (options[@"videoFramerate"] != nil) {
1400
+  if ([options objectForKey:@"videoFramerate"]) {
1397 1401
     transcoding.videoFramerate = [options[@"videoFramerate"] integerValue];
1398 1402
   }
1399
-  if (options[@"lowLatency"] != nil) {
1403
+  if ([options objectForKey:@"lowLatancy"]) {
1400 1404
     transcoding.lowLatency = [options[@"lowLatancy"] boolValue];
1401 1405
   }
1402
-  if (options[@"videoGop"] != nil) {
1406
+  if ([options objectForKey:@"videoGop"]) {
1403 1407
     transcoding.videoGop = [options[@"videoGop"] integerValue];
1404 1408
   }
1405
-  if (options[@"videoCodecProfile"] != nil) {
1409
+  if ([options objectForKey:@"videoCodecProfile"]) {
1406 1410
     transcoding.videoCodecProfile = (AgoraVideoCodecProfileType)[options[@"videoCodecProfile"] integerValue];
1407 1411
   }
1408
-  if (options[@"audioCodecProfile"] != nil) {
1412
+  if ([options objectForKey:@"audioCodecProfile"]) {
1409 1413
     transcoding.audioCodecProfile = (AgoraAudioCodecProfileType)[options[@"audioCodecProfile"] integerValue];
1410 1414
   }
1411
-  if (options[@"transcodingUsers"] != nil) {
1412
-    NSMutableArray<AgoraLiveTranscodingUser*> *transcodingUsers = [NSMutableArray new];
1413
-    for (NSDictionary *optionUser in options[@"users"]) {
1414
-      AgoraLiveTranscodingUser *liveUser = [AgoraLiveTranscodingUser new];
1415
-      liveUser.uid = (NSUInteger)[optionUser[@"uid"] integerValue];
1416
-      liveUser.rect = CGRectMake((CGFloat)[options[@"backgroundColor"][@"x"] floatValue], (CGFloat)[options[@"backgroundColor"][@"y"] floatValue], (CGFloat)[options[@"backgroundColor"][@"width"] floatValue], (CGFloat)[options[@"backgroundColor"][@"height"] floatValue]);
1417
-      liveUser.zOrder = [optionUser[@"zOrder"] integerValue];
1418
-      liveUser.alpha = [optionUser[@"alpha"] doubleValue];
1419
-      liveUser.audioChannel = [optionUser[@"audioChannel"] integerValue];
1420
-      [transcodingUsers addObject:liveUser];
1421
-    }
1422
-    transcoding.transcodingUsers = transcodingUsers;
1423
-  }
1424
-  if (options[@"transcodingExtraInfo"] != nil) {
1425
-    transcoding.transcodingExtraInfo = [options[@"transcodingExtraInfo"] stringValue];
1415
+  if ([options objectForKey:@"audioSampleRate"]) {
1416
+    transcoding.audioSampleRate = (AgoraAudioSampleRateType)[options[@"audioSampleRate"] integerValue];
1426 1417
   }
1427
-  if (options[@"watermark"] != nil) {
1418
+  if ([options objectForKey:@"watermark"]) {
1428 1419
     transcoding.watermark = [self makeAgoraImage:@{
1429 1420
                                                    @"url": options[@"watermark"][@"url"],
1430 1421
                                                    @"x": options[@"watermark"][@"x"],
@@ -1433,7 +1424,7 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options
1433 1424
                                                    @"height": options[@"watermark"][@"height"]
1434 1425
                                                    }];
1435 1426
   }
1436
-  if (options[@"backgroundImage"] != nil) {
1427
+  if ([options objectForKey:@"backgroundImage"]) {
1437 1428
     transcoding.backgroundImage = [self makeAgoraImage:@{
1438 1429
                                                          @"url": options[@"backgroundImage"][@"url"],
1439 1430
                                                          @"x": options[@"backgroundImage"][@"x"],
@@ -1442,19 +1433,39 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options
1442 1433
                                                          @"height": options[@"backgroundImage"][@"height"]
1443 1434
                                                          }];
1444 1435
   }
1445
-  if (options[@"backgroundColor"] != nil) {
1446
-    transcoding.backgroundColor = [[UIColor new] initWithRed:(CGFloat)[options[@"backgroundColor"][@"red"] floatValue] green:(CGFloat)[options[@"backgroundColor"][@"green"] floatValue] blue:(CGFloat)[options[@"backgroundColor"][@"blue"] floatValue] alpha:(CGFloat)[options[@"backgroundColor"][@"alpha"] floatValue]];
1447
-  }
1448
-  if (options[@"audioSampleRate"] != nil) {
1449
-    transcoding.audioSampleRate = (AgoraAudioSampleRateType)[options[@"audioSampleRate"] integerValue];
1436
+  
1437
+  if ([options objectForKey:@"backgroundColor"]) {
1438
+    transcoding.backgroundColor = [self UIColorFromRGB:(NSUInteger)[options[@"backgroundColor"] integerValue]];
1450 1439
   }
1451
-  if (options[@"audioBitrate"] != nil) {
1440
+  
1441
+  if ([options objectForKey:@"audioBitrate"]) {
1452 1442
     transcoding.audioBitrate = [options[@"audioBitrate"] integerValue];
1453 1443
   }
1454
-  if (options[@"audioChannels"] != nil) {
1444
+  
1445
+  if ([options objectForKey:@"audioChannels"]) {
1455 1446
     transcoding.audioChannels = [options[@"audioChannels"] integerValue];
1456 1447
   }
1457 1448
   
1449
+  if ([options objectForKey:@"transcodingUsers"]) {
1450
+    NSMutableArray<AgoraLiveTranscodingUser*> *transcodingUsers = [NSMutableArray new];
1451
+    for (NSDictionary *optionUser in options[@"transcodingUsers"]) {
1452
+      AgoraLiveTranscodingUser *liveUser = [AgoraLiveTranscodingUser new];
1453
+      liveUser.uid = (NSUInteger)[optionUser[@"uid"] integerValue];
1454
+      liveUser.rect = CGRectMake((CGFloat)[optionUser[@"x"] floatValue],
1455
+                                 (CGFloat)[optionUser[@"y"] floatValue],
1456
+                                 (CGFloat)[optionUser[@"width"] floatValue],
1457
+                                 (CGFloat)[optionUser[@"height"] floatValue]);
1458
+      liveUser.zOrder = [optionUser[@"zOrder"] integerValue];
1459
+      liveUser.alpha = [optionUser[@"alpha"] doubleValue];
1460
+      liveUser.audioChannel = [optionUser[@"audioChannel"] integerValue];
1461
+      [transcodingUsers addObject:liveUser];
1462
+    }
1463
+    transcoding.transcodingUsers = transcodingUsers;
1464
+  }
1465
+  if ([options objectForKey:@"transcodingExtraInfo"]) {
1466
+    transcoding.transcodingExtraInfo = [options[@"transcodingExtraInfo"] stringValue];
1467
+  }
1468
+  
1458 1469
   NSInteger res = [self.rtcEngine setLiveTranscoding:transcoding];
1459 1470
   if (res == 0) {
1460 1471
     resolve(nil);
@@ -1508,7 +1519,7 @@ RCT_EXPORT_METHOD(enableSoundPositionIndication:(bool) enabled
1508 1519
   }
1509 1520
 }
1510 1521
 
1511
-RCT_EXPORT_METHOD(setRemoteVoicePosition:(NSInteger) uid
1522
+RCT_EXPORT_METHOD(setRemoteVoicePosition:(NSUInteger) uid
1512 1523
                   pan:(float)pan
1513 1524
                   gain:(float)gain
1514 1525
                   resolve:(RCTPromiseResolveBlock)resolve
@@ -1529,7 +1540,7 @@ RCT_EXPORT_METHOD(startLastmileProbeTest:(NSDictionary*)config
1529 1540
   probeConfig.probeDownlink = [config[@"probeDownlink"] boolValue];
1530 1541
   probeConfig.expectedUplinkBitrate = [config[@"expectedUplinkBitrate"] integerValue];
1531 1542
   probeConfig.expectedDownlinkBitrate = [config[@"expectedDownlinkBitrate"] integerValue];
1532
-
1543
+  
1533 1544
   NSInteger res = [self.rtcEngine startLastmileProbeTest:probeConfig];
1534 1545
   if (res == 0) {
1535 1546
     resolve(nil);
@@ -1543,7 +1554,7 @@ RCT_EXPORT_METHOD(setRemoteUserPriority:(NSUInteger)uid
1543 1554
                   userPriority:(NSInteger)userPriority
1544 1555
                   resolve:(RCTPromiseResolveBlock)resolve
1545 1556
                   reject:(RCTPromiseRejectBlock)reject) {
1546
- 
1557
+  
1547 1558
   NSInteger res = [self.rtcEngine setRemoteUserPriority:uid type:(AgoraUserPriority)userPriority];
1548 1559
   if (res == 0) {
1549 1560
     resolve(nil);
@@ -1602,8 +1613,8 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1602 1613
                   :(RCTPromiseResolveBlock)resolve
1603 1614
                   reject:(RCTPromiseRejectBlock)reject) {
1604 1615
   if (YES == [_rtcEngine setMediaMetadataDataSource:self withType:AgoraMetadataTypeVideo] &&
1605
-    YES == [_rtcEngine setMediaMetadataDelegate:self withType:AgoraMetadataTypeVideo]
1606
-    ) {
1616
+      YES == [_rtcEngine setMediaMetadataDelegate:self withType:AgoraMetadataTypeVideo]
1617
+      ) {
1607 1618
     resolve(nil);
1608 1619
   } else {
1609 1620
     reject(@(-1).stringValue, @(-1).stringValue, nil);
@@ -1642,72 +1653,72 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1642 1653
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result {
1643 1654
   if (error != 0) {
1644 1655
     [self sendEvent:AGError  params:@{
1645
-                                            @"api": api,
1646
-                                            @"result": result,
1647
-                                            @"error": @(error)
1648
-                                            }];
1656
+                                      @"api": api,
1657
+                                      @"result": result,
1658
+                                      @"error": @(error)
1659
+                                      }];
1649 1660
   } else {
1650 1661
     [self sendEvent:AGApiCallExecute  params:@{
1651
-                                            @"api": api,
1652
-                                            @"result": result,
1653
-                                            @"error": @(error)
1654
-                                            }];
1662
+                                               @"api": api,
1663
+                                               @"result": result,
1664
+                                               @"error": @(error)
1665
+                                               }];
1655 1666
   }
1656 1667
 }
1657 1668
 
1658 1669
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
1659 1670
   [self sendEvent:AGJoinChannelSuccess params:@{
1660
-                                          @"channel": channel,
1661
-                                          @"uid": @(uid),
1662
-                                          @"elapsed": @(elapsed)
1663
-                                          }];
1671
+                                                @"channel": channel,
1672
+                                                @"uid": @(uid),
1673
+                                                @"elapsed": @(elapsed)
1674
+                                                }];
1664 1675
 }
1665 1676
 
1666 1677
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRejoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
1667 1678
   [self sendEvent:AGRejoinChannelSuccess params:@{
1668
-                                            @"channel": channel,
1669
-                                            @"uid": @(uid),
1670
-                                            @"elapsed": @(elapsed)
1671
-                                            }];
1679
+                                                  @"channel": channel,
1680
+                                                  @"uid": @(uid),
1681
+                                                  @"elapsed": @(elapsed)
1682
+                                                  }];
1672 1683
 }
1673 1684
 
1674 1685
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLeaveChannelWithStats:(AgoraChannelStats *_Nonnull)stats {
1675 1686
   [self sendEvent:AGLeaveChannel params:@{
1676
-                                           @"stats": @{
1677
-                                               @"duration": @(stats.duration),
1678
-                                               @"txBytes": @(stats.txBytes),
1679
-                                               @"rxBytes": @(stats.rxBytes),
1680
-                                               @"txAudioKBitrate": @(stats.txAudioKBitrate),
1681
-                                               @"rxAudioKBitrate": @(stats.rxVideoKBitrate),
1682
-                                               @"txVideoKBitrate": @(stats.txVideoKBitrate),
1683
-                                               @"rxVideoKBitrate": @(stats.rxVideoKBitrate),
1684
-                                               @"lastmileDelay": @(stats.lastmileDelay),
1685
-                                               @"userCount": @(stats.userCount),
1686
-                                               @"cpuAppUsage": @(stats.cpuAppUsage),
1687
-                                               @"cpuTotalUsage": @(stats.cpuTotalUsage)
1688
-                                               }
1689
-                                           }];
1687
+                                          @"stats": @{
1688
+                                              @"duration": @(stats.duration),
1689
+                                              @"txBytes": @(stats.txBytes),
1690
+                                              @"rxBytes": @(stats.rxBytes),
1691
+                                              @"txAudioKBitrate": @(stats.txAudioKBitrate),
1692
+                                              @"rxAudioKBitrate": @(stats.rxVideoKBitrate),
1693
+                                              @"txVideoKBitrate": @(stats.txVideoKBitrate),
1694
+                                              @"rxVideoKBitrate": @(stats.rxVideoKBitrate),
1695
+                                              @"lastmileDelay": @(stats.lastmileDelay),
1696
+                                              @"userCount": @(stats.userCount),
1697
+                                              @"cpuAppUsage": @(stats.cpuAppUsage),
1698
+                                              @"cpuTotalUsage": @(stats.cpuTotalUsage)
1699
+                                              }
1700
+                                          }];
1690 1701
 }
1691 1702
 
1692 1703
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didClientRoleChanged:(AgoraClientRole)oldRole newRole:(AgoraClientRole)newRole {
1693 1704
   [self sendEvent:AGClientRoleChanged params:@{
1694
-                                                @"oldRole": @(oldRole),
1695
-                                                @"newRole": @(newRole)
1696
-                                                }];
1705
+                                               @"oldRole": @(oldRole),
1706
+                                               @"newRole": @(newRole)
1707
+                                               }];
1697 1708
 }
1698 1709
 
1699 1710
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
1700 1711
   [self sendEvent:AGUserJoined params:@{
1701
-                                          @"uid": @(uid),
1702
-                                          @"elapsed": @(elapsed)
1703
-                                          }];
1712
+                                        @"uid": @(uid),
1713
+                                        @"elapsed": @(elapsed)
1714
+                                        }];
1704 1715
 }
1705 1716
 
1706 1717
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason {
1707 1718
   [self sendEvent:AGUserOffline params:@{
1708
-                                           @"uid": @(uid),
1709
-                                           @"reason": @(reason)
1710
-                                           }];
1719
+                                         @"uid": @(uid),
1720
+                                         @"reason": @(reason)
1721
+                                         }];
1711 1722
 }
1712 1723
 
1713 1724
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine networkTypeChangedToType:(AgoraNetworkType)type {
@@ -1725,26 +1736,26 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1725 1736
 
1726 1737
 - (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *_Nonnull)engine {
1727 1738
   [self sendEvent:AGConnectionLost params:@{
1728
-                                             @"message": @"connectionLost"
1729
-                                             }];
1739
+                                            @"message": @"connectionLost"
1740
+                                            }];
1730 1741
 }
1731 1742
 
1732 1743
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine tokenPrivilegeWillExpire:(NSString *_Nonnull)token {
1733 1744
   [self sendEvent:AGTokenPrivilegeWillExpire params:@{
1734
-                                                    @"token": token
1735
-                                                    }];
1745
+                                                      @"token": token
1746
+                                                      }];
1736 1747
 }
1737 1748
 
1738 1749
 - (void)rtcEngineRequestToken:(AgoraRtcEngineKit *_Nonnull)engine {
1739 1750
   [self sendEvent:AGRequestToken params:@{
1740
-                                        @"message": @"RequestToken"
1741
-                                        }];
1751
+                                          @"message": @"RequestToken"
1752
+                                          }];
1742 1753
 }
1743 1754
 
1744 1755
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didMicrophoneEnabled:(BOOL)enabled {
1745 1756
   [self sendEvent:AGMicrophoneEnabled params:@{
1746
-                                                @"enabled": @(enabled)
1747
-                                                }];
1757
+                                               @"enabled": @(enabled)
1758
+                                               }];
1748 1759
 }
1749 1760
 
1750 1761
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume {
@@ -1756,28 +1767,28 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1756 1767
                         }];
1757 1768
   }
1758 1769
   [self sendEvent:AGAudioVolumeIndication params:@{
1759
-                                                                 @"speakers": result,
1760
-                                                                 @"totalVolume": @(totalVolume)
1761
-                                                                 }];
1770
+                                                   @"speakers": result,
1771
+                                                   @"totalVolume": @(totalVolume)
1772
+                                                   }];
1762 1773
 }
1763 1774
 
1764 1775
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine activeSpeaker:(NSUInteger)speakerUid {
1765 1776
   [self sendEvent:AGActiveSpeaker params:@{
1766
-                                         @"uid": @(speakerUid)
1767
-                                         }];
1777
+                                           @"uid": @(speakerUid)
1778
+                                           }];
1768 1779
 }
1769 1780
 
1770 1781
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalAudioFrame:(NSInteger)elapsed {
1771 1782
   [self sendEvent:AGFirstLocalAudioFrame params:@{
1772
-                                                @"elapsed": @(elapsed)
1773
-                                                }];
1783
+                                                  @"elapsed": @(elapsed)
1784
+                                                  }];
1774 1785
 }
1775 1786
 
1776 1787
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteAudioFrameOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
1777 1788
   [self sendEvent:AGFirstRemoteAudioFrame params:@{
1778
-                                                      @"uid": @(uid),
1779
-                                                      @"elapsed": @(elapsed)
1780
-                                                      }];
1789
+                                                   @"uid": @(uid),
1790
+                                                   @"elapsed": @(elapsed)
1791
+                                                   }];
1781 1792
 }
1782 1793
 
1783 1794
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteAudioFrameDecodedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
@@ -1789,217 +1800,217 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1789 1800
 
1790 1801
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalVideoFrameWithSize:(CGSize)size elapsed:(NSInteger)elapsed {
1791 1802
   [self sendEvent:AGFirstLocalVideoFrame params:@{
1792
-                                                        @"width": @(size.width),
1793
-                                                        @"height": @(size.height),
1794
-                                                        @"elapsed": @(elapsed)
1795
-                                                        }];
1803
+                                                  @"width": @(size.width),
1804
+                                                  @"height": @(size.height),
1805
+                                                  @"elapsed": @(elapsed)
1806
+                                                  }];
1796 1807
 }
1797 1808
 
1798 1809
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
1799 1810
   [self sendEvent:AGFirstRemoteVideoDecoded params:@{
1800
-                                                        @"uid": @(uid),
1801
-                                                        @"width": @(size.width),
1802
-                                                        @"height": @(size.height),
1803
-                                                        @"elapsed": @(elapsed)
1804
-                                                        }];
1811
+                                                     @"uid": @(uid),
1812
+                                                     @"width": @(size.width),
1813
+                                                     @"height": @(size.height),
1814
+                                                     @"elapsed": @(elapsed)
1815
+                                                     }];
1805 1816
 }
1806 1817
 
1807 1818
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
1808 1819
   [self sendEvent:AGFirstRemoteVideoFrame params:@{
1809
-                                                      @"uid": @(uid),
1810
-                                                      @"width": @(size.width),
1811
-                                                      @"height": @(size.height),
1812
-                                                      @"elapsed": @(elapsed)}];
1820
+                                                   @"uid": @(uid),
1821
+                                                   @"width": @(size.width),
1822
+                                                   @"height": @(size.height),
1823
+                                                   @"elapsed": @(elapsed)}];
1813 1824
 }
1814 1825
 
1815 1826
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioMuted:(BOOL)muted byUid:(NSUInteger)uid {
1816 1827
   [self sendEvent:AGUserMuteAudio params:@{
1817
-                                         @"muted": @(muted),
1818
-                                         @"uid": @(uid)
1819
-                                         }];
1828
+                                           @"muted": @(muted),
1829
+                                           @"uid": @(uid)
1830
+                                           }];
1820 1831
 }
1821 1832
 
1822 1833
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoMuted:(BOOL)muted byUid:(NSUInteger)uid {
1823 1834
   [self sendEvent:AGUserMuteVideo params:@{
1824
-                                         @"muted": @(muted),
1825
-                                         @"uid": @(uid)
1826
-                                         }];
1835
+                                           @"muted": @(muted),
1836
+                                           @"uid": @(uid)
1837
+                                           }];
1827 1838
 }
1828 1839
 
1829 1840
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid {
1830 1841
   [self sendEvent:AGUserEnableVideo params:@{
1831
-                                           @"enabled": @(enabled),
1832
-                                           @"uid": @(uid)
1833
-                                           }];
1842
+                                             @"enabled": @(enabled),
1843
+                                             @"uid": @(uid)
1844
+                                             }];
1834 1845
 }
1835 1846
 
1836 1847
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid {
1837 1848
   [self sendEvent:AGUserEnableLocalVideo params:@{
1838
-                                                @"enabled": @(enabled),
1839
-                                                @"uid": @(uid)
1840
-                                                }];
1849
+                                                  @"enabled": @(enabled),
1850
+                                                  @"uid": @(uid)
1851
+                                                  }];
1841 1852
 }
1842 1853
 
1843 1854
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation {
1844 1855
   [self sendEvent:AGVideoSizeChanged params:@{
1845
-                                                 @"uid": @(uid),
1846
-                                                 @"width": @(size.width),
1847
-                                                 @"height": @(size.height),
1848
-                                                 @"rotation": @(rotation)
1849
-                                                 }];
1856
+                                              @"uid": @(uid),
1857
+                                              @"width": @(size.width),
1858
+                                              @"height": @(size.height),
1859
+                                              @"rotation": @(rotation)
1860
+                                              }];
1850 1861
 }
1851 1862
 
1852 1863
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state {
1853 1864
   [self sendEvent:AGRemoteVideoStateChanged params:@{
1854
-                                                        @"uid": @(uid),
1855
-                                                        @"state": @(state)
1856
-                                                        }];
1865
+                                                     @"uid": @(uid),
1866
+                                                     @"state": @(state)
1867
+                                                     }];
1857 1868
 }
1858 1869
 
1859 1870
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalPublishFallbackToAudioOnly:(BOOL)isFallbackOrRecover {
1860 1871
   [self sendEvent:AGLocalPublishFallbackToAudioOnly params:@{
1861
-                                                              @"isFallbackOrRecover": @(isFallbackOrRecover)
1862
-                                                              }];
1872
+                                                             @"isFallbackOrRecover": @(isFallbackOrRecover)
1873
+                                                             }];
1863 1874
 }
1864 1875
 
1865 1876
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRemoteSubscribeFallbackToAudioOnly:(BOOL)isFallbackOrRecover byUid:(NSUInteger)uid {
1866 1877
   [self sendEvent:AGRemoteSubscribeFallbackToAudioOnly params:@{
1867
-                                                                 @"isFallbackOrRecover": @(isFallbackOrRecover),
1868
-                                                                 @"uid": @(uid)
1869
-                                                                 }];
1878
+                                                                @"isFallbackOrRecover": @(isFallbackOrRecover),
1879
+                                                                @"uid": @(uid)
1880
+                                                                }];
1870 1881
 }
1871 1882
 
1872 1883
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioRouteChanged:(AgoraAudioOutputRouting)routing {
1873 1884
   [self sendEvent:AGAudioRouteChanged params:@{
1874
-                                                @"routing": @(routing)
1875
-                                                }];
1885
+                                               @"routing": @(routing)
1886
+                                               }];
1876 1887
 }
1877 1888
 
1878 1889
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraFocusDidChangedToRect:(CGRect)rect {
1879 1890
   [self sendEvent:AGCameraFocusAreaChanged params:@{
1880
-                                                       @"rect": @(rect)
1881
-                                                       }];
1891
+                                                    @"rect": @(rect)
1892
+                                                    }];
1882 1893
 }
1883 1894
 
1884 1895
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraExposureDidChangedToRect:(CGRect)rect {
1885 1896
   [self sendEvent:AGCameraExposureAreaChanged params:@{
1886
-                                                          @"rect": @(rect)
1887
-                                                          }];
1897
+                                                       @"rect": @(rect)
1898
+                                                       }];
1888 1899
 }
1889 1900
 
1890 1901
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStats:(AgoraRtcRemoteAudioStats *_Nonnull)stats {
1891 1902
   [self sendEvent:AGRemoteAudioStats params:@{
1892
-                                            @"stats": @{
1893
-                                                @"uid": @(stats.uid),
1894
-                                                @"quality": @(stats.quality),
1895
-                                                @"networkTransportDelay": @(stats.networkTransportDelay),
1896
-                                                @"jitterBufferDelay": @(stats.jitterBufferDelay),
1897
-                                                @"audioLossRate": @(stats.audioLossRate)
1898
-                                                }
1899
-                                            }];
1903
+                                              @"stats": @{
1904
+                                                  @"uid": @(stats.uid),
1905
+                                                  @"quality": @(stats.quality),
1906
+                                                  @"networkTransportDelay": @(stats.networkTransportDelay),
1907
+                                                  @"jitterBufferDelay": @(stats.jitterBufferDelay),
1908
+                                                  @"audioLossRate": @(stats.audioLossRate)
1909
+                                                  }
1910
+                                              }];
1900 1911
 }
1901 1912
 
1902 1913
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportRtcStats:(AgoraChannelStats *_Nonnull)stats {
1903 1914
   [self sendEvent:AGRtcStats params:@{
1904
-                                          @"stats": @{
1905
-                                              @"duration": @(stats.duration),
1906
-                                              @"txPacketLossRate": @(stats.txPacketLossRate),
1907
-                                              @"rxPacketLossRate": @(stats.rxPacketLossRate),
1908
-                                              @"txBytes": @(stats.txBytes),
1909
-                                              @"rxBytes": @(stats.rxBytes),
1910
-                                              @"txAudioKBitrate": @(stats.txAudioKBitrate),
1911
-                                              @"rxAudioKBitrate": @(stats.rxAudioKBitrate),
1912
-                                              @"txVideoKBitrate": @(stats.txVideoKBitrate),
1913
-                                              @"rxVideoKBitrate": @(stats.rxVideoKBitrate),
1914
-                                              @"lastmileDelay": @(stats.lastmileDelay),
1915
-                                              @"userCount": @(stats.userCount),
1916
-                                              @"cpuAppUsage": @(stats.cpuAppUsage),
1917
-                                              @"cpuTotalUsage": @(stats.cpuTotalUsage)
1918
-                                              }
1919
-                                          }];
1915
+                                      @"stats": @{
1916
+                                          @"duration": @(stats.duration),
1917
+                                          @"txPacketLossRate": @(stats.txPacketLossRate),
1918
+                                          @"rxPacketLossRate": @(stats.rxPacketLossRate),
1919
+                                          @"txBytes": @(stats.txBytes),
1920
+                                          @"rxBytes": @(stats.rxBytes),
1921
+                                          @"txAudioKBitrate": @(stats.txAudioKBitrate),
1922
+                                          @"rxAudioKBitrate": @(stats.rxAudioKBitrate),
1923
+                                          @"txVideoKBitrate": @(stats.txVideoKBitrate),
1924
+                                          @"rxVideoKBitrate": @(stats.rxVideoKBitrate),
1925
+                                          @"lastmileDelay": @(stats.lastmileDelay),
1926
+                                          @"userCount": @(stats.userCount),
1927
+                                          @"cpuAppUsage": @(stats.cpuAppUsage),
1928
+                                          @"cpuTotalUsage": @(stats.cpuTotalUsage)
1929
+                                          }
1930
+                                      }];
1920 1931
 }
1921 1932
 
1922 1933
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine lastmileQuality:(AgoraNetworkQuality)quality {
1923 1934
   [self sendEvent:AGLastmileQuality params:@{
1924
-                                           @"quality": @(quality)
1925
-                                           }];
1935
+                                             @"quality": @(quality)
1936
+                                             }];
1926 1937
 }
1927 1938
 
1928 1939
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine networkQuality:(NSUInteger)uid txQuality:(AgoraNetworkQuality)txQuality rxQuality:(AgoraNetworkQuality)rxQuality {
1929 1940
   [self sendEvent:AGNetworkQuality params:@{
1930
-                                          @"uid": @(uid),
1931
-                                          @"txQuality": @(txQuality),
1932
-                                          @"rxQuality": @(rxQuality)
1933
-                                          }];
1941
+                                            @"uid": @(uid),
1942
+                                            @"txQuality": @(txQuality),
1943
+                                            @"rxQuality": @(rxQuality)
1944
+                                            }];
1934 1945
 }
1935 1946
 
1936 1947
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStats:(AgoraRtcLocalVideoStats *_Nonnull)stats {
1937 1948
   [self sendEvent:AGLocalVideoStats params:@{
1938
-                                           @"stats": @{
1939
-                                               @"sentBitrate": @(stats.sentBitrate),
1940
-                                               @"sentFrameRate": @(stats.sentFrameRate)
1941
-                                               },
1942
-                                           @"encoderOutputFrameRate": @(stats.encoderOutputFrameRate),
1943
-                                           @"rendererOutputFrameRate":
1949
+                                             @"stats": @{
1950
+                                                 @"sentBitrate": @(stats.sentBitrate),
1951
+                                                 @"sentFrameRate": @(stats.sentFrameRate)
1952
+                                                 },
1953
+                                             @"encoderOutputFrameRate": @(stats.encoderOutputFrameRate),
1954
+                                             @"rendererOutputFrameRate":
1944 1955
                                                @(stats.rendererOutputFrameRate)
1945
-                                           }];
1956
+                                             }];
1946 1957
 }
1947 1958
 
1948 1959
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats {
1949 1960
   [self sendEvent:AGRemoteVideoStats params:@{
1950
-                                            @"stats": @{
1951
-                                                @"uid": @(stats.uid),
1952
-                                                @"width": @(stats.width),
1953
-                                                @"height": @(stats.height),
1954
-                                                @"receivedBitrate": @(stats.receivedBitrate),
1955
-                                                @"rendererOutputFrameRate": @(stats.rendererOutputFrameRate),
1956
-                                                @"rxStreamType": @(stats.rxStreamType),
1957
-                                                @"decoderOutputFrameRate": @(stats.decoderOutputFrameRate)
1958
-                                                }
1959
-                                            }];
1961
+                                              @"stats": @{
1962
+                                                  @"uid": @(stats.uid),
1963
+                                                  @"width": @(stats.width),
1964
+                                                  @"height": @(stats.height),
1965
+                                                  @"receivedBitrate": @(stats.receivedBitrate),
1966
+                                                  @"rendererOutputFrameRate": @(stats.rendererOutputFrameRate),
1967
+                                                  @"rxStreamType": @(stats.rxStreamType),
1968
+                                                  @"decoderOutputFrameRate": @(stats.decoderOutputFrameRate)
1969
+                                                  }
1970
+                                              }];
1960 1971
 }
1961 1972
 
1962 1973
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate {
1963 1974
   [self sendEvent:AGAudioTransportStatsOfUid params:@{
1964
-                                                    @"uid": @(uid),
1965
-                                                    @"delay": @(delay),
1966
-                                                    @"lost": @(lost),
1967
-                                                    @"rxKBitrate": @(rxKBitRate)
1968
-                                                    }];
1975
+                                                      @"uid": @(uid),
1976
+                                                      @"delay": @(delay),
1977
+                                                      @"lost": @(lost),
1978
+                                                      @"rxKBitrate": @(rxKBitRate)
1979
+                                                      }];
1969 1980
 }
1970 1981
 
1971 1982
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate {
1972 1983
   [self sendEvent:AGVideoTransportStatsOfUid params:@{
1973
-                                                    @"uid": @(uid),
1974
-                                                    @"delay": @(delay),
1975
-                                                    @"lost": @(lost),
1976
-                                                    @"rxKBitrate": @(rxKBitRate)
1977
-                                                    }];
1984
+                                                      @"uid": @(uid),
1985
+                                                      @"delay": @(delay),
1986
+                                                      @"lost": @(lost),
1987
+                                                      @"rxKBitrate": @(rxKBitRate)
1988
+                                                      }];
1978 1989
 }
1979 1990
 
1980 1991
 - (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine {
1981 1992
   [self sendEvent:AGRemoteAudioMixingStart params:@{
1982
-                                                     @"message": @"RemoteAudioMixingStarted"
1983
-                                                     }];
1993
+                                                    @"message": @"RemoteAudioMixingStarted"
1994
+                                                    }];
1984 1995
 }
1985 1996
 
1986 1997
 - (void)rtcEngineRemoteAudioMixingDidFinish:(AgoraRtcEngineKit *_Nonnull)engine {
1987 1998
   [self sendEvent:AGRemoteAudioMixingFinish params:@{
1988
-                                                      @"message": @"RemoteAudioMixingFinish"
1989
-                                                      }];
1999
+                                                     @"message": @"RemoteAudioMixingFinish"
2000
+                                                     }];
1990 2001
 }
1991 2002
 
1992 2003
 - (void)rtcEngineDidAudioEffectFinish:(AgoraRtcEngineKit *_Nonnull)engine soundId:(NSInteger)soundId {
1993 2004
   [self sendEvent:AGAudioEffectFinish params:@{
1994
-                                                @"soundid": @(soundId)
1995
-                                                }];
2005
+                                               @"soundid": @(soundId)
2006
+                                               }];
1996 2007
 }
1997 2008
 
1998 2009
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamPublishedWithUrl:(NSString *_Nonnull)url errorCode:(AgoraErrorCode)errorCode {
1999 2010
   [self sendEvent:AGStreamPublished params:@{
2000
-                                           @"url": url,
2001
-                                           @"code": @(errorCode)
2002
-                                           }];
2011
+                                             @"url": url,
2012
+                                             @"code": @(errorCode)
2013
+                                             }];
2003 2014
 }
2004 2015
 
2005 2016
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine rtmpStreamingChangedToState:(NSString *_Nonnull)url state:(AgoraRtmpStreamingState)state errorCode:(AgoraRtmpStreamingErrorCode)errorCode {
@@ -2012,14 +2023,14 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2012 2023
 
2013 2024
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamUnpublishedWithUrl:(NSString *_Nonnull)url {
2014 2025
   [self sendEvent:AGStreamUnpublish params:@{
2015
-                                           @"url": url,
2016
-                                           }];
2026
+                                             @"url": url,
2027
+                                             }];
2017 2028
 }
2018 2029
 
2019 2030
 - (void)rtcEngineTranscodingUpdated:(AgoraRtcEngineKit *_Nonnull)engine {
2020 2031
   [self sendEvent:AGTranscodingUpdate params:@{
2021
-                                              @"message": @"AGTranscodingUpdate"
2022
-                                              }];
2032
+                                               @"message": @"AGTranscodingUpdate"
2033
+                                               }];
2023 2034
 }
2024 2035
 
2025 2036
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStateChange:(AgoraLocalVideoStreamState)state error:(AgoraLocalVideoStreamError)error {
@@ -2031,10 +2042,10 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2031 2042
 
2032 2043
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamInjectedStatusOfUrl:(NSString *_Nonnull)url uid:(NSUInteger)uid status:(AgoraInjectStreamStatus)status {
2033 2044
   [self sendEvent:AGStreamInjectedStatus params:@{
2034
-                                                @"uid": @(uid),
2035
-                                                @"url": url,
2036
-                                                @"status": @(status)
2037
-                                                }];
2045
+                                                  @"uid": @(uid),
2046
+                                                  @"url": url,
2047
+                                                  @"status": @(status)
2048
+                                                  }];
2038 2049
 }
2039 2050
 
2040 2051
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data {
@@ -2047,24 +2058,24 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2047 2058
 
2048 2059
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurStreamMessageErrorFromUid:(NSUInteger)uid streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached {
2049 2060
   [self sendEvent:AGOccurStreamMessageError params:@{
2050
-                                                      @"uid": @(uid),
2051
-                                                      @"streamId": @(streamId),
2052
-                                                      @"error": @(error),
2053
-                                                      @"missed": @(missed),
2054
-                                                      @"cached": @(cached)
2055
-                                                      }];
2061
+                                                     @"uid": @(uid),
2062
+                                                     @"streamId": @(streamId),
2063
+                                                     @"error": @(error),
2064
+                                                     @"missed": @(missed),
2065
+                                                     @"cached": @(cached)
2066
+                                                     }];
2056 2067
 }
2057 2068
 
2058 2069
 - (void)rtcEngineMediaEngineDidLoaded:(AgoraRtcEngineKit *_Nonnull)engine {
2059 2070
   [self sendEvent:AGMediaEngineLoaded params:@{
2060
-                                                @"message": @"MediaEngineLoaded"
2061
-                                                }];
2071
+                                               @"message": @"MediaEngineLoaded"
2072
+                                               }];
2062 2073
 }
2063 2074
 
2064 2075
 - (void)rtcEngineMediaEngineDidStartCall:(AgoraRtcEngineKit *_Nonnull)engine {
2065 2076
   [self sendEvent:AGMediaEngineStartCall params:@{
2066
-                                                   @"message": @"AGMediaEngineStartCall"
2067
-                                                   }];
2077
+                                                  @"message": @"AGMediaEngineStartCall"
2078
+                                                  }];
2068 2079
 }
2069 2080
 
2070 2081
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioMixingStateDidChanged:(AgoraAudioMixingStateCode)state errorCode:(AgoraAudioMixingErrorCode)errorCode {
@@ -2095,4 +2106,4 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2095 2106
                                                      }];
2096 2107
 }
2097 2108
 
2098
-@end
2109
+@end

+ 7
- 6
lib/AgoraView.native.d.ts Просмотреть файл

@@ -4,16 +4,17 @@ import { AgoraViewProps } from "./types";
4 4
  * AgoraView is the render layer for rendering video stream
5 5
  *
6 6
  * This class is used to rendering native sdk stream
7
- *
8 7
  * @props {@link AgoraViewProps}
9 8
  *
10 9
  * @descrption AgoraViewProps has four properties.
11
- * @property number: mode, this property will setup video render mode. there is two avaliable mode {hidden: 1, fit: 2}, you could see more details [https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673](#here)
12
- * @property boolean: showLocalVideo, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
13
- * @property number: remoteUid, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
14
- * @property boolean: zOrderMediaOverlay, this property will working for android side and it likes zIndex behaviour on web side.
10
+ * @property mode: {@link AgoraViewMode}, this property will setup video render mode. You could see more [details](https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673)
11
+ * @property showLocalVideo: boolean, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
12
+ * @property remoteUid: number, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
13
+ * @property zOrderMediaOverlay: boolean, this property will working for android side and it likes zIndex behaviour on web side.
14
+ *
15
+ * @noInheritDoc
15 16
  */
16
-export default class AgoraView extends React.Component<AgoraViewProps> {
17
+export default class AgoraView extends React.Component<AgoraViewProps, {}, {}> {
17 18
     /**
18 19
      * render
19 20
      *

+ 12
- 5
lib/AgoraView.native.js Просмотреть файл

@@ -13,14 +13,15 @@ const RCTAgoraView = react_native_1.requireNativeComponent("RCTAgoraVideoView");
13 13
  * AgoraView is the render layer for rendering video stream
14 14
  *
15 15
  * This class is used to rendering native sdk stream
16
- *
17 16
  * @props {@link AgoraViewProps}
18 17
  *
19 18
  * @descrption AgoraViewProps has four properties.
20
- * @property number: mode, this property will setup video render mode. there is two avaliable mode {hidden: 1, fit: 2}, you could see more details [https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673](#here)
21
- * @property boolean: showLocalVideo, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
22
- * @property number: remoteUid, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
23
- * @property boolean: zOrderMediaOverlay, this property will working for android side and it likes zIndex behaviour on web side.
19
+ * @property mode: {@link AgoraViewMode}, this property will setup video render mode. You could see more [details](https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673)
20
+ * @property showLocalVideo: boolean, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
21
+ * @property remoteUid: number, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
22
+ * @property zOrderMediaOverlay: boolean, this property will working for android side and it likes zIndex behaviour on web side.
23
+ *
24
+ * @noInheritDoc
24 25
  */
25 26
 class AgoraView extends react_1.default.Component {
26 27
     /**
@@ -41,6 +42,12 @@ class AgoraView extends react_1.default.Component {
41 42
         for (let key in this.props) {
42 43
             htmlProps[key] = this.props[key];
43 44
         }
45
+        // convert uint32 to int32 for android
46
+        if (react_native_1.Platform.OS === 'android') {
47
+            const int32 = new Int32Array(1);
48
+            int32[0] = htmlProps.remoteUid;
49
+            htmlProps.remoteUid = int32[0];
50
+        }
44 51
         return htmlProps;
45 52
     }
46 53
 }

+ 1
- 1
lib/AgoraView.native.js.map Просмотреть файл

@@ -1 +1 @@
1
-{"version":3,"file":"AgoraView.native.js","sourceRoot":"","sources":["../src/AgoraView.native.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,+CAEqB;AAMrB;;;;GAIG;AAEH,MAAM,YAAY,GAAG,qCAAsB,CAAC,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAqB,SAAU,SAAQ,eAAK,CAAC,SAAyB;IAClE;;;;OAIG;IACI,MAAM;QACT,OAAO,CACH,8BAAC,YAAY,oBAAM,IAAI,CAAC,YAAY,EAAE,EAAK,CAC9C,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,YAAY;QAChB,IAAI,SAAS,GAAG,EAAoB,CAAC;QACrC,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YACxB,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAxBD,4BAwBC"}
1
+{"version":3,"file":"AgoraView.native.js","sourceRoot":"","sources":["../src/AgoraView.native.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,+CAGqB;AAMrB;;;;GAIG;AAEH,MAAM,YAAY,GAAG,qCAAsB,CAAC,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;;;;GAaG;AACH,MAAqB,SAAU,SAAQ,eAAK,CAAC,SAAiC;IAC1E;;;;OAIG;IACI,MAAM;QACT,OAAO,CACH,8BAAC,YAAY,oBAAM,IAAI,CAAC,YAAY,EAAE,EAAK,CAC9C,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,YAAY;QAChB,IAAI,SAAS,GAAG,EAAoB,CAAC;QACrC,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YACxB,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC;QAED,sCAAsC;QACtC,IAAI,uBAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;YAC3B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAChC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;YAC/B,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;SACjC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA/BD,4BA+BC"}

+ 13
- 4
lib/RtcEngine.native.d.ts Просмотреть файл

@@ -7,6 +7,9 @@ import { Option, Callback, AudioMixingOption, PlayEffectOption, AudioRecordingOp
7 7
  * Other methods of the RtcEngine object serve for agora native sdk and set up error logging.
8 8
  */
9 9
 declare class RtcEngine {
10
+    /**
11
+     * @ignore AG_PREFIX
12
+     */
10 13
     private static readonly AG_PREFIX;
11 14
     /**
12 15
      * Creates a RtcEngine Object internal.
@@ -26,13 +29,14 @@ declare class RtcEngine {
26 29
      * @param token
27 30
      * @param info
28 31
      */
29
-    static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): void;
32
+    static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): Promise<any>;
30 33
     /**
31 34
      * add event listener
32 35
      *
33 36
      * This method subscribes specified eventType and run listener. You should call this method at first.
34 37
      *
35
-     * @events
38
+     * @event listener
39
+     *
36 40
      * ---
37 41
      * name | description | usage |
38 42
      * error | occurs when emit error  | on("error", evt) |
@@ -106,6 +110,7 @@ declare class RtcEngine {
106 110
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) |
107 111
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) |
108 112
      * ---
113
+     *
109 114
      * @param eventType
110 115
      * @param listener
111 116
      * @return any
@@ -262,6 +267,10 @@ declare class RtcEngine {
262 267
      * @return Promise<any>
263 268
      */
264 269
     static muteAllRemoteVideoStreams(muted: boolean): Promise<any>;
270
+    /**
271
+     * @ignore Uint32ToInt32
272
+     */
273
+    private static Uint32ToInt32;
265 274
     /**
266 275
      * mute specified remote video stream.
267 276
      *
@@ -956,8 +965,8 @@ declare class RtcEngine {
956 965
      *
957 966
      * @param config LastmileProbeConfig {@link LastmileProbeConfig}
958 967
      *
959
-     * @event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
960
-     * @event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
968
+     * event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
969
+     * event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
961 970
      * @return Promise<any>
962 971
      */
963 972
     static startLastmileProbeTest(config: LastmileProbeConfig): Promise<any>;

+ 88
- 8
lib/RtcEngine.native.js Просмотреть файл

@@ -40,7 +40,8 @@ class RtcEngine {
40 40
      *
41 41
      * This method subscribes specified eventType and run listener. You should call this method at first.
42 42
      *
43
-     * @events
43
+     * @event listener
44
+     *
44 45
      * ---
45 46
      * name | description | usage |
46 47
      * error | occurs when emit error  | on("error", evt) |
@@ -114,11 +115,74 @@ class RtcEngine {
114 115
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) |
115 116
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) |
116 117
      * ---
118
+     *
117 119
      * @param eventType
118 120
      * @param listener
119 121
      * @return any
120 122
      */
121 123
     static on(eventType, listener) {
124
+        // convert int32 to uint32
125
+        if ([
126
+            'joinChannelSuccess',
127
+            'rejoinChannelSuccess',
128
+            'userJoined',
129
+            'userOffline',
130
+            'occurStreamMessageError',
131
+            'receiveStreamMessage',
132
+            'activeSpeaker',
133
+            'firstRemoteAudioFrame',
134
+            'firstRemoteVideoDecoded',
135
+            'firstRemoteVideoFrame',
136
+            'userMuteAudio',
137
+            'userMuteVideo',
138
+            'userEnableVideo',
139
+            'userEnableLocalVideo',
140
+            'videoSizeChanged',
141
+            'firstRemoteAudioDecoded',
142
+            'remoteVideoStateChanged',
143
+            'remoteSubscribeFallbackToAudioOnly',
144
+            'networkQuality',
145
+            'streamInjectedStatus',
146
+        ].indexOf(eventType) != -1) {
147
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
148
+                const uint32_uid = new Uint32Array(1);
149
+                uint32_uid[0] = args.uid;
150
+                args.uid = uint32_uid[0];
151
+                // convert int32 streamId to uint32 
152
+                if (args.streamId) {
153
+                    const uint32_streamId = new Uint32Array(1);
154
+                    uint32_streamId[0] = args.streamId;
155
+                    args.streamId = uint32_streamId[0];
156
+                }
157
+                listener(args);
158
+            });
159
+            return;
160
+        }
161
+        if (['audioVolumeIndication'].indexOf(eventType) != -1) {
162
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
163
+                args.speakers.map((speaker) => {
164
+                    const uint32_uid = new Uint32Array(1);
165
+                    uint32_uid[0] = speaker.uid;
166
+                    return Object.assign({}, speaker, { uid: uint32_uid[0] });
167
+                });
168
+                listener(args);
169
+            });
170
+            return;
171
+        }
172
+        if ([
173
+            'remoteAudioStats',
174
+            'remoteVideoStats',
175
+            'audioTransportStatsOfUid',
176
+            'videoTransportStatsOfUid',
177
+        ].indexOf(eventType) != -1) {
178
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
179
+                const uint32_uid = new Uint32Array(1);
180
+                uint32_uid[0] = args.stats.uid;
181
+                args.stats.uid = uint32_uid[0];
182
+                listener(args);
183
+            });
184
+            return;
185
+        }
122 186
         AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, listener);
123 187
     }
124 188
     /**
@@ -214,7 +278,8 @@ class RtcEngine {
214 278
      * @return Promise<any>
215 279
      */
216 280
     static setRemoteRenderMode(uid, mode) {
217
-        return Agora.setRemoteRenderMode(uid, mode);
281
+        let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
282
+        return Agora.setRemoteRenderMode(uint32, mode);
218 283
     }
219 284
     /**
220 285
      * start video preview
@@ -312,6 +377,14 @@ class RtcEngine {
312 377
     static muteAllRemoteVideoStreams(muted) {
313 378
         return Agora.muteAllRemoteVideoStreams(muted);
314 379
     }
380
+    /**
381
+     * @ignore Uint32ToInt32
382
+     */
383
+    static Uint32ToInt32(num) {
384
+        const int32 = new Int32Array(1);
385
+        int32[0] = num;
386
+        return int32[0];
387
+    }
315 388
     /**
316 389
      * mute specified remote video stream.
317 390
      *
@@ -321,7 +394,8 @@ class RtcEngine {
321 394
      * @return Promise<any>
322 395
      */
323 396
     static muteRemoteVideoStream(uid, muted) {
324
-        return Agora.muteRemoteVideoStream(uid, muted);
397
+        let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
398
+        return Agora.muteRemoteVideoStream(uint32, muted);
325 399
     }
326 400
     /**
327 401
      * set default mute all remote video stream
@@ -390,7 +464,8 @@ class RtcEngine {
390 464
      * @return Promise<any>
391 465
      */
392 466
     static muteRemoteAudioStream(uid, muted) {
393
-        return Agora.muteRemoteAudioStream(uid, muted);
467
+        let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
468
+        return Agora.muteRemoteAudioStream(uint32, muted);
394 469
     }
395 470
     /**
396 471
      * adjust recording signal volume
@@ -1157,7 +1232,8 @@ class RtcEngine {
1157 1232
      * @return Promise<any>
1158 1233
      */
1159 1234
     static setRemoteVoicePosition(uid, pan, gain) {
1160
-        return Agora.setRemoteVoicePosition(uid, pan, gain);
1235
+        let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
1236
+        return Agora.setRemoteVoicePosition(uint32, pan, gain);
1161 1237
     }
1162 1238
     /**
1163 1239
      * start the lastmile probe test
@@ -1166,8 +1242,8 @@ class RtcEngine {
1166 1242
      *
1167 1243
      * @param config LastmileProbeConfig {@link LastmileProbeConfig}
1168 1244
      *
1169
-     * @event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
1170
-     * @event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
1245
+     * event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
1246
+     * event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
1171 1247
      * @return Promise<any>
1172 1248
      */
1173 1249
     static startLastmileProbeTest(config) {
@@ -1195,7 +1271,8 @@ class RtcEngine {
1195 1271
      * @return Promise<any>
1196 1272
      */
1197 1273
     static setRemoteUserPriority(uid, userPrority) {
1198
-        return Agora.setRemoteUserPriority(uid, userPrority);
1274
+        let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
1275
+        return Agora.setRemoteUserPriority(uint32, userPrority);
1199 1276
     }
1200 1277
     /**
1201 1278
      * start an audio call test.
@@ -1301,6 +1378,9 @@ class RtcEngine {
1301 1378
         });
1302 1379
     }
1303 1380
 }
1381
+/**
1382
+ * @ignore AG_PREFIX
1383
+ */
1304 1384
 RtcEngine.AG_PREFIX = 'ag_rtc';
1305 1385
 exports.default = RtcEngine;
1306 1386
 //# sourceMappingURL=RtcEngine.native.js.map

+ 1
- 1
lib/RtcEngine.native.js.map
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 0
lib/index.d.ts Просмотреть файл

@@ -1,2 +1,3 @@
1 1
 export { default as AgoraView } from './AgoraView.native';
2 2
 export { default as RtcEngine } from './RtcEngine.native';
3
+export * from "./types";

+ 2
- 0
lib/index.js Просмотреть файл

@@ -1,7 +1,9 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
+const tslib_1 = require("tslib");
3 4
 var AgoraView_native_1 = require("./AgoraView.native");
4 5
 exports.AgoraView = AgoraView_native_1.default;
5 6
 var RtcEngine_native_1 = require("./RtcEngine.native");
6 7
 exports.RtcEngine = RtcEngine_native_1.default;
8
+tslib_1.__exportStar(require("./types"), exports);
7 9
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/index.js.map Просмотреть файл

@@ -1 +1 @@
1
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AAAhD,uCAAA,OAAO,CAAa;AAC5B,uDAAwD;AAAhD,uCAAA,OAAO,CAAa"}
1
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAwD;AAAhD,uCAAA,OAAO,CAAa;AAC5B,uDAAwD;AAAhD,uCAAA,OAAO,CAAa;AAC5B,kDAAwB"}

+ 79
- 27
lib/types.d.ts Просмотреть файл

@@ -1,4 +1,13 @@
1 1
 import { ViewProps } from 'react-native';
2
+/**
3
+ * AgoraViewMode
4
+ * @mode hidden Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
5
+ * @mode FIT Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
6
+ */
7
+export declare enum AgoraViewMode {
8
+    HIDDEN = 1,
9
+    FIT = 2
10
+}
2 11
 /**
3 12
  * VideoEncoderConfig details
4 13
  * @property width: number | The encoder video's width
@@ -16,15 +25,17 @@ export interface VideoEncoderConfig {
16 25
     orientationMode: number;
17 26
 }
18 27
 /**
19
- * Option is work for init method
20
- * @property: string appid Sets the appid
21
- * @property: number channelProfile Sets the channel mode. 0 is communication mode, 1 is broadcasting mode
22
- * @property: {@link VideoEncoderConfig} sets video encoding config
23
- * @property: mode is optional sets only enable video / audio, 0 is audio mode, 1 is video mode
24
- * @property: clientRole is only work in live mode, 1 is host, 2 is audience
25
- * @property: dualStream is optional parameter only for enable for detail see {@link https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/enableDualStreamMode:}
26
- * @property: audioProfile {@link https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioProfile.html}
27
- * @property: audioScenario {@link https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioScenario.html}
28
+ * Option is used to {@link init}
29
+ * @member {@link appid} Sets the appid
30
+ * @member {@link channelProfile} Number channelProfile Sets the channel mode. 0 is communication mode, 1 is broadcasting mode
31
+ * @member {@link VideoEncoderConfig} sets video encoding config
32
+ * @member {@link dualStream} is optional parameter only for enable for detail see [more](https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/enableDualStreamMode)
33
+ * @member {@link mode} is optional sets only enable video / audio, 0 is audio mode, 1 is video mode
34
+ * @member {@link clientRole} is only work in live mode, 1 is host, 2 is audience
35
+ * @member {@link audioProfile} Sets audio profile to agora rtc sdk See more [details](https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioProfile.html)
36
+ * @member {@link audioScenario} Sets audio scenario to agora rtc sdk more [details](https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioScenario.html)
37
+ * @member {@link beauty} {@link BeautyOption}
38
+ * @member {@link voice} {@link VoiceDecorator}
28 39
  */
29 40
 export interface Option {
30 41
     appid: String;
@@ -41,10 +52,11 @@ export interface Option {
41 52
 /**
42 53
  * VoiceDecorator is decorate local audio voice
43 54
  *
44
- * @property type: string | the range values ['changer' | 'reverbPreset'] This property is the identifier for audio voice decorator
45
- * @property value: number | the value for voice parameter option.
46
- * type 'reverbPreset' range values: [0 is "off", 1 is "popular", 2 is "rnb", 3 is "rock", 4 is "hiphop", 5 is "vocal concert", 6 is "KTV", 7 is "studio"]
47
- * type 'changer' range values: [0 is "off", 1 is "old man", 2 is "baby boy", 3 is "baby girl", 4 is "zhubajie", 5 is "ethereal", 6 is "hulk"]
55
+ * @description
56
+ *   type 'reverbPreset' range values: [0 is "off", 1 is "popular", 2 is "rnb", 3 is "rock", 4 is "hiphop", 5 is "vocal concert", 6 is "KTV", 7 is "studio"]
57
+ *   type 'changer' range values: [0 is "off", 1 is "old man", 2 is "baby boy", 3 is "baby girl", 4 is "zhubajie", 5 is "ethereal", 6 is "hulk"]
58
+ * @member type: string | the range values ['changer' | 'reverbPreset'] This property is the identifier for audio voice decorator
59
+ * @member value: number | the value for voice parameter option.
48 60
  */
49 61
 export interface VoiceDecorator {
50 62
     type: string;
@@ -69,21 +81,18 @@ export interface BackgroundImage {
69 81
     width: number;
70 82
     height: number;
71 83
 }
72
-export interface Rect {
73
-    x: number;
74
-    y: number;
75
-    width: number;
76
-    height: number;
77
-}
78 84
 export interface Size {
79 85
     width: number;
80 86
     height: number;
81 87
 }
82 88
 export interface TranscodingUser {
83 89
     uid: number;
84
-    zOrder: number;
85
-    rect: Rect;
90
+    x: number;
91
+    y: number;
92
+    width: number;
93
+    height: number;
86 94
     alpha: number;
95
+    zOrder: number;
87 96
     audioChannel: number;
88 97
 }
89 98
 export interface Color {
@@ -92,21 +101,64 @@ export interface Color {
92 101
     blue: number;
93 102
     alpha: number;
94 103
 }
104
+export declare enum VideoCodecProfile {
105
+    BASELINE = 66,
106
+    MAIN = 77,
107
+    HIGH = 100
108
+}
109
+export declare enum AudioCodecProfile {
110
+    LC_AAC = 0,
111
+    HE_AAC = 1
112
+}
113
+export declare enum AudioSampleRate {
114
+    TYPE_32000 = 32000,
115
+    TYPE_44100 = 44100,
116
+    TYPE_48000 = 48000
117
+}
118
+/**
119
+ * AgoraChannelStereo
120
+ * @note Agora’s self-defined audio channel type. We recommend choosing ONE or TWO. Special players are required if you choose TRHEE, FOUR or FIVE:
121
+ */
122
+export declare enum AudioChannelStereo {
123
+    ONE = 1,
124
+    TWO = 2,
125
+    TRHEE = 3,
126
+    FOUR = 4,
127
+    FIVE = 5
128
+}
129
+/**
130
+ * @member {@link size} {@link Size}
131
+ * @member {@link videoBitrate} integer number
132
+ * @member {@link videoFramerate} integer number
133
+ * @member {@link lowLatency} boolean
134
+ * @member {@link videoGop} number
135
+ * @member {@link videoCodecProfile} {@link VideoCodecProfile}
136
+ * @member {@link audioCodecProfile} {@link AudioCodecProfile}
137
+ * @member {@link audioSampleRate} {@link AudioSampleRate}
138
+ * @member {@link watermark} {@link BackgroundImage}
139
+ * @member {@link backgroundImage} {@link BackgroundImage}
140
+ * @member {@link backgroundColor} Standard RGB hex number: e.g. 0xffffff
141
+ * @member {@link audioBitrate} number
142
+ * @member {@link audioChannels} {@link AudioChannelStereo}
143
+ * @member {@link transcodingUsers} Array,{@link TranscodingUser}>,
144
+ * @member {@link transcodingExtraInfo} string
145
+ */
95 146
 export interface LiveTranscodingOption {
96 147
     size: Size;
97 148
     videoBitrate: number;
98 149
     videoFramerate: number;
99 150
     lowLatency: boolean;
100 151
     videoGop: number;
101
-    videoCodecProfile: number;
102
-    transcodingUsers: Array<TranscodingUser>;
103
-    transcodingExtraInfo: string;
152
+    videoCodecProfile: VideoCodecProfile;
153
+    audioCodecProfile: AudioCodecProfile;
154
+    audioSampleRate: AudioSampleRate;
104 155
     watermark: BackgroundImage;
105 156
     backgroundImage: BackgroundImage;
106
-    backgroundColor: Color;
107
-    audioSampleRate: number;
157
+    backgroundColor: number;
108 158
     audioBitrate: number;
109
-    audioChannels: number;
159
+    audioChannels: AudioChannelStereo;
160
+    transcodingUsers: Array<TranscodingUser>;
161
+    transcodingExtraInfo: string;
110 162
 }
111 163
 export interface VideoOption {
112 164
     uid: number;

+ 39
- 0
lib/types.js Просмотреть файл

@@ -1,3 +1,42 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
+/**
4
+ * AgoraViewMode
5
+ * @mode hidden Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
6
+ * @mode FIT Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
7
+ */
8
+var AgoraViewMode;
9
+(function (AgoraViewMode) {
10
+    AgoraViewMode[AgoraViewMode["HIDDEN"] = 1] = "HIDDEN";
11
+    AgoraViewMode[AgoraViewMode["FIT"] = 2] = "FIT";
12
+})(AgoraViewMode = exports.AgoraViewMode || (exports.AgoraViewMode = {}));
13
+var VideoCodecProfile;
14
+(function (VideoCodecProfile) {
15
+    VideoCodecProfile[VideoCodecProfile["BASELINE"] = 66] = "BASELINE";
16
+    VideoCodecProfile[VideoCodecProfile["MAIN"] = 77] = "MAIN";
17
+    VideoCodecProfile[VideoCodecProfile["HIGH"] = 100] = "HIGH";
18
+})(VideoCodecProfile = exports.VideoCodecProfile || (exports.VideoCodecProfile = {}));
19
+var AudioCodecProfile;
20
+(function (AudioCodecProfile) {
21
+    AudioCodecProfile[AudioCodecProfile["LC_AAC"] = 0] = "LC_AAC";
22
+    AudioCodecProfile[AudioCodecProfile["HE_AAC"] = 1] = "HE_AAC";
23
+})(AudioCodecProfile = exports.AudioCodecProfile || (exports.AudioCodecProfile = {}));
24
+var AudioSampleRate;
25
+(function (AudioSampleRate) {
26
+    AudioSampleRate[AudioSampleRate["TYPE_32000"] = 32000] = "TYPE_32000";
27
+    AudioSampleRate[AudioSampleRate["TYPE_44100"] = 44100] = "TYPE_44100";
28
+    AudioSampleRate[AudioSampleRate["TYPE_48000"] = 48000] = "TYPE_48000";
29
+})(AudioSampleRate = exports.AudioSampleRate || (exports.AudioSampleRate = {}));
30
+/**
31
+ * AgoraChannelStereo
32
+ * @note Agora’s self-defined audio channel type. We recommend choosing ONE or TWO. Special players are required if you choose TRHEE, FOUR or FIVE:
33
+ */
34
+var AudioChannelStereo;
35
+(function (AudioChannelStereo) {
36
+    AudioChannelStereo[AudioChannelStereo["ONE"] = 1] = "ONE";
37
+    AudioChannelStereo[AudioChannelStereo["TWO"] = 2] = "TWO";
38
+    AudioChannelStereo[AudioChannelStereo["TRHEE"] = 3] = "TRHEE";
39
+    AudioChannelStereo[AudioChannelStereo["FOUR"] = 4] = "FOUR";
40
+    AudioChannelStereo[AudioChannelStereo["FIVE"] = 5] = "FIVE";
41
+})(AudioChannelStereo = exports.AudioChannelStereo || (exports.AudioChannelStereo = {}));
3 42
 //# sourceMappingURL=types.js.map

+ 1
- 1
lib/types.js.map Просмотреть файл

@@ -1 +1 @@
1
-{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,qDAAU,CAAA;IACV,+CAAO,CAAA;AACT,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAuGD,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,kEAAa,CAAA;IACb,0DAAS,CAAA;IACT,2DAAU,CAAA;AACZ,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,6DAAU,CAAA;IACV,6DAAU,CAAA;AACZ,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B;AAED,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;AACpB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yDAAO,CAAA;IACP,yDAAO,CAAA;IACP,6DAAS,CAAA;IACT,2DAAQ,CAAA;IACR,2DAAQ,CAAA;AACV,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}

+ 3
- 2
package.json Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-agora",
3
-  "version": "2.4.1-alpha.2",
3
+  "version": "2.4.1-alpha.3",
4 4
   "description": "React Native around the Agora RTC SDKs for Android and iOS agora",
5 5
   "summary": "agora native sdk for react-native",
6 6
   "main": "lib/index.js",
@@ -49,7 +49,8 @@
49 49
     "react-native-typescript-transformer": "^1.2.11",
50 50
     "ts-jest": "^23.10.5",
51 51
     "tslint": "^5.12.1",
52
-    "typedoc": "^0.14.2",
52
+    "typedoc": "0.15.0",
53
+    "typedoc-plugin-no-inherit": "^1.1.9",
53 54
     "typescript": "^3.2.4"
54 55
   },
55 56
   "jest": {

+ 16
- 7
src/AgoraView.native.tsx Просмотреть файл

@@ -1,10 +1,11 @@
1 1
 import React from 'react';
2 2
 import {
3 3
     requireNativeComponent,
4
+    Platform
4 5
 } from 'react-native'
5 6
 
6 7
 import {
7
-    AgoraViewProps
8
+    AgoraViewProps,
8 9
 } from "./types";
9 10
 
10 11
 /**
@@ -19,16 +20,17 @@ const RCTAgoraView = requireNativeComponent("RCTAgoraVideoView");
19 20
  * AgoraView is the render layer for rendering video stream
20 21
  *
21 22
  * This class is used to rendering native sdk stream
22
- *
23 23
  * @props {@link AgoraViewProps}
24 24
  * 
25 25
  * @descrption AgoraViewProps has four properties.
26
- * @property number: mode, this property will setup video render mode. there is two avaliable mode {hidden: 1, fit: 2}, you could see more details [https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673](#here)
27
- * @property boolean: showLocalVideo, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
28
- * @property number: remoteUid, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
29
- * @property boolean: zOrderMediaOverlay, this property will working for android side and it likes zIndex behaviour on web side.
26
+ * @property mode: {@link AgoraViewMode}, this property will setup video render mode. You could see more [details](https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673)
27
+ * @property showLocalVideo: boolean, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
28
+ * @property remoteUid: number, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
29
+ * @property zOrderMediaOverlay: boolean, this property will working for android side and it likes zIndex behaviour on web side.
30
+ * 
31
+ * @noInheritDoc
30 32
  */
31
-export default class AgoraView extends React.Component<AgoraViewProps> {
33
+export default class AgoraView extends React.Component<AgoraViewProps, {}, {}> {
32 34
     /**
33 35
      * render
34 36
      *
@@ -50,6 +52,13 @@ export default class AgoraView extends React.Component<AgoraViewProps> {
50 52
         for (let key in this.props) {
51 53
             htmlProps[key] = this.props[key];
52 54
         }
55
+        
56
+        // convert uint32 to int32 for android
57
+        if (Platform.OS === 'android') {
58
+            const int32 = new Int32Array(1);
59
+            int32[0] = htmlProps.remoteUid;
60
+            htmlProps.remoteUid = int32[0]
61
+        }
53 62
         return htmlProps;
54 63
     }
55 64
 }

+ 97
- 13
src/RtcEngine.native.ts Просмотреть файл

@@ -40,6 +40,9 @@ const AgoraEventEmitter = new NativeEventEmitter(Agora);
40 40
  */
41 41
 class RtcEngine {
42 42
 
43
+    /**
44
+     * @ignore AG_PREFIX
45
+     */ 
43 46
     private static readonly AG_PREFIX: string = 'ag_rtc';
44 47
 
45 48
     /**
@@ -63,7 +66,7 @@ class RtcEngine {
63 66
      * @param token
64 67
      * @param info
65 68
      */
66
-    public static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): void {
69
+    public static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): Promise<any> {
67 70
         return Agora.joinChannel({channelName, uid, token, info});
68 71
     }
69 72
 
@@ -72,7 +75,8 @@ class RtcEngine {
72 75
      *
73 76
      * This method subscribes specified eventType and run listener. You should call this method at first.
74 77
      * 
75
-     * @events
78
+     * @event listener
79
+     * 
76 80
      * ---
77 81
      * name | description | usage |
78 82
      * error | occurs when emit error  | on("error", evt) |
@@ -146,11 +150,80 @@ class RtcEngine {
146 150
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) | 
147 151
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) | 
148 152
      * ---
153
+     * 
149 154
      * @param eventType
150 155
      * @param listener
151 156
      * @return any
152 157
      */
153 158
     public static on(eventType: string, listener: (...args: any[]) => any): any {
159
+        // convert int32 to uint32
160
+        if ([
161
+            'joinChannelSuccess',
162
+            'rejoinChannelSuccess',
163
+            'userJoined',
164
+            'userOffline',
165
+            'occurStreamMessageError',
166
+            'receiveStreamMessage',
167
+            'activeSpeaker',
168
+            'firstRemoteAudioFrame',
169
+            'firstRemoteVideoDecoded',
170
+            'firstRemoteVideoFrame',
171
+            'userMuteAudio',
172
+            'userMuteVideo',
173
+            'userEnableVideo',
174
+            'userEnableLocalVideo',
175
+            'videoSizeChanged',
176
+            'firstRemoteAudioDecoded',
177
+            'remoteVideoStateChanged',
178
+            'remoteSubscribeFallbackToAudioOnly',
179
+            'networkQuality',
180
+            'streamInjectedStatus',
181
+        ].indexOf(eventType) != -1) {
182
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
183
+                const uint32_uid = new Uint32Array(1);
184
+                uint32_uid[0] = args.uid;
185
+                args.uid = uint32_uid[0];
186
+
187
+                // convert int32 streamId to uint32 
188
+                if(args.streamId) {
189
+                    const uint32_streamId = new Uint32Array(1);
190
+                    uint32_streamId[0] = args.streamId;
191
+                    args.streamId = uint32_streamId[0];
192
+                }
193
+                listener(args);
194
+            });
195
+            return;
196
+        }
197
+
198
+        if (['audioVolumeIndication'].indexOf(eventType) != -1) {
199
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
200
+                args.speakers.map((speaker: any) => {
201
+                    const uint32_uid = new Uint32Array(1);
202
+                    uint32_uid[0] = speaker.uid;
203
+                    return {
204
+                        ...speaker,
205
+                        uid: uint32_uid[0]
206
+                    }
207
+                })
208
+                listener(args);
209
+            });
210
+            return;
211
+        }
212
+
213
+        if ([
214
+            'remoteAudioStats',
215
+            'remoteVideoStats',
216
+            'audioTransportStatsOfUid',
217
+            'videoTransportStatsOfUid',   
218
+        ].indexOf(eventType) != -1) {
219
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
220
+                const uint32_uid = new Uint32Array(1);
221
+                uint32_uid[0] = args.stats.uid;
222
+                args.stats.uid = uint32_uid[0];
223
+                listener(args);
224
+            });
225
+            return;
226
+        }
154 227
         AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, listener);
155 228
     }
156 229
 
@@ -256,7 +329,8 @@ class RtcEngine {
256 329
      * @return Promise<any>
257 330
      */
258 331
     public static setRemoteRenderMode(uid: number, mode: number): Promise<any> {
259
-        return Agora.setRemoteRenderMode(uid, mode);
332
+        let uint32 = Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
333
+        return Agora.setRemoteRenderMode(uint32, mode);
260 334
     }
261 335
 
262 336
     /**
@@ -366,6 +440,15 @@ class RtcEngine {
366 440
         return Agora.muteAllRemoteVideoStreams(muted);
367 441
     }
368 442
 
443
+    /**
444
+     * @ignore Uint32ToInt32
445
+     */
446
+    private static Uint32ToInt32(num: number) {
447
+        const int32 = new Int32Array(1);
448
+        int32[0] = num;
449
+        return int32[0];
450
+    }
451
+
369 452
     /**
370 453
      * mute specified remote video stream.
371 454
      *
@@ -375,7 +458,8 @@ class RtcEngine {
375 458
      * @return Promise<any>
376 459
      */
377 460
     public static muteRemoteVideoStream(uid: number, muted: boolean): Promise<any> {
378
-        return Agora.muteRemoteVideoStream(uid, muted);
461
+        let uint32 = Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
462
+        return Agora.muteRemoteVideoStream(uint32, muted);
379 463
     }
380 464
 
381 465
     /**
@@ -451,7 +535,8 @@ class RtcEngine {
451 535
      * @return Promise<any>
452 536
      */
453 537
     public static muteRemoteAudioStream(uid: number, muted: boolean): Promise<any> {
454
-        return Agora.muteRemoteAudioStream(uid, muted);
538
+        let uint32 = Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
539
+        return Agora.muteRemoteAudioStream(uint32, muted);
455 540
     }
456 541
 
457 542
     /**
@@ -1293,7 +1378,8 @@ class RtcEngine {
1293 1378
      * @return Promise<any>
1294 1379
      */
1295 1380
     static setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise<any> {
1296
-        return Agora.setRemoteVoicePosition(uid, pan, gain)
1381
+        let uint32 = Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
1382
+        return Agora.setRemoteVoicePosition(uint32, pan, gain)
1297 1383
     }
1298 1384
 
1299 1385
     /**
@@ -1303,8 +1389,8 @@ class RtcEngine {
1303 1389
      *
1304 1390
      * @param config LastmileProbeConfig {@link LastmileProbeConfig}
1305 1391
      *
1306
-     * @event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
1307
-     * @event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
1392
+     * event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
1393
+     * event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
1308 1394
      * @return Promise<any>
1309 1395
      */
1310 1396
     static startLastmileProbeTest(config: LastmileProbeConfig): Promise<any> {
@@ -1334,7 +1420,8 @@ class RtcEngine {
1334 1420
      * @return Promise<any>
1335 1421
      */
1336 1422
     static setRemoteUserPriority(uid: number, userPrority: number): Promise<any> {
1337
-        return Agora.setRemoteUserPriority(uid, userPrority);
1423
+        let uint32 = Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
1424
+        return Agora.setRemoteUserPriority(uint32, userPrority);
1338 1425
     }
1339 1426
 
1340 1427
     /**
@@ -1446,7 +1533,4 @@ class RtcEngine {
1446 1533
     }
1447 1534
 }
1448 1535
 
1449
-
1450
-
1451
-
1452
-export default RtcEngine;
1536
+export default RtcEngine;

+ 1
- 0
src/index.ts Просмотреть файл

@@ -1,2 +1,3 @@
1 1
 export {default as AgoraView} from './AgoraView.native';
2 2
 export {default as RtcEngine} from './RtcEngine.native';
3
+export * from "./types";

+ 84
- 29
src/types.ts Просмотреть файл

@@ -1,5 +1,14 @@
1
-import { View, ViewProps } from 'react-native';
1
+import { ViewProps } from 'react-native';
2 2
 
3
+/**
4
+ * AgoraViewMode
5
+ * @mode hidden Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
6
+ * @mode FIT Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
7
+ */
8
+export enum AgoraViewMode {
9
+  HIDDEN = 1,
10
+  FIT = 2
11
+}
3 12
 
4 13
 /**
5 14
  * VideoEncoderConfig details
@@ -19,15 +28,17 @@ export interface VideoEncoderConfig {
19 28
 }
20 29
 
21 30
 /**
22
- * Option is work for init method
23
- * @property: string appid Sets the appid
24
- * @property: number channelProfile Sets the channel mode. 0 is communication mode, 1 is broadcasting mode
25
- * @property: {@link VideoEncoderConfig} sets video encoding config
26
- * @property: mode is optional sets only enable video / audio, 0 is audio mode, 1 is video mode
27
- * @property: clientRole is only work in live mode, 1 is host, 2 is audience
28
- * @property: dualStream is optional parameter only for enable for detail see {@link https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/enableDualStreamMode:}
29
- * @property: audioProfile {@link https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioProfile.html}
30
- * @property: audioScenario {@link https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioScenario.html}
31
+ * Option is used to {@link init}
32
+ * @member {@link appid} Sets the appid
33
+ * @member {@link channelProfile} Number channelProfile Sets the channel mode. 0 is communication mode, 1 is broadcasting mode
34
+ * @member {@link VideoEncoderConfig} sets video encoding config
35
+ * @member {@link dualStream} is optional parameter only for enable for detail see [more](https://docs.agora.io/en/Video/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/enableDualStreamMode)
36
+ * @member {@link mode} is optional sets only enable video / audio, 0 is audio mode, 1 is video mode
37
+ * @member {@link clientRole} is only work in live mode, 1 is host, 2 is audience
38
+ * @member {@link audioProfile} Sets audio profile to agora rtc sdk See more [details](https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioProfile.html)
39
+ * @member {@link audioScenario} Sets audio scenario to agora rtc sdk more [details](https://docs.agora.io/en/Video/API%20Reference/oc/Constants/AgoraAudioScenario.html)
40
+ * @member {@link beauty} {@link BeautyOption}
41
+ * @member {@link voice} {@link VoiceDecorator}
31 42
  */
32 43
 export interface Option {
33 44
   appid: String,
@@ -45,10 +56,11 @@ export interface Option {
45 56
 /**
46 57
  * VoiceDecorator is decorate local audio voice
47 58
  *
48
- * @property type: string | the range values ['changer' | 'reverbPreset'] This property is the identifier for audio voice decorator
49
- * @property value: number | the value for voice parameter option.
50
- * type 'reverbPreset' range values: [0 is "off", 1 is "popular", 2 is "rnb", 3 is "rock", 4 is "hiphop", 5 is "vocal concert", 6 is "KTV", 7 is "studio"]
51
- * type 'changer' range values: [0 is "off", 1 is "old man", 2 is "baby boy", 3 is "baby girl", 4 is "zhubajie", 5 is "ethereal", 6 is "hulk"]
59
+ * @description
60
+ *   type 'reverbPreset' range values: [0 is "off", 1 is "popular", 2 is "rnb", 3 is "rock", 4 is "hiphop", 5 is "vocal concert", 6 is "KTV", 7 is "studio"]
61
+ *   type 'changer' range values: [0 is "off", 1 is "old man", 2 is "baby boy", 3 is "baby girl", 4 is "zhubajie", 5 is "ethereal", 6 is "hulk"]
62
+ * @member type: string | the range values ['changer' | 'reverbPreset'] This property is the identifier for audio voice decorator
63
+ * @member value: number | the value for voice parameter option.
52 64
  */
53 65
 export interface VoiceDecorator {
54 66
   type: string,
@@ -76,13 +88,6 @@ export interface BackgroundImage {
76 88
   height: number
77 89
 }
78 90
 
79
-export interface Rect {
80
-  x: number,
81
-  y: number,
82
-  width: number,
83
-  height: number
84
-}
85
-
86 91
 export interface Size {
87 92
   width: number,
88 93
   height: number
@@ -90,9 +95,12 @@ export interface Size {
90 95
 
91 96
 export interface TranscodingUser {
92 97
   uid: number,
93
-  zOrder: number,
94
-  rect: Rect,
98
+  x: number,
99
+  y: number,
100
+  width: number,
101
+  height: number,
95 102
   alpha: number,
103
+  zOrder: number,
96 104
   audioChannel: number
97 105
 }
98 106
 
@@ -103,21 +111,68 @@ export interface Color {
103 111
   alpha: number
104 112
 }
105 113
 
114
+export enum VideoCodecProfile {
115
+  BASELINE = 66,
116
+  MAIN = 77,
117
+  HIGH = 100
118
+}
119
+
120
+export enum AudioCodecProfile {
121
+  LC_AAC = 0,
122
+  HE_AAC = 1
123
+}
124
+
125
+export enum AudioSampleRate {
126
+  TYPE_32000 = 32000,
127
+  TYPE_44100 = 44100,
128
+  TYPE_48000 = 48000,
129
+}
130
+
131
+/**
132
+ * AgoraChannelStereo
133
+ * @note Agora’s self-defined audio channel type. We recommend choosing ONE or TWO. Special players are required if you choose TRHEE, FOUR or FIVE:
134
+ */
135
+export enum AudioChannelStereo {
136
+  ONE = 1,
137
+  TWO = 2,
138
+  TRHEE = 3,
139
+  FOUR = 4,
140
+  FIVE = 5
141
+}
142
+
143
+/**
144
+ * @member {@link size} {@link Size}
145
+ * @member {@link videoBitrate} integer number
146
+ * @member {@link videoFramerate} integer number
147
+ * @member {@link lowLatency} boolean
148
+ * @member {@link videoGop} number
149
+ * @member {@link videoCodecProfile} {@link VideoCodecProfile}
150
+ * @member {@link audioCodecProfile} {@link AudioCodecProfile}
151
+ * @member {@link audioSampleRate} {@link AudioSampleRate}
152
+ * @member {@link watermark} {@link BackgroundImage}
153
+ * @member {@link backgroundImage} {@link BackgroundImage}
154
+ * @member {@link backgroundColor} Standard RGB hex number: e.g. 0xffffff 
155
+ * @member {@link audioBitrate} number
156
+ * @member {@link audioChannels} {@link AudioChannelStereo}
157
+ * @member {@link transcodingUsers} Array,{@link TranscodingUser}>,
158
+ * @member {@link transcodingExtraInfo} string
159
+ */
106 160
 export interface LiveTranscodingOption {
107 161
   size: Size,
108 162
   videoBitrate: number,
109 163
   videoFramerate: number,
110 164
   lowLatency: boolean,
111 165
   videoGop: number,
112
-  videoCodecProfile: number,
113
-  transcodingUsers: Array<TranscodingUser>,
114
-  transcodingExtraInfo: string,
166
+  videoCodecProfile: VideoCodecProfile,
167
+  audioCodecProfile: AudioCodecProfile,
168
+  audioSampleRate: AudioSampleRate,
115 169
   watermark: BackgroundImage,
116 170
   backgroundImage: BackgroundImage,
117
-  backgroundColor: Color,
118
-  audioSampleRate: number,
171
+  backgroundColor: number,
119 172
   audioBitrate: number,
120
-  audioChannels: number,
173
+  audioChannels: AudioChannelStereo,
174
+  transcodingUsers: Array<TranscodingUser>,
175
+  transcodingExtraInfo: string,
121 176
 }
122 177
 
123 178
 export interface VideoOption {