Pārlūkot izejas kodu

chore. upgrade to 2.8.0

matrixbirds 4 gadus atpakaļ
vecāks
revīzija
14c44b42f0

+ 8
- 0
CHANGELOG Parādīt failu

@@ -1,5 +1,13 @@
1 1
 ## THE CHANGELOG
2 2
 
3
+#### 2.8.0-alpha.1
4
+  - add `string uid` api support
5
+  - android: deprecate `lowLatency` member of LiveTranscoding
6
+  - add methods `getUserInfoByUserAccount`, `getUserInfoByUid`, `joinChannelWithUserAccount`, `registerLocalUserAccount`
7
+  - add events `localUserRegistered`, `userInfoUpdated`
8
+  - android: upgrade native sdk to 2.8.2
9
+  - ios: upgrade native sdk to 2.8.0
10
+
3 11
 #### 2.4.1-alpha.3
4 12
 - refactor setLiveTranscoding: rename ios & android native parameters. export enum for javascript/typescript api.
5 13
 - fix negative number case in android platform.

+ 1
- 1
android/build.gradle Parādīt failu

@@ -61,7 +61,7 @@ dependencies {
61 61
     def androidSupportVersion = rootProject.hasProperty("androidSupportVersion")  ? rootProject.androidSupportVersion : DEFAULT_ANDROID_SUPPORT_VERSION
62 62
     // from internet
63 63
     implementation "com.android.support:appcompat-v7:$androidSupportVersion"
64
-    implementation "io.agora.rtc:full-sdk:2.4.1"
64
+    implementation "io.agora.rtc:full-sdk:2.8.2"
65 65
     // from node_modules
66 66
     implementation "com.facebook.react:react-native:+"
67 67
 }

+ 2
- 0
android/src/main/java/com/syan/agora/AgoraConst.java Parādīt failu

@@ -10,6 +10,8 @@ public class AgoraConst {
10 10
     public final static String AGRejoinChannelSuccess = "rejoinChannelSuccess";
11 11
     public final static String AGLeaveChannel = "leaveChannel";
12 12
     public final static String AGClientRoleChanged = "clientRoleChanged";
13
+    public final static String AGLocalUserRegistered = "localUserRegistered";
14
+    public final static String AGUserInfoUpdated = "userInfoUpdated";
13 15
     public final static String AGUserJoined = "userJoined";
14 16
     public final static String AGUserOffline = "userOffline";
15 17
     public final static String AGConnectionStateChanged = "connectionStateChanged";

+ 94
- 3
android/src/main/java/com/syan/agora/AgoraModule.java Parādīt failu

@@ -30,6 +30,7 @@ import io.agora.rtc.RtcEngine;
30 30
 import io.agora.rtc.internal.LastmileProbeConfig;
31 31
 import io.agora.rtc.live.LiveInjectStreamConfig;
32 32
 import io.agora.rtc.live.LiveTranscoding;
33
+import io.agora.rtc.models.UserInfo;
33 34
 import io.agora.rtc.video.AgoraImage;
34 35
 import io.agora.rtc.video.BeautyOptions;
35 36
 import io.agora.rtc.video.CameraCapturerConfiguration;
@@ -142,6 +143,9 @@ public class AgoraModule extends ReactContextBaseJavaModule {
142 143
     private static final String AgoraAudioMode = "AudioMode";
143 144
     private static final String AgoraVideoMode = "VideoMode";
144 145
 
146
+    private RtcEngine rtcEngine;
147
+    private String appId;
148
+
145 149
     public AgoraModule(ReactApplicationContext context) {
146 150
         super(context);
147 151
     }
@@ -379,6 +383,35 @@ public class AgoraModule extends ReactContextBaseJavaModule {
379 383
             });
380 384
         }
381 385
 
386
+        @Override
387
+        public void onLocalUserRegistered(final int uid, final String userAccount) {
388
+            runOnUiThread(new Runnable() {
389
+                @Override
390
+                public void run() {
391
+                    WritableMap map = Arguments.createMap();
392
+                    map.putInt("uid", uid);
393
+                    map.putString("userAccount", userAccount);
394
+                    sendEvent(getReactApplicationContext(), AGLocalUserRegistered, map);
395
+                }
396
+            });
397
+        }
398
+
399
+        @Override
400
+        public void onUserInfoUpdated(final int uid, final UserInfo peer) {
401
+            runOnUiThread(new Runnable() {
402
+                @Override
403
+                public void run() {
404
+                    WritableMap map = Arguments.createMap();
405
+                    map.putInt("uid", uid);
406
+                    WritableMap peerInfo = Arguments.createMap();
407
+                    peerInfo.putInt("uid", peer.uid);
408
+                    peerInfo.putString("userAccount", peer.userAccount);
409
+                    map.putMap("peer", peerInfo);
410
+                    sendEvent(getReactApplicationContext(), AGUserInfoUpdated, map);
411
+                }
412
+            });
413
+        }
414
+
382 415
         @Override
383 416
         public void onUserJoined(final int uid, final int elapsed) {
384 417
             runOnUiThread(new Runnable() {
@@ -775,6 +808,11 @@ public class AgoraModule extends ReactContextBaseJavaModule {
775 808
                     statsMap.putInt("networkTransportDelay", stats.networkTransportDelay);
776 809
                     statsMap.putInt("jitterBufferDelay", stats.jitterBufferDelay);
777 810
                     statsMap.putInt("audioLossRate", stats.audioLossRate);
811
+                    statsMap.putInt("totalFrozenTime", stats.totalFrozenTime);
812
+                    statsMap.putInt("frozenRate", stats.frozenRate);
813
+                    statsMap.putInt("numChannels", stats.numChannels);
814
+                    statsMap.putInt("receivedSampleRate", stats.receivedSampleRate);
815
+                    statsMap.putInt("receivedBitrate", stats.receivedBitrate);
778 816
                     WritableMap map = Arguments.createMap();
779 817
                     map.putMap("stats", statsMap);
780 818
                     sendEvent(getReactApplicationContext(), AGRemoteAudioStats, map);
@@ -865,6 +903,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
865 903
                     statsMap.putInt("receivedBitrate", stats.receivedBitrate);
866 904
                     statsMap.putInt("rendererOutputFrameRate", stats.rendererOutputFrameRate);
867 905
                     statsMap.putInt("rxStreamType", stats.rxStreamType);
906
+                    statsMap.putInt("totalFrozenTime", stats.totalFrozenTime);
907
+                    statsMap.putInt("frozenRate", stats.frozenRate);
868 908
                     WritableMap map = Arguments.createMap();
869 909
                     map.putMap("stats", statsMap);
870 910
                     sendEvent(getReactApplicationContext(), AGRemoteVideoStats, map);
@@ -1077,6 +1117,8 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1077 1117
     @ReactMethod
1078 1118
     public void init(ReadableMap options) {
1079 1119
         AgoraManager.getInstance().init(getReactApplicationContext(), mRtcEventHandler, options);
1120
+        appId = options.getString("appid");
1121
+        rtcEngine = AgoraManager.getInstance().mRtcEngine;
1080 1122
     }
1081 1123
 
1082 1124
     @ReactMethod
@@ -1130,6 +1172,58 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1130 1172
         }
1131 1173
     }
1132 1174
 
1175
+    @ReactMethod
1176
+    public void registerLocalUserAccount(ReadableMap options, Promise promise) {
1177
+        Integer res = rtcEngine.registerLocalUserAccount(appId, options.getString("userAccount"));
1178
+        if (res == 0) {
1179
+            promise.resolve(null);
1180
+        } else {
1181
+            promise.reject("-1", res.toString());
1182
+        }
1183
+    }
1184
+
1185
+    @ReactMethod
1186
+    public void joinChannelWithUserAccount(ReadableMap options, Promise promise) {
1187
+        String token = null;
1188
+        if (options.hasKey("token")) {
1189
+            token = options.getString("token");
1190
+        }
1191
+        Integer res = rtcEngine.joinChannelWithUserAccount(token, options.getString("channelName"), options.getString("userAccount"));
1192
+        if (res == 0) {
1193
+            promise.resolve(null);
1194
+        } else {
1195
+            promise.reject("-1", res.toString());
1196
+        }
1197
+    }
1198
+
1199
+    @ReactMethod
1200
+    public void getUserInfoByUid(Integer uid, Promise promise) {
1201
+        UserInfo info = new UserInfo();
1202
+        Integer res = rtcEngine.getUserInfoByUid(uid, info);
1203
+        if (res == 0) {
1204
+            WritableMap map = Arguments.createMap();
1205
+            map.putInt("uid", info.uid);
1206
+            map.putString("userAccount", info.userAccount);
1207
+            promise.resolve(map);
1208
+        } else {
1209
+            promise.reject("-1", res.toString());
1210
+        }
1211
+    }
1212
+
1213
+    @ReactMethod
1214
+    public void getUserInfoByUserAccount(String userAccount, Promise promise) {
1215
+        UserInfo info = new UserInfo();
1216
+        Integer res = rtcEngine.getUserInfoByUserAccount(userAccount, info);
1217
+        if (res == 0) {
1218
+            WritableMap map = Arguments.createMap();
1219
+            map.putInt("uid", info.uid);
1220
+            map.putString("userAccount", info.userAccount);
1221
+            promise.resolve(map);
1222
+        } else {
1223
+            promise.reject("-1", res.toString());
1224
+        }
1225
+    }
1226
+
1133 1227
     @ReactMethod
1134 1228
     public void leaveChannel(Promise promise) {
1135 1229
         Integer res = AgoraManager.getInstance().leaveChannel();
@@ -2018,9 +2112,6 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2018 2112
         if (options.hasKey("videoFramerate")) {
2019 2113
             transcoding.videoFramerate = options.getInt("videoFramerate");
2020 2114
         }
2021
-        if (options.hasKey("lowLatency")) {
2022
-            transcoding.lowLatency = options.getBoolean("lowLatency");
2023
-        }
2024 2115
         if (options.hasKey("videoGop")) {
2025 2116
             transcoding.videoGop = options.getInt("videoGop");
2026 2117
         }

+ 2
- 0
ios/RCTAgora/AgoraConst.h Parādīt failu

@@ -19,6 +19,8 @@ static NSString *AGJoinChannelSuccess = @"joinChannelSuccess";
19 19
 static NSString *AGRejoinChannelSuccess = @"rejoinChannelSuccess";
20 20
 static NSString *AGLeaveChannel = @"leaveChannel";
21 21
 static NSString *AGClientRoleChanged = @"clientRoleChanged";
22
+static NSString *AGLocalUserRegistered = @"localUserRegistered";
23
+static NSString *AGUserInfoUpdated = @"userInfoUpdated";
22 24
 static NSString *AGUserJoined = @"userJoined";
23 25
 static NSString *AGUserOffline = @"userOffline";
24 26
 static NSString *AGConnectionStateChanged = @"connectionStateChanged";

+ 2
- 0
ios/RCTAgora/AgoraConst.m Parādīt failu

@@ -35,6 +35,8 @@ static AgoraConst *_person;
35 35
                                   AGRejoinChannelSuccess,
36 36
                                   AGLeaveChannel,
37 37
                                   AGClientRoleChanged,
38
+                                  AGLocalUserRegistered,
39
+                                  AGUserInfoUpdated,
38 40
                                   AGUserJoined,
39 41
                                   AGUserOffline,
40 42
                                   AGConnectionStateChanged,

+ 86
- 6
ios/RCTAgora/RCTAgora.m Parādīt failu

@@ -17,6 +17,7 @@
17 17
 
18 18
 @interface RCTAgora ()
19 19
 @property (strong, nonatomic) AgoraRtcEngineKit *rtcEngine;
20
+@property (strong, nonatomic) NSString *appId;
20 21
 @property (strong, nonatomic) NSData *metadata;
21 22
 @end
22 23
 
@@ -176,6 +177,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
176 177
   [AgoraConst share].appid = options[@"appid"];
177 178
   
178 179
   self.rtcEngine = [AgoraRtcEngineKit sharedEngineWithAppId:options[@"appid"] delegate:self];
180
+  self.appId = options[@"appid"];
179 181
   
180 182
   [AgoraConst share].rtcEngine = self.rtcEngine;
181 183
   
@@ -299,6 +301,63 @@ RCT_EXPORT_METHOD(joinChannel:(NSDictionary *)options
299 301
   }
300 302
 }
301 303
 
304
+// register user account
305
+RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
306
+                  resolve:(RCTPromiseResolveBlock)resolve
307
+                  reject:(RCTPromiseRejectBlock)reject) {
308
+  NSInteger res = [self.rtcEngine registerLocalUserAccount:options[@"userAccount"] appId:self.appId];
309
+  if (res == 0) {
310
+    resolve(nil);
311
+  } else {
312
+    reject(@(-1).stringValue, @(res).stringValue, nil);
313
+  }
314
+}
315
+
316
+// join channel with user account
317
+RCT_EXPORT_METHOD(joinChannelWithUserAccount:(NSDictionary *)options
318
+                  resolve:(RCTPromiseResolveBlock)resolve
319
+                  reject:(RCTPromiseRejectBlock)reject) {
320
+  NSString *token = [options objectForKey:@"token"] != nil ? options[@"token"] : nil;
321
+  NSInteger res = [self.rtcEngine joinChannelByUserAccount:options[@"userAccount"] token:token channelId:options[@"channelName"] joinSuccess:nil];
322
+  if (res == 0) {
323
+    resolve(nil);
324
+  } else {
325
+    reject(@(-1).stringValue, @(res).stringValue, nil);
326
+  }
327
+}
328
+
329
+// get user info by uid
330
+RCT_EXPORT_METHOD(getUserInfoByUid:(NSUInteger)uid
331
+                  resolve:(RCTPromiseResolveBlock)resolve
332
+                  reject:(RCTPromiseRejectBlock)reject) {
333
+  AgoraErrorCode code = 0;
334
+  AgoraUserInfo *info = [self.rtcEngine getUserInfoByUid:uid withError:&code];
335
+  if ((int)code == 0) {
336
+    resolve(@{
337
+        @"uid": @(info.uid),
338
+        @"userAccount": info.userAccount
339
+    });
340
+  } else {
341
+    reject(@(-1).stringValue, @((int)code).stringValue, nil);
342
+  }
343
+}
344
+
345
+// get user info by user account
346
+RCT_EXPORT_METHOD(getUserInfoByUserAccount:(NSString *)userAccount
347
+                  resolve:(RCTPromiseResolveBlock)resolve
348
+                  reject:(RCTPromiseRejectBlock)reject) {
349
+  AgoraErrorCode code = 0;
350
+  AgoraUserInfo *info = [self.rtcEngine getUserInfoByUserAccount:userAccount withError:&code];
351
+  if ((int)code == 0) {
352
+    resolve(@{
353
+              @"uid": @(info.uid),
354
+              @"userAccount": info.userAccount
355
+              });
356
+  } else {
357
+    reject(@(-1).stringValue, @((int)code).stringValue, nil);
358
+  }
359
+}
360
+
302 361
 // leave channel
303 362
 RCT_EXPORT_METHOD(leaveChannel
304 363
                   :(RCTPromiseResolveBlock) resolve
@@ -1400,9 +1459,6 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options
1400 1459
   if ([options objectForKey:@"videoFramerate"]) {
1401 1460
     transcoding.videoFramerate = [options[@"videoFramerate"] integerValue];
1402 1461
   }
1403
-  if ([options objectForKey:@"lowLatancy"]) {
1404
-    transcoding.lowLatency = [options[@"lowLatancy"] boolValue];
1405
-  }
1406 1462
   if ([options objectForKey:@"videoGop"]) {
1407 1463
     transcoding.videoGop = [options[@"videoGop"] integerValue];
1408 1464
   }
@@ -1714,6 +1770,23 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1714 1770
                                         }];
1715 1771
 }
1716 1772
 
1773
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRegisteredLocalUser:(NSString *_Nonnull)userAccount withUid:(NSUInteger)uid {
1774
+  [self sendEvent:AGLocalUserRegistered params:@{
1775
+                                                 @"uid": @(uid),
1776
+                                                 @"userAccount": userAccount
1777
+                                                 }];
1778
+}
1779
+
1780
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didUpdatedUserInfo:(AgoraUserInfo *_Nonnull)userInfo withUid:(NSUInteger)uid {
1781
+  [self sendEvent:AGUserInfoUpdated params:@{
1782
+                                                 @"uid": @(uid),
1783
+                                                 @"peer": @{
1784
+                                                     @"uid": @(userInfo.uid),
1785
+                                                     @"userAccount": userInfo.userAccount
1786
+                                                 }}];
1787
+}
1788
+
1789
+
1717 1790
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason {
1718 1791
   [self sendEvent:AGUserOffline params:@{
1719 1792
                                          @"uid": @(uid),
@@ -1905,7 +1978,12 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1905 1978
                                                   @"quality": @(stats.quality),
1906 1979
                                                   @"networkTransportDelay": @(stats.networkTransportDelay),
1907 1980
                                                   @"jitterBufferDelay": @(stats.jitterBufferDelay),
1908
-                                                  @"audioLossRate": @(stats.audioLossRate)
1981
+                                                  @"audioLossRate": @(stats.audioLossRate),
1982
+                                                  @"totalFrozenTime": @(stats.totalFrozenTime),
1983
+                                                  @"frozenRate": @(stats.frozenRate),
1984
+                                                  @"numChannels": @(stats.numChannels),
1985
+                                                  @"receivedSampleRate": @(stats.receivedSampleRate),
1986
+                                                  @"receivedBitrate": @(stats.receivedBitrate),
1909 1987
                                                   }
1910 1988
                                               }];
1911 1989
 }
@@ -1965,7 +2043,9 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1965 2043
                                                   @"receivedBitrate": @(stats.receivedBitrate),
1966 2044
                                                   @"rendererOutputFrameRate": @(stats.rendererOutputFrameRate),
1967 2045
                                                   @"rxStreamType": @(stats.rxStreamType),
1968
-                                                  @"decoderOutputFrameRate": @(stats.decoderOutputFrameRate)
2046
+                                                  @"decoderOutputFrameRate": @(stats.decoderOutputFrameRate),
2047
+                                                  @"totalFrozenTime": @(stats.totalFrozenTime),
2048
+                                                  @"frozenRate": @(stats.frozenRate)
1969 2049
                                                   }
1970 2050
                                               }];
1971 2051
 }
@@ -2106,4 +2186,4 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2106 2186
                                                      }];
2107 2187
 }
2108 2188
 
2109
-@end
2189
+@end

+ 49
- 1
lib/RtcEngine.native.d.ts Parādīt failu

@@ -1,4 +1,4 @@
1
-import { Option, Callback, AudioMixingOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration } from "./types";
1
+import { Option, Callback, AgoraUserInfo, AudioMixingOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration } from "./types";
2 2
 /**
3 3
  * RtcEngine is the javascript object for control agora native sdk through react native bridge.
4 4
  *
@@ -30,6 +30,52 @@ declare class RtcEngine {
30 30
      * @param info
31 31
      */
32 32
     static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): Promise<any>;
33
+    /**
34
+     * Registers a user account.
35
+     *
36
+     * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the `on("localUserRegistered", callback)` on the local client, reporting the user ID and user account of the local user.
37
+     * To join a channel with a user account, you can choose either of the following:
38
+     * Call the {@link registerLocalUserAccount} method to create a user account, and then the {@link joinChannelWithUserAccount} method to join the channel.
39
+     * Call the {@link joinChannelWithUserAccount} method to join the channel.
40
+     *
41
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
42
+     *
43
+     * @param userAccount
44
+     * @returns Promise<any>
45
+     */
46
+    static registerLocalUserAccount(userAccount: string): Promise<any>;
47
+    /**
48
+     * Joins the channel with a user account.
49
+     *
50
+     * After the user successfully joins the channel, the SDK triggers the following callbacks:
51
+     *
52
+     * The local client: `on("localUserRegistered", callback)` and `on("joinChannelSuccess", callback)`.
53
+     * The remote client: `on("userJoined", callback)` and `on("userInfoUpdated", callback)`, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile.
54
+     *
55
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
56
+     *
57
+     * @param channelName
58
+     * @param userAccount
59
+     * @param token
60
+     * @returns Promise<any>
61
+     */
62
+    static joinChannelWithUserAccount(channelName: string, userAccount: string, token: string): Promise<any>;
63
+    /**
64
+     * Gets the user information by passing in the user account.
65
+     *
66
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
67
+     * @param uid
68
+     * @returns Promise<{@link AgoraUserInfo}>
69
+     */
70
+    static getUserInfoByUid(uid: number): Promise<AgoraUserInfo>;
71
+    /**
72
+     * Gets the user information by passing in the user account.
73
+     *
74
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
75
+     * @param userAccount
76
+     * @returns Promise<{@link AgoraUserInfo}>
77
+     */
78
+    static getUserInfoByUserAccount(userAccount: string): Promise<AgoraUserInfo>;
33 79
     /**
34 80
      * add event listener
35 81
      *
@@ -109,6 +155,8 @@ declare class RtcEngine {
109 155
      * localVideoChanged | occurs when the local video changed  | on("localVideoChanged", evt) |
110 156
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) |
111 157
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) |
158
+     * localUserRegistered | occurs when you register user account success | on("localUserRegistered", evt) |
159
+     * userInfoUpdated | occurs when you peer side using user account join channel | on("userInfoUpdated", evt) |
112 160
      * ---
113 161
      *
114 162
      * @param eventType

+ 84
- 0
lib/RtcEngine.native.js Parādīt failu

@@ -35,6 +35,75 @@ class RtcEngine {
35 35
     static joinChannel(channelName, uid, token, info) {
36 36
         return Agora.joinChannel({ channelName, uid, token, info });
37 37
     }
38
+    /**
39
+     * Registers a user account.
40
+     *
41
+     * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the `on("localUserRegistered", callback)` on the local client, reporting the user ID and user account of the local user.
42
+     * To join a channel with a user account, you can choose either of the following:
43
+     * Call the {@link registerLocalUserAccount} method to create a user account, and then the {@link joinChannelWithUserAccount} method to join the channel.
44
+     * Call the {@link joinChannelWithUserAccount} method to join the channel.
45
+     *
46
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
47
+     *
48
+     * @param userAccount
49
+     * @returns Promise<any>
50
+     */
51
+    static registerLocalUserAccount(userAccount) {
52
+        return Agora.registerLocalUserAccount({ userAccount });
53
+    }
54
+    /**
55
+     * Joins the channel with a user account.
56
+     *
57
+     * After the user successfully joins the channel, the SDK triggers the following callbacks:
58
+     *
59
+     * The local client: `on("localUserRegistered", callback)` and `on("joinChannelSuccess", callback)`.
60
+     * The remote client: `on("userJoined", callback)` and `on("userInfoUpdated", callback)`, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile.
61
+     *
62
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
63
+     *
64
+     * @param channelName
65
+     * @param userAccount
66
+     * @param token
67
+     * @returns Promise<any>
68
+     */
69
+    static joinChannelWithUserAccount(channelName, userAccount, token) {
70
+        return Agora.joinChannelWithUserAccount({ channelName, userAccount, token });
71
+    }
72
+    /**
73
+     * Gets the user information by passing in the user account.
74
+     *
75
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
76
+     * @param uid
77
+     * @returns Promise<{@link AgoraUserInfo}>
78
+     */
79
+    static getUserInfoByUid(uid) {
80
+        return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+            if (react_native_1.Platform.OS === 'android') {
82
+                const _uid = this.Uint32ToInt32(uid);
83
+                let result = yield Agora.getUserInfoByUid(_uid);
84
+                result.uid = this.Uint32ToInt32(result.uid);
85
+                return result;
86
+            }
87
+            return Agora.getUserInfoByUid(uid);
88
+        });
89
+    }
90
+    /**
91
+     * Gets the user information by passing in the user account.
92
+     *
93
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
94
+     * @param userAccount
95
+     * @returns Promise<{@link AgoraUserInfo}>
96
+     */
97
+    static getUserInfoByUserAccount(userAccount) {
98
+        return tslib_1.__awaiter(this, void 0, void 0, function* () {
99
+            if (react_native_1.Platform.OS === 'android') {
100
+                let result = yield Agora.getUserInfoByUserAccount(userAccount);
101
+                result.uid = this.Uint32ToInt32(result.uid);
102
+                return result;
103
+            }
104
+            return Agora.getUserInfoByUserAccount(userAccount);
105
+        });
106
+    }
38 107
     /**
39 108
      * add event listener
40 109
      *
@@ -114,6 +183,8 @@ class RtcEngine {
114 183
      * localVideoChanged | occurs when the local video changed  | on("localVideoChanged", evt) |
115 184
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) |
116 185
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) |
186
+     * localUserRegistered | occurs when you register user account success | on("localUserRegistered", evt) |
187
+     * userInfoUpdated | occurs when you peer side using user account join channel | on("userInfoUpdated", evt) |
117 188
      * ---
118 189
      *
119 190
      * @param eventType
@@ -143,6 +214,7 @@ class RtcEngine {
143 214
             'remoteSubscribeFallbackToAudioOnly',
144 215
             'networkQuality',
145 216
             'streamInjectedStatus',
217
+            'localUserRegistered'
146 218
         ].indexOf(eventType) != -1) {
147 219
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
148 220
                 const uint32_uid = new Uint32Array(1);
@@ -158,6 +230,18 @@ class RtcEngine {
158 230
             });
159 231
             return;
160 232
         }
233
+        if (['userInfoUpdated'].indexOf(eventType) != -1) {
234
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
235
+                const uint32_uid = new Uint32Array(1);
236
+                uint32_uid[0] = args.uid;
237
+                args.uid = uint32_uid[0];
238
+                const uint32_peer_uid = new Uint32Array(1);
239
+                uint32_peer_uid[0] = args.peer.uid;
240
+                args.peer.uid = uint32_peer_uid[0];
241
+                listener(args);
242
+            });
243
+            return;
244
+        }
161 245
         if (['audioVolumeIndication'].indexOf(eventType) != -1) {
162 246
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
163 247
                 args.speakers.map((speaker) => {

+ 1
- 1
lib/RtcEngine.native.js.map
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 9
- 0
lib/types.d.ts Parādīt failu

@@ -8,6 +8,15 @@ export declare enum AgoraViewMode {
8 8
     HIDDEN = 1,
9 9
     FIT = 2
10 10
 }
11
+/**
12
+ * AgoraUserInfo
13
+ * @property uid: number
14
+ * @property userAccount: string
15
+ */
16
+export interface AgoraUserInfo {
17
+    uid: number;
18
+    userAccount: string;
19
+}
11 20
 /**
12 21
  * VideoEncoderConfig details
13 22
  * @property width: number | The encoder video's width

+ 1
- 0
lib/types.js Parādīt failu

@@ -10,6 +10,7 @@ var AgoraViewMode;
10 10
     AgoraViewMode[AgoraViewMode["HIDDEN"] = 1] = "HIDDEN";
11 11
     AgoraViewMode[AgoraViewMode["FIT"] = 2] = "FIT";
12 12
 })(AgoraViewMode = exports.AgoraViewMode || (exports.AgoraViewMode = {}));
13
+;
13 14
 var VideoCodecProfile;
14 15
 (function (VideoCodecProfile) {
15 16
     VideoCodecProfile[VideoCodecProfile["BASELINE"] = 66] = "BASELINE";

+ 1
- 1
lib/types.js.map Parādīt failu

@@ -1 +1 @@
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"}
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;AAUA,CAAC;AAuGF,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"}

+ 1
- 1
package.json Parādīt failu

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-agora",
3
-  "version": "2.4.1-alpha.3",
3
+  "version": "2.8.0-alpha.1",
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",

+ 3
- 3
react-native-agora.podspec Parādīt failu

@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18 18
         sp.source_files = './ios/RCTAgora/libs/AgoraRtcCryptoLoader.framework/**/*.{c,h,m,mm,S,cpp}'
19 19
         sp.vendored_libraries = 'libcrypto.a'
20 20
     end
21
-      
21
+
22 22
     s.dependency 'React'
23
-    s.dependency "AgoraRtcEngine_iOS", "2.4.1"
24
-end
23
+    s.dependency "AgoraRtcEngine_iOS", "2.8"
24
+end

+ 87
- 0
src/RtcEngine.native.ts Parādīt failu

@@ -7,6 +7,7 @@ import {
7 7
 import {
8 8
     Option, Callback,
9 9
     VideoOption,
10
+    AgoraUserInfo,
10 11
     AudioMixingOption,
11 12
     DataStreamOption,
12 13
     PlayEffectOption,
@@ -70,6 +71,75 @@ class RtcEngine {
70 71
         return Agora.joinChannel({channelName, uid, token, info});
71 72
     }
72 73
 
74
+    /**
75
+     * Registers a user account.
76
+     * 
77
+     * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the `on("localUserRegistered", callback)` on the local client, reporting the user ID and user account of the local user.
78
+     * To join a channel with a user account, you can choose either of the following:
79
+     * Call the {@link registerLocalUserAccount} method to create a user account, and then the {@link joinChannelWithUserAccount} method to join the channel.
80
+     * Call the {@link joinChannelWithUserAccount} method to join the channel.
81
+     * 
82
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
83
+     * 
84
+     * @param userAccount
85
+     * @returns Promise<any>
86
+     */
87
+    public static registerLocalUserAccount(userAccount: string): Promise<any> {
88
+        return Agora.registerLocalUserAccount({userAccount});
89
+    }
90
+
91
+    /**
92
+     * Joins the channel with a user account.
93
+     * 
94
+     * After the user successfully joins the channel, the SDK triggers the following callbacks:
95
+     *
96
+     * The local client: `on("localUserRegistered", callback)` and `on("joinChannelSuccess", callback)`.
97
+     * The remote client: `on("userJoined", callback)` and `on("userInfoUpdated", callback)`, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile.
98
+     * 
99
+     * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
100
+     * 
101
+     * @param channelName
102
+     * @param userAccount
103
+     * @param token
104
+     * @returns Promise<any>
105
+     */
106
+    public static joinChannelWithUserAccount(channelName: string, userAccount: string, token: string): Promise<any> {
107
+        return Agora.joinChannelWithUserAccount({channelName, userAccount, token});
108
+    }
109
+
110
+    /**
111
+     * Gets the user information by passing in the user account.
112
+     * 
113
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
114
+     * @param uid 
115
+     * @returns Promise<{@link AgoraUserInfo}>
116
+     */
117
+    public static async getUserInfoByUid(uid: number): Promise<AgoraUserInfo> {
118
+        if (Platform.OS === 'android') {
119
+            const _uid = this.Uint32ToInt32(uid);
120
+            let result = await Agora.getUserInfoByUid(_uid);
121
+            result.uid = this.Uint32ToInt32(result.uid);
122
+            return result;
123
+        }
124
+        return Agora.getUserInfoByUid(uid);
125
+    }
126
+
127
+    /**
128
+     * Gets the user information by passing in the user account.
129
+     * 
130
+     * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
131
+     * @param userAccount 
132
+     * @returns Promise<{@link AgoraUserInfo}>
133
+     */
134
+    public static async getUserInfoByUserAccount(userAccount: string): Promise<AgoraUserInfo> {
135
+        if (Platform.OS === 'android') {
136
+            let result = await Agora.getUserInfoByUserAccount(userAccount);
137
+            result.uid = this.Uint32ToInt32(result.uid);
138
+            return result;
139
+        }
140
+        return Agora.getUserInfoByUserAccount(userAccount);
141
+    }
142
+
73 143
     /**
74 144
      * add event listener
75 145
      *
@@ -149,6 +219,8 @@ class RtcEngine {
149 219
      * localVideoChanged | occurs when the local video changed  | on("localVideoChanged", evt) | 
150 220
      * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) | 
151 221
      * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) | 
222
+     * localUserRegistered | occurs when you register user account success | on("localUserRegistered", evt) |
223
+     * userInfoUpdated | occurs when you peer side using user account join channel | on("userInfoUpdated", evt) |
152 224
      * ---
153 225
      * 
154 226
      * @param eventType
@@ -178,6 +250,7 @@ class RtcEngine {
178 250
             'remoteSubscribeFallbackToAudioOnly',
179 251
             'networkQuality',
180 252
             'streamInjectedStatus',
253
+            'localUserRegistered'
181 254
         ].indexOf(eventType) != -1) {
182 255
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
183 256
                 const uint32_uid = new Uint32Array(1);
@@ -195,6 +268,20 @@ class RtcEngine {
195 268
             return;
196 269
         }
197 270
 
271
+        if (['userInfoUpdated'].indexOf(eventType) != -1) {
272
+            AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
273
+                const uint32_uid = new Uint32Array(1);
274
+                uint32_uid[0] = args.uid;
275
+                args.uid = uint32_uid[0];
276
+
277
+                const uint32_peer_uid = new Uint32Array(1);
278
+                uint32_peer_uid[0] = args.peer.uid;
279
+                args.peer.uid = uint32_peer_uid[0];
280
+                listener(args);
281
+            });
282
+            return;
283
+        }
284
+
198 285
         if (['audioVolumeIndication'].indexOf(eventType) != -1) {
199 286
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
200 287
                 args.speakers.map((speaker: any) => {

+ 11
- 1
src/types.ts Parādīt failu

@@ -10,6 +10,16 @@ export enum AgoraViewMode {
10 10
   FIT = 2
11 11
 }
12 12
 
13
+/**
14
+ * AgoraUserInfo
15
+ * @property uid: number
16
+ * @property userAccount: string
17
+ */
18
+export interface AgoraUserInfo {
19
+  uid: number
20
+  userAccount: string
21
+};
22
+
13 23
 /**
14 24
  * VideoEncoderConfig details
15 25
  * @property width: number | The encoder video's width
@@ -161,7 +171,7 @@ export interface LiveTranscodingOption {
161 171
   size: Size,
162 172
   videoBitrate: number,
163 173
   videoFramerate: number,
164
-  lowLatency: boolean,
174
+  lowLatency: boolean, // @deprecate lowLatency
165 175
   videoGop: number,
166 176
   videoCodecProfile: VideoCodecProfile,
167 177
   audioCodecProfile: AudioCodecProfile,