@byteplus/react-native-live-push 1.1.3-rc.1 → 1.1.3-rc.3

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 (123) hide show
  1. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModule.java +13 -2
  2. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushPackage.java +16 -13
  3. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushView.java +16 -0
  4. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushViewManager.java +7 -2
  5. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerManager.java +397 -0
  6. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerView.java +423 -0
  7. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerViewManager.java +79 -0
  8. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/TextureMgr.java +168 -0
  9. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/YuvHelper.java +165 -0
  10. package/ios/VeLiveMixerHelper.h +44 -0
  11. package/ios/VeLiveMixerHelper.m +591 -0
  12. package/ios/VeLiveMixerView.h +69 -0
  13. package/ios/VeLiveMixerView.m +592 -0
  14. package/ios/VeLiveMixerViewManager.m +92 -0
  15. package/lib/commonjs/index.js +1779 -980
  16. package/lib/commonjs/typescript/android/index.d.ts +47 -0
  17. package/lib/commonjs/typescript/codegen/android/api.d.ts +1527 -0
  18. package/lib/commonjs/typescript/codegen/android/callback.d.ts +91 -0
  19. package/lib/commonjs/typescript/codegen/android/errorcode.d.ts +26 -0
  20. package/lib/commonjs/typescript/codegen/android/index.d.ts +5 -0
  21. package/lib/commonjs/typescript/codegen/android/keytype.d.ts +846 -0
  22. package/lib/commonjs/typescript/codegen/android/types.d.ts +33 -0
  23. package/lib/commonjs/typescript/codegen/ios/api.d.ts +222 -0
  24. package/lib/commonjs/typescript/codegen/ios/callback.d.ts +80 -0
  25. package/lib/commonjs/typescript/codegen/ios/errorcode.d.ts +54 -0
  26. package/lib/commonjs/typescript/codegen/ios/external.d.ts +1 -0
  27. package/lib/commonjs/typescript/codegen/ios/index.d.ts +6 -0
  28. package/lib/commonjs/typescript/codegen/ios/keytype.d.ts +460 -0
  29. package/lib/commonjs/typescript/codegen/ios/types.d.ts +46 -0
  30. package/lib/commonjs/typescript/codegen/pack/api.d.ts +1835 -0
  31. package/lib/commonjs/typescript/codegen/pack/callback.d.ts +400 -0
  32. package/lib/commonjs/typescript/codegen/pack/errorcode.d.ts +35 -0
  33. package/lib/commonjs/typescript/codegen/pack/index.d.ts +5 -0
  34. package/lib/commonjs/typescript/codegen/pack/keytype.d.ts +1392 -0
  35. package/lib/commonjs/typescript/codegen/pack/types.d.ts +68 -0
  36. package/lib/commonjs/typescript/codegen/type-shim.d.ts +6 -0
  37. package/lib/commonjs/typescript/component.d.ts +15 -0
  38. package/lib/commonjs/typescript/core/api.d.ts +17 -0
  39. package/lib/commonjs/typescript/core/callback.d.ts +2 -0
  40. package/lib/commonjs/typescript/core/env.d.ts +29 -0
  41. package/lib/commonjs/typescript/core/errorcode.d.ts +2 -0
  42. package/lib/commonjs/typescript/core/index.d.ts +6 -0
  43. package/lib/commonjs/typescript/core/keytype.d.ts +17 -0
  44. package/lib/commonjs/typescript/core/mixer.d.ts +26 -0
  45. package/lib/commonjs/typescript/core/pusher.d.ts +16 -0
  46. package/lib/commonjs/typescript/index.d.ts +3 -0
  47. package/lib/commonjs/typescript/ios/extends.d.ts +41 -0
  48. package/lib/commonjs/typescript/platforms/android/extends.d.ts +8 -0
  49. package/lib/commonjs/typescript/platforms/android/helper.d.ts +8 -0
  50. package/lib/commonjs/typescript/platforms/android/mixer.d.ts +8 -0
  51. package/lib/commonjs/typescript/platforms/ios/extends.d.ts +17 -0
  52. package/lib/commonjs/typescript/platforms/ios/helper.d.ts +8 -0
  53. package/lib/commonjs/typescript/platforms/ios/mixer.d.ts +9 -0
  54. package/lib/commonjs/typescript/runtime.d.ts +1 -0
  55. package/lib/commonjs/typescript/view/MixView.d.ts +52 -0
  56. package/lib/commonjs/typescript/view/VeImageView.d.ts +19 -0
  57. package/lib/commonjs/typescript/view/VeTextView.d.ts +7 -0
  58. package/lib/commonjs/typescript/view/VeView.d.ts +7 -0
  59. package/lib/commonjs/typescript/view/VeWebView.d.ts +7 -0
  60. package/lib/commonjs/typescript/view/index.d.ts +5 -0
  61. package/lib/module/index.js +1776 -982
  62. package/lib/module/typescript/android/index.d.ts +47 -0
  63. package/lib/module/typescript/codegen/android/api.d.ts +1527 -0
  64. package/lib/module/typescript/codegen/android/callback.d.ts +91 -0
  65. package/lib/module/typescript/codegen/android/errorcode.d.ts +26 -0
  66. package/lib/module/typescript/codegen/android/index.d.ts +5 -0
  67. package/lib/module/typescript/codegen/android/keytype.d.ts +846 -0
  68. package/lib/module/typescript/codegen/android/types.d.ts +33 -0
  69. package/lib/module/typescript/codegen/ios/api.d.ts +222 -0
  70. package/lib/module/typescript/codegen/ios/callback.d.ts +80 -0
  71. package/lib/module/typescript/codegen/ios/errorcode.d.ts +54 -0
  72. package/lib/module/typescript/codegen/ios/external.d.ts +1 -0
  73. package/lib/module/typescript/codegen/ios/index.d.ts +6 -0
  74. package/lib/module/typescript/codegen/ios/keytype.d.ts +460 -0
  75. package/lib/module/typescript/codegen/ios/types.d.ts +46 -0
  76. package/lib/module/typescript/codegen/pack/api.d.ts +1835 -0
  77. package/lib/module/typescript/codegen/pack/callback.d.ts +400 -0
  78. package/lib/module/typescript/codegen/pack/errorcode.d.ts +35 -0
  79. package/lib/module/typescript/codegen/pack/index.d.ts +5 -0
  80. package/lib/module/typescript/codegen/pack/keytype.d.ts +1392 -0
  81. package/lib/module/typescript/codegen/pack/types.d.ts +68 -0
  82. package/lib/module/typescript/codegen/type-shim.d.ts +6 -0
  83. package/lib/module/typescript/component.d.ts +15 -0
  84. package/lib/module/typescript/core/api.d.ts +17 -0
  85. package/lib/module/typescript/core/callback.d.ts +2 -0
  86. package/lib/module/typescript/core/env.d.ts +29 -0
  87. package/lib/module/typescript/core/errorcode.d.ts +2 -0
  88. package/lib/module/typescript/core/index.d.ts +6 -0
  89. package/lib/module/typescript/core/keytype.d.ts +17 -0
  90. package/lib/module/typescript/core/mixer.d.ts +26 -0
  91. package/lib/module/typescript/core/pusher.d.ts +16 -0
  92. package/lib/module/typescript/index.d.ts +3 -0
  93. package/lib/module/typescript/ios/extends.d.ts +41 -0
  94. package/lib/module/typescript/platforms/android/extends.d.ts +8 -0
  95. package/lib/module/typescript/platforms/android/helper.d.ts +8 -0
  96. package/lib/module/typescript/platforms/android/mixer.d.ts +8 -0
  97. package/lib/module/typescript/platforms/ios/extends.d.ts +17 -0
  98. package/lib/module/typescript/platforms/ios/helper.d.ts +8 -0
  99. package/lib/module/typescript/platforms/ios/mixer.d.ts +9 -0
  100. package/lib/module/typescript/runtime.d.ts +1 -0
  101. package/lib/module/typescript/view/MixView.d.ts +52 -0
  102. package/lib/module/typescript/view/VeImageView.d.ts +19 -0
  103. package/lib/module/typescript/view/VeTextView.d.ts +7 -0
  104. package/lib/module/typescript/view/VeView.d.ts +7 -0
  105. package/lib/module/typescript/view/VeWebView.d.ts +7 -0
  106. package/lib/module/typescript/view/index.d.ts +5 -0
  107. package/lib/typescript/codegen/android/api.d.ts +1 -121
  108. package/lib/typescript/codegen/ios/api.d.ts +1 -28
  109. package/lib/typescript/codegen/pack/api.d.ts +1 -133
  110. package/lib/typescript/core/api.d.ts +17 -2
  111. package/lib/typescript/core/keytype.d.ts +15 -0
  112. package/lib/typescript/core/mixer.d.ts +26 -0
  113. package/lib/typescript/index.d.ts +1 -0
  114. package/lib/typescript/platforms/android/extends.d.ts +8 -0
  115. package/lib/typescript/platforms/android/mixer.d.ts +8 -0
  116. package/lib/typescript/platforms/ios/mixer.d.ts +9 -0
  117. package/lib/typescript/view/MixView.d.ts +52 -0
  118. package/lib/typescript/view/VeImageView.d.ts +19 -0
  119. package/lib/typescript/view/VeTextView.d.ts +7 -0
  120. package/lib/typescript/view/VeView.d.ts +7 -0
  121. package/lib/typescript/view/VeWebView.d.ts +7 -0
  122. package/lib/typescript/view/index.d.ts +5 -0
  123. package/package.json +1 -1
@@ -0,0 +1,165 @@
1
+ package com.volcengine.velive.rn.push.mixer;
2
+
3
+ import android.content.Context;
4
+ import android.graphics.Bitmap;
5
+ import android.graphics.Matrix;
6
+ import android.renderscript.Allocation;
7
+ import android.renderscript.Element;
8
+ import android.renderscript.RenderScript;
9
+ import android.renderscript.ScriptIntrinsicYuvToRGB;
10
+ import android.renderscript.Type;
11
+
12
+ import java.nio.ByteBuffer;
13
+
14
+ public class YuvHelper {
15
+ private static RenderScript globalRS = null;
16
+ public static synchronized RenderScript getGlobalRS(Context context) {
17
+ if (globalRS == null) {
18
+ globalRS = RenderScript.create(context.getApplicationContext());
19
+ }
20
+ return globalRS;
21
+ }
22
+ public static void destroyGlobalRS() {
23
+ if (globalRS != null) {
24
+ globalRS.destroy();
25
+ globalRS = null;
26
+ }
27
+ }
28
+ public static class NV21ToBitmap {
29
+ private RenderScript rs;
30
+ private ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic;
31
+ private Type.Builder yuvType, rgbaType;
32
+
33
+ public NV21ToBitmap(Context context) {
34
+ rs = YuvHelper.getGlobalRS(context);
35
+ yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
36
+ yuvType = new Type.Builder(rs, Element.U8(rs));
37
+ rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs));
38
+ }
39
+
40
+ public void cleanup() {
41
+ try {
42
+ if (yuvToRgbIntrinsic != null) {
43
+ yuvToRgbIntrinsic.destroy();
44
+ yuvToRgbIntrinsic = null;
45
+ }
46
+ // 不销毁全局 rs
47
+ // rs = null;
48
+ } catch (Exception e) {
49
+ // Ignore
50
+ }
51
+ }
52
+
53
+ public Bitmap nv21ToBitmap(byte[] nv21, int width, int height) {
54
+ Allocation in = null;
55
+ Allocation out = null;
56
+ try {
57
+ yuvType.setX(nv21.length);
58
+ in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);
59
+ in.copyFrom(nv21);
60
+
61
+ rgbaType.setX(width).setY(height);
62
+ out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);
63
+ yuvToRgbIntrinsic.setInput(in);
64
+ yuvToRgbIntrinsic.forEach(out);
65
+
66
+ Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
67
+ out.copyTo(bmp);
68
+
69
+ return bmp;
70
+ } finally {
71
+ if (in != null) {
72
+ in.destroy();
73
+ }
74
+ if (out != null) {
75
+ out.destroy();
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ public static void NV21toI420(ByteBuffer input, ByteBuffer output, final int width, final int height) {
82
+ final int size = width * height;
83
+ final int quarter = size / 4;
84
+ final int v0 = size + quarter;
85
+
86
+ System.arraycopy(input.array(), 0, output.array(), 0, size);
87
+
88
+ for (int u = size, v = v0, o = size; u < v0; u++, v++, o += 2) {
89
+ output.array()[v] = input.array()[o];
90
+ output.array()[u] = input.array()[o + 1];
91
+ }
92
+ output.limit(width * height * 3 / 2);
93
+ output.position(0);
94
+ }
95
+
96
+ public static void NV21toNV12(ByteBuffer input, ByteBuffer output, final int width, final int height) {
97
+ final int size = width * height;
98
+
99
+ System.arraycopy(input.array(), 0, output.array(), 0, size);
100
+ for (int i = size; i < 1.5f * size; i += 2) {
101
+ output.array()[i] = input.array()[i + 1];
102
+ output.array()[i + 1] = input.array()[i];
103
+ }
104
+ output.position(0);
105
+ output.limit(width * height * 3 / 2);
106
+ }
107
+
108
+ public static void NV12toI420(ByteBuffer input, ByteBuffer output, final int width, final int height) {
109
+ final int size = width * height;
110
+ final int quarter = size / 4;
111
+ final int v0 = size + quarter;
112
+
113
+ System.arraycopy(input.array(), 0, output.array(), 0, size);
114
+
115
+ for (int u = size, v = v0, o = size; u < v0; u++, v++, o += 2) {
116
+ output.array()[v] = input.array()[o + 1];
117
+ output.array()[u] = input.array()[o];
118
+ }
119
+ }
120
+
121
+ public static void I420toNV21(ByteBuffer input, ByteBuffer output, final int width, final int height) {
122
+ final int size = width * height;
123
+ final int quarter = size / 4;
124
+ final int v0 = size + quarter;
125
+
126
+ System.arraycopy(input.array(), 0, output.array(), 0, size);
127
+
128
+ for (int u = size, v = v0, o = size; u < v0; u++, v++, o += 2) {
129
+ output.array()[o + 1] = input.array()[v];
130
+ output.array()[o] = input.array()[u];
131
+ }
132
+ }
133
+
134
+ public static Bitmap rotateBitmap(Bitmap origin, float alpha, boolean horizontalMirror, boolean verticalMirror) {
135
+ if (origin == null || origin.isRecycled()) {
136
+ return null;
137
+ }
138
+
139
+ try {
140
+ int width = origin.getWidth();
141
+ int height = origin.getHeight();
142
+ Matrix matrix = new Matrix();
143
+ float sx = 1;
144
+ float sy = 1;
145
+ if (horizontalMirror) {
146
+ sx = -1;
147
+ }
148
+ if (verticalMirror) {
149
+ sy = -1;
150
+ }
151
+ matrix.postScale(sx, sy);
152
+ matrix.postRotate(alpha);
153
+
154
+ if (origin.isRecycled()) {
155
+ return null;
156
+ }
157
+
158
+ return Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
159
+ } catch (IllegalStateException e) {
160
+ return null;
161
+ } catch (Exception e) {
162
+ return null;
163
+ }
164
+ }
165
+ }
@@ -0,0 +1,44 @@
1
+ //
2
+ // VeLiveMixerHelper.h
3
+ // react-native-live-push
4
+ //
5
+ // Created by ByteDance on 2024/12/09.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "VeLiveMixerView.h"
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ // 前向声明
14
+ @class VeLivePusher;
15
+
16
+ // 混流管理器助手类 - 完全对齐Android MixerManager.java
17
+ @interface VeLiveMixerHelper : NSObject <VeLiveBitmapCaptureCallback>
18
+
19
+ // 对齐Android的static cachedMixedViews
20
+ @property (class, nonatomic, strong) NSMutableDictionary<NSString *, VeLiveMixerUIView *> *cachedMixedViews;
21
+
22
+ @property (nonatomic, weak) VeLivePusher *pusher;
23
+
24
+ - (instancetype)initWithPusher:(VeLivePusher *)pusher;
25
+
26
+ // Public方法 - 完全对齐Android MixerManager的public接口
27
+ - (void)setPusher:(VeLivePusher *)pusher;
28
+ - (int)addView:(NSString *)viewId config:(NSDictionary *)viewInfo;
29
+ - (BOOL)updateView:(NSString *)viewId config:(NSDictionary *)viewInfo;
30
+ - (BOOL)removeView:(NSString *)viewId;
31
+ - (void)captureView:(NSString *)viewId;
32
+
33
+ // Static方法 - 只保留Android中实际存在的
34
+ + (void)setupCallbackForMixerView:(VeLiveMixerUIView *)mixerView streamId:(int)streamId;
35
+ + (void)sendBitmapToMixerStatic:(int)streamId bitmap:(UIImage *)bitmap;
36
+ + (VeLiveMixerHelper *)findActiveMixerManager;
37
+ + (void)onViewReady:(NSString *)viewId mixerView:(VeLiveMixerUIView *)mixerView;
38
+
39
+ // 清理资源
40
+ - (void)cleanup;
41
+
42
+ @end
43
+
44
+ NS_ASSUME_NONNULL_END