react-native-webrtc 155.0.0 → 155.0.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.
|
@@ -8,6 +8,8 @@ import android.media.projection.MediaProjectionConfig;
|
|
|
8
8
|
import android.util.DisplayMetrics;
|
|
9
9
|
import android.util.Log;
|
|
10
10
|
import android.os.Build;
|
|
11
|
+
import android.os.Handler;
|
|
12
|
+
import android.os.Looper;
|
|
11
13
|
|
|
12
14
|
import androidx.core.util.Consumer;
|
|
13
15
|
|
|
@@ -34,7 +36,9 @@ import java.util.List;
|
|
|
34
36
|
import java.util.Map;
|
|
35
37
|
import java.util.Objects;
|
|
36
38
|
import java.util.UUID;
|
|
39
|
+
import java.util.concurrent.CompletableFuture;
|
|
37
40
|
import java.util.concurrent.TimeUnit;
|
|
41
|
+
import java.util.concurrent.TimeoutException;
|
|
38
42
|
import java.util.stream.Collectors;
|
|
39
43
|
|
|
40
44
|
/**
|
|
@@ -92,8 +96,14 @@ class GetUserMediaImpl {
|
|
|
92
96
|
|
|
93
97
|
mediaProjectionPermissionResultData = data;
|
|
94
98
|
|
|
95
|
-
MediaProjectionService.launch(activity)
|
|
96
|
-
|
|
99
|
+
CompletableFuture<Void> launchFuture = MediaProjectionService.launch(activity);
|
|
100
|
+
|
|
101
|
+
// CompletableFuture.orTimeout() requires API 31; this is a no-op if already completed.
|
|
102
|
+
new Handler(Looper.getMainLooper()).postDelayed(
|
|
103
|
+
() -> launchFuture.completeExceptionally(new TimeoutException()),
|
|
104
|
+
TimeUnit.SECONDS.toMillis(10));
|
|
105
|
+
|
|
106
|
+
launchFuture
|
|
97
107
|
.whenCompleteAsync((value, error) -> {
|
|
98
108
|
if (error != null) {
|
|
99
109
|
Log.e(TAG, "Failed to start MediaProjection service", error);
|
|
@@ -51,23 +51,6 @@
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// Enable Center Stage when the device supports it; cooperative with Control Center.
|
|
55
|
-
if (@available(iOS 16.0, *)) {
|
|
56
|
-
BOOL centerStageSupported = NO;
|
|
57
|
-
for (AVCaptureDeviceFormat *fmt in [RTCCameraVideoCapturer supportedFormatsForDevice:self.device]) {
|
|
58
|
-
if (fmt.isCenterStageSupported) {
|
|
59
|
-
centerStageSupported = YES;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (centerStageSupported) {
|
|
64
|
-
AVCaptureDevice.centerStageControlMode = AVCaptureCenterStageControlModeCooperative;
|
|
65
|
-
AVCaptureDevice.centerStageEnabled = YES;
|
|
66
|
-
} else if (AVCaptureDevice.isCenterStageEnabled) {
|
|
67
|
-
AVCaptureDevice.centerStageEnabled = NO;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
54
|
AVCaptureDeviceFormat *format = [self selectFormatForDevice:self.device
|
|
72
55
|
withTargetWidth:self.width
|
|
73
56
|
withTargetHeight:self.height];
|
|
@@ -79,17 +62,6 @@
|
|
|
79
62
|
|
|
80
63
|
self.selectedFormat = format;
|
|
81
64
|
|
|
82
|
-
// Clamp fps to the range Center Stage allows for this format.
|
|
83
|
-
int fps = self.frameRate;
|
|
84
|
-
if (@available(iOS 16.0, *)) {
|
|
85
|
-
if (AVCaptureDevice.isCenterStageEnabled) {
|
|
86
|
-
AVFrameRateRange *csRange = format.videoFrameRateRangeForCenterStage;
|
|
87
|
-
if (csRange) {
|
|
88
|
-
fps = MAX((int)csRange.minFrameRate, MIN(fps, (int)csRange.maxFrameRate));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
65
|
AVCaptureSession *session = self.capturer.captureSession;
|
|
94
66
|
if (@available(iOS 16.0, *)) {
|
|
95
67
|
BOOL enable = self.enableMultitaskingCameraAccess;
|
|
@@ -111,7 +83,7 @@
|
|
|
111
83
|
__weak VideoCaptureController *weakSelf = self;
|
|
112
84
|
[self.capturer startCaptureWithDevice:self.device
|
|
113
85
|
format:format
|
|
114
|
-
fps:
|
|
86
|
+
fps:self.frameRate
|
|
115
87
|
completionHandler:^(NSError *err) {
|
|
116
88
|
if (err) {
|
|
117
89
|
RCTLogError(@"[VideoCaptureController] Error starting capture: %@", err);
|
|
@@ -298,18 +270,7 @@
|
|
|
298
270
|
AVCaptureDeviceFormat *selectedFormat = nil;
|
|
299
271
|
int currentDiff = INT_MAX;
|
|
300
272
|
|
|
301
|
-
BOOL centerStageEnabled = NO;
|
|
302
|
-
if (@available(iOS 16.0, *)) {
|
|
303
|
-
centerStageEnabled = AVCaptureDevice.isCenterStageEnabled;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
273
|
for (AVCaptureDeviceFormat *format in formats) {
|
|
307
|
-
// Center Stage only permits supported formats.
|
|
308
|
-
if (@available(iOS 16.0, *)) {
|
|
309
|
-
if (centerStageEnabled && !format.isCenterStageSupported) {
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
274
|
CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
|
|
314
275
|
FourCharCode pixelFormat = CMFormatDescriptionGetMediaSubType(format.formatDescription);
|
|
315
276
|
int diff = abs(targetWidth - dimension.width) + abs(targetHeight - dimension.height);
|