@byteplus/react-native-live-push 1.1.3-rc.4 → 1.2.0-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 (59) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/com/volcengine/velive/rn/push/ClassHelper.java +9 -0
  3. package/android/src/main/java/com/volcengine/velive/rn/push/NativeVariableManager.java +5 -8
  4. package/android/src/main/java/com/volcengine/velive/rn/push/VeLivePushModule.java +1 -0
  5. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerManager.java +1 -3
  6. package/android/src/main/java/com/volcengine/velive/rn/push/mixer/MixerView.java +33 -22
  7. package/ios/VeLiveMixerHelper.h +7 -5
  8. package/ios/VeLiveMixerHelper.m +1 -1
  9. package/ios/VeLiveMixerViewManager.m +2 -2
  10. package/lib/commonjs/index.js +23202 -20302
  11. package/lib/commonjs/typescript/android/index.d.ts +0 -3
  12. package/lib/commonjs/typescript/codegen/android/api.d.ts +190 -644
  13. package/lib/commonjs/typescript/codegen/android/callback.d.ts +234 -2
  14. package/lib/commonjs/typescript/codegen/android/errorcode.d.ts +66 -0
  15. package/lib/commonjs/typescript/codegen/android/keytype.d.ts +1014 -181
  16. package/lib/commonjs/typescript/codegen/ios/api.d.ts +890 -0
  17. package/lib/commonjs/typescript/codegen/ios/callback.d.ts +162 -0
  18. package/lib/commonjs/typescript/codegen/ios/errorcode.d.ts +101 -1
  19. package/lib/commonjs/typescript/codegen/ios/keytype.d.ts +694 -0
  20. package/lib/commonjs/typescript/codegen/pack/api.d.ts +303 -686
  21. package/lib/commonjs/typescript/codegen/pack/callback.d.ts +37 -38
  22. package/lib/commonjs/typescript/codegen/pack/errorcode.d.ts +75 -5
  23. package/lib/commonjs/typescript/codegen/pack/keytype.d.ts +1002 -298
  24. package/lib/commonjs/typescript/core/api.d.ts +2 -1
  25. package/lib/commonjs/typescript/core/pusher.d.ts +0 -3
  26. package/lib/module/index.js +23203 -20302
  27. package/lib/module/typescript/android/index.d.ts +0 -3
  28. package/lib/module/typescript/codegen/android/api.d.ts +190 -644
  29. package/lib/module/typescript/codegen/android/callback.d.ts +234 -2
  30. package/lib/module/typescript/codegen/android/errorcode.d.ts +66 -0
  31. package/lib/module/typescript/codegen/android/keytype.d.ts +1014 -181
  32. package/lib/module/typescript/codegen/ios/api.d.ts +890 -0
  33. package/lib/module/typescript/codegen/ios/callback.d.ts +162 -0
  34. package/lib/module/typescript/codegen/ios/errorcode.d.ts +101 -1
  35. package/lib/module/typescript/codegen/ios/keytype.d.ts +694 -0
  36. package/lib/module/typescript/codegen/pack/api.d.ts +303 -686
  37. package/lib/module/typescript/codegen/pack/callback.d.ts +37 -38
  38. package/lib/module/typescript/codegen/pack/errorcode.d.ts +75 -5
  39. package/lib/module/typescript/codegen/pack/keytype.d.ts +1002 -298
  40. package/lib/module/typescript/core/api.d.ts +2 -1
  41. package/lib/module/typescript/core/pusher.d.ts +0 -3
  42. package/lib/typescript/android/index.d.ts +0 -3
  43. package/lib/typescript/codegen/android/api.d.ts +190 -644
  44. package/lib/typescript/codegen/android/callback.d.ts +234 -2
  45. package/lib/typescript/codegen/android/errorcode.d.ts +66 -0
  46. package/lib/typescript/codegen/android/keytype.d.ts +1014 -181
  47. package/lib/typescript/codegen/ios/api.d.ts +890 -0
  48. package/lib/typescript/codegen/ios/callback.d.ts +162 -0
  49. package/lib/typescript/codegen/ios/errorcode.d.ts +101 -1
  50. package/lib/typescript/codegen/ios/keytype.d.ts +694 -0
  51. package/lib/typescript/codegen/pack/api.d.ts +303 -686
  52. package/lib/typescript/codegen/pack/callback.d.ts +37 -38
  53. package/lib/typescript/codegen/pack/errorcode.d.ts +75 -5
  54. package/lib/typescript/codegen/pack/keytype.d.ts +1002 -298
  55. package/lib/typescript/core/api.d.ts +2 -1
  56. package/lib/typescript/core/pusher.d.ts +0 -3
  57. package/package.json +1 -1
  58. package/react-native-velive-push.podspec +3 -3
  59. package/android/src/main/java/com/volcengine/velive/rn/push/ScreenCaptureHelper.java +0 -73
@@ -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.2.3"
91
- api 'com.bytedanceapi:ttsdk-ttlivepush_rtc:1.41.300.103'
90
+ implementation "com.volcengine:VolcApiEngine:1.6.2"
91
+ api 'com.bytedanceapi:ttsdk-ttlivepush_rtc:1.46.300.2'
92
92
  }
@@ -0,0 +1,9 @@
1
+ package com.volcengine.velive.rn.push;
2
+ import com.ss.avframework.live.statistics.VeLivePusherStatisticsExt;
3
+ import com.volcengine.VolcApiEngine.runtime.Util;
4
+
5
+ public class ClassHelper {
6
+ public static void init() {
7
+ Util.JsonAbleClass.add(VeLivePusherStatisticsExt.class);
8
+ }
9
+ }
@@ -1,19 +1,16 @@
1
1
  package com.volcengine.velive.rn.push;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
-
5
4
  import com.facebook.react.bridge.ReactApplicationContext;
6
5
  import com.volcengine.VolcApiEngine.*;
7
6
 
8
7
  public class NativeVariableManager {
9
- static void init(@NonNull VolcApiEngine apiEngine, ReactApplicationContext reactContext) {
8
+ static void init(@NonNull VolcApiEngine apiEngine,
9
+ ReactApplicationContext reactContext) {
10
10
  var m = apiEngine.msgClient.proto.variableManager;
11
-
12
- m.registerVar("ApplicationContext", (Object[] args) -> reactContext.getApplicationContext());
13
- m.registerVar("ReactApplicationContext", (Object[] args) -> reactContext);
14
11
 
15
- var helper = new ScreenCaptureHelper(reactContext);
16
- m.registerVar("screenIntent", helper::getScreenIntent);
17
- helper.setup();
12
+ m.registerVar("ApplicationContext",
13
+ (Object[] args) -> reactContext.getApplicationContext());
14
+ m.registerVar("ReactApplicationContext", (Object[] args) -> reactContext);
18
15
  }
19
16
  }
@@ -50,6 +50,7 @@ public class VeLivePushModule extends VeLivePushModuleSpec implements IEventRece
50
50
  apiEngine = new VolcApiEngine(getReactApplicationContext(), this);
51
51
 
52
52
  NativeVariableManager.init(apiEngine, super.context);
53
+ ClassHelper.init();
53
54
  return true;
54
55
  }
55
56
 
@@ -167,6 +167,7 @@ public class MixerManager {
167
167
  MixerView mixerView = (MixerView)view;
168
168
  mixerView.setBitmapCaptureCallback(null);
169
169
  }
170
+ cachedMixedViews.remove(viewId);
170
171
 
171
172
  pusher.getMixerManager().removeVideoStream(layout.streamId);
172
173
  return true;
@@ -267,9 +268,6 @@ public class MixerManager {
267
268
  } catch (Exception e) {
268
269
  // Ignore
269
270
  } finally {
270
- if (bitmap != null && !bitmap.isRecycled()) {
271
- bitmap.recycle();
272
- }
273
271
  textureMgr.cleanup();
274
272
  }
275
273
  }
@@ -150,7 +150,7 @@ public class MixerView extends FrameLayout {
150
150
 
151
151
  private void startRealtimeCapture() {
152
152
  long interval = (long)(1000f / captureFramerate);
153
-
153
+
154
154
  captureRunnable = new Runnable() {
155
155
  @Override
156
156
  public void run() {
@@ -260,7 +260,7 @@ public class MixerView extends FrameLayout {
260
260
  return;
261
261
  }
262
262
  lastCaptureTime = currentTime;
263
-
263
+
264
264
  synchronized (captureLock) {
265
265
  if (isCapturing.compareAndSet(false, true)) {
266
266
  Bitmap bitmap = null;
@@ -271,9 +271,16 @@ public class MixerView extends FrameLayout {
271
271
  }
272
272
  } catch (OutOfMemoryError e) {
273
273
  System.gc();
274
+ // If an OOM occurs and the bitmap has not been passed to
275
+ // processBitmap, recycle it
276
+ if (bitmap != null && !bitmap.isRecycled()) {
277
+ bitmap.recycle();
278
+ }
279
+ } catch (Exception e) {
280
+ // If any other exception occurs and the bitmap has not been passed to
281
+ // processBitmap, recycle it
274
282
  if (bitmap != null && !bitmap.isRecycled()) {
275
283
  bitmap.recycle();
276
- bitmap = null;
277
284
  }
278
285
  } finally {
279
286
  isCapturing.set(false);
@@ -313,7 +320,7 @@ public class MixerView extends FrameLayout {
313
320
  }
314
321
  return;
315
322
  }
316
-
323
+
317
324
  // Call callback first if set (for MixerManager)
318
325
  if (bitmapCaptureCallback != null) {
319
326
  try {
@@ -321,7 +328,8 @@ public class MixerView extends FrameLayout {
321
328
  bitmapCaptureCallback.onBitmapCaptured(bitmap);
322
329
  } catch (Exception e) {
323
330
  if (bitmapCaptureCallback != null) {
324
- bitmapCaptureCallback.onCaptureError("Callback error: " + e.getMessage());
331
+ bitmapCaptureCallback.onCaptureError("Callback error: " +
332
+ e.getMessage());
325
333
  }
326
334
  }
327
335
  } else {
@@ -341,19 +349,23 @@ public class MixerView extends FrameLayout {
341
349
  } catch (IllegalStateException e) {
342
350
  // Ignore
343
351
  }
344
-
345
- // if no callback, recycle immediately to avoid accumulation
346
- if (bitmap != null && !bitmap.isRecycled()) {
347
- bitmap.recycle();
348
- return;
349
- }
350
352
  }
351
353
 
352
354
  // Clean up old bitmap
353
355
  if (lastBitmap != null && !lastBitmap.isRecycled()) {
354
356
  lastBitmap.recycle();
355
357
  }
356
- lastBitmap = bitmap;
358
+
359
+ // 如果没有设置回调,立即释放当前 bitmap 以避免内存累积
360
+ // 如果设置了回调,bitmap 将由回调的接收方负责管理
361
+ if (bitmapCaptureCallback == null) {
362
+ if (bitmap != null && !bitmap.isRecycled()) {
363
+ bitmap.recycle();
364
+ }
365
+ lastBitmap = null;
366
+ } else {
367
+ lastBitmap = bitmap;
368
+ }
357
369
  }
358
370
 
359
371
  public void handleCommand(String command, @Nullable ReadableArray args) {
@@ -384,7 +396,7 @@ public class MixerView extends FrameLayout {
384
396
  MixerManager.onViewReady(viewId, this);
385
397
  }
386
398
  }
387
-
399
+
388
400
  @Override
389
401
  protected void onDetachedFromWindow() {
390
402
  super.onDetachedFromWindow();
@@ -393,24 +405,23 @@ public class MixerView extends FrameLayout {
393
405
  }
394
406
  cleanup();
395
407
  }
396
-
397
- public void setViewId(String viewId) {
398
- this.viewId = viewId;
408
+
409
+ public void setViewId(String viewId) {
410
+ this.viewId = viewId;
399
411
  MixerManager.cachedMixedViews.put(viewId, this);
400
412
  // 通知MixerManager视图已准备好,检查是否有待处理的回调
401
413
  MixerManager.onViewReady(viewId, this);
402
414
  }
403
415
 
404
416
  // Add callback support for MixerManager integration
405
- public void setBitmapCaptureCallback(MixerManager.BitmapCaptureCallback callback) {
417
+ public void
418
+ setBitmapCaptureCallback(MixerManager.BitmapCaptureCallback callback) {
406
419
  this.bitmapCaptureCallback = callback;
407
420
  }
408
421
 
409
422
  // Public method for manual capture (called by MixerManager)
410
- public void performManualCapture() {
411
- performCapture("manual");
412
- }
413
-
423
+ public void performManualCapture() { performCapture("manual"); }
424
+
414
425
  private void cleanup() {
415
426
  isDestroyed.set(true);
416
427
  stopCapture();
@@ -420,4 +431,4 @@ public class MixerView extends FrameLayout {
420
431
  lastBitmap = null;
421
432
  }
422
433
  }
423
- }
434
+ }
@@ -5,8 +5,8 @@
5
5
  // Created by ByteDance on 2024/12/09.
6
6
  //
7
7
 
8
- #import <Foundation/Foundation.h>
9
8
  #import "VeLiveMixerView.h"
9
+ #import <Foundation/Foundation.h>
10
10
 
11
11
  NS_ASSUME_NONNULL_BEGIN
12
12
 
@@ -17,9 +17,10 @@ NS_ASSUME_NONNULL_BEGIN
17
17
  @interface VeLiveMixerHelper : NSObject <VeLiveBitmapCaptureCallback>
18
18
 
19
19
  // 对齐Android的static cachedMixedViews
20
- @property (class, nonatomic, strong) NSMutableDictionary<NSString *, VeLiveMixerUIView *> *cachedMixedViews;
20
+ @property(class, nonatomic, strong)
21
+ NSMutableDictionary<NSString *, VeLiveMixerUIView *> *cachedMixedViews;
21
22
 
22
- @property (nonatomic, weak) VeLivePusher *pusher;
23
+ @property(nonatomic, weak) VeLivePusher *pusher;
23
24
 
24
25
  - (instancetype)initWithPusher:(VeLivePusher *)pusher;
25
26
 
@@ -31,7 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
31
32
  - (void)captureView:(NSString *)viewId;
32
33
 
33
34
  // Static方法 - 只保留Android中实际存在的
34
- + (void)setupCallbackForMixerView:(VeLiveMixerUIView *)mixerView streamId:(int)streamId;
35
+ + (void)setupCallbackForMixerView:(VeLiveMixerUIView *)mixerView
36
+ streamId:(int)streamId;
35
37
  + (void)sendBitmapToMixerStatic:(int)streamId bitmap:(UIImage *)bitmap;
36
38
  + (VeLiveMixerHelper *)findActiveMixerManager;
37
39
  + (void)onViewReady:(NSString *)viewId mixerView:(VeLiveMixerUIView *)mixerView;
@@ -41,4 +43,4 @@ NS_ASSUME_NONNULL_BEGIN
41
43
 
42
44
  @end
43
45
 
44
- NS_ASSUME_NONNULL_END
46
+ NS_ASSUME_NONNULL_END
@@ -6,7 +6,7 @@
6
6
  //
7
7
 
8
8
  #import "VeLiveMixerHelper.h"
9
- #import <TTSDKLivePushRTS/TTSDKLivePushRTS.h>
9
+ #import <TTSDKFramework/VeLivePusher.h>
10
10
  #import <UIKit/UIKit.h>
11
11
  #import <mach/mach.h>
12
12
  #import <mach/task_info.h>
@@ -33,7 +33,7 @@ RCT_CUSTOM_VIEW_PROPERTY(viewId, NSString, VeLiveMixerUIView) {
33
33
  if (json == nil) {
34
34
  return;
35
35
  }
36
-
36
+
37
37
  NSString *viewId = [RCTConvert NSString:json];
38
38
  [view setViewId:viewId];
39
39
  }
@@ -89,4 +89,4 @@ RCT_CUSTOM_VIEW_PROPERTY(autoSensitivity, NSNumber, VeLiveMixerUIView) {
89
89
  [view setAutoSensitivity:sensitivity];
90
90
  }
91
91
 
92
- @end
92
+ @end