@volcengine/react-native-live-pull 1.5.1-rc.2 → 1.5.2-rc.1

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.
@@ -46,18 +46,13 @@
46
46
  - (void) insertSubview:(UIView *)view atIndex:(NSInteger)index {
47
47
  // NSLog(@"insert playview, self bounds=%f x %f", self.bounds.size.width, self.bounds.size.height);
48
48
  // NSLog(@"insert playview, view frame=%f x %f", view.frame.size.width, view.frame.size.height);
49
-
50
- dispatch_async(dispatch_get_main_queue(), ^{
51
49
  [super insertSubview:view atIndex:index];
52
50
  [self setSubViewLayout:view];
53
- });
54
51
  }
55
52
 
56
53
  - (void) addSubview:(UIView *)view {
57
- dispatch_async(dispatch_get_main_queue(), ^{
58
54
  [super addSubview:view];
59
55
  [self setSubViewLayout:view];
60
- });
61
56
  }
62
57
 
63
58
  // 设置 Auto Layout,确保 subView 始终匹配 view 尺寸
@@ -52,11 +52,17 @@ NSString *const kObserverKey = @"pip-observer";
52
52
  if (@available(iOS 14.2, *)) {
53
53
  _canStartPictureInPictureAutomaticallyFromInline = NO;
54
54
  }
55
+ // 监听从通知中心/后台返回活跃状态
56
+ [[NSNotificationCenter defaultCenter] addObserver:self
57
+ selector:@selector(handleAppDidBecomeActive)
58
+ name:UIApplicationDidBecomeActiveNotification
59
+ object:nil];
55
60
  }
56
61
  return self;
57
62
  }
58
63
 
59
64
  - (void)dealloc {
65
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
60
66
  [self disableVideoFrameObserver];
61
67
  [self stopPlaybackStateTimer];
62
68
 
@@ -68,6 +74,31 @@ NSString *const kObserverKey = @"pip-observer";
68
74
  [[VeLivePlayerMultiObserver sharedInstance] removeObserver:kObserverKey];
69
75
  }
70
76
 
77
+ - (void)handleAppDidBecomeActive {
78
+
79
+ if (self.pipController && [self.pipController pictureInPictureController]) {
80
+ // 只有在 PIP 开启状态下才需要重连,避免干扰正常播放
81
+ AVPictureInPictureController *controller =
82
+ [self.pipController pictureInPictureController];
83
+ if (controller.isPictureInPictureActive) {
84
+ __weak typeof(self) weakSelf = self;
85
+ dispatch_async(dispatch_get_main_queue(), ^{
86
+ __strong typeof(weakSelf) strongSelf = weakSelf;
87
+ if (!strongSelf) return;
88
+ // 强制重新绑定 ContentView。
89
+ // 这会诱导底层重新创建 IOSurface,修复内核日志中的 SID: 0x0 报错。
90
+ [strongSelf.pipController setContentView:strongSelf.contentView completion:^{
91
+ __strong typeof(weakSelf) strongSelf = weakSelf;
92
+ if (!strongSelf) return;
93
+ // 刷新播放状态,确保画面立即同步
94
+ [[strongSelf.pipController pictureInPictureController] invalidatePlaybackState];
95
+ NSLog(@"PIP: App active, re-bound Surface to fix potential corruption.");
96
+ }];
97
+ });
98
+ }
99
+ }
100
+ }
101
+
71
102
  // Start playback state refresh timer
72
103
  - (void)startPlaybackStateTimer {
73
104
  [self stopPlaybackStateTimer];
@@ -245,7 +276,7 @@ NSString *const kObserverKey = @"pip-observer";
245
276
  self.enableVideoObserver = YES;
246
277
  [self.player
247
278
  enableVideoFrameObserver:YES
248
- pixelFormat:VeLivePlayerPixelFormatBGRA32
279
+ pixelFormat:VeLivePlayerPixelFormatNV12
249
280
  bufferType:VeLivePlayerVideoBufferTypeSampleBuffer];
250
281
  [[VeLivePlayerMultiObserver sharedInstance] removeObserver:kObserverKey];
251
282
  [[VeLivePlayerMultiObserver sharedInstance] addObserver:kObserverKey
@@ -372,6 +403,20 @@ NSString *const kObserverKey = @"pip-observer";
372
403
  - (void)onRenderVideoFrame:(TVLManager *_Nonnull)player
373
404
  videoFrame:(VeLivePlayerVideoFrame *_Nonnull)videoFrame {
374
405
  @autoreleasepool {
406
+ UIApplicationState state = [UIApplication sharedApplication].applicationState;
407
+
408
+ // 【核心修正】
409
+ // 1. 如果是 Active (前台),正常推流。
410
+ // 2. 如果是 Background (正常画中画/后台),正常推流。
411
+ // 3. 【拦截】只有当状态是 Inactive 时:
412
+ // 这通常对应“下拉通知中心”、“拉下控制中心”或“系统弹窗”遮挡。
413
+ // 此时日志中的 SID: 0x0 报错最集中,必须拦截推流以保护内核句柄。
414
+ NSLog(@"PIP: Application state is %ld", (long)state);
415
+ if (state == UIApplicationStateInactive) {
416
+ // 如果正在画中画过程中,且 App 处于非活跃(被遮挡)状态,暂时丢弃这一帧
417
+ return;
418
+ }
419
+
375
420
  // Ensure pipController exists and is valid, avoid processing buffer during
376
421
  // destruction
377
422
  if (!self.pipController || !self.enableVideoObserver) {
@@ -470,4 +515,4 @@ NSString *const kObserverKey = @"pip-observer";
470
515
  }
471
516
  }
472
517
 
473
- @end
518
+ @end
@@ -14558,7 +14558,7 @@ function initAndroidEnv(config) {
14558
14558
  .setLicenseUri(config.LicenseUri.android);
14559
14559
  androidEnv = builder.build();
14560
14560
  EnvHelper.init(androidEnv, {
14561
- hybrid_ua: "rn|pull|".concat("1.5.0"),
14561
+ hybrid_ua: "rn|pull|".concat("1.5.1"),
14562
14562
  });
14563
14563
  Env.openAppLog(config.openLog);
14564
14564
  return [2 /*return*/];
@@ -14569,7 +14569,7 @@ function initAndroidEnv(config) {
14569
14569
  function initIOSEnv(config) {
14570
14570
  return __awaiter(this, void 0, void 0, function () {
14571
14571
  return __generator(this, function (_a) {
14572
- VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: config.AppID, hybrid_ua: "rn|pull|".concat("1.5.0") }));
14572
+ VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: config.AppID, hybrid_ua: "rn|pull|".concat("1.5.1") }));
14573
14573
  return [2 /*return*/];
14574
14574
  });
14575
14575
  });
@@ -14556,7 +14556,7 @@ function initAndroidEnv(config) {
14556
14556
  .setLicenseUri(config.LicenseUri.android);
14557
14557
  androidEnv = builder.build();
14558
14558
  EnvHelper.init(androidEnv, {
14559
- hybrid_ua: "rn|pull|".concat("1.5.0"),
14559
+ hybrid_ua: "rn|pull|".concat("1.5.1"),
14560
14560
  });
14561
14561
  Env.openAppLog(config.openLog);
14562
14562
  return [2 /*return*/];
@@ -14567,7 +14567,7 @@ function initAndroidEnv(config) {
14567
14567
  function initIOSEnv(config) {
14568
14568
  return __awaiter(this, void 0, void 0, function () {
14569
14569
  return __generator(this, function (_a) {
14570
- VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: config.AppID, hybrid_ua: "rn|pull|".concat("1.5.0") }));
14570
+ VeLivePlayerHelper.startWithConfiguration(__assign(__assign({}, config), { LicenseUri: config.LicenseUri.ios, appLogAid: config.AppID, hybrid_ua: "rn|pull|".concat("1.5.1") }));
14571
14571
  return [2 /*return*/];
14572
14572
  });
14573
14573
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/react-native-live-pull",
3
- "version": "1.5.1-rc.2",
3
+ "version": "1.5.2-rc.1",
4
4
  "peerDependencies": {
5
5
  "react": "*",
6
6
  "react-native": "*"