|
@@ -301,6 +301,18 @@ RCT_EXPORT_METHOD(joinChannel:(NSDictionary *)options
|
301
|
301
|
}
|
302
|
302
|
}
|
303
|
303
|
|
|
304
|
+// switch channel
|
|
305
|
+RCT_EXPORT_METHOD(switchChannel:(NSDictionary *)options
|
|
306
|
+ resolve:(RCTPromiseResolveBlock)resolve
|
|
307
|
+ reject:(RCTPromiseRejectBlock)reject) {
|
|
308
|
+ NSInteger res = [self.rtcEngine switchChannelByToken:options[@"token"] channelId:options[@"channelName"] joinSuccess:nil];
|
|
309
|
+ if (res == 0) {
|
|
310
|
+ resolve(nil);
|
|
311
|
+ } else {
|
|
312
|
+ reject(@(-1).stringValue, @(res).stringValue, nil);
|
|
313
|
+ }
|
|
314
|
+}
|
|
315
|
+
|
304
|
316
|
// register user account
|
305
|
317
|
RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
|
306
|
318
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
@@ -362,20 +374,26 @@ RCT_EXPORT_METHOD(getUserInfoByUserAccount:(NSString *)userAccount
|
362
|
374
|
RCT_EXPORT_METHOD(leaveChannel
|
363
|
375
|
:(RCTPromiseResolveBlock) resolve
|
364
|
376
|
reject:(RCTPromiseRejectBlock) reject) {
|
365
|
|
- NSInteger res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stat) {
|
|
377
|
+ NSInteger res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stats) {
|
366
|
378
|
[self sendEvent:AGLeaveChannel params:@{
|
367
|
379
|
@"message": @"leaveChannel",
|
368
|
|
- @"duration": @(stat.duration),
|
369
|
|
- @"txBytes": @(stat.txBytes),
|
370
|
|
- @"rxBytes": @(stat.rxBytes),
|
371
|
|
- @"txAudioKBitrate": @(stat.txAudioKBitrate),
|
372
|
|
- @"rxAudioKBitrate": @(stat.rxAudioKBitrate),
|
373
|
|
- @"txVideoKBitrate": @(stat.txVideoKBitrate),
|
374
|
|
- @"rxVideoKBitrate": @(stat.rxVideoKBitrate),
|
375
|
|
- @"lastmileDelay": @(stat.lastmileDelay),
|
376
|
|
- @"userCount": @(stat.userCount),
|
377
|
|
- @"cpuAppUsage": @(stat.cpuAppUsage),
|
378
|
|
- @"cpuTotalUsage": @(stat.cpuTotalUsage)
|
|
380
|
+ @"duration": @(stats.duration),
|
|
381
|
+ @"txBytes": @(stats.txBytes),
|
|
382
|
+ @"rxBytes": @(stats.rxBytes),
|
|
383
|
+ @"txAudioBytes": @(stats.txAudioBytes),
|
|
384
|
+ @"txVideoBytes": @(stats.txVideoBytes),
|
|
385
|
+ @"rxAudioBytes": @(stats.rxAudioBytes),
|
|
386
|
+ @"rxVideoBytes": @(stats.rxVideoBytes),
|
|
387
|
+ @"txPacketLossRate": @(stats.txPacketLossRate),
|
|
388
|
+ @"rxPacketLossRate": @(stats.rxPacketLossRate),
|
|
389
|
+ @"txAudioKBitrate": @(stats.txAudioKBitrate),
|
|
390
|
+ @"rxAudioKBitrate": @(stats.rxAudioKBitrate),
|
|
391
|
+ @"txVideoKBitrate": @(stats.txVideoKBitrate),
|
|
392
|
+ @"rxVideoKBitrate": @(stats.rxVideoKBitrate),
|
|
393
|
+ @"lastmileDelay": @(stats.lastmileDelay),
|
|
394
|
+ @"userCount": @(stats.userCount),
|
|
395
|
+ @"cpuAppUsage": @(stats.cpuAppUsage),
|
|
396
|
+ @"cpuTotalUsage": @(stats.cpuTotalUsage)
|
379
|
397
|
}];
|
380
|
398
|
}];
|
381
|
399
|
if (res == 0) {
|
|
@@ -1744,6 +1762,12 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
1744
|
1762
|
@"duration": @(stats.duration),
|
1745
|
1763
|
@"txBytes": @(stats.txBytes),
|
1746
|
1764
|
@"rxBytes": @(stats.rxBytes),
|
|
1765
|
+ @"txAudioBytes": @(stats.txAudioBytes),
|
|
1766
|
+ @"txVideoBytes": @(stats.txVideoBytes),
|
|
1767
|
+ @"rxAudioBytes": @(stats.rxAudioBytes),
|
|
1768
|
+ @"rxVideoBytes": @(stats.rxVideoBytes),
|
|
1769
|
+ @"txPacketLossRate": @(stats.txPacketLossRate),
|
|
1770
|
+ @"rxPacketLossRate": @(stats.rxPacketLossRate),
|
1747
|
1771
|
@"txAudioKBitrate": @(stats.txAudioKBitrate),
|
1748
|
1772
|
@"rxAudioKBitrate": @(stats.rxVideoKBitrate),
|
1749
|
1773
|
@"txVideoKBitrate": @(stats.txVideoKBitrate),
|
|
@@ -1825,12 +1849,30 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
1825
|
1849
|
}];
|
1826
|
1850
|
}
|
1827
|
1851
|
|
1828
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didMicrophoneEnabled:(BOOL)enabled {
|
1829
|
|
- [self sendEvent:AGMicrophoneEnabled params:@{
|
1830
|
|
- @"enabled": @(enabled)
|
|
1852
|
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStateChange:(AgoraAudioLocalState)state error:(AgoraAudioLocalError)error {
|
|
1853
|
+ [self sendEvent:AGLocalAudioStateChanged params:@{
|
|
1854
|
+ @"state": @(state),
|
|
1855
|
+ @"error": @(error)
|
1831
|
1856
|
}];
|
1832
|
1857
|
}
|
1833
|
1858
|
|
|
1859
|
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStateChangedOfUid:(NSUInteger)uid state:(AgoraAudioRemoteState)state reason:(AgoraAudioRemoteStateReason)reason elapsed:(NSInteger)elapsed {
|
|
1860
|
+ [self sendEvent:AGRemoteAudioStateChanged params:@{
|
|
1861
|
+ @"uid": @(uid),
|
|
1862
|
+ @"state": @(state),
|
|
1863
|
+ @"reason": @(reason),
|
|
1864
|
+ @"elapsed": @(elapsed)
|
|
1865
|
+ }];
|
|
1866
|
+}
|
|
1867
|
+
|
|
1868
|
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStats:(AgoraRtcLocalAudioStats *_Nonnull)stats {
|
|
1869
|
+ [self sendEvent:AGLocalAudioStats params:@{
|
|
1870
|
+ @"numChannels": @(stats.numChannels),
|
|
1871
|
+ @"sentSampleRate": @(stats.sentSampleRate),
|
|
1872
|
+ @"sentBitrate": @(stats.sentBitrate),
|
|
1873
|
+ }];
|
|
1874
|
+}
|
|
1875
|
+
|
1834
|
1876
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume {
|
1835
|
1877
|
NSMutableArray *result = [NSMutableArray new];
|
1836
|
1878
|
for (AgoraRtcAudioVolumeInfo *speaker in speakers) {
|
|
@@ -1879,15 +1921,6 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
1879
|
1921
|
}];
|
1880
|
1922
|
}
|
1881
|
1923
|
|
1882
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
|
1883
|
|
- [self sendEvent:AGFirstRemoteVideoDecoded params:@{
|
1884
|
|
- @"uid": @(uid),
|
1885
|
|
- @"width": @(size.width),
|
1886
|
|
- @"height": @(size.height),
|
1887
|
|
- @"elapsed": @(elapsed)
|
1888
|
|
- }];
|
1889
|
|
-}
|
1890
|
|
-
|
1891
|
1924
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
|
1892
|
1925
|
[self sendEvent:AGFirstRemoteVideoFrame params:@{
|
1893
|
1926
|
@"uid": @(uid),
|
|
@@ -1903,27 +1936,6 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
1903
|
1936
|
}];
|
1904
|
1937
|
}
|
1905
|
1938
|
|
1906
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoMuted:(BOOL)muted byUid:(NSUInteger)uid {
|
1907
|
|
- [self sendEvent:AGUserMuteVideo params:@{
|
1908
|
|
- @"muted": @(muted),
|
1909
|
|
- @"uid": @(uid)
|
1910
|
|
- }];
|
1911
|
|
-}
|
1912
|
|
-
|
1913
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid {
|
1914
|
|
- [self sendEvent:AGUserEnableVideo params:@{
|
1915
|
|
- @"enabled": @(enabled),
|
1916
|
|
- @"uid": @(uid)
|
1917
|
|
- }];
|
1918
|
|
-}
|
1919
|
|
-
|
1920
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid {
|
1921
|
|
- [self sendEvent:AGUserEnableLocalVideo params:@{
|
1922
|
|
- @"enabled": @(enabled),
|
1923
|
|
- @"uid": @(uid)
|
1924
|
|
- }];
|
1925
|
|
-}
|
1926
|
|
-
|
1927
|
1939
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation {
|
1928
|
1940
|
[self sendEvent:AGVideoSizeChanged params:@{
|
1929
|
1941
|
@"uid": @(uid),
|
|
@@ -1992,10 +2004,14 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
1992
|
2004
|
[self sendEvent:AGRtcStats params:@{
|
1993
|
2005
|
@"stats": @{
|
1994
|
2006
|
@"duration": @(stats.duration),
|
1995
|
|
- @"txPacketLossRate": @(stats.txPacketLossRate),
|
1996
|
|
- @"rxPacketLossRate": @(stats.rxPacketLossRate),
|
1997
|
2007
|
@"txBytes": @(stats.txBytes),
|
1998
|
2008
|
@"rxBytes": @(stats.rxBytes),
|
|
2009
|
+ @"txAudioBytes": @(stats.txAudioBytes),
|
|
2010
|
+ @"txVideoBytes": @(stats.txVideoBytes),
|
|
2011
|
+ @"rxAudioBytes": @(stats.rxAudioBytes),
|
|
2012
|
+ @"rxVideoBytes": @(stats.rxVideoBytes),
|
|
2013
|
+ @"txPacketLossRate": @(stats.txPacketLossRate),
|
|
2014
|
+ @"rxPacketLossRate": @(stats.rxPacketLossRate),
|
1999
|
2015
|
@"txAudioKBitrate": @(stats.txAudioKBitrate),
|
2000
|
2016
|
@"rxAudioKBitrate": @(stats.rxAudioKBitrate),
|
2001
|
2017
|
@"txVideoKBitrate": @(stats.txVideoKBitrate),
|
|
@@ -2050,24 +2066,6 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
|
2050
|
2066
|
}];
|
2051
|
2067
|
}
|
2052
|
2068
|
|
2053
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate {
|
2054
|
|
- [self sendEvent:AGAudioTransportStatsOfUid params:@{
|
2055
|
|
- @"uid": @(uid),
|
2056
|
|
- @"delay": @(delay),
|
2057
|
|
- @"lost": @(lost),
|
2058
|
|
- @"rxKBitrate": @(rxKBitRate)
|
2059
|
|
- }];
|
2060
|
|
-}
|
2061
|
|
-
|
2062
|
|
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate {
|
2063
|
|
- [self sendEvent:AGVideoTransportStatsOfUid params:@{
|
2064
|
|
- @"uid": @(uid),
|
2065
|
|
- @"delay": @(delay),
|
2066
|
|
- @"lost": @(lost),
|
2067
|
|
- @"rxKBitrate": @(rxKBitRate)
|
2068
|
|
- }];
|
2069
|
|
-}
|
2070
|
|
-
|
2071
|
2069
|
- (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine {
|
2072
|
2070
|
[self sendEvent:AGRemoteAudioMixingStart params:@{
|
2073
|
2071
|
@"message": @"RemoteAudioMixingStarted"
|