@byteplus/react-native-live-pull 1.0.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/android/build.gradle +93 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +9 -0
  6. package/android/src/main/AndroidManifestNew.xml +8 -0
  7. package/android/src/main/java/com/volcengine/velive/rn/pull/NativeVariableManager.java +15 -0
  8. package/android/src/main/java/com/volcengine/velive/rn/pull/VolcLiveModule.java +108 -0
  9. package/android/src/main/java/com/volcengine/velive/rn/pull/VolcLiveModuleSpec.java +17 -0
  10. package/android/src/main/java/com/volcengine/velive/rn/pull/VolcLivePackage.java +27 -0
  11. package/android/src/main/java/com/volcengine/velive/rn/pull/VolcView.java +32 -0
  12. package/android/src/main/java/com/volcengine/velive/rn/pull/VolcViewManager.java +87 -0
  13. package/android/src/main/java/com/volcengine/velive/rn/pull/autogen/MethodSignature.java +129 -0
  14. package/ios/VeLivePullSDK.h +24 -0
  15. package/ios/VeLivePullSDK.m +91 -0
  16. package/ios/VeLivePullView.h +25 -0
  17. package/ios/VeLivePullView.m +74 -0
  18. package/ios/VeLivePullViewManager.m +59 -0
  19. package/lib/commonjs/index.js +10697 -0
  20. package/lib/module/index.js +10684 -0
  21. package/lib/typescript/codegen/android/api.d.ts +61 -0
  22. package/lib/typescript/codegen/android/callback.d.ts +40 -0
  23. package/lib/typescript/codegen/android/errorcode.d.ts +53 -0
  24. package/lib/typescript/codegen/android/index.d.ts +5 -0
  25. package/lib/typescript/codegen/android/keytype.d.ts +263 -0
  26. package/lib/typescript/codegen/android/types.d.ts +30 -0
  27. package/lib/typescript/codegen/ios/api.d.ts +81 -0
  28. package/lib/typescript/codegen/ios/callback.d.ts +44 -0
  29. package/lib/typescript/codegen/ios/errorcode.d.ts +56 -0
  30. package/lib/typescript/codegen/ios/index.d.ts +5 -0
  31. package/lib/typescript/codegen/ios/keytype.d.ts +271 -0
  32. package/lib/typescript/codegen/ios/types.d.ts +35 -0
  33. package/lib/typescript/codegen/pack/api.d.ts +381 -0
  34. package/lib/typescript/codegen/pack/callback.d.ts +217 -0
  35. package/lib/typescript/codegen/pack/errorcode.d.ts +150 -0
  36. package/lib/typescript/codegen/pack/index.d.ts +5 -0
  37. package/lib/typescript/codegen/pack/keytype.d.ts +931 -0
  38. package/lib/typescript/codegen/pack/types.d.ts +1 -0
  39. package/lib/typescript/component.d.ts +8 -0
  40. package/lib/typescript/core/api.d.ts +1 -0
  41. package/lib/typescript/core/callback.d.ts +1 -0
  42. package/lib/typescript/core/env.d.ts +38 -0
  43. package/lib/typescript/core/errorcode.d.ts +1 -0
  44. package/lib/typescript/core/index.d.ts +6 -0
  45. package/lib/typescript/core/keytype.d.ts +1 -0
  46. package/lib/typescript/core/player.d.ts +16 -0
  47. package/lib/typescript/index.d.ts +2 -0
  48. package/lib/typescript/platforms/android/extends.d.ts +39 -0
  49. package/lib/typescript/platforms/ios/extends.d.ts +41 -0
  50. package/lib/typescript/runtime/index.d.ts +1 -0
  51. package/package.json +32 -0
  52. package/react-native-velive-pull.podspec +45 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright 2024 Beijing Volcano Engine Technology Co., Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # 火山引擎直播拉流 React Native SDK
2
+
@@ -0,0 +1,93 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:7.2.1"
9
+ }
10
+ }
11
+
12
+ def isNewArchitectureEnabled() {
13
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
14
+ }
15
+
16
+ apply plugin: "com.android.library"
17
+ apply from: "https://ve-vos.volccdn.com/script/vevos-repo-base.gradle"
18
+
19
+ if (isNewArchitectureEnabled()) {
20
+ apply plugin: "com.facebook.react"
21
+ }
22
+
23
+ def getExtOrDefault(name) {
24
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["LivePull_" + name]
25
+ }
26
+
27
+ def getExtOrIntegerDefault(name) {
28
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["LivePull_" + name]).toInteger()
29
+ }
30
+
31
+ def supportsNamespace() {
32
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
33
+ def major = parsed[0].toInteger()
34
+ def minor = parsed[1].toInteger()
35
+
36
+ // Namespace support was added in 7.3.0
37
+ return (major == 7 && minor >= 3) || major >= 8
38
+ }
39
+
40
+ android {
41
+ if (supportsNamespace()) {
42
+ namespace "com.volcengine.velive.rn.pull"
43
+
44
+ sourceSets {
45
+ main {
46
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
47
+ }
48
+ }
49
+ }
50
+
51
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
52
+
53
+ defaultConfig {
54
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
55
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
56
+
57
+ consumerProguardFiles 'proguard-rules.pro'
58
+ }
59
+
60
+ buildTypes {
61
+ release {
62
+ minifyEnabled false
63
+ }
64
+ }
65
+
66
+ lintOptions {
67
+ disable "GradleCompatible"
68
+ }
69
+
70
+ compileOptions {
71
+ sourceCompatibility JavaVersion.VERSION_1_8
72
+ targetCompatibility JavaVersion.VERSION_1_8
73
+ }
74
+ }
75
+
76
+ repositories {
77
+ mavenCentral()
78
+ google()
79
+ maven {
80
+ url "https://artifact.bytedance.com/repository/Volcengine/" // volc public maven repo
81
+ }
82
+ }
83
+
84
+
85
+ dependencies {
86
+ // For < 0.71, this will be from the local maven repo
87
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
88
+ // noinspection GradleDynamicVersion
89
+ implementation "com.facebook.react:react-native:+"
90
+
91
+ implementation "com.volcengine:VolcApiEngine:1.0.1"
92
+ implementation 'com.bytedanceapi:ttsdk-ttlivepull_rtc:1.41.3.4'
93
+ }
@@ -0,0 +1,5 @@
1
+ LivePull_kotlinVersion=1.7.0
2
+ LivePull_minSdkVersion=21
3
+ LivePull_targetSdkVersion=31
4
+ LivePull_compileSdkVersion=31
5
+ LivePull_ndkversion=21.4.7075529
@@ -0,0 +1,9 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.volcengine.velive.rn.pull">
3
+
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
6
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
7
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8
+
9
+ </manifest>
@@ -0,0 +1,8 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
5
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
6
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7
+
8
+ </manifest>
@@ -0,0 +1,15 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.volcengine.VolcApiEngine.runtime.*;
7
+
8
+ public class NativeVariableManager {
9
+ static void init(@NonNull MessageClient msgClient, ReactApplicationContext reactContext) {
10
+ var m = msgClient.proto.variableManager;
11
+
12
+ m.registerVar("ApplicationContext", (Object[] args) -> reactContext.getApplicationContext());
13
+ m.registerVar("ReactApplicationContext", (Object[] args) -> reactContext);
14
+ }
15
+ }
@@ -0,0 +1,108 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import androidx.annotation.Nullable;
4
+
5
+ import com.facebook.react.bridge.Arguments;
6
+ import com.facebook.react.bridge.Callback;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.bridge.ReactContext;
9
+ import com.facebook.react.bridge.ReactMethod;
10
+ import com.facebook.react.bridge.ReadableMap;
11
+ import com.facebook.react.bridge.WritableMap;
12
+ import com.facebook.react.module.annotations.ReactModule;
13
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
14
+
15
+ import com.volcengine.VolcApiEngine.runtime.*;
16
+ import com.volcengine.velive.rn.pull.autogen.MethodSignature;
17
+
18
+ @ReactModule(name = VolcLiveModule.NAME)
19
+ public class VolcLiveModule extends VolcLiveModuleSpec implements IEventReceiver {
20
+ public static final String NAME = "VolcLiveModule";
21
+
22
+ VolcApiEngine apiEngine = null;
23
+
24
+ VolcLiveModule(ReactApplicationContext context) {
25
+ super(context);
26
+ MethodSignature.init();
27
+ }
28
+
29
+ @Override
30
+ public String getName() {
31
+ return NAME;
32
+ }
33
+
34
+ @ReactMethod(isBlockingSynchronousMethod = true)
35
+ public boolean newApiEngine() {
36
+ if (apiEngine == null) {
37
+ apiEngine = new VolcApiEngine(super.context, this);
38
+ NativeVariableManager.init(apiEngine.msgClient, super.context);
39
+ return true;
40
+ }
41
+
42
+ return false;
43
+ }
44
+
45
+ @ReactMethod(isBlockingSynchronousMethod = true)
46
+ public String callApiSync(ReadableMap arg) {
47
+ try {
48
+ newApiEngine();
49
+ String params = arg.getString("params");
50
+ return this.apiEngine.callApi(params);
51
+ } catch (Exception e) {
52
+ e.printStackTrace();
53
+ throw new RuntimeException(e);
54
+ }
55
+ }
56
+
57
+ @ReactMethod(isBlockingSynchronousMethod = false)
58
+ public void callApi(ReadableMap arg, Callback callback) {
59
+ try {
60
+ newApiEngine();
61
+ String params = arg.getString("params");
62
+ this.apiEngine.callApi(params, (res) -> {
63
+ callback.invoke(res.toJsonString());
64
+ });
65
+ } catch (Exception e) {
66
+ e.printStackTrace();
67
+ throw new RuntimeException(e);
68
+ }
69
+ }
70
+
71
+ private int listenerCount = 0;
72
+
73
+ @ReactMethod
74
+ public void addListener(String eventName) {
75
+ if (listenerCount == 0) {
76
+ // Set up any upstream listeners or background tasks as necessary
77
+ }
78
+
79
+ listenerCount += 1;
80
+ }
81
+
82
+ @ReactMethod
83
+ public void removeListeners(Integer count) {
84
+ listenerCount -= count;
85
+ if (listenerCount == 0) {
86
+ // Remove upstream listeners, stop unnecessary background tasks
87
+ }
88
+ }
89
+
90
+ private void sendEvent(ReactContext reactContext,
91
+ String eventName,
92
+ @Nullable WritableMap params) {
93
+ reactContext
94
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
95
+ .emit(eventName, params);
96
+ }
97
+
98
+ @Override
99
+ public void OnEvent(String event, String data) {
100
+ final WritableMap map = Arguments.createMap();
101
+ map.putString("event", event);
102
+ map.putString("data", data);
103
+
104
+ super.context
105
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
106
+ .emit(VolcLiveModuleSpec.EVENT, map);
107
+ }
108
+ }
@@ -0,0 +1,17 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext;
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
5
+
6
+ public abstract class VolcLiveModuleSpec extends ReactContextBaseJavaModule {
7
+ static final String EVENT = "VolcLive:onEvent";
8
+
9
+ VolcLiveModuleSpec(ReactApplicationContext context) {
10
+ super(context);
11
+ this.context = context;
12
+ }
13
+
14
+ public ReactApplicationContext context;
15
+
16
+ public abstract void OnEvent(String eventName, String data);
17
+ }
@@ -0,0 +1,27 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.uimanager.ViewManager;
9
+
10
+ import java.util.ArrayList;
11
+ import java.util.List;
12
+
13
+ public class VolcLivePackage implements ReactPackage {
14
+ @Override
15
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
16
+ List<ViewManager> viewManagers = new ArrayList<>();
17
+ viewManagers.add(new VolcViewManager());
18
+ return viewManagers;
19
+ }
20
+
21
+ @Override
22
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
23
+ List<NativeModule> modules = new ArrayList<>();
24
+ modules.add(new VolcLiveModule(reactContext));
25
+ return modules;
26
+ }
27
+ }
@@ -0,0 +1,32 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import android.content.Context;
4
+ import android.widget.FrameLayout;
5
+
6
+ import com.facebook.react.bridge.Arguments;
7
+ import com.facebook.react.bridge.ReactContext;
8
+ import com.facebook.react.bridge.WritableMap;
9
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
10
+
11
+ public class VolcView extends FrameLayout {
12
+ public String viewId;
13
+ public boolean hasRegister = false;
14
+
15
+ public VolcView(Context context) {
16
+ super(context);
17
+ }
18
+
19
+ public void setViewId(String viewId) {
20
+ this.viewId = viewId;
21
+ this.hasRegister = true;
22
+ this.emitOnLoad();
23
+ }
24
+
25
+ public void emitOnLoad() {
26
+ WritableMap event = Arguments.createMap();
27
+ ReactContext reactContext = (ReactContext)getContext();
28
+ reactContext
29
+ .getJSModule(RCTEventEmitter.class)
30
+ .receiveEvent(getId(), "load", event);
31
+ }
32
+ }
@@ -0,0 +1,87 @@
1
+ package com.volcengine.velive.rn.pull;
2
+
3
+ import android.view.SurfaceView;
4
+ import android.view.View;
5
+
6
+ import androidx.annotation.NonNull;
7
+ import androidx.annotation.Nullable;
8
+
9
+ import com.facebook.react.bridge.ReadableArray;
10
+ import com.facebook.react.common.MapBuilder;
11
+ import com.facebook.react.uimanager.SimpleViewManager;
12
+ import com.facebook.react.uimanager.ThemedReactContext;
13
+ import com.facebook.react.uimanager.annotations.ReactProp;
14
+ import com.volcengine.VolcApiEngine.view.*;
15
+
16
+ import java.util.Map;
17
+
18
+ public class VolcViewManager extends SimpleViewManager<VolcView> implements VolcViewManagerInterface<VolcView> {
19
+ public static final String NAME = "VolcView";
20
+
21
+ private ThemedReactContext context;
22
+
23
+ @NonNull
24
+ @Override
25
+ public String getName() {
26
+ return NAME;
27
+ }
28
+
29
+ @NonNull
30
+ @Override
31
+ public VolcView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
32
+ context = themedReactContext;
33
+ return new VolcView(themedReactContext);
34
+ }
35
+
36
+ @ReactProp(name = "viewId")
37
+ public void setViewId(VolcView view, String viewId) {
38
+ view.setViewId(viewId);
39
+ com.volcengine.VolcApiEngine.view.VolcViewManager.putViewById(viewId, view);
40
+ }
41
+
42
+ @ReactProp(name = "kind")
43
+ public void setKind(VolcView 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
+ }
52
+ }
53
+
54
+ public void setVisible(VolcView view, Boolean visible) {
55
+ if(visible) {
56
+ view.setVisibility(View.INVISIBLE);
57
+ } else {
58
+ view.setVisibility(View.VISIBLE);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Handle "create" command (called from JS) and call createFragment method
64
+ */
65
+ public void receiveCommand(
66
+ @NonNull VolcView root,
67
+ String command,
68
+ @Nullable ReadableArray args
69
+ ) {
70
+ super.receiveCommand(root, command, args);
71
+
72
+ if (command.equals("setVisible")) {
73
+ assert args != null;
74
+ setVisible(root, args.getBoolean(0));
75
+ }
76
+ }
77
+
78
+ public Map getExportedCustomBubblingEventTypeConstants() {
79
+ return MapBuilder.builder().put(
80
+ "load",
81
+ MapBuilder.of(
82
+ "phasedRegistrationNames",
83
+ MapBuilder.of("bubbled", "onLoad")
84
+ )
85
+ ).build();
86
+ }
87
+ }
@@ -0,0 +1,129 @@
1
+ package com.volcengine.velive.rn.pull.autogen;
2
+
3
+ import static com.volcengine.VolcApiEngine.runtime.MethodSignature.*;
4
+
5
+ import android.view.Surface;
6
+ import android.view.SurfaceHolder;
7
+
8
+ import com.ss.videoarch.liveplayer.VeLivePlayer;
9
+ import com.ss.videoarch.liveplayer.VeLivePlayerConfiguration;
10
+ import com.ss.videoarch.liveplayer.VeLivePlayerDef;
11
+ import com.ss.videoarch.liveplayer.VeLivePlayerObserver;
12
+ import com.ss.videoarch.liveplayer.VeLivePlayerStreamData;
13
+ import com.ss.videoarch.liveplayer.log.VeLivePlayerLogConfig;
14
+
15
+ import java.util.Map;
16
+
17
+ public class MethodSignature {
18
+ static public void init() {
19
+ try {
20
+ var r = createClassMethodRegister("com.ss.videoarch.liveplayer.VideoLiveManager");
21
+
22
+ r.put(
23
+ "setConfig",
24
+ VeLivePlayer.class.getMethod("setConfig", VeLivePlayerConfiguration.class));
25
+
26
+ r.put(
27
+ "setObserver",
28
+ VeLivePlayer.class.getMethod("setObserver", VeLivePlayerObserver.class));
29
+
30
+ r.put("setRenderFillMode",
31
+ VeLivePlayer.class.getMethod("setRenderFillMode", VeLivePlayerDef.VeLivePlayerFillMode.class));
32
+
33
+ r.put("getVersion", VeLivePlayer.class.getMethod("getVersion"));
34
+
35
+ r.put(
36
+ "setSurfaceHolder",
37
+ VeLivePlayer.class.getMethod("setSurfaceHolder", SurfaceHolder.class));
38
+
39
+ r.put("setSurface",
40
+ VeLivePlayer.class.getMethod("setSurface", Surface.class));
41
+
42
+ r.put(
43
+ "setPlayUrl",
44
+ VeLivePlayer.class.getMethod("setPlayUrl", String.class));
45
+
46
+ r.put(
47
+ "setLogLevel",
48
+ VeLivePlayer.class.getMethod("setLogLevel", VeLivePlayerLogConfig.VeLivePlayerLogLevel.class));
49
+
50
+ r.put(
51
+ "setLogConfig",
52
+ VeLivePlayer.class.getMethod("setLogConfig", VeLivePlayerLogConfig.class));
53
+
54
+ r.put("setPlayStreamData",
55
+ VeLivePlayer.class.getMethod("setPlayStreamData", VeLivePlayerStreamData.class));
56
+
57
+ r.put(
58
+ "play",
59
+ VeLivePlayer.class.getMethod("play"));
60
+ r.put(
61
+ "pause",
62
+ VeLivePlayer.class.getMethod("pause"));
63
+
64
+ r.put(
65
+ "stop",
66
+ VeLivePlayer.class.getMethod("stop"));
67
+
68
+ r.put("destroy", VeLivePlayer.class.getMethod("destroy"));
69
+
70
+ r.put(
71
+ "switchResolution",
72
+ VeLivePlayer.class.getMethod("switchResolution", VeLivePlayerDef.VeLivePlayerResolution.class));
73
+
74
+ r.put("isPlaying", VeLivePlayer.class.getMethod("isPlaying"));
75
+
76
+ r.put(
77
+ "setPlayerVolume",
78
+ VeLivePlayer.class.getMethod("setPlayerVolume", float.class));
79
+
80
+ r.put("setMute", VeLivePlayer.class.getMethod("setMute", boolean.class));
81
+
82
+ r.put("isMute", VeLivePlayer.class.getMethod("isMute"));
83
+
84
+ r.put(
85
+ "setUrlHostIP",
86
+ VeLivePlayer.class.getMethod("setUrlHostIP", Map.class));
87
+
88
+ r.put(
89
+ "setGlobalUrlHostIP",
90
+ VeLivePlayer.class.getMethod("setGlobalUrlHostIP", Map.class));
91
+
92
+ r.put(
93
+ "setProperty",
94
+ VeLivePlayer.class.getMethod("setProperty", String.class, Object.class));
95
+
96
+ r.put(
97
+ "snapshot",
98
+ VeLivePlayer.class.getMethod("snapshot"));
99
+
100
+ r.put(
101
+ "enableVideoFrameObserver",
102
+ VeLivePlayer.class.getMethod(
103
+ "enableVideoFrameObserver",
104
+ boolean.class, VeLivePlayerDef.VeLivePlayerPixelFormat.class, VeLivePlayerDef.VeLivePlayerVideoBufferType.class));
105
+
106
+ r.put(
107
+ "enableAudioFrameObserver",
108
+ VeLivePlayer.class.getMethod(
109
+ "enableAudioFrameObserver",
110
+ boolean.class, boolean.class));
111
+
112
+ r.put(
113
+ "setRenderRotation",
114
+ VeLivePlayer.class.getMethod("setRenderRotation", VeLivePlayerDef.VeLivePlayerRotation.class));
115
+
116
+ r.put(
117
+ "setRenderMirror",
118
+ VeLivePlayer.class.getMethod("setRenderMirror", VeLivePlayerDef.VeLivePlayerMirror.class));
119
+
120
+
121
+ r.put("setEnableSuperResolution", VeLivePlayer.class.getMethod("setEnableSuperResolution", boolean.class));
122
+
123
+ r.put("setEnableSharpen", VeLivePlayer.class.getMethod("setEnableSharpen", boolean.class));
124
+
125
+ } catch (NoSuchMethodException e) {
126
+ throw new RuntimeException(e);
127
+ }
128
+ }
129
+ }
@@ -0,0 +1,24 @@
1
+ //
2
+ // VeLivePullSDK.h
3
+ // rn
4
+ //
5
+ // Created by ByteDance on 2024/4/10.
6
+ //
7
+
8
+ #ifndef VeLivePullSDK_h
9
+ #define VeLivePullSDK_h
10
+
11
+ #import <Foundation/Foundation.h>
12
+ #import <React/RCTBridgeModule.h>
13
+ #import <React/RCTEventEmitter.h>
14
+ #import "VolcApiEngine/Engine.h"
15
+
16
+ @interface RCTVolcLiveModule : RCTEventEmitter <RCTBridgeModule>
17
+
18
+ @property(nonatomic, strong) VolcApiEngine *volcApiEngine;
19
+
20
+ + (instancetype)shareInstance;
21
+
22
+ @end
23
+
24
+ #endif /* VeLivePullSDK_h */
@@ -0,0 +1,91 @@
1
+ //
2
+ // VeLivePullSDK.m
3
+ // rn
4
+ //
5
+ // Created by ByteDance on 2024/4/10.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+ #import <Foundation/Foundation.h>
10
+
11
+ #import <TTSDKFramework/TTSDKFramework.h>
12
+
13
+ #import "VolcApiEngine/VolcEventObserver.h"
14
+ #import "VeLivePullSDK.h"
15
+
16
+ #define EVENT_NAME @"VolcLive:onEvent"
17
+
18
+ @interface RCTVolcLiveModule () <EventObserver>
19
+
20
+ @end
21
+
22
+ static RCTVolcLiveModule *instance = nil;
23
+
24
+ @implementation RCTVolcLiveModule
25
+ {
26
+ bool hasListeners;
27
+ }
28
+
29
+ + (instancetype)shareInstance {
30
+ return instance;
31
+ }
32
+
33
+ + (BOOL)requiresMainQueueSetup {
34
+ return YES;
35
+ }
36
+
37
+ + (void)_unsedForKeepOnly {
38
+ Protocol *unused = @protocol(VeLivePlayerObserver);
39
+ NSLog(@"Loaded Protocol: %p", unused);
40
+ }
41
+
42
+ - (dispatch_queue_t)methodQueue {
43
+ return dispatch_get_main_queue();
44
+ }
45
+
46
+ - (instancetype)init {
47
+ self = [super init];
48
+ if (self != nil) {
49
+ self.volcApiEngine = nil;
50
+ instance = self;
51
+ }
52
+ return instance;
53
+ }
54
+
55
+ - (NSArray<NSString *> *)supportedEvents {
56
+ return @[ EVENT_NAME ];
57
+ }
58
+
59
+ - (void)onEvent:(NSString *)eventName data:(id)eventData
60
+ {
61
+ NSDictionary * dic = @{ @"event": eventName, @"data": eventData };
62
+ [self sendEventWithName:EVENT_NAME body:dic];
63
+ }
64
+
65
+ RCT_EXPORT_MODULE();
66
+
67
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(newApiEngine)
68
+ {
69
+ if (self.volcApiEngine == nil) {
70
+ self.volcApiEngine = [[VolcApiEngine alloc] init];
71
+ [self.volcApiEngine setObserver:self];
72
+ }
73
+ return nil;
74
+ }
75
+
76
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(callApiSync:(nonnull NSDictionary *) args)
77
+ {
78
+ [self newApiEngine];
79
+ return [instance.volcApiEngine callApi:args];
80
+ }
81
+
82
+ RCT_EXPORT_METHOD(callApi:(nonnull NSDictionary *)args callback:(RCTResponseSenderBlock) callback)
83
+ {
84
+ [self newApiEngine];
85
+ dispatch_async(dispatch_get_main_queue(), ^{
86
+ id _val = [self.volcApiEngine callApi:args];
87
+ callback(@[_val]);
88
+ });
89
+ }
90
+
91
+ @end