react-native-webrtc 1.89.3 → 1.94.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.
- package/.prettierignore +9 -0
- package/.prettierrc.json +10 -0
- package/README.md +4 -1
- package/android/libs/.placeholder +0 -0
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
- package/android/src/main/java/com/oney/WebRTCModule/LibraryLoader.java +21 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +301 -324
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +9 -84
- package/apple/.placeholder +0 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +3 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +4 -1
- package/ios/RCTWebRTC/VideoCaptureController.h +2 -2
- package/ios/RCTWebRTC/VideoCaptureController.m +131 -48
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +56 -26
- package/metro.config.js +3 -4
- package/metro.config.macos.js +7 -8
- package/package.json +21 -12
- package/react-native.config.js +5 -6
- package/{EventEmitter.js → src/EventEmitter.js} +1 -1
- package/{MediaDevices.js → src/MediaDevices.js} +6 -12
- package/src/MediaStream.js +128 -0
- package/src/MediaStreamError.js +12 -0
- package/src/MediaStreamErrorEvent.js +11 -0
- package/src/MediaStreamEvent.js +11 -0
- package/src/MediaStreamTrack.js +104 -0
- package/src/MediaStreamTrackEvent.js +11 -0
- package/src/MessageEvent.js +10 -0
- package/{Permissions.js → src/Permissions.js} +26 -23
- package/src/RTCDataChannel.js +143 -0
- package/src/RTCDataChannelEvent.js +11 -0
- package/src/RTCEvent.js +8 -0
- package/src/RTCIceCandidate.js +20 -0
- package/src/RTCIceCandidateEvent.js +15 -0
- package/src/RTCPeerConnection.js +349 -0
- package/src/RTCSessionDescription.js +22 -0
- package/{RTCUtil.js → src/RTCUtil.js} +56 -57
- package/src/RTCView.js +60 -0
- package/src/ScreenCapturePickerView.js +4 -0
- package/{getDisplayMedia.js → src/getDisplayMedia.js} +8 -11
- package/src/getUserMedia.js +98 -0
- package/src/index.js +44 -0
- package/tools/build-webrtc.py +60 -46
- package/tools/downloadBitcode.sh +4 -16
- package/tools/downloadWebRTC.js +100 -0
- package/MediaStream.js +0 -138
- package/MediaStreamError.js +0 -14
- package/MediaStreamErrorEvent.js +0 -12
- package/MediaStreamEvent.js +0 -12
- package/MediaStreamTrack.js +0 -118
- package/MediaStreamTrackEvent.js +0 -12
- package/MessageEvent.js +0 -11
- package/RTCDataChannel.js +0 -161
- package/RTCDataChannelEvent.js +0 -12
- package/RTCEvent.js +0 -9
- package/RTCIceCandidate.js +0 -21
- package/RTCIceCandidateEvent.js +0 -16
- package/RTCPeerConnection.js +0 -390
- package/RTCSessionDescription.js +0 -23
- package/RTCView.js +0 -70
- package/ScreenCapturePickerView.js +0 -7
- package/android/libs/libjingle_peerconnection.so.jar +0 -0
- package/android/libs/libwebrtc.jar +0 -0
- package/apple/WebRTC.xcframework.tgz +0 -0
- package/getUserMedia.js +0 -98
- package/index.js +0 -47
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -46,33 +46,8 @@ public class WebRTCView extends ViewGroup {
|
|
|
46
46
|
private static final ScalingType DEFAULT_SCALING_TYPE
|
|
47
47
|
= ScalingType.SCALE_ASPECT_FIT;
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* {@link View#isInLayout()} as a <tt>Method</tt> to be invoked via
|
|
51
|
-
* reflection in order to accommodate its lack of availability before API
|
|
52
|
-
* level 18. {@link ViewCompat#isInLayout(View)} is the best solution but I
|
|
53
|
-
* could not make it available along with
|
|
54
|
-
* {@link ViewCompat#isAttachedToWindow(View)} at the time of this writing.
|
|
55
|
-
*/
|
|
56
|
-
private static final Method IS_IN_LAYOUT;
|
|
57
|
-
|
|
58
49
|
private static final String TAG = WebRTCModule.TAG;
|
|
59
50
|
|
|
60
|
-
static {
|
|
61
|
-
// IS_IN_LAYOUT
|
|
62
|
-
Method isInLayout = null;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
Method m = WebRTCView.class.getMethod("isInLayout");
|
|
66
|
-
|
|
67
|
-
if (boolean.class.isAssignableFrom(m.getReturnType())) {
|
|
68
|
-
isInLayout = m;
|
|
69
|
-
}
|
|
70
|
-
} catch (NoSuchMethodException e) {
|
|
71
|
-
// Fall back to the behavior of ViewCompat#isInLayout(View).
|
|
72
|
-
}
|
|
73
|
-
IS_IN_LAYOUT = isInLayout;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
51
|
/**
|
|
77
52
|
* The number of instances for {@link SurfaceViewRenderer}, used for logging.
|
|
78
53
|
* When the renderer is initialized, it creates a new {@link javax.microedition.khronos.egl.EGLContext}
|
|
@@ -196,27 +171,6 @@ public class WebRTCView extends ViewGroup {
|
|
|
196
171
|
surfaceViewRenderer.clearImage();
|
|
197
172
|
}
|
|
198
173
|
|
|
199
|
-
/**
|
|
200
|
-
* Gets the {@link VideoTrack}, if any, (to be) rendered by this
|
|
201
|
-
* {@code WebRTCView}.
|
|
202
|
-
*
|
|
203
|
-
* @return The {@code VideoTrack} (to be) rendered by this
|
|
204
|
-
* {@code WebRTCView}.
|
|
205
|
-
*/
|
|
206
|
-
private VideoTrack getVideoTrack() {
|
|
207
|
-
VideoTrack videoTrack = this.videoTrack;
|
|
208
|
-
|
|
209
|
-
// XXX If WebRTCModule#mediaStreamTrackRelease has already been invoked
|
|
210
|
-
// on videoTrack, then it is no longer safe to call methods (e.g.
|
|
211
|
-
// addRenderer, removeRenderer) on videoTrack.
|
|
212
|
-
if (videoTrack != null
|
|
213
|
-
&& videoTrack != getVideoTrackForStreamURL(this.streamURL)) {
|
|
214
|
-
videoTrack = null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return videoTrack;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
174
|
private VideoTrack getVideoTrackForStreamURL(String streamURL) {
|
|
221
175
|
VideoTrack videoTrack = null;
|
|
222
176
|
|
|
@@ -238,28 +192,6 @@ public class WebRTCView extends ViewGroup {
|
|
|
238
192
|
return videoTrack;
|
|
239
193
|
}
|
|
240
194
|
|
|
241
|
-
/**
|
|
242
|
-
* If this <tt>View</tt> has {@link View#isInLayout()}, invokes it and
|
|
243
|
-
* returns its return value; otherwise, returns <tt>false</tt> like
|
|
244
|
-
* {@link ViewCompat#isInLayout(View)}.
|
|
245
|
-
*
|
|
246
|
-
* @return If this <tt>View</tt> has <tt>View#isInLayout()</tt>, invokes it
|
|
247
|
-
* and returns its return value; otherwise, returns <tt>false</tt>.
|
|
248
|
-
*/
|
|
249
|
-
private boolean invokeIsInLayout() {
|
|
250
|
-
Method m = IS_IN_LAYOUT;
|
|
251
|
-
boolean b = false;
|
|
252
|
-
|
|
253
|
-
if (m != null) {
|
|
254
|
-
try {
|
|
255
|
-
b = (boolean) m.invoke(this);
|
|
256
|
-
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
257
|
-
// Fall back to the behavior of ViewCompat#isInLayout(View).
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return b;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
195
|
@Override
|
|
264
196
|
protected void onAttachedToWindow() {
|
|
265
197
|
try {
|
|
@@ -402,20 +334,15 @@ public class WebRTCView extends ViewGroup {
|
|
|
402
334
|
*/
|
|
403
335
|
private void removeRendererFromVideoTrack() {
|
|
404
336
|
if (rendererAttached) {
|
|
405
|
-
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
406
|
-
// invoked on videoTrack, then it is no longer safe to call methods
|
|
407
|
-
// (e.g. addSink, removeSink) on videoTrack. It is OK to
|
|
408
|
-
// skip the removeSink invocation in such a case because
|
|
409
|
-
// VideoTrack#dispose() has performed it already.
|
|
410
|
-
VideoTrack videoTrack = getVideoTrack();
|
|
411
|
-
|
|
412
337
|
if (videoTrack != null) {
|
|
338
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
339
|
+
// invoked on videoTrack, then it is no longer safe to call removeSink
|
|
340
|
+
// on the instance, it will throw IllegalStateException.
|
|
413
341
|
try {
|
|
414
342
|
videoTrack.removeSink(surfaceViewRenderer);
|
|
415
343
|
} catch (Throwable tr) {
|
|
416
344
|
// Releasing streams happens in the WebRTC thread, thus we might (briefly) hold
|
|
417
|
-
// a reference to a released stream.
|
|
418
|
-
Log.e(TAG, "Failed to remove renderer", tr);
|
|
345
|
+
// a reference to a released stream. Just ignore the error and move on.
|
|
419
346
|
}
|
|
420
347
|
}
|
|
421
348
|
|
|
@@ -446,7 +373,7 @@ public class WebRTCView extends ViewGroup {
|
|
|
446
373
|
surfaceViewRenderer.requestLayout();
|
|
447
374
|
// The above is not enough though when the video frame's dimensions or
|
|
448
375
|
// rotation change. The following will suffice.
|
|
449
|
-
if (!
|
|
376
|
+
if (!ViewCompat.isInLayout(this)) {
|
|
450
377
|
onLayout(
|
|
451
378
|
/* changed */ false,
|
|
452
379
|
getLeft(), getTop(), getRight(), getBottom());
|
|
@@ -597,13 +524,8 @@ public class WebRTCView extends ViewGroup {
|
|
|
597
524
|
* all preconditions for the start of rendering are met.
|
|
598
525
|
*/
|
|
599
526
|
private void tryAddRendererToVideoTrack() {
|
|
600
|
-
VideoTrack videoTrack;
|
|
601
|
-
|
|
602
527
|
if (!rendererAttached
|
|
603
|
-
|
|
604
|
-
// invoked on videoTrack, then it is no longer safe to call
|
|
605
|
-
// methods (e.g. addRenderer, removeRenderer) on videoTrack.
|
|
606
|
-
&& (videoTrack = getVideoTrack()) != null
|
|
528
|
+
&& videoTrack != null
|
|
607
529
|
&& ViewCompat.isAttachedToWindow(this)) {
|
|
608
530
|
EglBase.Context sharedContext = EglUtils.getRootEglBaseContext();
|
|
609
531
|
|
|
@@ -622,6 +544,9 @@ public class WebRTCView extends ViewGroup {
|
|
|
622
544
|
surfaceViewRendererInstances--;
|
|
623
545
|
}
|
|
624
546
|
|
|
547
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
548
|
+
// invoked on videoTrack, then it is no longer safe to call addSink
|
|
549
|
+
// on the instance, it will throw IllegalStateException.
|
|
625
550
|
try {
|
|
626
551
|
videoTrack.addSink(surfaceViewRenderer);
|
|
627
552
|
} catch (Throwable tr) {
|
|
File without changes
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
// Created by Alex-Dan Bumbu on 20/01/2021.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
#if !TARGET_OS_OSX
|
|
9
|
+
|
|
8
10
|
#import <ReplayKit/ReplayKit.h>
|
|
9
11
|
#import <React/RCTUIManager.h>
|
|
10
12
|
|
|
11
13
|
#import "ScreenCapturePickerViewManager.h"
|
|
12
|
-
//#import "WebRTCModule.h"
|
|
13
14
|
|
|
14
15
|
NSString* const kRTCScreenSharingExtension = @"RTCScreenSharingExtension";
|
|
15
16
|
|
|
@@ -63,3 +64,5 @@ RCT_EXPORT_METHOD(show:(nonnull NSNumber *)reactTag) {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
@end
|
|
67
|
+
|
|
68
|
+
#endif // !TARGET_OS_OSX
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
@interface VideoCaptureController : CaptureController
|
|
8
8
|
|
|
9
|
-
@property (nonatomic, readonly,
|
|
10
|
-
@property (nonatomic, readonly) int frameRate;
|
|
9
|
+
@property (nonatomic, readonly, strong) AVCaptureDeviceFormat *selectedFormat;
|
|
10
|
+
@property (nonatomic, readonly, assign) int frameRate;
|
|
11
11
|
|
|
12
12
|
-(instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
|
|
13
13
|
andConstraints:(NSDictionary *)constraints;
|
|
@@ -4,32 +4,36 @@
|
|
|
4
4
|
#import <React/RCTLog.h>
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
@
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
@interface VideoCaptureController ()
|
|
8
|
+
|
|
9
|
+
@property (nonatomic, strong) RTCCameraVideoCapturer *capturer;
|
|
10
|
+
@property (nonatomic, strong) AVCaptureDeviceFormat *selectedFormat;
|
|
11
|
+
@property (nonatomic, strong) AVCaptureDevice *device;
|
|
12
|
+
@property (nonatomic, copy) NSString *deviceId;
|
|
13
|
+
@property (nonatomic, assign) BOOL running;
|
|
14
|
+
@property (nonatomic, assign) BOOL usingFrontCamera;
|
|
15
|
+
@property (nonatomic, assign) int width;
|
|
16
|
+
@property (nonatomic, assign) int height;
|
|
17
|
+
@property (nonatomic, assign) int frameRate;
|
|
18
|
+
|
|
19
|
+
@end
|
|
16
20
|
|
|
17
|
-
@
|
|
21
|
+
@implementation VideoCaptureController
|
|
18
22
|
|
|
19
|
-
-(instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
|
|
20
|
-
|
|
23
|
+
- (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
|
|
24
|
+
andConstraints:(NSDictionary *)constraints {
|
|
21
25
|
self = [super init];
|
|
22
26
|
if (self) {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
self.capturer = capturer;
|
|
28
|
+
self.running = NO;
|
|
25
29
|
|
|
26
30
|
// Default to the front camera.
|
|
27
|
-
|
|
31
|
+
self.usingFrontCamera = YES;
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
self.deviceId = constraints[@"deviceId"];
|
|
34
|
+
self.width = [constraints[@"width"] intValue];
|
|
35
|
+
self.height = [constraints[@"height"] intValue];
|
|
36
|
+
self.frameRate = [constraints[@"frameRate"] intValue];
|
|
33
37
|
|
|
34
38
|
id facingMode = constraints[@"facingMode"];
|
|
35
39
|
|
|
@@ -45,55 +49,59 @@
|
|
|
45
49
|
position = AVCaptureDevicePositionFront;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
self.usingFrontCamera = position == AVCaptureDevicePositionFront;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
return self;
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
-(void)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
- (void)dealloc {
|
|
60
|
+
self.device = NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)startCapture {
|
|
64
|
+
if (self.deviceId) {
|
|
65
|
+
self.device = [AVCaptureDevice deviceWithUniqueID:self.deviceId];
|
|
59
66
|
}
|
|
60
|
-
if (!device) {
|
|
67
|
+
if (!self.device) {
|
|
61
68
|
AVCaptureDevicePosition position
|
|
62
|
-
=
|
|
69
|
+
= self.usingFrontCamera
|
|
63
70
|
? AVCaptureDevicePositionFront
|
|
64
71
|
: AVCaptureDevicePositionBack;
|
|
65
|
-
device = [self findDeviceForPosition:position];
|
|
72
|
+
self.device = [self findDeviceForPosition:position];
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
if (!device) {
|
|
75
|
+
if (!self.device) {
|
|
69
76
|
RCTLogWarn(@"[VideoCaptureController] No capture devices found!");
|
|
70
77
|
|
|
71
78
|
return;
|
|
72
79
|
}
|
|
73
|
-
|
|
80
|
+
|
|
74
81
|
AVCaptureDeviceFormat *format
|
|
75
|
-
= [self selectFormatForDevice:device
|
|
76
|
-
withTargetWidth:
|
|
77
|
-
withTargetHeight:
|
|
78
|
-
if (format
|
|
79
|
-
RCTLogWarn(@"[VideoCaptureController] No valid formats for device %@", device);
|
|
82
|
+
= [self selectFormatForDevice:self.device
|
|
83
|
+
withTargetWidth:self.width
|
|
84
|
+
withTargetHeight:self.height];
|
|
85
|
+
if (!format) {
|
|
86
|
+
RCTLogWarn(@"[VideoCaptureController] No valid formats for device %@", self.device);
|
|
80
87
|
|
|
81
88
|
return;
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
|
|
91
|
+
self.selectedFormat = format;
|
|
85
92
|
|
|
86
93
|
RCTLog(@"[VideoCaptureController] Capture will start");
|
|
87
94
|
|
|
88
95
|
// Starting the capture happens on another thread. Wait for it.
|
|
89
96
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
|
|
98
|
+
__weak VideoCaptureController *weakSelf = self;
|
|
99
|
+
[self.capturer startCaptureWithDevice:self.device format:format fps:self.frameRate completionHandler:^(NSError *err) {
|
|
92
100
|
if (err) {
|
|
93
101
|
RCTLogError(@"[VideoCaptureController] Error starting capture: %@", err);
|
|
94
102
|
} else {
|
|
95
103
|
RCTLog(@"[VideoCaptureController] Capture started");
|
|
96
|
-
|
|
104
|
+
weakSelf.running = YES;
|
|
97
105
|
}
|
|
98
106
|
dispatch_semaphore_signal(semaphore);
|
|
99
107
|
}];
|
|
@@ -101,36 +109,81 @@
|
|
|
101
109
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
-(void)stopCapture {
|
|
105
|
-
if (!
|
|
112
|
+
- (void)stopCapture {
|
|
113
|
+
if (!self.running)
|
|
106
114
|
return;
|
|
107
115
|
|
|
108
116
|
RCTLog(@"[VideoCaptureController] Capture will stop");
|
|
109
117
|
// Stopping the capture happens on another thread. Wait for it.
|
|
110
118
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
111
119
|
|
|
112
|
-
|
|
120
|
+
__weak VideoCaptureController *weakSelf = self;
|
|
121
|
+
[self.capturer stopCaptureWithCompletionHandler:^{
|
|
113
122
|
RCTLog(@"[VideoCaptureController] Capture stopped");
|
|
114
|
-
|
|
123
|
+
weakSelf.running = NO;
|
|
124
|
+
weakSelf.device = nil;
|
|
125
|
+
|
|
115
126
|
dispatch_semaphore_signal(semaphore);
|
|
116
127
|
}];
|
|
117
128
|
|
|
118
129
|
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
119
130
|
}
|
|
120
131
|
|
|
121
|
-
-(void)switchCamera {
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
- (void)switchCamera {
|
|
133
|
+
self.usingFrontCamera = !self.usingFrontCamera;
|
|
134
|
+
self.deviceId = nil;
|
|
135
|
+
self.device = nil;
|
|
124
136
|
|
|
125
137
|
[self startCapture];
|
|
126
138
|
}
|
|
127
139
|
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
#pragma mark NSKeyValueObserving
|
|
141
|
+
|
|
142
|
+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
|
|
143
|
+
if (@available(iOS 11.1, *)) {
|
|
144
|
+
if ([object isKindOfClass:[AVCaptureDevice class]] && [keyPath isEqualToString:@"systemPressureState"]) {
|
|
145
|
+
AVCaptureDevice *device = (AVCaptureDevice *)object;
|
|
146
|
+
AVCaptureSystemPressureLevel pressureLevel = ((AVCaptureSystemPressureState *)change[NSKeyValueChangeNewKey]).level;
|
|
147
|
+
if (pressureLevel == AVCaptureSystemPressureLevelSerious || pressureLevel == AVCaptureSystemPressureLevelCritical) {
|
|
148
|
+
RCTLogWarn(@"[VideoCaptureController] Reached elevated system pressure level: %@. Throttling frame rate.", pressureLevel);
|
|
149
|
+
[self throttleFrameRateForDevice:device];
|
|
150
|
+
}
|
|
151
|
+
else if (pressureLevel == AVCaptureSystemPressureLevelNominal) {
|
|
152
|
+
RCTLogWarn(@"[VideoCaptureController] Restored normal system pressure level. Resetting frame rate to default.");
|
|
153
|
+
[self resetFrameRateForDevice:device];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (void)registerSystemPressureStateObserverForDevice:(AVCaptureDevice *)device {
|
|
160
|
+
if (@available(iOS 11.1, *)) {
|
|
161
|
+
[device addObserver:self
|
|
162
|
+
forKeyPath:@"systemPressureState"
|
|
163
|
+
options:NSKeyValueObservingOptionNew
|
|
164
|
+
context:nil];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)removeObserverForDevice:(AVCaptureDevice *)device {
|
|
169
|
+
if (@available(iOS 11.1, *)) {
|
|
170
|
+
[device removeObserver:self forKeyPath:@"systemPressureState"];
|
|
171
|
+
}
|
|
130
172
|
}
|
|
131
173
|
|
|
132
174
|
#pragma mark Private
|
|
133
175
|
|
|
176
|
+
- (void)setDevice:(AVCaptureDevice *)device {
|
|
177
|
+
if (_device) {
|
|
178
|
+
[self removeObserverForDevice:_device];
|
|
179
|
+
}
|
|
180
|
+
if (device) {
|
|
181
|
+
[self registerSystemPressureStateObserverForDevice:device];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_device = device;
|
|
185
|
+
}
|
|
186
|
+
|
|
134
187
|
- (AVCaptureDevice *)findDeviceForPosition:(AVCaptureDevicePosition)position {
|
|
135
188
|
NSArray<AVCaptureDevice *> *captureDevices = [RTCCameraVideoCapturer captureDevices];
|
|
136
189
|
for (AVCaptureDevice *device in captureDevices) {
|
|
@@ -165,4 +218,34 @@
|
|
|
165
218
|
return selectedFormat;
|
|
166
219
|
}
|
|
167
220
|
|
|
221
|
+
- (void)throttleFrameRateForDevice:(AVCaptureDevice *)device {
|
|
222
|
+
NSError *error = nil;
|
|
223
|
+
|
|
224
|
+
[device lockForConfiguration:&error];
|
|
225
|
+
if (error) {
|
|
226
|
+
RCTLog(@"[VideoCaptureController] Could not lock device for configuration: %@", error);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
device.activeVideoMinFrameDuration = CMTimeMake(1, 20);
|
|
231
|
+
device.activeVideoMaxFrameDuration = CMTimeMake(1, 15);
|
|
232
|
+
|
|
233
|
+
[device unlockForConfiguration];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
- (void)resetFrameRateForDevice:(AVCaptureDevice *)device {
|
|
237
|
+
NSError *error = nil;
|
|
238
|
+
|
|
239
|
+
[device lockForConfiguration:&error];
|
|
240
|
+
if (error) {
|
|
241
|
+
RCTLog(@"[VideoCaptureController] Could not lock device for configuration: %@", error);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
device.activeVideoMinFrameDuration = kCMTimeInvalid;
|
|
246
|
+
device.activeVideoMaxFrameDuration = kCMTimeInvalid;
|
|
247
|
+
|
|
248
|
+
[device unlockForConfiguration];
|
|
249
|
+
}
|
|
250
|
+
|
|
168
251
|
@end
|
|
@@ -210,28 +210,37 @@ RCT_EXPORT_METHOD(peerConnectionCreateAnswer:(nonnull NSNumber *)peerConnectionI
|
|
|
210
210
|
}];
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
RCT_EXPORT_METHOD(peerConnectionSetLocalDescription:(
|
|
213
|
+
RCT_EXPORT_METHOD(peerConnectionSetLocalDescription:(nonnull NSNumber *)objectID
|
|
214
|
+
desc:(RTCSessionDescription *)desc
|
|
215
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
216
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
214
217
|
{
|
|
215
|
-
RTCPeerConnection
|
|
218
|
+
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
|
|
216
219
|
if (!peerConnection) {
|
|
220
|
+
reject(@"E_INVALID", @"PeerConnection not found", nil);
|
|
217
221
|
return;
|
|
218
222
|
}
|
|
219
223
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
224
|
+
__weak RTCPeerConnection *weakPc = peerConnection;
|
|
225
|
+
|
|
226
|
+
RTCSetSessionDescriptionCompletionHandler handler = ^(NSError *error) {
|
|
227
|
+
if (error) {
|
|
228
|
+
reject(@"E_OPERATION_ERROR", error.localizedDescription, nil);
|
|
229
|
+
} else {
|
|
230
|
+
RTCPeerConnection *strongPc = weakPc;
|
|
231
|
+
id newSdp = @{
|
|
232
|
+
@"type": [RTCSessionDescription stringForType:strongPc.localDescription.type],
|
|
233
|
+
@"sdp": strongPc.localDescription.sdp
|
|
234
|
+
};
|
|
235
|
+
resolve(newSdp);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
if (desc == nil) {
|
|
240
|
+
[peerConnection setLocalDescriptionWithCompletionHandler:handler];
|
|
241
|
+
} else {
|
|
242
|
+
[peerConnection setLocalDescription:desc completionHandler:handler];
|
|
243
|
+
}
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription:(RTCSessionDescription *)sdp objectID:(nonnull NSNumber *)objectID callback:(RCTResponseSenderBlock)callback)
|
|
@@ -258,20 +267,31 @@ RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription:(RTCSessionDescription *)sd
|
|
|
258
267
|
}];
|
|
259
268
|
}
|
|
260
269
|
|
|
261
|
-
RCT_EXPORT_METHOD(peerConnectionAddICECandidate:(
|
|
270
|
+
RCT_EXPORT_METHOD(peerConnectionAddICECandidate:(nonnull NSNumber *)objectID
|
|
271
|
+
candidate:(RTCIceCandidate*)candidate
|
|
272
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
273
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
262
274
|
{
|
|
263
275
|
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
|
|
264
276
|
if (!peerConnection) {
|
|
277
|
+
reject(@"E_INVALID", @"PeerConnection not found", nil);
|
|
265
278
|
return;
|
|
266
279
|
}
|
|
267
280
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
281
|
+
__weak RTCPeerConnection *weakPc = peerConnection;
|
|
282
|
+
[peerConnection addIceCandidate:candidate
|
|
283
|
+
completionHandler:^(NSError *error) {
|
|
284
|
+
if (error) {
|
|
285
|
+
reject(@"E_OPERATION_ERROR", @"addIceCandidate failed", error);
|
|
286
|
+
} else {
|
|
287
|
+
RTCPeerConnection *strongPc = weakPc;
|
|
288
|
+
id newSdp = @{
|
|
289
|
+
@"type": [RTCSessionDescription stringForType:strongPc.remoteDescription.type],
|
|
290
|
+
@"sdp": strongPc.remoteDescription.sdp
|
|
291
|
+
};
|
|
292
|
+
resolve(newSdp);
|
|
293
|
+
}
|
|
294
|
+
}];
|
|
275
295
|
}
|
|
276
296
|
|
|
277
297
|
RCT_EXPORT_METHOD(peerConnectionClose:(nonnull NSNumber *)objectID)
|
|
@@ -321,6 +341,16 @@ RCT_EXPORT_METHOD(peerConnectionGetStats:(nonnull NSNumber *) objectID
|
|
|
321
341
|
}];
|
|
322
342
|
}
|
|
323
343
|
|
|
344
|
+
RCT_EXPORT_METHOD(peerConnectionRestartIce:(nonnull NSNumber *)objectID)
|
|
345
|
+
{
|
|
346
|
+
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
|
|
347
|
+
if (!peerConnection) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
[peerConnection restartIce];
|
|
352
|
+
}
|
|
353
|
+
|
|
324
354
|
/**
|
|
325
355
|
* Constructs a JSON <tt>NSString</tt> representation of a specific
|
|
326
356
|
* <tt>RTCStatisticsReport</tt>s.
|
|
@@ -375,7 +405,7 @@ RCT_EXPORT_METHOD(peerConnectionGetStats:(nonnull NSNumber *) objectID
|
|
|
375
405
|
if ([statisticsValue isKindOfClass:[NSArray class]]) {
|
|
376
406
|
[s appendString:@"["];
|
|
377
407
|
BOOL firstValue = YES;
|
|
378
|
-
for (NSObject *value in statisticsValue) {
|
|
408
|
+
for (NSObject *value in (NSArray *)statisticsValue) {
|
|
379
409
|
if(firstValue) {
|
|
380
410
|
firstValue = NO;
|
|
381
411
|
} else {
|
package/metro.config.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
const blacklist = require('metro-config/src/defaults/blacklist');
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
resolver: {
|
|
5
|
+
blacklistRE: blacklist([/node_modules\/react-native-macos\/.*/])
|
|
6
|
+
}
|
|
8
7
|
};
|
package/metro.config.macos.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const blacklist = require('metro-config/src/defaults/blacklist');
|
|
4
3
|
|
|
5
4
|
const rnmPath = path.resolve(__dirname, 'node_modules/react-native-macos');
|
|
6
5
|
|
|
7
6
|
module.exports = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
resolver: {
|
|
8
|
+
extraNodeModules: {
|
|
9
|
+
'react-native': rnmPath
|
|
10
|
+
},
|
|
11
|
+
platforms: ['macos', 'ios', 'android'],
|
|
12
|
+
blacklistRE: blacklist([/node_modules\/react-native\/.*/])
|
|
13
|
+
}
|
|
15
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webrtc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.94.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
|
|
@@ -16,25 +16,34 @@
|
|
|
16
16
|
"android",
|
|
17
17
|
"webrtc"
|
|
18
18
|
],
|
|
19
|
+
"main": "src/index.js",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"base64-js": "
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"uuid": "^3.3.2"
|
|
21
|
+
"base64-js": "1.5.1",
|
|
22
|
+
"event-target-shim": "6.0.2",
|
|
23
|
+
"tar": "6.1.11",
|
|
24
|
+
"uuid": "3.4.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react-native": ">=0.60.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"postinstall": "
|
|
31
|
-
|
|
32
|
-
"cross-os": {
|
|
33
|
-
"darwin-extract": {
|
|
34
|
-
"darwin": "tar -zxf apple/WebRTC.xcframework.tgz -C apple"
|
|
35
|
-
}
|
|
30
|
+
"postinstall": "node tools/downloadWebRTC.js",
|
|
31
|
+
"prepare": "husky install"
|
|
36
32
|
},
|
|
37
33
|
"bugs": {
|
|
38
34
|
"url": "https://github.com/react-native-webrtc/react-native-webrtc/issues"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"husky": "7.0.2",
|
|
38
|
+
"lint-staged": "11.2.3",
|
|
39
|
+
"prettier": "2.4.1"
|
|
40
|
+
},
|
|
41
|
+
"lint-staged": {
|
|
42
|
+
"**/*": "prettier --write --ignore-unknown"
|
|
43
|
+
},
|
|
44
|
+
"webrtc-builds": {
|
|
45
|
+
"android": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/android-webrtc.tgz",
|
|
46
|
+
"ios": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework.tgz",
|
|
47
|
+
"ios-bitcode": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework-bitcode.tgz"
|
|
39
48
|
}
|
|
40
49
|
}
|