@byteplus/react-native-live-push 1.1.3-rc.4 → 1.1.4-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 (123) hide show
  1. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModule.java +2 -13
  2. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushPackage.java +13 -16
  3. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushView.java +0 -16
  4. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushViewManager.java +2 -7
  5. package/lib/commonjs/index.js +1027 -466
  6. package/lib/module/index.js +1029 -463
  7. package/lib/typescript/codegen/android/api.d.ts +121 -1
  8. package/lib/typescript/codegen/ios/api.d.ts +28 -1
  9. package/lib/typescript/codegen/pack/api.d.ts +133 -1
  10. package/lib/typescript/core/api.d.ts +2 -17
  11. package/lib/typescript/core/keytype.d.ts +0 -16
  12. package/lib/typescript/index.d.ts +0 -1
  13. package/package.json +1 -1
  14. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerManager.java +0 -412
  15. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerView.java +0 -423
  16. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerViewManager.java +0 -79
  17. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/TextureMgr.java +0 -168
  18. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/YuvHelper.java +0 -165
  19. package/ios/VeLiveMixerHelper.h +0 -44
  20. package/ios/VeLiveMixerHelper.m +0 -620
  21. package/ios/VeLiveMixerView.h +0 -69
  22. package/ios/VeLiveMixerView.m +0 -600
  23. package/ios/VeLiveMixerViewManager.m +0 -92
  24. package/lib/commonjs/typescript/android/index.d.ts +0 -47
  25. package/lib/commonjs/typescript/codegen/android/api.d.ts +0 -1527
  26. package/lib/commonjs/typescript/codegen/android/callback.d.ts +0 -91
  27. package/lib/commonjs/typescript/codegen/android/errorcode.d.ts +0 -26
  28. package/lib/commonjs/typescript/codegen/android/index.d.ts +0 -5
  29. package/lib/commonjs/typescript/codegen/android/keytype.d.ts +0 -846
  30. package/lib/commonjs/typescript/codegen/android/types.d.ts +0 -33
  31. package/lib/commonjs/typescript/codegen/ios/api.d.ts +0 -222
  32. package/lib/commonjs/typescript/codegen/ios/callback.d.ts +0 -80
  33. package/lib/commonjs/typescript/codegen/ios/errorcode.d.ts +0 -54
  34. package/lib/commonjs/typescript/codegen/ios/external.d.ts +0 -1
  35. package/lib/commonjs/typescript/codegen/ios/index.d.ts +0 -6
  36. package/lib/commonjs/typescript/codegen/ios/keytype.d.ts +0 -460
  37. package/lib/commonjs/typescript/codegen/ios/types.d.ts +0 -46
  38. package/lib/commonjs/typescript/codegen/pack/api.d.ts +0 -1835
  39. package/lib/commonjs/typescript/codegen/pack/callback.d.ts +0 -400
  40. package/lib/commonjs/typescript/codegen/pack/errorcode.d.ts +0 -35
  41. package/lib/commonjs/typescript/codegen/pack/index.d.ts +0 -5
  42. package/lib/commonjs/typescript/codegen/pack/keytype.d.ts +0 -1392
  43. package/lib/commonjs/typescript/codegen/pack/types.d.ts +0 -68
  44. package/lib/commonjs/typescript/codegen/type-shim.d.ts +0 -6
  45. package/lib/commonjs/typescript/component.d.ts +0 -15
  46. package/lib/commonjs/typescript/core/api.d.ts +0 -17
  47. package/lib/commonjs/typescript/core/callback.d.ts +0 -2
  48. package/lib/commonjs/typescript/core/env.d.ts +0 -29
  49. package/lib/commonjs/typescript/core/errorcode.d.ts +0 -2
  50. package/lib/commonjs/typescript/core/index.d.ts +0 -6
  51. package/lib/commonjs/typescript/core/keytype.d.ts +0 -18
  52. package/lib/commonjs/typescript/core/mixer.d.ts +0 -26
  53. package/lib/commonjs/typescript/core/pusher.d.ts +0 -16
  54. package/lib/commonjs/typescript/index.d.ts +0 -3
  55. package/lib/commonjs/typescript/ios/extends.d.ts +0 -41
  56. package/lib/commonjs/typescript/platforms/android/extends.d.ts +0 -8
  57. package/lib/commonjs/typescript/platforms/android/helper.d.ts +0 -8
  58. package/lib/commonjs/typescript/platforms/android/mixer.d.ts +0 -8
  59. package/lib/commonjs/typescript/platforms/ios/extends.d.ts +0 -17
  60. package/lib/commonjs/typescript/platforms/ios/helper.d.ts +0 -8
  61. package/lib/commonjs/typescript/platforms/ios/mixer.d.ts +0 -9
  62. package/lib/commonjs/typescript/runtime.d.ts +0 -1
  63. package/lib/commonjs/typescript/view/MixView.d.ts +0 -52
  64. package/lib/commonjs/typescript/view/VeImageView.d.ts +0 -19
  65. package/lib/commonjs/typescript/view/VeTextView.d.ts +0 -7
  66. package/lib/commonjs/typescript/view/VeView.d.ts +0 -7
  67. package/lib/commonjs/typescript/view/VeWebView.d.ts +0 -7
  68. package/lib/commonjs/typescript/view/index.d.ts +0 -5
  69. package/lib/module/typescript/android/index.d.ts +0 -47
  70. package/lib/module/typescript/codegen/android/api.d.ts +0 -1527
  71. package/lib/module/typescript/codegen/android/callback.d.ts +0 -91
  72. package/lib/module/typescript/codegen/android/errorcode.d.ts +0 -26
  73. package/lib/module/typescript/codegen/android/index.d.ts +0 -5
  74. package/lib/module/typescript/codegen/android/keytype.d.ts +0 -846
  75. package/lib/module/typescript/codegen/android/types.d.ts +0 -33
  76. package/lib/module/typescript/codegen/ios/api.d.ts +0 -222
  77. package/lib/module/typescript/codegen/ios/callback.d.ts +0 -80
  78. package/lib/module/typescript/codegen/ios/errorcode.d.ts +0 -54
  79. package/lib/module/typescript/codegen/ios/external.d.ts +0 -1
  80. package/lib/module/typescript/codegen/ios/index.d.ts +0 -6
  81. package/lib/module/typescript/codegen/ios/keytype.d.ts +0 -460
  82. package/lib/module/typescript/codegen/ios/types.d.ts +0 -46
  83. package/lib/module/typescript/codegen/pack/api.d.ts +0 -1835
  84. package/lib/module/typescript/codegen/pack/callback.d.ts +0 -400
  85. package/lib/module/typescript/codegen/pack/errorcode.d.ts +0 -35
  86. package/lib/module/typescript/codegen/pack/index.d.ts +0 -5
  87. package/lib/module/typescript/codegen/pack/keytype.d.ts +0 -1392
  88. package/lib/module/typescript/codegen/pack/types.d.ts +0 -68
  89. package/lib/module/typescript/codegen/type-shim.d.ts +0 -6
  90. package/lib/module/typescript/component.d.ts +0 -15
  91. package/lib/module/typescript/core/api.d.ts +0 -17
  92. package/lib/module/typescript/core/callback.d.ts +0 -2
  93. package/lib/module/typescript/core/env.d.ts +0 -29
  94. package/lib/module/typescript/core/errorcode.d.ts +0 -2
  95. package/lib/module/typescript/core/index.d.ts +0 -6
  96. package/lib/module/typescript/core/keytype.d.ts +0 -18
  97. package/lib/module/typescript/core/mixer.d.ts +0 -26
  98. package/lib/module/typescript/core/pusher.d.ts +0 -16
  99. package/lib/module/typescript/index.d.ts +0 -3
  100. package/lib/module/typescript/ios/extends.d.ts +0 -41
  101. package/lib/module/typescript/platforms/android/extends.d.ts +0 -8
  102. package/lib/module/typescript/platforms/android/helper.d.ts +0 -8
  103. package/lib/module/typescript/platforms/android/mixer.d.ts +0 -8
  104. package/lib/module/typescript/platforms/ios/extends.d.ts +0 -17
  105. package/lib/module/typescript/platforms/ios/helper.d.ts +0 -8
  106. package/lib/module/typescript/platforms/ios/mixer.d.ts +0 -9
  107. package/lib/module/typescript/runtime.d.ts +0 -1
  108. package/lib/module/typescript/view/MixView.d.ts +0 -52
  109. package/lib/module/typescript/view/VeImageView.d.ts +0 -19
  110. package/lib/module/typescript/view/VeTextView.d.ts +0 -7
  111. package/lib/module/typescript/view/VeView.d.ts +0 -7
  112. package/lib/module/typescript/view/VeWebView.d.ts +0 -7
  113. package/lib/module/typescript/view/index.d.ts +0 -5
  114. package/lib/typescript/core/mixer.d.ts +0 -26
  115. package/lib/typescript/platforms/android/extends.d.ts +0 -8
  116. package/lib/typescript/platforms/android/mixer.d.ts +0 -8
  117. package/lib/typescript/platforms/ios/mixer.d.ts +0 -9
  118. package/lib/typescript/view/MixView.d.ts +0 -52
  119. package/lib/typescript/view/VeImageView.d.ts +0 -19
  120. package/lib/typescript/view/VeTextView.d.ts +0 -7
  121. package/lib/typescript/view/VeView.d.ts +0 -7
  122. package/lib/typescript/view/VeWebView.d.ts +0 -7
  123. package/lib/typescript/view/index.d.ts +0 -5
@@ -1,412 +0,0 @@
1
- package com.volcengine.velive.rn.push.mixer;
2
-
3
- import android.graphics.Bitmap;
4
- import android.util.Log;
5
- import android.view.View;
6
- import android.view.ViewTreeObserver;
7
- import com.ss.avframework.live.VeLivePusher;
8
- import com.ss.avframework.live.VeLivePusherDef.VeLiveMixVideoLayout;
9
- import com.ss.avframework.live.VeLivePusherDef.VeLivePusherRenderMode;
10
- import com.ss.avframework.live.VeLivePusherDef.VeLiveStreamMixDescription;
11
- import com.ss.avframework.live.VeLiveVideoFrame;
12
- import java.util.HashMap;
13
- import java.util.Map;
14
- import java.util.concurrent.ConcurrentHashMap;
15
- import javax.annotation.Nullable;
16
- import org.json.JSONObject;
17
-
18
- public class MixerManager {
19
- public static Map<String, View> cachedMixedViews = new HashMap<>();
20
-
21
- private static final String TAG = "MixerManager";
22
-
23
- private VeLivePusher pusher;
24
- private final Map<String, VeLiveMixVideoLayout> mixedViewLayout =
25
- new ConcurrentHashMap<>();
26
- private final Map<String, Integer> viewIdToStreamId =
27
- new ConcurrentHashMap<>();
28
- private final Map<String, Integer> pendingCallbacks =
29
- new ConcurrentHashMap<>();
30
-
31
- public void setPusher(VeLivePusher pusher) { this.pusher = pusher; }
32
-
33
- /**
34
- * Add a view to the mixer
35
- * @param viewId Unique identifier for the view
36
- * @param viewInfo Configuration for the view
37
- * @return streamId for this view
38
- */
39
- public int addView(String viewId, JSONObject viewInfo) {
40
- try {
41
- if (pusher == null || pusher.getMixerManager() == null) {
42
- return -1;
43
- }
44
-
45
- if (viewIdToStreamId.containsKey(viewId)) {
46
- return viewIdToStreamId.get(viewId);
47
- }
48
-
49
- int videoStreamId = pusher.getMixerManager().addVideoStream();
50
- VeLiveStreamMixDescription description = new VeLiveStreamMixDescription();
51
- VeLiveMixVideoLayout layout = new VeLiveMixVideoLayout();
52
- layout.x = (float)viewInfo.getDouble("x");
53
- layout.y = (float)viewInfo.getDouble("y");
54
- layout.width = (float)viewInfo.getDouble("width");
55
- layout.height = (float)viewInfo.getDouble("height");
56
- layout.alpha = (float)viewInfo.optDouble("alpha", 1.0);
57
- layout.zOrder = viewInfo.optInt("zOrder", 0);
58
- int renderModeValue = viewInfo.optInt("renderMode", 0);
59
- VeLivePusherRenderMode[] renderModes = VeLivePusherRenderMode.values();
60
- if (renderModeValue >= 0 && renderModeValue < renderModes.length) {
61
- layout.renderMode = renderModes[renderModeValue];
62
- } else {
63
- layout.renderMode = VeLivePusherRenderMode.values()[0];
64
- }
65
- layout.streamId = videoStreamId;
66
- description.mixVideoStreams.add(layout);
67
- mixedViewLayout.put(viewId, layout);
68
- viewIdToStreamId.put(viewId, videoStreamId);
69
- pusher.getMixerManager().updateStreamMixDescription(description);
70
-
71
- View view = cachedMixedViews.get(viewId);
72
- if (view instanceof MixerView) {
73
- MixerView mixerView = (MixerView)view;
74
- setupCallbackForMixerView(mixerView, videoStreamId);
75
-
76
- android.os.Handler mainHandler =
77
- new android.os.Handler(android.os.Looper.getMainLooper());
78
- mainHandler.postDelayed(new Runnable() {
79
- @Override
80
- public void run() {
81
- try {
82
- mixerView.performManualCapture();
83
- } catch (Exception e) {
84
- Log.w(TAG, "Failed to perform manual capture after addView", e);
85
- }
86
- }
87
- }, 300);
88
- } else {
89
- pendingCallbacks.put(viewId, videoStreamId);
90
- }
91
-
92
- return videoStreamId;
93
- } catch (Exception e) {
94
- return -1;
95
- }
96
- }
97
-
98
- /**
99
- * Update view configuration
100
- */
101
- public boolean updateView(String viewId, JSONObject viewInfo) {
102
- try {
103
- VeLiveMixVideoLayout layout = mixedViewLayout.get(viewId);
104
- if (layout == null) {
105
- return false;
106
- }
107
- VeLiveStreamMixDescription description = new VeLiveStreamMixDescription();
108
- layout.x = (float)viewInfo.getDouble("x");
109
- layout.y = (float)viewInfo.getDouble("y");
110
- layout.width = (float)viewInfo.getDouble("width");
111
- layout.height = (float)viewInfo.getDouble("height");
112
- layout.alpha = (float)viewInfo.optDouble("alpha", 1.0);
113
- Integer streamId = viewIdToStreamId.get(viewId);
114
- if (streamId != null) {
115
- layout.streamId = streamId;
116
- }
117
- if (viewInfo.has("zOrder")) {
118
- layout.zOrder = viewInfo.getInt("zOrder");
119
- }
120
- if (viewInfo.has("renderMode")) {
121
- int renderModeValue = viewInfo.getInt("renderMode");
122
- VeLivePusherRenderMode[] renderModes = VeLivePusherRenderMode.values();
123
- if (renderModeValue >= 0 && renderModeValue < renderModes.length) {
124
- layout.renderMode = renderModes[renderModeValue];
125
- }
126
- }
127
- mixedViewLayout.put(viewId, layout);
128
- description.mixVideoStreams.add(layout);
129
- pusher.getMixerManager().updateStreamMixDescription(description);
130
-
131
- View view = cachedMixedViews.get(viewId);
132
- if (view instanceof MixerView) {
133
- MixerView mixerView = (MixerView)view;
134
- android.os.Handler mainHandler =
135
- new android.os.Handler(android.os.Looper.getMainLooper());
136
- mainHandler.postDelayed(new Runnable() {
137
- @Override
138
- public void run() {
139
- try {
140
- mixerView.performManualCapture();
141
- } catch (Exception e) {
142
- Log.w(TAG, "Failed to perform manual capture after update", e);
143
- }
144
- }
145
- }, 300);
146
- }
147
- return true;
148
- } catch (Exception e) {
149
- return false;
150
- }
151
- }
152
-
153
- /**
154
- * Remove view from mixer
155
- */
156
- public boolean removeView(String viewId) {
157
- try {
158
- VeLiveMixVideoLayout layout = mixedViewLayout.remove(viewId);
159
- if (layout == null) {
160
- return false;
161
- }
162
-
163
- viewIdToStreamId.remove(viewId);
164
-
165
- View view = cachedMixedViews.get(viewId);
166
- if (view instanceof MixerView) {
167
- MixerView mixerView = (MixerView)view;
168
- mixerView.setBitmapCaptureCallback(null);
169
- }
170
-
171
- pusher.getMixerManager().removeVideoStream(layout.streamId);
172
- return true;
173
-
174
- } catch (Exception e) {
175
- return false;
176
- }
177
- }
178
-
179
- /**
180
- * Manually trigger bitmap capture for a view
181
- */
182
- public void captureView(String viewId) {
183
- View view = cachedMixedViews.get(viewId);
184
- if (view instanceof MixerView) {
185
- MixerView mixerView = (MixerView)view;
186
- mixerView.performManualCapture();
187
- }
188
- }
189
-
190
- /**
191
- * Called when MixerView is ready - check for pending callbacks
192
- */
193
- public static void onViewReady(String viewId, MixerView mixerView) {
194
- try {
195
- MixerManager instance = findActiveMixerManager();
196
- if (instance != null) {
197
- Integer streamId = instance.pendingCallbacks.remove(viewId);
198
- if (streamId != null) {
199
- setupCallbackForMixerView(mixerView, streamId);
200
-
201
- android.os.Handler mainHandler =
202
- new android.os.Handler(android.os.Looper.getMainLooper());
203
- mainHandler.postDelayed(new Runnable() {
204
- @Override
205
- public void run() {
206
- try {
207
- VeLiveMixVideoLayout layout =
208
- instance.mixedViewLayout.get(viewId);
209
- if (layout != null && instance.pusher != null &&
210
- instance.pusher.getMixerManager() != null) {
211
- VeLiveStreamMixDescription description =
212
- new VeLiveStreamMixDescription();
213
- description.mixVideoStreams.add(layout);
214
- instance.pusher.getMixerManager().updateStreamMixDescription(
215
- description);
216
- }
217
- mixerView.performManualCapture();
218
- } catch (Exception e) {
219
- Log.w(TAG, "Failed to perform operations in onViewReady", e);
220
- }
221
- }
222
- }, 300);
223
- }
224
- }
225
- } catch (Exception e) {
226
- Log.w(TAG, "Error in onViewReady", e);
227
- }
228
- }
229
-
230
- /**
231
- * Send captured bitmap to mixer as video frame
232
- */
233
- private void sendBitmapToMixer(int streamId, Bitmap bitmap) {
234
- try {
235
- if (bitmap == null || bitmap.isRecycled()) {
236
- return;
237
- }
238
-
239
- if (pusher == null || pusher.getMixerManager() == null) {
240
- return;
241
- }
242
-
243
- int width = bitmap.getWidth();
244
- int height = bitmap.getHeight();
245
-
246
- if (width <= 0 || height <= 0) {
247
- return;
248
- }
249
-
250
- TextureMgr textureMgr = new TextureMgr(width, height);
251
- textureMgr.dealWithTexture(bitmap, new TextureMgr.RenderListener() {
252
- @Override
253
- public void doBusiness(int texture) {
254
- try {
255
- if (texture <= 0) {
256
- return;
257
- }
258
-
259
- long pts = System.currentTimeMillis() * 1000;
260
- VeLiveVideoFrame videoFrame =
261
- new VeLiveVideoFrame(width, height, pts, texture, false, null);
262
-
263
- if (pusher != null && pusher.getMixerManager() != null) {
264
- pusher.getMixerManager().sendCustomVideoFrame(videoFrame,
265
- streamId);
266
- }
267
- } catch (Exception e) {
268
- // Ignore
269
- } finally {
270
- if (bitmap != null && !bitmap.isRecycled()) {
271
- bitmap.recycle();
272
- }
273
- textureMgr.cleanup();
274
- }
275
- }
276
- });
277
- } catch (Exception e) {
278
- // Ignore
279
- }
280
- }
281
-
282
- /**
283
- * Static method to set up callback for MixerView
284
- * Now with intelligent layout waiting logic
285
- */
286
- private static void setupCallbackForMixerView(MixerView mixerView,
287
- int streamId) {
288
- if (mixerView == null) {
289
- return;
290
- }
291
-
292
- mixerView.setBitmapCaptureCallback(new BitmapCaptureCallback() {
293
- @Override
294
- public void onBitmapCaptured(Bitmap bitmap) {
295
- try {
296
- if (bitmap != null && !bitmap.isRecycled()) {
297
- sendBitmapToMixerStatic(streamId, bitmap);
298
- }
299
- } catch (OutOfMemoryError e) {
300
- System.gc();
301
- } catch (Exception e) {
302
- // Ignore
303
- }
304
- }
305
-
306
- @Override
307
- public void onCaptureError(String error) {
308
- // Ignore
309
- }
310
- });
311
-
312
- if (mixerView.getWidth() > 0 && mixerView.getHeight() > 0) {
313
- try {
314
- mixerView.performManualCapture();
315
- } catch (Exception e) {
316
- // Ignore
317
- }
318
- } else {
319
- ViewTreeObserver.OnGlobalLayoutListener layoutListener =
320
- new ViewTreeObserver.OnGlobalLayoutListener() {
321
- @Override
322
- public void onGlobalLayout() {
323
- try {
324
- if (mixerView.getViewTreeObserver().isAlive()) {
325
- if (mixerView.getWidth() > 0 && mixerView.getHeight() > 0) {
326
- mixerView.getViewTreeObserver()
327
- .removeOnGlobalLayoutListener(this);
328
- mixerView.performManualCapture();
329
- }
330
- }
331
- } catch (Exception e) {
332
- // Ignore
333
- }
334
- }
335
- };
336
-
337
- try {
338
- mixerView.getViewTreeObserver().addOnGlobalLayoutListener(
339
- layoutListener);
340
- } catch (Exception e) {
341
- // Ignore
342
- }
343
- }
344
- }
345
-
346
- /**
347
- * Static version of sendBitmapToMixer - finds the active MixerManager
348
- * instance
349
- */
350
- private static void sendBitmapToMixerStatic(int streamId, Bitmap bitmap) {
351
- try {
352
- MixerManager instance = findActiveMixerManager();
353
- if (instance != null && instance.pusher != null) {
354
- instance.sendBitmapToMixer(streamId, bitmap);
355
- }
356
- } catch (Exception e) {
357
- // Ignore
358
- }
359
- }
360
-
361
- /**
362
- * Find the active MixerManager instance
363
- */
364
- private static MixerManager findActiveMixerManager() {
365
- MixerManager instance = currentInstance;
366
- if (instance != null && instance.pusher != null) {
367
- return instance;
368
- }
369
- return null;
370
- }
371
-
372
- private static volatile MixerManager currentInstance;
373
-
374
- public MixerManager() {
375
- synchronized (MixerManager.class) { currentInstance = this; }
376
- }
377
-
378
- /**
379
- * cleanup method to release resources
380
- */
381
- public void cleanup() {
382
- try {
383
- for (String viewId : cachedMixedViews.keySet()) {
384
- View view = cachedMixedViews.get(viewId);
385
- if (view instanceof MixerView) {
386
- MixerView mixerView = (MixerView)view;
387
- mixerView.setBitmapCaptureCallback(null);
388
- }
389
- }
390
-
391
- mixedViewLayout.clear();
392
- viewIdToStreamId.clear();
393
- pendingCallbacks.clear();
394
-
395
- synchronized (MixerManager.class) {
396
- if (currentInstance == this) {
397
- currentInstance = null;
398
- }
399
- }
400
-
401
- pusher = null;
402
- } catch (Exception e) {
403
- // Ignore
404
- }
405
- }
406
-
407
- // Callback interface for bitmap capture
408
- public interface BitmapCaptureCallback {
409
- void onBitmapCaptured(Bitmap bitmap);
410
- void onCaptureError(String error);
411
- }
412
- }