Browse Source

fix. video render mode and release 2.4.0-alpha.5

matrixbirds 5 years ago
parent
commit
3f54f25723

+ 1
- 0
CHANGELOG View File

6
 - support 2.4.0-alpha.2 using 0.55.1 as peerDependency and support typescript
6
 - support 2.4.0-alpha.2 using 0.55.1 as peerDependency and support typescript
7
 - support 2.4.0-alpha.3 bugfix iOS receiveStreamMessage data is null
7
 - support 2.4.0-alpha.3 bugfix iOS receiveStreamMessage data is null
8
 - support 2.4.0-alpha.4 bugfix iOS videoSizeChanged field rotation typo
8
 - support 2.4.0-alpha.4 bugfix iOS videoSizeChanged field rotation typo
9
+- support 2.4.0-alpha.5 bugfix Android & iOS side not support fit mode and hidden mode. Deprecate: setupLocalVideo & setupRemoteVideo
9
 
10
 
10
 #### 2.3.3-alpha
11
 #### 2.3.3-alpha
11
 - support agora video sdk 2.3.3
12
 - support agora video sdk 2.3.3

+ 27
- 11
android/src/main/java/com/syan/agora/AgoraManager.java View File

173
     }
173
     }
174
 
174
 
175
     /**
175
     /**
176
-     * 设置本地视频,即前置摄像头预览
176
+     * setupLocalVideo will render video from local side capture into ui layout
177
      */
177
      */
178
-    public int setupLocalVideo() {
179
-        //创建一个SurfaceView用作视频预览
178
+    public int setupLocalVideo(Integer mode) {
180
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
179
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
181
-        //将SurfaceView保存起来在SparseArray中,后续会将其加入界面。key为视频的用户id,这里是本地视频, 默认id是0
182
-
183
         mSurfaceViews.put(mLocalUid, surfaceView);
180
         mSurfaceViews.put(mLocalUid, surfaceView);
184
-
185
-        //设置本地视频,渲染模式选择VideoCanvas.RENDER_MODE_HIDDEN,如果选其他模式会出现视频不会填充满整个SurfaceView的情况,
186
-        //具体渲染模式参考官方文档https://docs.agora.io/cn/user_guide/API/android_api.html#set-local-video-view-setuplocalvideo
187
-        return mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, mLocalUid));
181
+        return mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, mode, mLocalUid));
188
     }
182
     }
189
 
183
 
190
-    public int setupRemoteVideo(final int uid) {
184
+    /**
185
+     * setupRemoteVideo will render video from remote side capture into ui layout
186
+     */
187
+    public int setupRemoteVideo(final int uid, final Integer mode) {
191
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
188
         SurfaceView surfaceView = RtcEngine.CreateRendererView(context);
192
         mSurfaceViews.put(uid, surfaceView);
189
         mSurfaceViews.put(uid, surfaceView);
193
-        return mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
190
+        return mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, mode, uid));
191
+    }
192
+
193
+    /**
194
+     * set local video render mode
195
+     * @param Integer renderMode
196
+     * @return result state
197
+     */
198
+    public int setLocalRenderMode(final Integer renderMode) {
199
+        return mRtcEngine.setLocalRenderMode(renderMode);
200
+    }
201
+
202
+    /**
203
+     * set remote video render mode
204
+     * @param Integer uid
205
+     * @param Integer renderMode
206
+     * @return result state
207
+     */
208
+    public int setRemoteRenderMode(final Integer uid, final Integer renderMode) {
209
+        return mRtcEngine.setRemoteRenderMode(uid, renderMode);
194
     }
210
     }
195
 
211
 
196
     public int setEnableSpeakerphone(boolean enabled) {
212
     public int setEnableSpeakerphone(boolean enabled) {

+ 0
- 58
android/src/main/java/com/syan/agora/AgoraModule.java View File

1188
         RtcEngine.destroy();
1188
         RtcEngine.destroy();
1189
     }
1189
     }
1190
 
1190
 
1191
-    @ReactMethod
1192
-    public void setupLocalVideo() {
1193
-        try {
1194
-            int res = AgoraManager.getInstance().setupLocalVideo();
1195
-            if (res != 0) throw new ReactNativeAgoraException("setupLocalVideo Failed", res);
1196
-        } catch (Exception e) {
1197
-            WritableMap err = Arguments.createMap();
1198
-            err.putBoolean("success", false);
1199
-            err.putString("message", e.toString());
1200
-            sendEvent(getReactApplicationContext(), "error", err);
1201
-        }
1202
-    }
1203
-
1204
-    @ReactMethod
1205
-    public void setupRemoteVideo(ReadableMap options) {
1206
-        try {
1207
-            int uid = options.getInt("uid");
1208
-            int res = AgoraManager.getInstance().setupRemoteVideo(uid);
1209
-            if (res != 0) throw new ReactNativeAgoraException("setupRemoteVideo Failed", res);
1210
-        } catch(Exception e) {
1211
-            WritableMap err = Arguments.createMap();
1212
-            err.putBoolean("success", false);
1213
-            err.putString("message", e.toString());
1214
-            sendEvent(getReactApplicationContext(), "error", err);
1215
-        }
1216
-    }
1217
-
1218
     @ReactMethod
1191
     @ReactMethod
1219
     public void startPreview() {
1192
     public void startPreview() {
1220
         AgoraManager.getInstance().startPreview();
1193
         AgoraManager.getInstance().startPreview();
1814
         }
1787
         }
1815
     }
1788
     }
1816
 
1789
 
1817
-//  deprecated
1818
-//    @ReactMethod
1819
-//    public void startEchoTest(Promise promise) {
1820
-//        try {
1821
-//            int res = AgoraManager.getInstance().mRtcEngine
1822
-//                    .startEchoTest();
1823
-//            if (res != 0) throw new ReactNativeAgoraException("startEchoTest Failed", res);
1824
-//            WritableMap map = Arguments.createMap();
1825
-//            map.putBoolean("success", true);
1826
-//            map.putInt("value", res);
1827
-//            promise.resolve(map);
1828
-//        } catch (Exception e) {
1829
-//            promise.reject("131009", e);
1830
-//        }
1831
-//    }
1832
-
1833
     @ReactMethod
1790
     @ReactMethod
1834
     public void stopEchoTest(Promise promise) {
1791
     public void stopEchoTest(Promise promise) {
1835
         try {
1792
         try {
2507
         }
2464
         }
2508
     }
2465
     }
2509
 
2466
 
2510
-//    deprecated
2511
-//    @ReactMethod
2512
-//    public void setVideoQualityParameters(boolean quality, Promise promise) {
2513
-//        try {
2514
-//            int res = AgoraManager.getInstance().mRtcEngine.setVideoQualityParameters(quality);
2515
-//            if (res != 0) throw new ReactNativeAgoraException("sendStreamMessage Failed", res);
2516
-//            WritableMap map = Arguments.createMap();
2517
-//            map.putBoolean("success", true);
2518
-//            map.putInt("value", res);
2519
-//            promise.resolve(map);
2520
-//        } catch (Exception e) {
2521
-//            promise.reject(e);
2522
-//        }
2523
-//    }
2524
-
2525
     @ReactMethod
2467
     @ReactMethod
2526
     public void setLocalVideoMirrorMode(int mode, Promise promise) {
2468
     public void setLocalVideoMirrorMode(int mode, Promise promise) {
2527
         try {
2469
         try {

+ 1
- 1
android/src/main/java/com/syan/agora/AgoraPackage.java View File

26
     @Override
26
     @Override
27
     public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
27
     public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
28
         return Arrays.<ViewManager>asList(
28
         return Arrays.<ViewManager>asList(
29
-                new AgoraViewManage()
29
+                new AgoraViewManager()
30
         );
30
         );
31
     }
31
     }
32
 }
32
 }

+ 53
- 0
android/src/main/java/com/syan/agora/AgoraVideoView.java View File

2
 
2
 
3
 import android.content.Context;
3
 import android.content.Context;
4
 import android.util.AttributeSet;
4
 import android.util.AttributeSet;
5
+import android.view.SurfaceView;
6
+import android.view.View;
5
 import android.widget.LinearLayout;
7
 import android.widget.LinearLayout;
6
 
8
 
9
+import io.agora.rtc.mediaio.AgoraSurfaceView;
10
+
7
 /**
11
 /**
8
  * Created by DB on 2017/6/27.
12
  * Created by DB on 2017/6/27.
9
  */
13
  */
10
 
14
 
11
 public class AgoraVideoView extends LinearLayout {
15
 public class AgoraVideoView extends LinearLayout {
16
+    public boolean isShowLocalVideo() {
17
+        return showLocalVideo;
18
+    }
19
+
20
+    public void setShowLocalVideo(boolean showLocalVideo) {
21
+        this.showLocalVideo = showLocalVideo;
22
+    }
23
+
24
+    public Integer getRenderMode() {
25
+        return renderMode;
26
+    }
27
+
28
+    public void setRenderMode(Integer renderMode) {
29
+        this.renderMode = renderMode;
30
+
31
+    }
32
+
33
+    public Integer getRemoteUid() {
34
+        return remoteUid;
35
+    }
36
+
37
+    public void setRemoteUid(Integer remoteUid) {
38
+        this.remoteUid = remoteUid;
39
+    }
40
+
41
+    public boolean getZOrderMediaOverlay() {
42
+        return zOrderMediaOverlay;
43
+    }
44
+
45
+    public void setZOrderMediaOverlay(boolean zOrderMediaOverlay) {
46
+        this.zOrderMediaOverlay = zOrderMediaOverlay;
47
+    }
48
+
49
+    private boolean showLocalVideo;
50
+    private Integer renderMode = 1;
51
+    private Integer remoteUid;
52
+    private boolean zOrderMediaOverlay;
53
+    private SurfaceView surfaceView;
12
 
54
 
13
     public AgoraVideoView(Context context) {
55
     public AgoraVideoView(Context context) {
14
         super(context);
56
         super(context);
22
     public AgoraVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
64
     public AgoraVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
23
         super(context, attrs, defStyleAttr);
65
         super(context, attrs, defStyleAttr);
24
     }
66
     }
67
+
68
+    protected void onVisibilityChanged(View changedView, int visibility) {
69
+        super.onVisibilityChanged(changedView, visibility);
70
+        if (changedView == this) {
71
+            if (null != remoteUid) {
72
+                AgoraManager.getInstance().setRemoteRenderMode(remoteUid, renderMode);
73
+            } else {
74
+                AgoraManager.getInstance().setLocalRenderMode(renderMode);
75
+            }
76
+        }
77
+    }
25
 }
78
 }

+ 0
- 53
android/src/main/java/com/syan/agora/AgoraViewManage.java View File

1
-package com.syan.agora;
2
-
3
-import android.view.SurfaceView;
4
-
5
-import com.facebook.react.uimanager.SimpleViewManager;
6
-import com.facebook.react.uimanager.ThemedReactContext;
7
-import com.facebook.react.uimanager.annotations.ReactProp;
8
-
9
-/**
10
- * Created by DB on 2017/6/23.
11
- */
12
-
13
-public class AgoraViewManage extends SimpleViewManager<AgoraVideoView> {
14
-
15
-    public static final String REACT_CLASS = "RCTAgoraView";
16
-
17
-    public SurfaceView surfaceView;
18
-
19
-    @Override
20
-    public String getName() {
21
-        return REACT_CLASS;
22
-    }
23
-
24
-    @Override
25
-    protected AgoraVideoView createViewInstance(ThemedReactContext reactContext) {
26
-        return new AgoraVideoView(reactContext);
27
-    }
28
-
29
-    @ReactProp(name = "showLocalVideo")
30
-    public void setShowLocalVideo(final AgoraVideoView agoraVideoView, boolean showLocalVideo) {
31
-
32
-        AgoraManager.getInstance().setupLocalVideo();
33
-        surfaceView = AgoraManager.getInstance().getLocalSurfaceView();
34
-        //surfaceView.setVisibility(View.VISIBLE);
35
-        agoraVideoView.addView(surfaceView);
36
-//        surfaceView.setZOrderMediaOverlay(true);
37
-
38
-    }
39
-
40
-    @ReactProp(name = "zOrderMediaOverlay")
41
-    public void setZOrderMediaOverlay(final AgoraVideoView agoraVideoView, boolean zOrderMediaOverlay) {
42
-        surfaceView.setZOrderMediaOverlay(zOrderMediaOverlay);
43
-    }
44
-
45
-    @ReactProp(name = "remoteUid")
46
-    public void setRemoteUid(final AgoraVideoView agoraVideoView, final int remoteUid) {
47
-        AgoraManager.getInstance().setupRemoteVideo(remoteUid);
48
-        surfaceView = AgoraManager.getInstance().getSurfaceView(remoteUid);
49
-        //surfaceView.setVisibility(View.VISIBLE);
50
-        agoraVideoView.addView(surfaceView);
51
-//        surfaceView.setZOrderMediaOverlay(true);
52
-    }
53
-}

+ 61
- 0
android/src/main/java/com/syan/agora/AgoraViewManager.java View File

1
+package com.syan.agora;
2
+
3
+import android.view.SurfaceView;
4
+
5
+import com.facebook.react.uimanager.SimpleViewManager;
6
+import com.facebook.react.uimanager.ThemedReactContext;
7
+import com.facebook.react.uimanager.annotations.ReactProp;
8
+
9
+/**
10
+ * Created by DB on 2017/6/23.
11
+ */
12
+
13
+public class AgoraViewManager extends SimpleViewManager<AgoraVideoView> {
14
+
15
+    public static final String REACT_CLASS = "RCTAgoraVideoView";
16
+
17
+    public SurfaceView surfaceView;
18
+
19
+    @Override
20
+    public String getName() {
21
+        return REACT_CLASS;
22
+    }
23
+
24
+    @Override
25
+    protected AgoraVideoView createViewInstance(ThemedReactContext reactContext) {
26
+        return new AgoraVideoView(reactContext);
27
+    }
28
+
29
+    @ReactProp(name = "mode")
30
+    public void setRenderMode(final AgoraVideoView agoraVideoView, Integer renderMode) {
31
+        agoraVideoView.setRenderMode(renderMode);
32
+    }
33
+
34
+    @ReactProp(name = "showLocalVideo")
35
+    public void setShowLocalVideo(final AgoraVideoView agoraVideoView, boolean showLocalVideo) {
36
+        agoraVideoView.setShowLocalVideo(showLocalVideo);
37
+        if (showLocalVideo) {
38
+            AgoraManager.getInstance().setupLocalVideo(agoraVideoView.getRenderMode());
39
+            surfaceView = AgoraManager.getInstance().getLocalSurfaceView();
40
+            surfaceView.setZOrderMediaOverlay(agoraVideoView.getZOrderMediaOverlay());
41
+            agoraVideoView.addView(surfaceView);
42
+        }
43
+    }
44
+
45
+    @ReactProp(name = "zOrderMediaOverlay")
46
+    public void setZOrderMediaOverlay(final AgoraVideoView agoraVideoView, boolean zOrderMediaOverlay) {
47
+        surfaceView.setZOrderMediaOverlay(zOrderMediaOverlay);
48
+    }
49
+
50
+    @ReactProp(name = "remoteUid")
51
+    public void setRemoteUid(final AgoraVideoView agoraVideoView, final int remoteUid) {
52
+        agoraVideoView.setRemoteUid(remoteUid);
53
+        if (remoteUid > 0) {
54
+            AgoraManager.getInstance().setupRemoteVideo(remoteUid, agoraVideoView.getRenderMode());
55
+            surfaceView = AgoraManager.getInstance().getSurfaceView(remoteUid);
56
+            surfaceView.setZOrderMediaOverlay(agoraVideoView.getZOrderMediaOverlay());
57
+            agoraVideoView.addView(surfaceView);
58
+        }
59
+    }
60
+
61
+}

+ 0
- 39
ios/RCTAgora/RCTAgora.m View File

146
 // init
146
 // init
147
 RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
147
 RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
148
   [self startObserving];
148
   [self startObserving];
149
-  NSLog(@"startObserving events");
150
   [AgoraConst share].appid = options[@"appid"];
149
   [AgoraConst share].appid = options[@"appid"];
151
   
150
   
152
   self.rtcEngine = [AgoraRtcEngineKit sharedEngineWithAppId:options[@"appid"] delegate:self];
151
   self.rtcEngine = [AgoraRtcEngineKit sharedEngineWithAppId:options[@"appid"] delegate:self];
313
   [AgoraRtcEngineKit destroy];
312
   [AgoraRtcEngineKit destroy];
314
 }
313
 }
315
 
314
 
316
-// set local video canvas
317
-RCT_EXPORT_METHOD(setupLocalVideo:(NSDictionary *)options){
318
-  AgoraRtcVideoCanvas *canvas = [AgoraRtcVideoCanvas new];
319
-  canvas.uid = [AgoraConst share].localUid;
320
-  canvas.view = [self.bridge.uiManager viewForReactTag:options[@"reactTag"]];
321
-  canvas.renderMode = [options[@"renderMode"] integerValue];
322
-  [self.rtcEngine setupLocalVideo:canvas];
323
-}
324
-
325
-// set remote video canvas
326
-RCT_EXPORT_METHOD(setupRemoteVideo:(NSDictionary *) options) {
327
-  AgoraRtcVideoCanvas *canvas = [AgoraRtcVideoCanvas new];
328
-  canvas.uid = [options[@"uid"] integerValue];
329
-  canvas.view = [self.bridge.uiManager viewForReactTag:options[@"reactTag"]];
330
-  canvas.renderMode = [options[@"renderMode"] integerValue];
331
-  [self.rtcEngine setupRemoteVideo:canvas];
332
-}
333
-
334
 // set local video render mode
315
 // set local video render mode
335
 RCT_EXPORT_METHOD(setLocalRenderMode:(NSInteger) mode) {
316
 RCT_EXPORT_METHOD(setLocalRenderMode:(NSInteger) mode) {
336
   [self.rtcEngine setLocalRenderMode:mode];
317
   [self.rtcEngine setLocalRenderMode:mode];
1391
   }
1372
   }
1392
 }
1373
 }
1393
 
1374
 
1394
-// deprecated
1395
-// set video quality
1396
-//RCT_EXPORT_METHOD(setVideoQualityParameters
1397
-//                  :(BOOL) quality
1398
-//                  resolve:(RCTPromiseResolveBlock)resolve
1399
-//                  reject:(RCTPromiseRejectBlock)reject) {
1400
-//  NSInteger res = [self.rtcEngine setVideoQualityParameters:quality];
1401
-//  if (res == 0) {
1402
-//    resolve(@{@"success": @(YES)});
1403
-//  } else {
1404
-//    reject(@"131033", @"setVideoQualityParameters failed", [self makeNSError:@{
1405
-//                                                                               @"code": @(131033),
1406
-//                                                                               @"message":@{
1407
-//                                                                                   @"success": @(NO),
1408
-//                                                                                   @"value":[NSNumber numberWithInteger:res]
1409
-//                                                                                   }
1410
-//                                                                               }]);
1411
-//  }
1412
-//}
1413
-
1414
 // set local video mirror mode
1375
 // set local video mirror mode
1415
 RCT_EXPORT_METHOD(setLocalVideoMirrorMode
1376
 RCT_EXPORT_METHOD(setLocalVideoMirrorMode
1416
                   :(NSInteger) mode
1377
                   :(NSInteger) mode

+ 1
- 1
ios/RCTAgora/RCTAgoraVideoView.h View File

12
 @interface RCTAgoraVideoView : UIView
12
 @interface RCTAgoraVideoView : UIView
13
 
13
 
14
 @property (strong, nonatomic) AgoraRtcEngineKit *rtcEngine;
14
 @property (strong, nonatomic) AgoraRtcEngineKit *rtcEngine;
15
-
16
 @property (nonatomic) BOOL showLocalVideo;
15
 @property (nonatomic) BOOL showLocalVideo;
17
 @property (nonatomic) NSInteger remoteUid;
16
 @property (nonatomic) NSInteger remoteUid;
17
+@property (nonatomic) NSInteger renderMode;
18
 
18
 
19
 @end
19
 @end

+ 25
- 7
ios/RCTAgora/RCTAgoraVideoView.m View File

7
 //
7
 //
8
 
8
 
9
 #import "RCTAgoraVideoView.h"
9
 #import "RCTAgoraVideoView.h"
10
+#import <React/RCTBridgeModule.h>
10
 
11
 
11
 @implementation RCTAgoraVideoView
12
 @implementation RCTAgoraVideoView
12
 
13
 
14
   
15
   
15
   if (self == [super init]) {
16
   if (self == [super init]) {
16
     _rtcEngine = [AgoraConst share].rtcEngine;
17
     _rtcEngine = [AgoraConst share].rtcEngine;
18
+    _renderMode = AgoraVideoRenderModeHidden;
17
   }
19
   }
18
   
20
   
19
   return self;
21
   return self;
20
 }
22
 }
21
 
23
 
24
+- (void)setRenderMode:(NSInteger)renderMode {
25
+  _renderMode = renderMode;
26
+}
27
+
22
 - (void)setShowLocalVideo:(BOOL)showLocalVideo {
28
 - (void)setShowLocalVideo:(BOOL)showLocalVideo {
23
-  if (showLocalVideo) {
24
-    AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
29
+  _showLocalVideo = showLocalVideo;
30
+  AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
31
+  if (_showLocalVideo) {
25
     canvas.uid = [AgoraConst share].localUid;
32
     canvas.uid = [AgoraConst share].localUid;
26
     canvas.view = self;
33
     canvas.view = self;
27
-    canvas.renderMode = AgoraVideoRenderModeHidden;
34
+    canvas.renderMode = _renderMode;
28
     [_rtcEngine setupLocalVideo:canvas];
35
     [_rtcEngine setupLocalVideo:canvas];
29
   }
36
   }
30
 }
37
 }
31
 
38
 
32
 -(void)setRemoteUid:(NSInteger)remoteUid {
39
 -(void)setRemoteUid:(NSInteger)remoteUid {
33
-  if (remoteUid > 0) {
34
-    AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
35
-    canvas.uid = remoteUid;
40
+  _remoteUid = remoteUid;
41
+  AgoraRtcVideoCanvas *canvas = [[AgoraRtcVideoCanvas alloc] init];
42
+  if (_remoteUid > 0) {
43
+    canvas.uid = _remoteUid;
36
     canvas.view = self;
44
     canvas.view = self;
37
-    canvas.renderMode = AgoraVideoRenderModeHidden;
45
+    canvas.renderMode = _renderMode;
38
     [_rtcEngine setupRemoteVideo:canvas];
46
     [_rtcEngine setupRemoteVideo:canvas];
47
+    return;
48
+  }
49
+}
50
+
51
+-(void) willMoveToSuperview:(UIView *)newSuperview {
52
+  [super willMoveToSuperview:newSuperview];
53
+  if (_remoteUid > 0) {
54
+    [_rtcEngine setRemoteRenderMode:_remoteUid mode:_renderMode];
55
+  } else {
56
+    [_rtcEngine setLocalRenderMode:_renderMode];
39
   }
57
   }
40
 }
58
 }
41
 
59
 

+ 12
- 3
ios/RCTAgora/RCTAgoraViewManager.m View File

11
 
11
 
12
 @implementation RCTAgoraViewManager
12
 @implementation RCTAgoraViewManager
13
 
13
 
14
-RCT_EXPORT_MODULE()
14
+RCT_EXPORT_MODULE(RCTAgoraVideoView)
15
 
15
 
16
-RCT_EXPORT_VIEW_PROPERTY(showLocalVideo, BOOL)
17
-RCT_EXPORT_VIEW_PROPERTY(remoteUid, NSInteger)
16
+RCT_CUSTOM_VIEW_PROPERTY(mode, NSInteger, RCTAgoraVideoView) {
17
+  view.renderMode = [RCTConvert NSInteger:json];
18
+}
19
+
20
+RCT_CUSTOM_VIEW_PROPERTY(showLocalVideo, BOOL, RCTAgoraVideoView) {
21
+  view.showLocalVideo = [RCTConvert BOOL:json];
22
+}
23
+
24
+RCT_CUSTOM_VIEW_PROPERTY(remoteUid, NSInteger, RCTAgoraVideoView) {
25
+  view.remoteUid = [RCTConvert NSInteger:json];
26
+}
18
 
27
 
19
 - (UIView *)view {
28
 - (UIView *)view {
20
   return [RCTAgoraVideoView new];
29
   return [RCTAgoraVideoView new];

+ 6
- 0
lib/AgoraView.native.d.ts View File

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

+ 7
- 1
lib/AgoraView.native.js View File

8
  *
8
  *
9
  * This @object is used to bridge native layer between react layer.
9
  * This @object is used to bridge native layer between react layer.
10
  */
10
  */
11
-const RCTAgoraView = react_native_1.requireNativeComponent("RCTAgoraView");
11
+const RCTAgoraView = react_native_1.requireNativeComponent("RCTAgoraVideoView");
12
 /**
12
 /**
13
  * AgoraView is the render layer for rendering video stream
13
  * AgoraView is the render layer for rendering video stream
14
  *
14
  *
15
  * This class is used to rendering native sdk stream
15
  * This class is used to rendering native sdk stream
16
  *
16
  *
17
  * @props {@link AgoraViewProps}
17
  * @props {@link AgoraViewProps}
18
+ *
19
+ * @descrption AgoraViewProps has four properties.
20
+ * @property number: mode, this property will setup video render mode. there is two avaliable mode {hidden: 1, fit: 2}, you could see more details [https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673](#here)
21
+ * @property boolean: showLocalVideo, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
22
+ * @property number: remoteUid, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
23
+ * @property boolean: zOrderMediaOverlay, this property will working for android side and it likes zIndex behaviour on web side.
18
  */
24
  */
19
 class AgoraView extends react_1.default.Component {
25
 class AgoraView extends react_1.default.Component {
20
     /**
26
     /**

+ 1
- 1
lib/AgoraView.native.js.map View File

1
-{"version":3,"file":"AgoraView.native.js","sourceRoot":"","sources":["../src/AgoraView.native.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,+CAEqB;AAMrB;;;;GAIG;AAEH,MAAM,YAAY,GAAG,qCAAsB,CAAC,cAAc,CAAC,CAAC;AAE5D;;;;;;GAMG;AACH,MAAqB,SAAU,SAAQ,eAAK,CAAC,SAAyB;IAClE;;;;OAIG;IACI,MAAM;QACT,OAAO,CACH,8BAAC,YAAY,oBAAM,IAAI,CAAC,YAAY,EAAE,EAAK,CAC9C,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,YAAY;QAChB,IAAI,SAAS,GAAG,EAAoB,CAAC;QACrC,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YACxB,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAxBD,4BAwBC"}
1
+{"version":3,"file":"AgoraView.native.js","sourceRoot":"","sources":["../src/AgoraView.native.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,+CAEqB;AAMrB;;;;GAIG;AAEH,MAAM,YAAY,GAAG,qCAAsB,CAAC,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAqB,SAAU,SAAQ,eAAK,CAAC,SAAyB;IAClE;;;;OAIG;IACI,MAAM;QACT,OAAO,CACH,8BAAC,YAAY,oBAAM,IAAI,CAAC,YAAY,EAAE,EAAK,CAC9C,CAAA;IACL,CAAC;IAED;;;;OAIG;IACK,YAAY;QAChB,IAAI,SAAS,GAAG,EAAoB,CAAC;QACrC,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;YACxB,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAxBD,4BAwBC"}

+ 13
- 27
lib/RtcEngine.native.d.ts View File

1
-import { Option, Callback, VideoOption, AudioMixingOption, DataStreamOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration } from "./types";
1
+import { Option, Callback, AudioMixingOption, DataStreamOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration } from "./types";
2
 /**
2
 /**
3
  * RtcEngine is the javascript object for control agora native sdk through react native bridge.
3
  * RtcEngine is the javascript object for control agora native sdk through react native bridge.
4
  *
4
  *
98
      * @returns Promise<{success, value}>
98
      * @returns Promise<{success, value}>
99
      */
99
      */
100
     static destroy(): Promise<any>;
100
     static destroy(): Promise<any>;
101
-    /**
102
-     * show local video
103
-     *
104
-     * This method calls native sdk render canvas for local video.
105
-     * @param options {@link VideoOption}
106
-     */
107
-    static setupLocalVideo(options: VideoOption): void;
108
-    /**
109
-     * show remote video
110
-     *
111
-     * This method calls native sdk render canvas for remote video.
112
-     * @param options {@link VideoOption}
113
-     */
114
-    static setupRemoteVideo(options: VideoOption): void;
115
     /**
101
     /**
116
      * set local video render mode
102
      * set local video render mode
117
      *
103
      *
513
      */
499
      */
514
     static setAudioSessionOperationRestriction(): void;
500
     static setAudioSessionOperationRestriction(): void;
515
     /**
501
     /**
516
-     * @deprecated
517
-     * start echo test
518
-     *
519
-     * This method launches an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly.
520
-     * @returns Promise<{success, value}>
502
+     * @deprecated startEchoTest
503
+     * startEchoTest
521
      */
504
      */
522
     /**
505
     /**
523
      * stop echo test
506
      * stop echo test
650
      */
633
      */
651
     static removeInjectStreamUrl(options: RemoveInjectStreamOption): Promise<any>;
634
     static removeInjectStreamUrl(options: RemoveInjectStreamOption): Promise<any>;
652
     /**
635
     /**
653
-     * @deprecated
654
-     * set video quality
655
-     *
656
-     * This method sets the preferences for the video quality. (Live broadcast only).
657
-     *
658
-     * @param quality boolean
659
-     * @returns Promise<{success, value}>
636
+     * @deprecated setupLocalVideo
637
+     * setupLocalVideo
638
+     */
639
+    /**
640
+     * @deprecated setupRemoteVideo
641
+     * setupRemoteVideo
642
+     */
643
+    /**
644
+     * @deprecated setVideoQualityParameters
645
+     * setVideoQualityParameters
660
      */
646
      */
661
     /**
647
     /**
662
      * set local video mirror mode
648
      * set local video mirror mode

+ 12
- 36
lib/RtcEngine.native.js View File

128
     static destroy() {
128
     static destroy() {
129
         return Agora.destroy();
129
         return Agora.destroy();
130
     }
130
     }
131
-    /**
132
-     * show local video
133
-     *
134
-     * This method calls native sdk render canvas for local video.
135
-     * @param options {@link VideoOption}
136
-     */
137
-    static setupLocalVideo(options) {
138
-        Agora.setupLocalVideo(options);
139
-    }
140
-    /**
141
-     * show remote video
142
-     *
143
-     * This method calls native sdk render canvas for remote video.
144
-     * @param options {@link VideoOption}
145
-     */
146
-    static setupRemoteVideo(options) {
147
-        Agora.setupRemoteVideo(options);
148
-    }
149
     /**
131
     /**
150
      * set local video render mode
132
      * set local video render mode
151
      *
133
      *
659
         Agora.setAudioSessionOperationRestriction();
641
         Agora.setAudioSessionOperationRestriction();
660
     }
642
     }
661
     /**
643
     /**
662
-     * @deprecated
663
-     * start echo test
664
-     *
665
-     * This method launches an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly.
666
-     * @returns Promise<{success, value}>
644
+     * @deprecated startEchoTest
645
+     * startEchoTest
667
      */
646
      */
668
-    // public static startEchoTest(): Promise<any> {
669
-    //     return Agora.startEchoTest();
670
-    // }
671
     /**
647
     /**
672
      * stop echo test
648
      * stop echo test
673
      *
649
      *
829
         return Agora.removeInjectStreamUrl(options);
805
         return Agora.removeInjectStreamUrl(options);
830
     }
806
     }
831
     /**
807
     /**
832
-     * @deprecated
833
-     * set video quality
834
-     *
835
-     * This method sets the preferences for the video quality. (Live broadcast only).
836
-     *
837
-     * @param quality boolean
838
-     * @returns Promise<{success, value}>
808
+     * @deprecated setupLocalVideo
809
+     * setupLocalVideo
810
+     */
811
+    /**
812
+     * @deprecated setupRemoteVideo
813
+     * setupRemoteVideo
814
+     */
815
+    /**
816
+     * @deprecated setVideoQualityParameters
817
+     * setVideoQualityParameters
839
      */
818
      */
840
-    // public static setVideoQualityParameters(quality: boolean): Promise<any> {
841
-    //     return Agora.setVideoQualityParameters(quality);
842
-    // }
843
     /**
819
     /**
844
      * set local video mirror mode
820
      * set local video mirror mode
845
      *
821
      *

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


+ 1
- 0
lib/types.d.ts View File

122
 export declare type String = Nullable<string>;
122
 export declare type String = Nullable<string>;
123
 export declare type Number = Nullable<number> | 0;
123
 export declare type Number = Nullable<number> | 0;
124
 export interface AgoraViewProps extends ViewProps {
124
 export interface AgoraViewProps extends ViewProps {
125
+    mode: number;
125
     showLocalVideo: boolean;
126
     showLocalVideo: boolean;
126
     remoteUid: number;
127
     remoteUid: number;
127
     zOrderMediaOverlay: boolean;
128
     zOrderMediaOverlay: boolean;

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "react-native-agora",
2
   "name": "react-native-agora",
3
-  "version": "2.4.0-alpha.4",
3
+  "version": "2.4.0-alpha.5",
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

25
   #
25
   #
26
 
26
 
27
   s.platform     = :ios
27
   s.platform     = :ios
28
-  # s.platform     = :ios, "5.0"
28
+  s.platform     = :ios, "5.0"
29
 
29
 
30
   #  When using multiple platforms
30
   #  When using multiple platforms
31
   # s.ios.deployment_target = "5.0"
31
   # s.ios.deployment_target = "5.0"

+ 7
- 1
src/AgoraView.native.tsx View File

13
  * This @object is used to bridge native layer between react layer.
13
  * This @object is used to bridge native layer between react layer.
14
  */
14
  */
15
 
15
 
16
-const RCTAgoraView = requireNativeComponent("RCTAgoraView");
16
+const RCTAgoraView = requireNativeComponent("RCTAgoraVideoView");
17
 
17
 
18
 /**
18
 /**
19
  * AgoraView is the render layer for rendering video stream
19
  * AgoraView is the render layer for rendering video stream
21
  * This class is used to rendering native sdk stream
21
  * This class is used to rendering native sdk stream
22
  *
22
  *
23
  * @props {@link AgoraViewProps}
23
  * @props {@link AgoraViewProps}
24
+ * 
25
+ * @descrption AgoraViewProps has four properties.
26
+ * @property number: mode, this property will setup video render mode. there is two avaliable mode {hidden: 1, fit: 2}, you could see more details [https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_rtc_engine.html#ac08882c4d0ec47b329900df169493673](#here)
27
+ * @property boolean: showLocalVideo, this property will render local video, NOTICE: IF YOU SET showLocalVideo YOU CANNOT SET remoteUid
28
+ * @property number: remoteUid, this property will render video with remote uid, NOTICE: IF YOU SET remoteUid YOU CANNOT SET showLocalVideo
29
+ * @property boolean: zOrderMediaOverlay, this property will working for android side and it likes zIndex behaviour on web side.
24
  */
30
  */
25
 export default class AgoraView extends React.Component<AgoraViewProps> {
31
 export default class AgoraView extends React.Component<AgoraViewProps> {
26
     /**
32
     /**

+ 16
- 39
src/RtcEngine.native.ts View File

170
         return Agora.destroy();
170
         return Agora.destroy();
171
     }
171
     }
172
 
172
 
173
-    /**
174
-     * show local video
175
-     *
176
-     * This method calls native sdk render canvas for local video.
177
-     * @param options {@link VideoOption}
178
-     */
179
-
180
-    public static setupLocalVideo(options: VideoOption) {
181
-        Agora.setupLocalVideo(options);
182
-    }
183
-
184
-    /**
185
-     * show remote video
186
-     *
187
-     * This method calls native sdk render canvas for remote video.
188
-     * @param options {@link VideoOption}
189
-     */
190
-    public static setupRemoteVideo(options: VideoOption) {
191
-        Agora.setupRemoteVideo(options);
192
-    }
193
-
194
     /**
173
     /**
195
      * set local video render mode
174
      * set local video render mode
196
      *
175
      *
760
      }
739
      }
761
 
740
 
762
     /**
741
     /**
763
-     * @deprecated
764
-     * start echo test
765
-     *
766
-     * This method launches an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly.
767
-     * @returns Promise<{success, value}>
742
+     * @deprecated startEchoTest
743
+     * startEchoTest
768
      */
744
      */
769
-    // public static startEchoTest(): Promise<any> {
770
-    //     return Agora.startEchoTest();
771
-    // }
745
+
772
 
746
 
773
     /**
747
     /**
774
      * stop echo test
748
      * stop echo test
946
     }
920
     }
947
 
921
 
948
     /**
922
     /**
949
-     * @deprecated
950
-     * set video quality
951
-     *
952
-     * This method sets the preferences for the video quality. (Live broadcast only).
953
-     *
954
-     * @param quality boolean
955
-     * @returns Promise<{success, value}>
923
+     * @deprecated setupLocalVideo
924
+     * setupLocalVideo 
925
+     */
926
+
927
+    /**
928
+     * @deprecated setupRemoteVideo
929
+     * setupRemoteVideo 
930
+     */
931
+
932
+
933
+    /**
934
+     * @deprecated setVideoQualityParameters
935
+     * setVideoQualityParameters
956
      */
936
      */
957
-    // public static setVideoQualityParameters(quality: boolean): Promise<any> {
958
-    //     return Agora.setVideoQualityParameters(quality);
959
-    // }
960
 
937
 
961
     /**
938
     /**
962
      * set local video mirror mode
939
      * set local video mirror mode

+ 1
- 0
src/types.ts View File

139
 export type Number = Nullable<number> | 0;
139
 export type Number = Nullable<number> | 0;
140
 
140
 
141
 export interface AgoraViewProps extends ViewProps {
141
 export interface AgoraViewProps extends ViewProps {
142
+  mode: number,
142
   showLocalVideo: boolean,
143
   showLocalVideo: boolean,
143
   remoteUid: number,
144
   remoteUid: number,
144
   zOrderMediaOverlay: boolean,
145
   zOrderMediaOverlay: boolean,