邓博 7 yıl önce
ebeveyn
işleme
6861abd047

+ 28
- 0
RTCEngine.js Dosyayı Görüntüle

@@ -0,0 +1,28 @@
1
+import {
2
+    NativeModules,
3
+    findNodeHandle,
4
+    NativeAppEventEmitter
5
+} from 'react-native';
6
+
7
+const { Agora } = NativeModules
8
+
9
+export default {
10
+    ...Agora,
11
+    init(options = {}) {
12
+        this.listener && this.listener.remove();
13
+        Agora.init(options);
14
+    },
15
+    joinChannel(channelName = '001'){
16
+        Agora.joinChannel(channelName)
17
+    },
18
+    eventEmitter(fnConf) {
19
+        //there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
20
+        this.listener && this.listener.remove();
21
+        this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
22
+            fnConf[event['type']] && fnConf[event['type']](event);
23
+        });
24
+    },
25
+    removeEmitter() {
26
+        this.listener && this.listener.remove();
27
+    }
28
+};

BIN
android/libs/agora-rtc-sdk.jar Dosyayı Görüntüle


+ 18
- 3
android/src/main/java/com/syan/agora/AgoraModule.java Dosyayı Görüntüle

@@ -128,15 +128,30 @@ public class AgoraModule extends ReactContextBaseJavaModule {
128 128
          */
129 129
         @Override
130 130
         public void onLeaveChannel(RtcStats stats) {
131
-
131
+            runOnUiThread(new Runnable() {
132
+                @Override
133
+                public void run() {
134
+                    WritableMap map = Arguments.createMap();
135
+                    map.putString("type", "onLeaveChannel");
136
+                    commonEvent(map);
137
+                }
138
+            });
132 139
         }
133 140
 
134 141
         /**
135 142
          * 用户uid离线时的回调
136 143
          */
137 144
         @Override
138
-        public void onUserOffline(int uid, int reason) {
139
-
145
+        public void onUserOffline(final int uid, int reason) {
146
+            runOnUiThread(new Runnable() {
147
+                @Override
148
+                public void run() {
149
+                    WritableMap map = Arguments.createMap();
150
+                    map.putString("type", "onUserOffline");
151
+                    map.putInt("uid", uid);
152
+                    commonEvent(map);
153
+                }
154
+            });
140 155
         }
141 156
     };
142 157
 

BIN
android/src/main/jniLibs/arm64-v8a/libHDACEngine.so Dosyayı Görüntüle


BIN
android/src/main/jniLibs/arm64-v8a/libagora-rtc-sdk-jni.so Dosyayı Görüntüle


BIN
android/src/main/jniLibs/armeabi-v7a/libHDACEngine.so Dosyayı Görüntüle


BIN
android/src/main/jniLibs/armeabi-v7a/libagora-rtc-sdk-jni.so Dosyayı Görüntüle


+ 68
- 22
android/src/main/jniLibs/include/IAgoraRtcEngine.h Dosyayı Görüntüle

@@ -123,6 +123,7 @@ enum WARN_CODE_TYPE
123 123
     WARN_ADM_RECORD_AUDIO_SILENCE = 1019,
124 124
     WARN_ADM_PLAYOUT_MALFUNCTION = 1020,
125 125
     WARN_ADM_RECORD_MALFUNCTION = 1021,
126
+    WARN_ADM_RECORD_AUDIO_LOWLEVEL = 1031,
126 127
     WARN_APM_HOWLING = 1051,
127 128
 
128 129
     // sdk: 100~1000
@@ -213,7 +214,7 @@ enum LOG_FILTER_TYPE
213 214
 
214 215
 enum MAX_DEVICE_ID_LENGTH_TYPE
215 216
 {
216
-    MAX_DEVICE_ID_LENGTH = 128
217
+    MAX_DEVICE_ID_LENGTH = 512
217 218
 };
218 219
 
219 220
 enum QUALITY_REPORT_FORMAT_TYPE
@@ -237,7 +238,7 @@ enum MEDIA_ENGINE_EVENT_CODE_TYPE
237 238
     MEDIA_ENGINE_ROLE_COMM_PEER = 23,
238 239
     MEDIA_ENGINE_ROLE_GAME_PEER = 24,
239 240
     // iOS adm sample rate changed
240
-    MEDIA_ENGINE_AUDIO_ADM_SAMPLE_RATE_CHANGE = 110
241
+    MEDIA_ENGINE_AUDIO_ADM_REQUIRE_RESTART = 110
241 242
 };
242 243
 
243 244
 enum MEDIA_DEVICE_STATE_TYPE
@@ -434,6 +435,41 @@ struct VideoCompositingLayout
434 435
     {}
435 436
 };
436 437
 
438
+#if defined(_WIN32)
439
+
440
+enum RTMP_STREAM_LIFE_CYCLE_TYPE
441
+{
442
+	RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL = 1,
443
+	RTMP_STREAM_LIFE_CYCLE_BIND2OWNER = 2,
444
+};
445
+
446
+struct PublisherConfiguration {
447
+	int width;
448
+	int height;
449
+	int framerate;
450
+	int bitrate;
451
+	int defaultLayout;
452
+	int lifecycle;
453
+	bool owner;
454
+	const char* publishUrl;
455
+	const char* rawStreamUrl;
456
+	const char* extraInfo;
457
+
458
+	PublisherConfiguration()
459
+		: width(640)
460
+		, height(360)
461
+		, framerate(15)
462
+		, bitrate(500)
463
+		, defaultLayout(1)
464
+		, lifecycle(RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL)
465
+		, owner(true)
466
+		, publishUrl(NULL)
467
+		, rawStreamUrl(NULL)
468
+		, extraInfo(NULL)
469
+	{}
470
+
471
+};
472
+#endif
437 473
 #if !defined(__ANDROID__)
438 474
 struct VideoCanvas
439 475
 {
@@ -570,7 +606,7 @@ public:
570 606
     * @param [in] uid
571 607
     *        the uid of the peer
572 608
     * @param [in] quality
573
-    *        the quality of the user 0~5 the higher the better
609
+    *        the quality of the user, see QUALITY_TYPE for value definition
574 610
     * @param [in] delay
575 611
     *        the average time of the audio packages delayed
576 612
     * @param [in] lost
@@ -900,6 +936,28 @@ public:
900 936
     */
901 937
     virtual void onRequestChannelKey() {
902 938
     }
939
+
940
+    /**
941
+    * when the first local audio frame generated, the function will be called
942
+    * @param [in] elapsed
943
+    *        the time elapsed from remote user called joinChannel in ms
944
+    */
945
+    virtual void onFirstLocalAudioFrame(int elapsed) {
946
+        (void)elapsed;
947
+    }
948
+
949
+    /**
950
+    * when the first remote audio frame arrived, the function will be called
951
+    * @param [in] uid
952
+    *        the UID of the remote user
953
+    * @param [in] elapsed
954
+    *        the time elapsed from remote user called joinChannel in ms
955
+    */
956
+    virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) {
957
+        (void)uid;
958
+        (void)elapsed;
959
+    }
960
+
903 961
 };
904 962
 
905 963
 /**
@@ -1339,6 +1397,10 @@ public:
1339 1397
 
1340 1398
     virtual int setVideoCompositingLayout(const VideoCompositingLayout& sei) = 0;
1341 1399
     virtual int clearVideoCompositingLayout() = 0;
1400
+
1401
+#if defined(_WIN32)
1402
+	virtual int configPublisher(const PublisherConfiguration& config) = 0;
1403
+#endif
1342 1404
 };
1343 1405
 
1344 1406
 
@@ -1616,25 +1678,6 @@ public:
1616 1678
         return setObject("rtc.video.set_remote_video_stream", "{\"uid\":%u,\"stream\":%d}", uid, streamType);
1617 1679
     }
1618 1680
 
1619
-
1620
-    /**
1621
-     * play the video stream from network
1622
-     * @param [in] uri the link of video source
1623
-     * @return return 0 if success or an error code
1624
-     */
1625
-    int startPlayingStream(const char* uri) {
1626
-        return m_parameter ? m_parameter->setString("rtc.api.video.start_play_stream", uri) : -ERR_NOT_INITIALIZED;
1627
-    }
1628
-
1629
-    /**
1630
-     *  stop playing the video stream from network
1631
-     *
1632
-     * @return return 0 if success or an error code
1633
-     */
1634
-    int stopPlayingStream() {
1635
-        return m_parameter ? m_parameter->setBool("rtc.api.video.stop_play_stream", true) : -ERR_NOT_INITIALIZED;
1636
-    }
1637
-
1638 1681
     /**
1639 1682
     * set play sound volume
1640 1683
     * @param [in] volume
@@ -1752,6 +1795,9 @@ public:
1752 1795
             r = pos;
1753 1796
         return r;
1754 1797
     }
1798
+    int setAudioMixingPosition(int pos /*in ms*/) {
1799
+        return m_parameter ? m_parameter->setInt("che.audio.mixing.file.position", pos) : -ERR_NOT_INITIALIZED;
1800
+    }
1755 1801
 #if defined(__APPLE__)
1756 1802
 	/**
1757 1803
 	* start screen capture

BIN
android/src/main/jniLibs/x86/libHDACEngine.so Dosyayı Görüntüle


BIN
android/src/main/jniLibs/x86/libagora-rtc-sdk-jni.so Dosyayı Görüntüle


+ 4
- 36
index.js Dosyayı Görüntüle

@@ -1,38 +1,6 @@
1
-import {
2
-    NativeModules,
3
-    findNodeHandle,
4
-    NativeAppEventEmitter
5
-} from 'react-native';
6 1
 
7
-const { Agora } = NativeModules
2
+import _AgoraView from './AgoraView'
3
+import _RTCEngine from './RTCEngine'
8 4
 
9
-export default {
10
-
11
-    init(options = {}) {
12
-        this.listener && this.listener.remove();
13
-        Agora.init(options);
14
-    },
15
-    joinChannel(channelName = '001'){
16
-        Agora.joinChannel(channelName)
17
-    },
18
-    eventEmitter(fnConf) {
19
-        // const {
20
-        //     onFirstRemoteVideoDecoded = () => {},
21
-        //     onJoinChannelSuccess = () => {},
22
-        //     onUserJoined = () => {},
23
-        //     onError = () => {},
24
-        //     onWarning = () => {}
25
-        // } = options;
26
-
27
-        // let fnConf = {...options};
28
-        //there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
29
-        this.listener && this.listener.remove();
30
-        this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
31
-            fnConf[event['type']] && fnConf[event['type']](event);
32
-        });
33
-    },
34
-    removeEmitter() {
35
-        this.listener && this.listener.remove();
36
-    }
37
-
38
-};
5
+export const AgoraView = _AgoraView;
6
+export const RTCEngine = _RTCEngine;

+ 17
- 0
ios/RCTAgora/AgoraConst.h Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+//
2
+//  MyAgoraRtcEngineKit.h
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>
10
+
11
+@interface AgoraConst : NSObject
12
+
13
+@property (nonatomic, copy) NSString *appid;
14
+
15
++ (instancetype)share;
16
+
17
+@end

+ 36
- 0
ios/RCTAgora/AgoraConst.m Dosyayı Görüntüle

@@ -0,0 +1,36 @@
1
+//
2
+//  MyAgoraRtcEngineKit.m
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import "AgoraConst.h"
10
+
11
+@implementation AgoraConst
12
+
13
+static AgoraConst *_person;
14
++ (instancetype)allocWithZone:(struct _NSZone *)zone{
15
+    static dispatch_once_t predicate;
16
+    dispatch_once(&predicate, ^{
17
+        _person = [super allocWithZone:zone];
18
+    });
19
+    return _person;
20
+}
21
+
22
++ (instancetype)share {
23
+    static dispatch_once_t onceToken;
24
+    dispatch_once(&onceToken, ^{
25
+        _person = [[self alloc]init];
26
+    });
27
+    return _person;
28
+}
29
+
30
+- (id)copyWithZone:(NSZone *)zone {
31
+    return _person;
32
+}
33
+
34
+
35
+
36
+@end

+ 59
- 38
ios/RCTAgora/RCTAgora.m Dosyayı Görüntüle

@@ -11,6 +11,7 @@
11 11
 #import <React/RCTBridge.h>
12 12
 #import <React/RCTUIManager.h>
13 13
 #import <React/RCTView.h>
14
+#import "AgoraConst.h"
14 15
 
15 16
 @interface RCTAgora ()
16 17
 @property (strong, nonatomic) AgoraRtcEngineKit *rtcEngine;
@@ -45,7 +46,9 @@ RCT_EXPORT_MODULE();
45 46
  *  @param reactTag        绑定view的tag
46 47
  *  @return 0 when executed successfully. return negative value if failed.
47 48
  */
48
-RCT_EXPORT_METHOD(loadAgoraKit:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback) {
49
+RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
50
+    
51
+    [AgoraConst share].appid = options[@"appid"];
49 52
     
50 53
     self.rtcEngine = [AgoraRtcEngineKit sharedEngineWithAppId:options[@"appid"] delegate:self];
51 54
     
@@ -60,35 +63,23 @@ RCT_EXPORT_METHOD(loadAgoraKit:(NSDictionary *)options callback:(RCTResponseSend
60 63
     //开启预览
61 64
     [self.rtcEngine startPreview];
62 65
     
63
-    [self.rtcEngine joinChannelByKey:nil channelName:options[@"channelName"] info:options[@"info"] uid:0 joinSuccess:^(NSString *channel, NSUInteger uid, NSInteger elapsed) {
64
-        
65
-        NSMutableDictionary *params = [NSMutableDictionary dictionary];
66
-        
67
-        params[@"channel"] = channel;
68
-        params[@"uid"] = [NSNumber numberWithInteger:uid];
69
-        params[@"elapsed"] = [NSNumber numberWithInteger:elapsed];
70
-        callback(@[params]);
71
-        
72
-        //绑定本地视图
73
-        AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
74
-        canvas.uid = uid;
75
-        canvas.view = [self.bridge.uiManager viewForReactTag:options[@"reactTag"]];
76
-        canvas.renderMode = AgoraRtc_Render_Hidden;
77
-        [self.rtcEngine setupLocalVideo:canvas];
78
-        
79
-    }];
80
-    
81 66
     //Agora Native SDK 与 Agora Web SDK 间的互通
82 67
     [self.rtcEngine enableWebSdkInteroperability:YES];
83 68
     
84 69
 }
85 70
 
71
+//加入房间
72
+RCT_EXPORT_METHOD(joinChannel:(NSString *)channelName) {
73
+    [self.rtcEngine joinChannelByKey:nil channelName:channelName info:nil uid:0 joinSuccess:NULL];
74
+}
86 75
 
87 76
 //离开频道
88 77
 RCT_EXPORT_METHOD(leaveChannel){
89
-    [AgoraRtcEngineKit destroy];
90 78
     [self.rtcEngine leaveChannel:^(AgoraRtcStats *stat) {
79
+        NSMutableDictionary *params = @{}.mutableCopy;
80
+        params[@"type"] = @"onLeaveChannel";
91 81
         
82
+        [self sendEvent:params];
92 83
     }];
93 84
 }
94 85
 
@@ -175,20 +166,48 @@ RCT_EXPORT_METHOD(stopRecordingService:(NSString*)recordingKey){
175 166
     [self.rtcEngine stopRecordingService:recordingKey];
176 167
 }
177 168
 
169
+//获取版本号
170
+RCT_EXPORT_METHOD(getSdkVersion:(RCTResponseSenderBlock)callback){
171
+    callback(@[[AgoraRtcEngineKit getSdkVersion]]);
172
+}
173
+
174
+
178 175
 /*
179 176
  该回调方法表示SDK运行时出现了(网络或媒体相关的)错误。通常情况下,SDK上报的错误意味着SDK无法自动恢复,需要应用程序干预或提示用户。
180 177
  比如启动通话失败时,SDK会上报AgoraRtc_Error_StartCall(1002)错误。
181 178
  应用程序可以提示用户启动通话失败,并调用leaveChannel退出频道。
182 179
  */
183 180
 - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOccurError:(AgoraRtcErrorCode)errorCode{
181
+    NSMutableDictionary *params = @{}.mutableCopy;
182
+    params[@"type"] = @"onError";
183
+    params[@"err"] = [NSNumber numberWithInteger:errorCode];;
184
+    
185
+    [self sendEvent:params];
186
+}
187
+
188
+/*
189
+ 警告
190
+ */
191
+- (void)rtcEngine:(AgoraRtcEngineKit *)engine didOccurWarning:(AgoraRtcWarningCode)warningCode {
192
+    NSMutableDictionary *params = @{}.mutableCopy;
193
+    params[@"type"] = @"onWarning";
194
+    params[@"err"] = [NSNumber numberWithInteger:warningCode];;
184 195
     
196
+    [self sendEvent:params];
185 197
 }
186 198
 
199
+
187 200
 /*
188 201
  客户端成功加入了指定的频道
189 202
  */
190 203
 - (void)rtcEngine:(AgoraRtcEngineKit *)engine didJoinChannel:(NSString*)channel withUid:(NSUInteger)uid elapsed:(NSInteger) elapsed {
204
+
205
+    NSMutableDictionary *params = @{}.mutableCopy;
206
+    params[@"type"] = @"onJoinChannelSuccess";
207
+    params[@"uid"] = [NSNumber numberWithInteger:uid];
208
+    params[@"channel"] = channel;
191 209
     
210
+    [self sendEvent:params];
192 211
 }
193 212
 
194 213
 /*
@@ -196,13 +215,11 @@ RCT_EXPORT_METHOD(stopRecordingService:(NSString*)recordingKey){
196 215
  */
197 216
 - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed {
198 217
     
199
-    NSMutableDictionary *params = [NSMutableDictionary dictionary];
200
-    
218
+    NSMutableDictionary *params = @{}.mutableCopy;
219
+    params[@"type"] = @"onFirstRemoteVideoDecoded";
201 220
     params[@"uid"] = [NSNumber numberWithInteger:uid];
202
-    params[@"size"] = @{@"width": [NSString stringWithFormat:@"%f", size.width], @"height": [NSString stringWithFormat:@"%f", size.height]};
203
-    params[@"elapsed"] = [NSNumber numberWithInteger:elapsed];
204 221
     
205
-    [_bridge.eventDispatcher sendDeviceEventWithName:@"firstRemoteVideoDecodedOfUid" body:params];
222
+    [self sendEvent:params];
206 223
 
207 224
 }
208 225
 
@@ -210,34 +227,38 @@ RCT_EXPORT_METHOD(stopRecordingService:(NSString*)recordingKey){
210 227
  用户加入回调
211 228
  */
212 229
 - (void)rtcEngine:(AgoraRtcEngineKit *)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
213
- 
214
-    [_bridge.eventDispatcher sendDeviceEventWithName:@"didJoinedOfUid" body:[NSNumber numberWithInteger:uid]];
230
+    NSMutableDictionary *params = @{}.mutableCopy;
231
+    params[@"type"] = @"onUserJoined";
232
+    params[@"uid"] = [NSNumber numberWithInteger:uid];
233
+    
234
+    [self sendEvent:params];
215 235
 }
216 236
 
217 237
 /*
218 238
  用户离线回调
219 239
  */
220 240
 - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraRtcUserOfflineReason)reason {
241
+    NSMutableDictionary *params = @{}.mutableCopy;
242
+    params[@"type"] = @"onUserOffline";
243
+    params[@"uid"] = [NSNumber numberWithInteger:uid];
221 244
     
245
+    [self sendEvent:params];
222 246
 }
223 247
 
224
-/*
225
- 报告本地用户的网络质量,该回调方法每两秒触发一次
226
- */
227
-- (void)rtcEngine:(AgoraRtcEngineKit *)engine lastmileQuality:(AgoraRtcQuality)quality {
228
-    
248
+- (void)sendEvent:(NSDictionary *)params {
249
+    [_bridge.eventDispatcher sendDeviceEventWithName:@"agoraEvent" body:params];
229 250
 }
230 251
 
231 252
 - (dispatch_queue_t)methodQueue {
232 253
     return dispatch_get_main_queue();
233 254
 }
234 255
 
235
-RCT_EXPORT_METHOD(getViewWithTag:(nonnull NSNumber *)reactTag) {
236
-    
237
-    UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
238
-    NSLog(@"%@",view);
239
-    
240
-}
256
+//RCT_EXPORT_METHOD(getViewWithTag:(nonnull NSNumber *)reactTag) {
257
+//    
258
+//    UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
259
+//    NSLog(@"%@",view);
260
+//    
261
+//}
241 262
 
242 263
 @end
243 264
 

+ 19
- 0
ios/RCTAgora/RCTAgoraVideoView.h Dosyayı Görüntüle

@@ -0,0 +1,19 @@
1
+//
2
+//  RCTAgoraVideoView.h
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+#import "AgoraConst.h"
11
+
12
+@interface RCTAgoraVideoView : UIView
13
+
14
+@property (strong, nonatomic) AgoraRtcEngineKit *rtcEngine;
15
+
16
+@property (nonatomic) NSInteger localUid;
17
+@property (nonatomic) NSInteger remoteUid;
18
+
19
+@end

+ 42
- 0
ios/RCTAgora/RCTAgoraVideoView.m Dosyayı Görüntüle

@@ -0,0 +1,42 @@
1
+//
2
+//  RCTAgoraVideoView.m
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import "RCTAgoraVideoView.h"
10
+
11
+@implementation RCTAgoraVideoView
12
+
13
+- (instancetype)init{
14
+    
15
+    if (self == [super init]) {
16
+        _rtcEngine =  [AgoraRtcEngineKit sharedEngineWithAppId:[AgoraConst share].appid delegate:nil];
17
+    }
18
+    
19
+    return self;
20
+}
21
+
22
+- (void)setLocalUid:(NSInteger)localUid {
23
+    if (localUid == 0) {
24
+        AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
25
+        canvas.uid = localUid;
26
+        canvas.view = self;
27
+        canvas.renderMode = AgoraRtc_Render_Hidden;
28
+        [_rtcEngine setupLocalVideo:canvas];
29
+    }
30
+}
31
+
32
+-(void)setRemoteUid:(NSInteger)remoteUid {
33
+    if (remoteUid > 0) {
34
+        AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
35
+        canvas.uid = remoteUid;
36
+        canvas.view = self;
37
+        canvas.renderMode = AgoraRtc_Render_Hidden;
38
+        [_rtcEngine setupRemoteVideo:canvas];
39
+    }
40
+}
41
+
42
+@end

+ 14
- 0
ios/RCTAgora/RCTAgoraViewManager.h Dosyayı Görüntüle

@@ -0,0 +1,14 @@
1
+//
2
+//  AgoraViewManager.h
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import "RCTViewManager.h"
10
+
11
+
12
+@interface RCTAgoraViewManager : RCTViewManager
13
+
14
+@end

+ 25
- 0
ios/RCTAgora/RCTAgoraViewManager.m Dosyayı Görüntüle

@@ -0,0 +1,25 @@
1
+//
2
+//  AgoraViewManager.m
3
+//  RCTAgora
4
+//
5
+//  Created by 邓博 on 2017/6/30.
6
+//  Copyright © 2017年 Syan. All rights reserved.
7
+//
8
+
9
+#import "RCTAgoraViewManager.h"
10
+#import "RCTAgoraVideoView.h"
11
+
12
+@implementation RCTAgoraViewManager
13
+
14
+RCT_EXPORT_MODULE()
15
+
16
+RCT_EXPORT_VIEW_PROPERTY(localUid, NSInteger)
17
+RCT_EXPORT_VIEW_PROPERTY(remoteUid, NSInteger)
18
+
19
+- (UIView *)view {
20
+
21
+    return [RCTAgoraVideoView new];
22
+}
23
+
24
+
25
+@end

BIN
ios/RCTAgora/libs/AgoraRtcCryptoLoader.framework/AgoraRtcCryptoLoader Dosyayı Görüntüle


+ 52
- 10
ios/RCTAgora/libs/AgoraRtcEngineKit.framework/Headers/AgoraRtcEngineKit.h Dosyayı Görüntüle

@@ -208,6 +208,10 @@ typedef NS_ENUM(NSUInteger, AgoraRtcLogFilter) {
208 208
     AgoraRtc_LogFilter_Critical = 0x0008,
209 209
 };
210 210
 
211
+typedef NS_ENUM(NSInteger, AgoraRtmpStreamLifeCycle) {
212
+    RtmpStream_LifeCycle_Bind2Channel = 1,
213
+    RtmpStream_LifeCycle_Bind2Ownner = 2,
214
+};
211 215
 
212 216
 typedef NS_ENUM(NSUInteger, AgoraRtcRenderMode) {
213 217
     /**
@@ -317,6 +321,8 @@ __attribute__((visibility("default"))) @interface AgoraRtcStats : NSObject
317 321
 @property (assign, nonatomic) NSUInteger txVideoKBitrate;
318 322
 @property (assign, nonatomic) NSUInteger rxVideoKBitrate;
319 323
 @property (assign, nonatomic) NSUInteger users;
324
+@property (assign, nonatomic) double cpuAppUsage;
325
+@property (assign, nonatomic) double cpuTotalUsage;
320 326
 @end
321 327
 
322 328
 __attribute__((visibility("default"))) @interface AgoraRtcLocalVideoStats : NSObject
@@ -358,6 +364,31 @@ __attribute__((visibility("default"))) @interface AgoraRtcVideoCompositingLayout
358 364
 @property (copy, nonatomic) NSString* appData;//app defined data
359 365
 @end
360 366
 
367
+__attribute__((visibility("default"))) @interface AgoraPublisherConfiguration : NSObject
368
+@property (assign, nonatomic) BOOL owner;
369
+@property (assign, nonatomic) NSInteger width;
370
+@property (assign, nonatomic) NSInteger height;
371
+@property (assign, nonatomic) NSInteger framerate;
372
+@property (assign, nonatomic) NSInteger bitrate;
373
+@property (assign, nonatomic) NSInteger defaultLayout;
374
+@property (assign, nonatomic) AgoraRtmpStreamLifeCycle lifeCycle;
375
+@property (copy, nonatomic) NSString* publishUrl;
376
+@property (copy, nonatomic) NSString* rawStreamUrl;
377
+@property (copy, nonatomic) NSString* extraInfo;
378
+-(BOOL) validate;
379
+-(NSString *) toJsonString;
380
+@end
381
+
382
+__attribute__((visibility("default"))) @interface AgoraPublisherConfigurationBuilder : NSObject
383
+- (AgoraPublisherConfigurationBuilder *) setOwner:(BOOL)isOwner;
384
+- (AgoraPublisherConfigurationBuilder *) setWidth:(NSInteger)width height:(NSInteger)height framerate:(NSInteger)framerate bitrate:(NSInteger)bitrate;
385
+- (AgoraPublisherConfigurationBuilder *) setDefaultLayout:(NSInteger)layoutStyle;
386
+- (AgoraPublisherConfigurationBuilder *) setLifeCycle:(AgoraRtmpStreamLifeCycle)lifecycle;
387
+- (AgoraPublisherConfigurationBuilder *) setPublisherUrl:(NSString*)url;
388
+- (AgoraPublisherConfigurationBuilder *) setRawStreamUrl:(NSString*)url;
389
+- (AgoraPublisherConfigurationBuilder *) setExtraInfo:(NSString *)info;
390
+- (AgoraPublisherConfiguration *) build;
391
+@end
361 392
 
362 393
 @class AgoraRtcEngineKit;
363 394
 @protocol AgoraRtcEngineDelegate <NSObject>
@@ -674,6 +705,24 @@ __attribute__((visibility("default"))) @interface AgoraRtcVideoCompositingLayout
674 705
  *  @param engine The engine kit
675 706
  */
676 707
 - (void)rtcEngineRequestChannelKey:(AgoraRtcEngineKit *)engine;
708
+
709
+/**
710
+ *  Event of the first audio frame is sent.
711
+ *
712
+ *  @param engine  The engine kit
713
+ *  @param elapsed The elapsed time(ms) from the beginning of the session.
714
+ */
715
+- (void)rtcEngine:(AgoraRtcEngineKit *)engine firstLocalAudioFrame:(NSInteger)elapsed;
716
+
717
+/**
718
+ *  Event of the first audio frame from remote user is received.
719
+ *
720
+ *  @param engine  The engine kit
721
+ *  @param uid     The remote user id
722
+ *  @param elapsed The elapsed time(ms) from the beginning of the session.
723
+ */
724
+- (void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteAudioFrameOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed;
725
+
677 726
 @end
678 727
 
679 728
 
@@ -978,7 +1027,7 @@ __attribute__((visibility("default"))) @interface AgoraRtcEngineKit : NSObject
978 1027
 - (int)adjustAudioMixingVolume:(NSInteger) volume;
979 1028
 - (int)getAudioMixingDuration;
980 1029
 - (int)getAudioMixingCurrentPosition;
981
-
1030
+- (int)setAudioMixingPosition:(NSInteger) pos;
982 1031
 
983 1032
 /**
984 1033
  *  Start screen capture
@@ -1217,15 +1266,6 @@ __attribute__((visibility("default"))) @interface AgoraRtcEngineKit : NSObject
1217 1266
 - (int) setRemoteVideoStream: (NSUInteger) uid
1218 1267
                         type: (AgoraRtcVideoStreamType) streamType;
1219 1268
 
1220
-/**
1221
- * play the video stream from network
1222
- *
1223
- * @param [in] uri the link of video source
1224
- *
1225
- * @return return 0 if success or an error code
1226
- */
1227
-- (int) startPlayingStream:(NSString*)uri __deprecated;
1228
-- (int) stopPlayingStream __deprecated;
1229 1269
 
1230 1270
 - (int) startRecordingService:(NSString*)recordingKey;
1231 1271
 - (int) stopRecordingService:(NSString*)recordingKey;
@@ -1275,6 +1315,8 @@ __attribute__((visibility("default"))) @interface AgoraRtcEngineKit : NSObject
1275 1315
 
1276 1316
 - (int)setVideoQualityParameters:(BOOL)preferFrameRateOverImageQuality;
1277 1317
 
1318
+- (int)configPublisher:(AgoraPublisherConfiguration *)config;
1319
+
1278 1320
 - (int)setVideoCompositingLayout:(AgoraRtcVideoCompositingLayout*)layout;
1279 1321
 
1280 1322
 - (int)clearVideoCompositingLayout;

+ 68
- 22
ios/RCTAgora/libs/AgoraRtcEngineKit.framework/Headers/IAgoraRtcEngine.h Dosyayı Görüntüle

@@ -123,6 +123,7 @@ enum WARN_CODE_TYPE
123 123
     WARN_ADM_RECORD_AUDIO_SILENCE = 1019,
124 124
     WARN_ADM_PLAYOUT_MALFUNCTION = 1020,
125 125
     WARN_ADM_RECORD_MALFUNCTION = 1021,
126
+    WARN_ADM_RECORD_AUDIO_LOWLEVEL = 1031,
126 127
     WARN_APM_HOWLING = 1051,
127 128
 
128 129
     // sdk: 100~1000
@@ -213,7 +214,7 @@ enum LOG_FILTER_TYPE
213 214
 
214 215
 enum MAX_DEVICE_ID_LENGTH_TYPE
215 216
 {
216
-    MAX_DEVICE_ID_LENGTH = 128
217
+    MAX_DEVICE_ID_LENGTH = 512
217 218
 };
218 219
 
219 220
 enum QUALITY_REPORT_FORMAT_TYPE
@@ -237,7 +238,7 @@ enum MEDIA_ENGINE_EVENT_CODE_TYPE
237 238
     MEDIA_ENGINE_ROLE_COMM_PEER = 23,
238 239
     MEDIA_ENGINE_ROLE_GAME_PEER = 24,
239 240
     // iOS adm sample rate changed
240
-    MEDIA_ENGINE_AUDIO_ADM_SAMPLE_RATE_CHANGE = 110
241
+    MEDIA_ENGINE_AUDIO_ADM_REQUIRE_RESTART = 110
241 242
 };
242 243
 
243 244
 enum MEDIA_DEVICE_STATE_TYPE
@@ -434,6 +435,41 @@ struct VideoCompositingLayout
434 435
     {}
435 436
 };
436 437
 
438
+#if defined(_WIN32)
439
+
440
+enum RTMP_STREAM_LIFE_CYCLE_TYPE
441
+{
442
+	RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL = 1,
443
+	RTMP_STREAM_LIFE_CYCLE_BIND2OWNER = 2,
444
+};
445
+
446
+struct PublisherConfiguration {
447
+	int width;
448
+	int height;
449
+	int framerate;
450
+	int bitrate;
451
+	int defaultLayout;
452
+	int lifecycle;
453
+	bool owner;
454
+	const char* publishUrl;
455
+	const char* rawStreamUrl;
456
+	const char* extraInfo;
457
+
458
+	PublisherConfiguration()
459
+		: width(640)
460
+		, height(360)
461
+		, framerate(15)
462
+		, bitrate(500)
463
+		, defaultLayout(1)
464
+		, lifecycle(RTMP_STREAM_LIFE_CYCLE_BIND2CHANNEL)
465
+		, owner(true)
466
+		, publishUrl(NULL)
467
+		, rawStreamUrl(NULL)
468
+		, extraInfo(NULL)
469
+	{}
470
+
471
+};
472
+#endif
437 473
 #if !defined(__ANDROID__)
438 474
 struct VideoCanvas
439 475
 {
@@ -570,7 +606,7 @@ public:
570 606
     * @param [in] uid
571 607
     *        the uid of the peer
572 608
     * @param [in] quality
573
-    *        the quality of the user 0~5 the higher the better
609
+    *        the quality of the user, see QUALITY_TYPE for value definition
574 610
     * @param [in] delay
575 611
     *        the average time of the audio packages delayed
576 612
     * @param [in] lost
@@ -900,6 +936,28 @@ public:
900 936
     */
901 937
     virtual void onRequestChannelKey() {
902 938
     }
939
+
940
+    /**
941
+    * when the first local audio frame generated, the function will be called
942
+    * @param [in] elapsed
943
+    *        the time elapsed from remote user called joinChannel in ms
944
+    */
945
+    virtual void onFirstLocalAudioFrame(int elapsed) {
946
+        (void)elapsed;
947
+    }
948
+
949
+    /**
950
+    * when the first remote audio frame arrived, the function will be called
951
+    * @param [in] uid
952
+    *        the UID of the remote user
953
+    * @param [in] elapsed
954
+    *        the time elapsed from remote user called joinChannel in ms
955
+    */
956
+    virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) {
957
+        (void)uid;
958
+        (void)elapsed;
959
+    }
960
+
903 961
 };
904 962
 
905 963
 /**
@@ -1339,6 +1397,10 @@ public:
1339 1397
 
1340 1398
     virtual int setVideoCompositingLayout(const VideoCompositingLayout& sei) = 0;
1341 1399
     virtual int clearVideoCompositingLayout() = 0;
1400
+
1401
+#if defined(_WIN32)
1402
+	virtual int configPublisher(const PublisherConfiguration& config) = 0;
1403
+#endif
1342 1404
 };
1343 1405
 
1344 1406
 
@@ -1616,25 +1678,6 @@ public:
1616 1678
         return setObject("rtc.video.set_remote_video_stream", "{\"uid\":%u,\"stream\":%d}", uid, streamType);
1617 1679
     }
1618 1680
 
1619
-
1620
-    /**
1621
-     * play the video stream from network
1622
-     * @param [in] uri the link of video source
1623
-     * @return return 0 if success or an error code
1624
-     */
1625
-    int startPlayingStream(const char* uri) {
1626
-        return m_parameter ? m_parameter->setString("rtc.api.video.start_play_stream", uri) : -ERR_NOT_INITIALIZED;
1627
-    }
1628
-
1629
-    /**
1630
-     *  stop playing the video stream from network
1631
-     *
1632
-     * @return return 0 if success or an error code
1633
-     */
1634
-    int stopPlayingStream() {
1635
-        return m_parameter ? m_parameter->setBool("rtc.api.video.stop_play_stream", true) : -ERR_NOT_INITIALIZED;
1636
-    }
1637
-
1638 1681
     /**
1639 1682
     * set play sound volume
1640 1683
     * @param [in] volume
@@ -1752,6 +1795,9 @@ public:
1752 1795
             r = pos;
1753 1796
         return r;
1754 1797
     }
1798
+    int setAudioMixingPosition(int pos /*in ms*/) {
1799
+        return m_parameter ? m_parameter->setInt("che.audio.mixing.file.position", pos) : -ERR_NOT_INITIALIZED;
1800
+    }
1755 1801
 #if defined(__APPLE__)
1756 1802
 	/**
1757 1803
 	* start screen capture

+ 1
- 1
package.json Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-agora",
3
-  "version": "1.0.4",
3
+  "version": "1.0.5",
4 4
   "description": "声网Agora",
5 5
   "main": "index.js",
6 6
   "scripts": {