react-native-webrtc 1.92.0 → 1.94.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.
- package/.prettierignore +9 -0
- package/.prettierrc.json +10 -0
- package/README.md +2 -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/StringUtils.java +24 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +222 -275
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +9 -84
- package/apple/.placeholder +0 -0
- package/ios/RCTWebRTC/VideoCaptureController.h +2 -2
- package/ios/RCTWebRTC/VideoCaptureController.m +131 -48
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +39 -20
- 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 +61 -49
- 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 -379
- 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
|
|
@@ -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
|
|
@@ -402,34 +402,53 @@ RCT_EXPORT_METHOD(peerConnectionRestartIce:(nonnull NSNumber *)objectID)
|
|
|
402
402
|
[s appendString:key];
|
|
403
403
|
[s appendString:@"\":"];
|
|
404
404
|
NSObject *statisticsValue = [statistics.values objectForKey:key];
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
405
|
+
[self appendValue:statisticsValue toString:s];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
[s appendString:@"}]"];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
[s appendString:@"]"];
|
|
412
|
+
|
|
413
|
+
return s;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
- (void)appendValue:(NSObject *)statisticsValue toString:(NSMutableString *)s {
|
|
417
|
+
if ([statisticsValue isKindOfClass:[NSArray class]]) {
|
|
418
|
+
[s appendString:@"["];
|
|
419
|
+
BOOL firstValue = YES;
|
|
420
|
+
for (NSObject *element in (NSArray *)statisticsValue) {
|
|
421
|
+
if(firstValue) {
|
|
410
422
|
firstValue = NO;
|
|
411
|
-
|
|
423
|
+
} else {
|
|
412
424
|
[s appendString:@","];
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
[s appendString:@"\""];
|
|
416
|
-
[s appendString:[NSString stringWithFormat:@"%@", value]];
|
|
417
|
-
[s appendString:@"\""];
|
|
418
425
|
}
|
|
419
|
-
|
|
420
|
-
|
|
426
|
+
|
|
427
|
+
[s appendString:@"\""];
|
|
428
|
+
[s appendString:[NSString stringWithFormat:@"%@", element]];
|
|
429
|
+
[s appendString:@"\""];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
[s appendString:@"]"];
|
|
433
|
+
} else if ([statisticsValue isKindOfClass:[NSDictionary class]]) {
|
|
434
|
+
NSError *error;
|
|
435
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:statisticsValue
|
|
436
|
+
options:0
|
|
437
|
+
error:&error];
|
|
438
|
+
|
|
439
|
+
if (!jsonData) {
|
|
421
440
|
[s appendString:@"\""];
|
|
422
441
|
[s appendString:[NSString stringWithFormat:@"%@", statisticsValue]];
|
|
423
442
|
[s appendString:@"\""];
|
|
443
|
+
} else {
|
|
444
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
445
|
+
[s appendString:jsonString];
|
|
424
446
|
}
|
|
447
|
+
} else {
|
|
448
|
+
[s appendString:@"\""];
|
|
449
|
+
[s appendString:[NSString stringWithFormat:@"%@", statisticsValue]];
|
|
450
|
+
[s appendString:@"\""];
|
|
425
451
|
}
|
|
426
|
-
|
|
427
|
-
[s appendString:@"}]"];
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
[s appendString:@"]"];
|
|
431
|
-
|
|
432
|
-
return s;
|
|
433
452
|
}
|
|
434
453
|
|
|
435
454
|
- (NSString *)stringForPeerConnectionState:(RTCPeerConnectionState)state {
|
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.1",
|
|
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
|
}
|
package/react-native.config.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
'use strict';
|
|
3
2
|
|
|
4
3
|
const macSwitch = '--use-react-native-macos';
|
|
5
4
|
|
|
6
5
|
if (process.argv.includes(macSwitch)) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
process.argv = process.argv.filter(arg => arg !== macSwitch);
|
|
7
|
+
process.argv.push('--config=metro.config.macos.js');
|
|
8
|
+
module.exports = {
|
|
9
|
+
reactNativePath: 'node_modules/react-native-macos'
|
|
10
|
+
};
|
|
12
11
|
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
|
|
3
|
-
import {NativeModules} from 'react-native';
|
|
4
|
-
import
|
|
2
|
+
import { NativeModules } from 'react-native';
|
|
3
|
+
import { defineCustomEventTarget } from 'event-target-shim';
|
|
5
4
|
|
|
6
5
|
import getDisplayMedia from './getDisplayMedia';
|
|
7
6
|
import getUserMedia from './getUserMedia';
|
|
8
7
|
|
|
9
|
-
const {WebRTCModule} = NativeModules;
|
|
8
|
+
const { WebRTCModule } = NativeModules;
|
|
10
9
|
|
|
11
|
-
const MEDIA_DEVICES_EVENTS = [
|
|
12
|
-
'devicechange'
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
|
|
16
|
-
// TODO: implement.
|
|
17
|
-
ondevicechange: ?Function;
|
|
10
|
+
const MEDIA_DEVICES_EVENTS = ['devicechange'];
|
|
18
11
|
|
|
12
|
+
class MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {
|
|
19
13
|
/**
|
|
20
14
|
* W3C "Media Capture and Streams" compatible {@code enumerateDevices}
|
|
21
15
|
* implementation.
|
|
@@ -40,7 +34,7 @@ class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
|
|
|
40
34
|
* implementation.
|
|
41
35
|
* See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices
|
|
42
36
|
*
|
|
43
|
-
* @param {*} constraints
|
|
37
|
+
* @param {*} constraints
|
|
44
38
|
* @returns {Promise}
|
|
45
39
|
*/
|
|
46
40
|
getUserMedia(constraints) {
|