Browse Source

upgrade. stage 1 & ios

matrixbirds 5 years ago
parent
commit
39ba1255fc

+ 3
- 7
ios/RCTAgora/AgoraConst.h View File

28
 static NSString *AGTokenPrivilegeWillExpire = @"tokenPrivilegeWillExpire";
28
 static NSString *AGTokenPrivilegeWillExpire = @"tokenPrivilegeWillExpire";
29
 static NSString *AGRequestToken = @"requestToken";
29
 static NSString *AGRequestToken = @"requestToken";
30
 
30
 
31
-static NSString *AGMicrophoneEnabled = @"microphoneEnabled";
31
+static NSString *AGLocalAudioStateChanged = @"localAudioStateChanged";
32
+static NSString *AGRemoteAudioStateChanged = @"remoteAudioStateChanged";
33
+static NSString *AGLocalAudioStats = @"localAudioStats";
32
 static NSString *AGAudioVolumeIndication = @"audioVolumeIndication";
34
 static NSString *AGAudioVolumeIndication = @"audioVolumeIndication";
33
 static NSString *AGActiveSpeaker = @"activeSpeaker";
35
 static NSString *AGActiveSpeaker = @"activeSpeaker";
34
 static NSString *AGFirstLocalAudioFrame = @"firstLocalAudioFrame";
36
 static NSString *AGFirstLocalAudioFrame = @"firstLocalAudioFrame";
35
 static NSString *AGFirstRemoteAudioFrame = @"firstRemoteAudioFrame";
37
 static NSString *AGFirstRemoteAudioFrame = @"firstRemoteAudioFrame";
36
 static NSString *AGFirstRemoteAudioDecoded = @"firstRemoteAudioDecoded";
38
 static NSString *AGFirstRemoteAudioDecoded = @"firstRemoteAudioDecoded";
37
 static NSString *AGFirstLocalVideoFrame = @"firstLocalVideoFrame";
39
 static NSString *AGFirstLocalVideoFrame = @"firstLocalVideoFrame";
38
-static NSString *AGFirstRemoteVideoDecoded = @"firstRemoteVideoDecoded";
39
 static NSString *AGFirstRemoteVideoFrame = @"firstRemoteVideoFrame";
40
 static NSString *AGFirstRemoteVideoFrame = @"firstRemoteVideoFrame";
40
 static NSString *AGUserMuteAudio = @"userMuteAudio";
41
 static NSString *AGUserMuteAudio = @"userMuteAudio";
41
-static NSString *AGUserMuteVideo = @"userMuteVideo";
42
-static NSString *AGUserEnableVideo = @"userEnableVideo";
43
-static NSString *AGUserEnableLocalVideo = @"userEnableLocalVideo";
44
 static NSString *AGVideoSizeChanged = @"videoSizeChanged";
42
 static NSString *AGVideoSizeChanged = @"videoSizeChanged";
45
 static NSString *AGRemoteVideoStateChanged = @"remoteVideoStateChanged";
43
 static NSString *AGRemoteVideoStateChanged = @"remoteVideoStateChanged";
46
 static NSString *AGLocalPublishFallbackToAudioOnly = @"localPublishFallbackToAudioOnly";
44
 static NSString *AGLocalPublishFallbackToAudioOnly = @"localPublishFallbackToAudioOnly";
56
 static NSString *AGLocalVideoStats = @"localVideoStats";
54
 static NSString *AGLocalVideoStats = @"localVideoStats";
57
 static NSString *AGRemoteVideoStats = @"remoteVideoStats";
55
 static NSString *AGRemoteVideoStats = @"remoteVideoStats";
58
 static NSString *AGRemoteAudioStats = @"remoteAudioStats";
56
 static NSString *AGRemoteAudioStats = @"remoteAudioStats";
59
-static NSString *AGAudioTransportStatsOfUid = @"audioTransportStatsOfUid";
60
-static NSString *AGVideoTransportStatsOfUid = @"videoTransportStatsOfUid";
61
 
57
 
62
 static NSString *AGRemoteAudioMixingStart = @"remoteAudioMixingStart";
58
 static NSString *AGRemoteAudioMixingStart = @"remoteAudioMixingStart";
63
 static NSString *AGRemoteAudioMixingFinish = @"remoteAudioMixingFinish";
59
 static NSString *AGRemoteAudioMixingFinish = @"remoteAudioMixingFinish";

+ 3
- 7
ios/RCTAgora/AgoraConst.m View File

44
                                   AGTokenPrivilegeWillExpire,
44
                                   AGTokenPrivilegeWillExpire,
45
                                   AGRequestToken,
45
                                   AGRequestToken,
46
                                   
46
                                   
47
-                                  AGMicrophoneEnabled,
47
+                                  AGLocalAudioStateChanged,
48
+                                  AGRemoteAudioStateChanged,
49
+                                  AGLocalAudioStats,
48
                                   AGAudioVolumeIndication,
50
                                   AGAudioVolumeIndication,
49
                                   AGActiveSpeaker,
51
                                   AGActiveSpeaker,
50
                                   AGFirstLocalAudioFrame,
52
                                   AGFirstLocalAudioFrame,
51
                                   AGFirstRemoteAudioFrame,
53
                                   AGFirstRemoteAudioFrame,
52
                                   AGFirstRemoteAudioDecoded,
54
                                   AGFirstRemoteAudioDecoded,
53
                                   AGFirstLocalVideoFrame,
55
                                   AGFirstLocalVideoFrame,
54
-                                  AGFirstRemoteVideoDecoded,
55
                                   AGFirstRemoteVideoFrame,
56
                                   AGFirstRemoteVideoFrame,
56
                                   AGUserMuteAudio,
57
                                   AGUserMuteAudio,
57
-                                  AGUserMuteVideo,
58
-                                  AGUserEnableVideo,
59
-                                  AGUserEnableLocalVideo,
60
                                   AGVideoSizeChanged,
58
                                   AGVideoSizeChanged,
61
                                   AGRemoteVideoStateChanged,
59
                                   AGRemoteVideoStateChanged,
62
                                   AGLocalPublishFallbackToAudioOnly,
60
                                   AGLocalPublishFallbackToAudioOnly,
72
                                   AGLocalVideoStats,
70
                                   AGLocalVideoStats,
73
                                   AGRemoteVideoStats,
71
                                   AGRemoteVideoStats,
74
                                   AGRemoteAudioStats,
72
                                   AGRemoteAudioStats,
75
-                                  AGAudioTransportStatsOfUid,
76
-                                  AGVideoTransportStatsOfUid,
77
                                   
73
                                   
78
                                   AGAudioMixingStateChanged,
74
                                   AGAudioMixingStateChanged,
79
                                   AGRemoteAudioMixingStart,
75
                                   AGRemoteAudioMixingStart,

+ 63
- 65
ios/RCTAgora/RCTAgora.m View File

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
 // register user account
316
 // register user account
305
 RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
317
 RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
306
                   resolve:(RCTPromiseResolveBlock)resolve
318
                   resolve:(RCTPromiseResolveBlock)resolve
362
 RCT_EXPORT_METHOD(leaveChannel
374
 RCT_EXPORT_METHOD(leaveChannel
363
                   :(RCTPromiseResolveBlock) resolve
375
                   :(RCTPromiseResolveBlock) resolve
364
                   reject:(RCTPromiseRejectBlock) reject) {
376
                   reject:(RCTPromiseRejectBlock) reject) {
365
-  NSInteger res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stat) {
377
+  NSInteger res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stats) {
366
     [self sendEvent:AGLeaveChannel params:@{
378
     [self sendEvent:AGLeaveChannel params:@{
367
                                             @"message": @"leaveChannel",
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
   if (res == 0) {
399
   if (res == 0) {
1744
                                               @"duration": @(stats.duration),
1762
                                               @"duration": @(stats.duration),
1745
                                               @"txBytes": @(stats.txBytes),
1763
                                               @"txBytes": @(stats.txBytes),
1746
                                               @"rxBytes": @(stats.rxBytes),
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
                                               @"txAudioKBitrate": @(stats.txAudioKBitrate),
1771
                                               @"txAudioKBitrate": @(stats.txAudioKBitrate),
1748
                                               @"rxAudioKBitrate": @(stats.rxVideoKBitrate),
1772
                                               @"rxAudioKBitrate": @(stats.rxVideoKBitrate),
1749
                                               @"txVideoKBitrate": @(stats.txVideoKBitrate),
1773
                                               @"txVideoKBitrate": @(stats.txVideoKBitrate),
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
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume {
1876
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume {
1835
   NSMutableArray *result = [NSMutableArray new];
1877
   NSMutableArray *result = [NSMutableArray new];
1836
   for (AgoraRtcAudioVolumeInfo *speaker in speakers) {
1878
   for (AgoraRtcAudioVolumeInfo *speaker in speakers) {
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
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
1924
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
1892
   [self sendEvent:AGFirstRemoteVideoFrame params:@{
1925
   [self sendEvent:AGFirstRemoteVideoFrame params:@{
1893
                                                    @"uid": @(uid),
1926
                                                    @"uid": @(uid),
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
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation {
1939
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation {
1928
   [self sendEvent:AGVideoSizeChanged params:@{
1940
   [self sendEvent:AGVideoSizeChanged params:@{
1929
                                               @"uid": @(uid),
1941
                                               @"uid": @(uid),
1992
   [self sendEvent:AGRtcStats params:@{
2004
   [self sendEvent:AGRtcStats params:@{
1993
                                       @"stats": @{
2005
                                       @"stats": @{
1994
                                           @"duration": @(stats.duration),
2006
                                           @"duration": @(stats.duration),
1995
-                                          @"txPacketLossRate": @(stats.txPacketLossRate),
1996
-                                          @"rxPacketLossRate": @(stats.rxPacketLossRate),
1997
                                           @"txBytes": @(stats.txBytes),
2007
                                           @"txBytes": @(stats.txBytes),
1998
                                           @"rxBytes": @(stats.rxBytes),
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
                                           @"txAudioKBitrate": @(stats.txAudioKBitrate),
2015
                                           @"txAudioKBitrate": @(stats.txAudioKBitrate),
2000
                                           @"rxAudioKBitrate": @(stats.rxAudioKBitrate),
2016
                                           @"rxAudioKBitrate": @(stats.rxAudioKBitrate),
2001
                                           @"txVideoKBitrate": @(stats.txVideoKBitrate),
2017
                                           @"txVideoKBitrate": @(stats.txVideoKBitrate),
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
 - (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine {
2069
 - (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine {
2072
   [self sendEvent:AGRemoteAudioMixingStart params:@{
2070
   [self sendEvent:AGRemoteAudioMixingStart params:@{
2073
                                                     @"message": @"RemoteAudioMixingStarted"
2071
                                                     @"message": @"RemoteAudioMixingStarted"

+ 18
- 7
lib/RtcEngine.native.d.ts View File

34
      * @param info
34
      * @param info
35
      */
35
      */
36
     static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): Promise<any>;
36
     static joinChannel(channelName: string, uid?: number, token?: string, info?: Object): Promise<any>;
37
+    /**
38
+     * switch to specified channel
39
+     *
40
+     * This method will switch channel smoothly than you invoke leaveChannel & joinChannel.
41
+     * Otherwise, it will invoke error by the event
42
+     * It will occurs two events:
43
+     * Occurs leaveChannel when achieve leaving stage
44
+     * Occurs joinChannelSuccess when achieve joining stage
45
+     * @param channelName
46
+     * @param token
47
+     */
48
+    static switchChannel(channelName: string, token?: string): Promise<any>;
49
+    static startChannelMediaRelay(): void;
50
+    static updateChannelMediaRelay(): void;
51
+    static stopChannelMediaRelay(): void;
37
     /**
52
     /**
38
      * Registers a user account.
53
      * Registers a user account.
39
      *
54
      *
117
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
132
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
118
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
133
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
119
      * requestToken | occurs when token expired | on("requestToken") |
134
      * requestToken | occurs when token expired | on("requestToken") |
120
-     * microphoneEnabled | occurs when microphone enable state changed | on("microphoneEnabled", evt) |
135
+     * localAudioStateChanged | occurs when local audio device state changed | on("localAudioStateChanged", (state, errorCode) => {}) |
121
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
136
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
122
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
137
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
123
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
138
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
124
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
139
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
125
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
140
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
126
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
141
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
127
-     * firstRemoteVideoDecoded | occurs when received first video frame from remote side decoded | on("firstRemoteVideoDecoded", evt) |
128
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
142
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
129
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
143
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
130
-     * userMuteVideo | occurs when user mute video | on("userMuteVideo", evt) |
131
-     * userEnableVideo | occurs when remote side's user change video enable state | on("userEnableVideo", evt) |
132
-     * userEnableLocalVideo | occurs when user change video enable state on local | on("userEnableLocalVideo", evt) |
133
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
144
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
134
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
145
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
146
+     * remoteAudioStateChanged | occurs when remote audio state has any changed | on("remoteAudioStateChanged", evt) |
147
+     * localAudioStats | occurs when engine start to report local audio stats | on("localAudioStats", evt) |
135
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
148
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
136
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
149
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
137
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
150
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
143
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) |
156
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) |
144
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) |
157
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) |
145
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) |
158
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) |
146
-     * audioTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote audio stream. | on("audioTransportStatsOfUid", evt) |
147
-     * videoTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote video stream.| on("videoTransportStatsOfUid", evt) |
148
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) |
159
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) |
149
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) |
160
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) |
150
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) |
161
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) |

+ 24
- 14
lib/RtcEngine.native.js View File

35
     static joinChannel(channelName, uid, token, info) {
35
     static joinChannel(channelName, uid, token, info) {
36
         return Agora.joinChannel({ channelName, uid, token, info });
36
         return Agora.joinChannel({ channelName, uid, token, info });
37
     }
37
     }
38
+    /**
39
+     * switch to specified channel
40
+     *
41
+     * This method will switch channel smoothly than you invoke leaveChannel & joinChannel.
42
+     * Otherwise, it will invoke error by the event
43
+     * It will occurs two events:
44
+     * Occurs leaveChannel when achieve leaving stage
45
+     * Occurs joinChannelSuccess when achieve joining stage
46
+     * @param channelName
47
+     * @param token
48
+     */
49
+    static switchChannel(channelName, token) {
50
+        return Agora.switchChannel({ channelName, token });
51
+    }
52
+    static startChannelMediaRelay() {
53
+    }
54
+    static updateChannelMediaRelay() {
55
+    }
56
+    static stopChannelMediaRelay() {
57
+    }
38
     /**
58
     /**
39
      * Registers a user account.
59
      * Registers a user account.
40
      *
60
      *
141
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
161
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
142
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
162
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
143
      * requestToken | occurs when token expired | on("requestToken") |
163
      * requestToken | occurs when token expired | on("requestToken") |
144
-     * microphoneEnabled | occurs when microphone enable state changed | on("microphoneEnabled", evt) |
164
+     * localAudioStateChanged | occurs when local audio device state changed | on("localAudioStateChanged", (state, errorCode) => {}) |
145
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
165
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
146
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
166
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
147
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
167
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
148
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
168
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
149
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
169
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
150
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
170
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
151
-     * firstRemoteVideoDecoded | occurs when received first video frame from remote side decoded | on("firstRemoteVideoDecoded", evt) |
152
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
171
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
153
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
172
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
154
-     * userMuteVideo | occurs when user mute video | on("userMuteVideo", evt) |
155
-     * userEnableVideo | occurs when remote side's user change video enable state | on("userEnableVideo", evt) |
156
-     * userEnableLocalVideo | occurs when user change video enable state on local | on("userEnableLocalVideo", evt) |
157
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
173
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
158
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
174
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
175
+     * remoteAudioStateChanged | occurs when remote audio state has any changed | on("remoteAudioStateChanged", evt) |
176
+     * localAudioStats | occurs when engine start to report local audio stats | on("localAudioStats", evt) |
159
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
177
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
160
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
178
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
161
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
179
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
167
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) |
185
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) |
168
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) |
186
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) |
169
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) |
187
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) |
170
-     * audioTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote audio stream. | on("audioTransportStatsOfUid", evt) |
171
-     * videoTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote video stream.| on("videoTransportStatsOfUid", evt) |
172
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) |
188
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) |
173
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) |
189
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) |
174
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) |
190
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) |
203
             'receiveStreamMessage',
219
             'receiveStreamMessage',
204
             'activeSpeaker',
220
             'activeSpeaker',
205
             'firstRemoteAudioFrame',
221
             'firstRemoteAudioFrame',
206
-            'firstRemoteVideoDecoded',
207
             'firstRemoteVideoFrame',
222
             'firstRemoteVideoFrame',
208
             'userMuteAudio',
223
             'userMuteAudio',
209
-            'userMuteVideo',
210
-            'userEnableVideo',
211
-            'userEnableLocalVideo',
212
             'videoSizeChanged',
224
             'videoSizeChanged',
213
-            'firstRemoteAudioDecoded',
214
             'remoteVideoStateChanged',
225
             'remoteVideoStateChanged',
226
+            'remoteAudioStateChanged',
215
             'remoteSubscribeFallbackToAudioOnly',
227
             'remoteSubscribeFallbackToAudioOnly',
216
             'networkQuality',
228
             'networkQuality',
217
             'streamInjectedStatus',
229
             'streamInjectedStatus',
248
         if ([
260
         if ([
249
             'remoteAudioStats',
261
             'remoteAudioStats',
250
             'remoteVideoStats',
262
             'remoteVideoStats',
251
-            'audioTransportStatsOfUid',
252
-            'videoTransportStatsOfUid',
253
         ].indexOf(eventType) != -1) {
263
         ].indexOf(eventType) != -1) {
254
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
264
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
255
                 args.stats.uid = this.Int32ToUint32(args.stats.uid);
265
                 args.stats.uid = this.Int32ToUint32(args.stats.uid);

+ 1
- 1
lib/RtcEngine.native.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "react-native-agora",
2
   "name": "react-native-agora",
3
-  "version": "2.8.0-alpha.2",
3
+  "version": "2.9.0-alpha.1",
4
   "description": "React Native around the Agora RTC SDKs for Android and iOS agora",
4
   "description": "React Native around the Agora RTC SDKs for Android and iOS agora",
5
   "summary": "agora native sdk for react-native",
5
   "summary": "agora native sdk for react-native",
6
   "main": "lib/index.js",
6
   "main": "lib/index.js",

+ 1
- 1
react-native-agora.podspec View File

20
     end
20
     end
21
 
21
 
22
     s.dependency 'React'
22
     s.dependency 'React'
23
-    s.dependency "AgoraRtcEngine_iOS", "2.8"
23
+    s.dependency "AgoraRtcEngine_iOS", "2.9"
24
 end
24
 end

+ 31
- 14
src/RtcEngine.native.ts View File

76
         return Agora.joinChannel({channelName, uid, token, info});
76
         return Agora.joinChannel({channelName, uid, token, info});
77
     }
77
     }
78
 
78
 
79
+    /**
80
+     * switch to specified channel
81
+     *
82
+     * This method will switch channel smoothly than you invoke leaveChannel & joinChannel.
83
+     * Otherwise, it will invoke error by the event
84
+     * It will occurs two events:
85
+     * Occurs leaveChannel when achieve leaving stage
86
+     * Occurs joinChannelSuccess when achieve joining stage
87
+     * @param channelName
88
+     * @param token
89
+     */
90
+    public static switchChannel(channelName: string, token?: string): Promise<any> {
91
+        return Agora.switchChannel({channelName, token});
92
+    }
93
+    
94
+    public static startChannelMediaRelay() {
95
+
96
+    }
97
+
98
+    public static updateChannelMediaRelay() {
99
+
100
+    }
101
+
102
+    public static stopChannelMediaRelay() {
103
+        
104
+    }
105
+
79
     /**
106
     /**
80
      * Registers a user account.
107
      * Registers a user account.
81
      * 
108
      * 
182
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
209
      * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
183
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
210
      * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
184
      * requestToken | occurs when token expired | on("requestToken") |
211
      * requestToken | occurs when token expired | on("requestToken") |
185
-     * microphoneEnabled | occurs when microphone enable state changed | on("microphoneEnabled", evt) |
212
+     * localAudioStateChanged | occurs when local audio device state changed | on("localAudioStateChanged", (state, errorCode) => {}) |
186
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
213
      * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
187
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
214
      * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
188
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
215
      * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
189
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
216
      * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
190
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
217
      * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
191
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
218
      * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
192
-     * firstRemoteVideoDecoded | occurs when received first video frame from remote side decoded | on("firstRemoteVideoDecoded", evt) |
193
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
219
      * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
194
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
220
      * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
195
-     * userMuteVideo | occurs when user mute video | on("userMuteVideo", evt) |
196
-     * userEnableVideo | occurs when remote side's user change video enable state | on("userEnableVideo", evt) |
197
-     * userEnableLocalVideo | occurs when user change video enable state on local | on("userEnableLocalVideo", evt) |
198
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
221
      * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
199
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
222
      * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
223
+     * remoteAudioStateChanged | occurs when remote audio state has any changed | on("remoteAudioStateChanged", evt) |
224
+     * localAudioStats | occurs when engine start to report local audio stats | on("localAudioStats", evt) |
200
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
225
      * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
201
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
226
      * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
202
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
227
      * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
208
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) | 
233
      * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) | 
209
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) | 
234
      * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) | 
210
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) | 
235
      * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) | 
211
-     * audioTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote audio stream. | on("audioTransportStatsOfUid", evt) | 
212
-     * videoTransportStatsOfUid | occurs when reports  transport-layer statistics of each remote video stream.| on("videoTransportStatsOfUid", evt) | 
213
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) | 
236
      * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) | 
214
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) | 
237
      * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) | 
215
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) | 
238
      * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) | 
244
             'receiveStreamMessage',
267
             'receiveStreamMessage',
245
             'activeSpeaker',
268
             'activeSpeaker',
246
             'firstRemoteAudioFrame',
269
             'firstRemoteAudioFrame',
247
-            'firstRemoteVideoDecoded',
248
             'firstRemoteVideoFrame',
270
             'firstRemoteVideoFrame',
249
             'userMuteAudio',
271
             'userMuteAudio',
250
-            'userMuteVideo',
251
-            'userEnableVideo',
252
-            'userEnableLocalVideo',
253
             'videoSizeChanged',
272
             'videoSizeChanged',
254
-            'firstRemoteAudioDecoded',
255
             'remoteVideoStateChanged',
273
             'remoteVideoStateChanged',
274
+            'remoteAudioStateChanged',
256
             'remoteSubscribeFallbackToAudioOnly',
275
             'remoteSubscribeFallbackToAudioOnly',
257
             'networkQuality',
276
             'networkQuality',
258
             'streamInjectedStatus',
277
             'streamInjectedStatus',
295
         if ([
314
         if ([
296
             'remoteAudioStats',
315
             'remoteAudioStats',
297
             'remoteVideoStats',
316
             'remoteVideoStats',
298
-            'audioTransportStatsOfUid',
299
-            'videoTransportStatsOfUid',   
300
         ].indexOf(eventType) != -1) {
317
         ].indexOf(eventType) != -1) {
301
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
318
             AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
302
                 args.stats.uid = this.Int32ToUint32(args.stats.uid);
319
                 args.stats.uid = this.Int32ToUint32(args.stats.uid);