@volcengine/react-native-live-push 1.0.2 → 1.1.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/volcengine/velive/rn/push/NativeVariableManager.java +1 -1
  4. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModule.java +5 -3
  5. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushView.java +86 -11
  6. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushViewManager.java +29 -40
  7. package/ios/VeLivePushView.m +1 -1
  8. package/ios/VeLivePushViewManager.m +5 -1
  9. package/lib/commonjs/index.js +21800 -17843
  10. package/lib/module/index.js +21800 -17836
  11. package/lib/typescript/android/index.d.ts +3 -0
  12. package/lib/typescript/codegen/android/api.d.ts +353 -125
  13. package/lib/typescript/codegen/android/callback.d.ts +36 -5
  14. package/lib/typescript/codegen/android/errorcode.d.ts +12 -0
  15. package/lib/typescript/codegen/android/keytype.d.ts +305 -73
  16. package/lib/typescript/codegen/android/types.d.ts +7 -6
  17. package/lib/typescript/codegen/ios/api.d.ts +81 -118
  18. package/lib/typescript/codegen/ios/callback.d.ts +22 -58
  19. package/lib/typescript/codegen/ios/external.d.ts +1 -0
  20. package/lib/typescript/codegen/ios/index.d.ts +1 -0
  21. package/lib/typescript/codegen/ios/keytype.d.ts +40 -98
  22. package/lib/typescript/codegen/ios/types.d.ts +16 -5
  23. package/lib/typescript/codegen/pack/api.d.ts +1261 -1195
  24. package/lib/typescript/codegen/pack/callback.d.ts +166 -270
  25. package/lib/typescript/codegen/pack/errorcode.d.ts +24 -122
  26. package/lib/typescript/codegen/pack/index.d.ts +1 -1
  27. package/lib/typescript/codegen/pack/keytype.d.ts +1095 -1244
  28. package/lib/typescript/codegen/pack/types.d.ts +67 -0
  29. package/lib/typescript/component.d.ts +10 -3
  30. package/lib/typescript/core/api.d.ts +2 -2
  31. package/lib/typescript/core/callback.d.ts +2 -2
  32. package/lib/typescript/core/errorcode.d.ts +2 -2
  33. package/lib/typescript/core/keytype.d.ts +2 -7
  34. package/lib/typescript/platforms/ios/extends.d.ts +17 -0
  35. package/package.json +7 -4
  36. package/react-native-velive-push.podspec +1 -1
package/README.md CHANGED
@@ -1,2 +1,3 @@
1
1
  # 火山引擎直播推流 React Native SDK
2
2
 
3
+ 详见[使用说明](https://www.volcengine.com/docs/6469/1314105)
@@ -87,6 +87,6 @@ dependencies {
87
87
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
88
88
  //noinspection GradleDynamicVersion
89
89
  implementation "com.facebook.react:react-native:+"
90
- implementation "com.volcengine:VolcApiEngine:1.0.3"
90
+ implementation "com.volcengine:VolcApiEngine:1.2.3"
91
91
  implementation 'com.bytedanceapi:ttsdk-ttlivepush_rtc:1.41.3.4'
92
92
  }
@@ -3,7 +3,7 @@ package com.volcengine.velive.rn.push;
3
3
  import androidx.annotation.NonNull;
4
4
 
5
5
  import com.facebook.react.bridge.ReactApplicationContext;
6
- import com.volcengine.VolcApiEngine.runtime.*;
6
+ import com.volcengine.VolcApiEngine.*;
7
7
 
8
8
  public class NativeVariableManager {
9
9
  static void init(@NonNull VolcApiEngine apiEngine, ReactApplicationContext reactContext) {
@@ -3,6 +3,7 @@ package com.volcengine.velive.rn.push;
3
3
  import static com.volcengine.VolcApiEngine.runtime.Util.JsonAbleClass;
4
4
 
5
5
  import android.util.Log;
6
+ import android.view.View;
6
7
 
7
8
  import androidx.annotation.Nullable;
8
9
 
@@ -18,12 +19,13 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
18
19
  import com.ss.avframework.live.VeLivePusherConfiguration;
19
20
  import com.ss.avframework.live.VeLivePusherDef;
20
21
  import com.ss.avframework.live.VeLivePusherObserver;
21
- import com.volcengine.VolcApiEngine.runtime.*;
22
+ import com.ss.avframework.live.statistics.VeLivePusherStatisticsExt;
23
+ import com.volcengine.VolcApiEngine.*;
22
24
  import com.volcengine.VolcApiEngine.view.*;
23
25
 
24
26
  public class VeLivePushModule extends VeLivePushModuleSpec implements IEventReceiver {
25
27
  static {
26
- JsonAbleClass.add(VeLivePusherDef.VeLivePusherStatistics.class);
28
+ JsonAbleClass.add(VeLivePusherStatisticsExt.class);
27
29
  }
28
30
 
29
31
  VolcApiEngine apiEngine = null;
@@ -176,7 +178,7 @@ public class VeLivePushModule extends VeLivePushModuleSpec implements IEventRece
176
178
  }
177
179
  });
178
180
 
179
- mLivePusher.setRenderView(VolcViewManager.getViewById("live-pusher"));
181
+ mLivePusher.setRenderView((View) VolcViewManager.getViewById("live-pusher"));
180
182
  mLivePusher.startVideoCapture(VeLivePusherDef.VeLiveVideoCaptureType.VeLiveVideoCaptureFrontCamera);
181
183
  }
182
184
  }
@@ -1,34 +1,107 @@
1
1
  package com.volcengine.velive.rn.push;
2
2
 
3
- import android.content.Context;
3
+ import android.graphics.SurfaceTexture;
4
4
  import android.util.Log;
5
+ import android.view.SurfaceHolder;
5
6
  import android.view.SurfaceView;
7
+ import android.view.TextureView;
6
8
  import android.view.View;
7
9
  import android.widget.FrameLayout;
8
-
10
+ import androidx.annotation.NonNull;
9
11
  import com.facebook.react.bridge.Arguments;
10
12
  import com.facebook.react.bridge.ReactContext;
11
13
  import com.facebook.react.bridge.WritableMap;
14
+ import com.facebook.react.uimanager.ThemedReactContext;
12
15
  import com.facebook.react.uimanager.events.RCTEventEmitter;
16
+ import com.volcengine.VolcApiEngine.view.VolcViewManager;
13
17
 
14
18
  public class VeLivePushView extends FrameLayout {
15
19
  public String viewId;
20
+ public String viewKind;
16
21
  public boolean hasRegister = false;
17
-
18
- public VeLivePushView(Context context) {
22
+ private final ThemedReactContext themedReactContext;
23
+ private boolean hasLoad = false;
24
+ private View subview;
25
+
26
+ public VeLivePushView(ThemedReactContext context) {
19
27
  super(context);
28
+ this.themedReactContext = context;
20
29
  }
21
-
30
+
22
31
  public void setViewId(String viewId) {
23
- this.viewId = viewId;
32
+ this.viewId = viewId;
24
33
  this.hasRegister = true;
25
34
  this.emitOnLoad();
26
35
  }
27
-
36
+
37
+ public void setViewKind(String viewKind) {
38
+ this.viewKind = viewKind;
39
+ switch (viewKind) {
40
+ case "SurfaceView":
41
+ SurfaceView surfaceView =
42
+ new SurfaceView(themedReactContext.getReactApplicationContext());
43
+ surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
44
+ @Override
45
+ public void surfaceCreated(@NonNull SurfaceHolder holder) {
46
+ hasLoad = true;
47
+ subview = surfaceView;
48
+ VolcViewManager.putViewById(viewId, subview);
49
+ emitOnLoad();
50
+ }
51
+
52
+ @Override
53
+ public void surfaceChanged(@NonNull SurfaceHolder holder, int format,
54
+ int width, int height) {}
55
+
56
+ @Override
57
+ public void surfaceDestroyed(@NonNull SurfaceHolder holder) {}
58
+ });
59
+ this.addView(surfaceView);
60
+ break;
61
+ case "TextureView":
62
+ TextureView textureView =
63
+ new TextureView(themedReactContext.getReactApplicationContext());
64
+ subview = textureView;
65
+ textureView.setSurfaceTextureListener(
66
+ new TextureView.SurfaceTextureListener() {
67
+ @Override
68
+ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
69
+ int width, int height) {
70
+ hasLoad = true;
71
+ VolcViewManager.putViewById(viewId, subview);
72
+ emitOnLoad();
73
+ }
74
+ @Override
75
+ public void onSurfaceTextureSizeChanged(
76
+ SurfaceTexture surfaceTexture, int width, int height) {}
77
+ @Override
78
+ public boolean onSurfaceTextureDestroyed(
79
+ SurfaceTexture surfaceTexture) {
80
+ return true;
81
+ }
82
+ @Override
83
+ public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
84
+ }
85
+ });
86
+ this.addView(textureView);
87
+ break;
88
+ default:
89
+ break;
90
+ }
91
+ }
92
+
93
+ public void resetSurface() {
94
+ if (subview instanceof SurfaceView) {
95
+ SurfaceView surface = (SurfaceView)subview;
96
+ removeView(surface);
97
+ addView(surface);
98
+ }
99
+ }
100
+
28
101
  public void setVisible(Boolean visible) {
29
102
  Log.i("surfaceView", "setVisible");
30
103
  View subview = this.getChildAt(0);
31
- if(visible) {
104
+ if (visible) {
32
105
  subview.setVisibility(View.VISIBLE);
33
106
  } else {
34
107
  subview.setVisibility(View.INVISIBLE);
@@ -36,10 +109,12 @@ public class VeLivePushView extends FrameLayout {
36
109
  }
37
110
 
38
111
  public void emitOnLoad() {
112
+ if (hasLoad) {
113
+ return;
114
+ }
39
115
  WritableMap event = Arguments.createMap();
40
116
  ReactContext reactContext = (ReactContext)getContext();
41
- reactContext
42
- .getJSModule(RCTEventEmitter.class)
43
- .receiveEvent(getId(), "load", event);
117
+ reactContext.getJSModule(RCTEventEmitter.class)
118
+ .receiveEvent(getId(), "load", event);
44
119
  }
45
120
  }
@@ -1,25 +1,20 @@
1
1
  package com.volcengine.velive.rn.push;
2
2
 
3
- import android.view.SurfaceView;
4
- import android.view.View;
5
-
3
+ import android.os.Looper;
6
4
  import androidx.annotation.NonNull;
7
5
  import androidx.annotation.Nullable;
8
-
9
6
  import com.facebook.react.bridge.ReadableArray;
10
7
  import com.facebook.react.common.MapBuilder;
11
8
  import com.facebook.react.uimanager.SimpleViewManager;
12
9
  import com.facebook.react.uimanager.ThemedReactContext;
13
10
  import com.facebook.react.uimanager.annotations.ReactProp;
14
- import com.volcengine.VolcApiEngine.view.*;
15
-
16
11
  import java.util.Map;
17
12
 
18
- public class VeLivePushViewManager extends SimpleViewManager<VeLivePushView> implements VolcViewManagerInterface<VeLivePushView> {
13
+ public class VeLivePushViewManager extends SimpleViewManager<VeLivePushView> {
19
14
  public static final String NAME = "VeLivePushView";
20
-
21
- private ThemedReactContext context;
22
15
 
16
+ private ThemedReactContext context;
17
+
23
18
  @NonNull
24
19
  @Override
25
20
  public String getName() {
@@ -28,60 +23,54 @@ public class VeLivePushViewManager extends SimpleViewManager<VeLivePushView> imp
28
23
 
29
24
  @NonNull
30
25
  @Override
31
- public VeLivePushView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
32
- context = themedReactContext;
33
- return new VeLivePushView(themedReactContext);
26
+ protected VeLivePushView
27
+ createViewInstance(@NonNull ThemedReactContext reactContext) {
28
+ // 确保在主线程创建
29
+ if (Looper.myLooper() != Looper.getMainLooper()) {
30
+ throw new IllegalStateException(
31
+ "View must be created on the main thread");
32
+ }
33
+ context = reactContext;
34
+ return new VeLivePushView(reactContext);
34
35
  }
35
-
36
+
36
37
  @ReactProp(name = "viewId")
37
38
  public void setViewId(VeLivePushView view, String viewId) {
38
39
  view.setViewId(viewId);
39
- VolcViewManager.putViewById(viewId, view);
40
40
  }
41
41
 
42
42
  @ReactProp(name = "kind")
43
43
  public void setKind(VeLivePushView view, String kind) {
44
- var themedReactContext = this.context;
45
-
46
- switch (kind) {
47
- case "SurfaceView" -> {
48
- SurfaceView subView = new SurfaceView(themedReactContext.getReactApplicationContext());
49
- view.addView(subView);
50
- }
51
- case "View" -> {
52
- View subView = new View(themedReactContext.getApplicationContext());
53
- view.addView(subView);
54
- }
55
- }
44
+ view.setViewKind(kind);
56
45
  }
57
-
46
+
58
47
  public void setVisible(VeLivePushView view, Boolean visible) {
59
48
  view.setVisible(visible);
60
49
  }
50
+
51
+ public void resetSurface(VeLivePushView view) {
52
+ view.resetSurface();
53
+ }
61
54
 
62
55
  /**
63
56
  * Handle "create" command (called from JS) and call createFragment method
64
57
  */
65
- public void receiveCommand(
66
- @NonNull VeLivePushView root,
67
- String command,
68
- @Nullable ReadableArray args
69
- ) {
58
+ public void receiveCommand(@NonNull VeLivePushView root, String command,
59
+ @Nullable ReadableArray args) {
70
60
  super.receiveCommand(root, command, args);
71
-
61
+
72
62
  if (command.equals("setVisible")) {
73
63
  assert args != null;
74
64
  setVisible(root, args.getBoolean(0));
65
+ } else if(command.equals("resetSurface")) {
66
+ resetSurface(root);
75
67
  }
76
68
  }
77
69
 
78
70
  public Map getExportedCustomBubblingEventTypeConstants() {
79
- return MapBuilder.builder().put(
80
- "load",
81
- MapBuilder.of(
82
- "phasedRegistrationNames",
83
- MapBuilder.of("bubbled", "onLoad")
84
- )
85
- ).build();
71
+ return MapBuilder.builder()
72
+ .put("load", MapBuilder.of("phasedRegistrationNames",
73
+ MapBuilder.of("bubbled", "onViewLoad")))
74
+ .build();
86
75
  }
87
76
  }
@@ -30,7 +30,7 @@
30
30
  [self emitLoaded];
31
31
  }
32
32
 
33
- - (void) setOnLoad:(RCTBubblingEventBlock)onLoad {
33
+ - (void) setOnViewLoad:(RCTBubblingEventBlock)onLoad {
34
34
  _onLoad = onLoad;
35
35
 
36
36
  [self emitLoaded];
@@ -16,10 +16,14 @@
16
16
 
17
17
  @implementation VeLivePushViewManager
18
18
 
19
+ + (BOOL)requiresMainQueueSetup {
20
+ return YES;
21
+ }
22
+
19
23
  RCT_EXPORT_MODULE(VeLivePushView)
20
24
 
21
25
  // 导出 events
22
- RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTBubblingEventBlock)
26
+ RCT_EXPORT_VIEW_PROPERTY(onViewLoad, RCTBubblingEventBlock)
23
27
 
24
28
  // 导出 events
25
29
  RCT_CUSTOM_VIEW_PROPERTY(viewId, NSString, VeLivePushUIView)