react-native-webrtc 106.0.5 → 106.0.7

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 (81) hide show
  1. package/.clang-format +11 -0
  2. package/LICENSE +2 -1
  3. package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +0 -1
  4. package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +7 -15
  5. package/android/src/main/java/com/oney/WebRTCModule/CameraEventsHandler.java +3 -12
  6. package/android/src/main/java/com/oney/WebRTCModule/DataChannelWrapper.java +12 -16
  7. package/android/src/main/java/com/oney/WebRTCModule/DisplayUtils.java +1 -1
  8. package/android/src/main/java/com/oney/WebRTCModule/EglUtils.java +1 -1
  9. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +29 -43
  10. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +123 -116
  11. package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +60 -61
  12. package/android/src/main/java/com/oney/WebRTCModule/ReactBridgeUtil.java +1 -2
  13. package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +11 -13
  14. package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +116 -119
  15. package/android/src/main/java/com/oney/WebRTCModule/StringUtils.java +8 -14
  16. package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +1 -2
  17. package/android/src/main/java/com/oney/WebRTCModule/TrackCapturerEventsEmitter.java +3 -4
  18. package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +5 -9
  19. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +335 -350
  20. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModulePackage.java +4 -10
  21. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +74 -98
  22. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +10 -9
  23. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +2 -6
  24. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +4 -5
  25. package/ios/RCTWebRTC/CaptureController.h +2 -9
  26. package/ios/RCTWebRTC/CaptureController.m +0 -7
  27. package/ios/RCTWebRTC/DataChannelWrapper.h +9 -13
  28. package/ios/RCTWebRTC/DataChannelWrapper.m +4 -5
  29. package/ios/RCTWebRTC/RCTConvert+WebRTC.h +2 -2
  30. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +166 -171
  31. package/ios/RCTWebRTC/RTCMediaStreamTrack+React.h +1 -1
  32. package/ios/RCTWebRTC/RTCMediaStreamTrack+React.m +1 -1
  33. package/ios/RCTWebRTC/RTCVideoViewManager.h +0 -8
  34. package/ios/RCTWebRTC/RTCVideoViewManager.m +205 -214
  35. package/ios/RCTWebRTC/ScreenCaptureController.h +2 -9
  36. package/ios/RCTWebRTC/ScreenCaptureController.m +10 -16
  37. package/ios/RCTWebRTC/ScreenCapturePickerViewManager.h +0 -7
  38. package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +26 -34
  39. package/ios/RCTWebRTC/ScreenCapturer.h +1 -8
  40. package/ios/RCTWebRTC/ScreenCapturer.m +56 -55
  41. package/ios/RCTWebRTC/SerializeUtils.h +16 -16
  42. package/ios/RCTWebRTC/SerializeUtils.m +98 -99
  43. package/ios/RCTWebRTC/SocketConnection.h +1 -8
  44. package/ios/RCTWebRTC/SocketConnection.m +31 -38
  45. package/ios/RCTWebRTC/TrackCapturerEventsEmitter.h +4 -4
  46. package/ios/RCTWebRTC/TrackCapturerEventsEmitter.m +5 -6
  47. package/ios/RCTWebRTC/VideoCaptureController.h +6 -7
  48. package/ios/RCTWebRTC/VideoCaptureController.m +54 -53
  49. package/ios/RCTWebRTC/WebRTCModule+Permissions.m +14 -13
  50. package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.h +3 -3
  51. package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +105 -100
  52. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +3 -2
  53. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +196 -226
  54. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +7 -14
  55. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +625 -603
  56. package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +128 -139
  57. package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +4 -5
  58. package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +26 -35
  59. package/ios/RCTWebRTC/WebRTCModule.h +13 -20
  60. package/ios/RCTWebRTC/WebRTCModule.m +69 -84
  61. package/ios/RCTWebRTC.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  62. package/lib/commonjs/RTCPeerConnection.js +79 -56
  63. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  64. package/lib/commonjs/RTCRtpEncodingParameters.js +12 -3
  65. package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
  66. package/lib/commonjs/RTCRtpTransceiver.js +1 -1
  67. package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
  68. package/lib/module/RTCPeerConnection.js +79 -56
  69. package/lib/module/RTCPeerConnection.js.map +1 -1
  70. package/lib/module/RTCRtpEncodingParameters.js +12 -3
  71. package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
  72. package/lib/module/RTCRtpTransceiver.js +1 -1
  73. package/lib/module/RTCRtpTransceiver.js.map +1 -1
  74. package/lib/typescript/RTCPeerConnection.d.ts +4 -4
  75. package/package.json +3 -2
  76. package/src/RTCPeerConnection.ts +70 -63
  77. package/src/RTCRtpEncodingParameters.ts +12 -3
  78. package/src/RTCRtpTransceiver.ts +1 -1
  79. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  80. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  81. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -8,9 +8,9 @@
8
8
  #else
9
9
  #import <WebRTC/RTCMTLNSVideoView.h>
10
10
  #endif
11
- #import <WebRTC/RTCVideoTrack.h>
12
11
  #import <WebRTC/RTCCVPixelBuffer.h>
13
12
  #import <WebRTC/RTCVideoFrame.h>
13
+ #import <WebRTC/RTCVideoTrack.h>
14
14
 
15
15
  #import "RTCVideoViewManager.h"
16
16
  #import "WebRTCModule.h"
@@ -22,20 +22,20 @@
22
22
  * the CSS style {@code object-fit}.
23
23
  */
24
24
  typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
25
- /**
26
- * The contain value defined by https://www.w3.org/TR/css3-images/#object-fit:
27
- *
28
- * The replaced content is sized to maintain its aspect ratio while fitting
29
- * within the element's content box.
30
- */
31
- RTCVideoViewObjectFitContain,
32
- /**
33
- * The cover value defined by https://www.w3.org/TR/css3-images/#object-fit:
34
- *
35
- * The replaced content is sized to maintain its aspect ratio while filling
36
- * the element's entire content box.
37
- */
38
- RTCVideoViewObjectFitCover
25
+ /**
26
+ * The contain value defined by https://www.w3.org/TR/css3-images/#object-fit:
27
+ *
28
+ * The replaced content is sized to maintain its aspect ratio while fitting
29
+ * within the element's content box.
30
+ */
31
+ RTCVideoViewObjectFitContain,
32
+ /**
33
+ * The cover value defined by https://www.w3.org/TR/css3-images/#object-fit:
34
+ *
35
+ * The replaced content is sized to maintain its aspect ratio while filling
36
+ * the element's entire content box.
37
+ */
38
+ RTCVideoViewObjectFitCover
39
39
  };
40
40
 
41
41
  /**
@@ -44,9 +44,9 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
44
44
  */
45
45
 
46
46
  #if !TARGET_OS_OSX
47
- @interface RTCVideoView : UIView <RTCVideoViewDelegate>
47
+ @interface RTCVideoView : UIView<RTCVideoViewDelegate>
48
48
  #else
49
- @interface RTCVideoView : NSView <RTCVideoViewDelegate>
49
+ @interface RTCVideoView : NSView<RTCVideoViewDelegate>
50
50
  #endif
51
51
 
52
52
  /**
@@ -54,7 +54,7 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
54
54
  * the video specified by {@link #videoTrack} during its rendering. Typically,
55
55
  * applications choose to mirror the front/user-facing camera.
56
56
  */
57
- @property (nonatomic) BOOL mirror;
57
+ @property(nonatomic) BOOL mirror;
58
58
 
59
59
  /**
60
60
  * In the fashion of
@@ -62,7 +62,7 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
62
62
  * and https://www.w3.org/TR/html5/rendering.html#video-object-fit, resembles
63
63
  * the CSS style {@code object-fit}.
64
64
  */
65
- @property (nonatomic) RTCVideoViewObjectFit objectFit;
65
+ @property(nonatomic) RTCVideoViewObjectFit objectFit;
66
66
 
67
67
  /**
68
68
  * The {@link RRTCVideoRenderer} which implements the actual rendering and which
@@ -70,28 +70,28 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
70
70
  * {@link #_videoSize}.
71
71
  */
72
72
  #if !TARGET_OS_OSX
73
- @property (nonatomic, readonly) __kindof UIView<RTCVideoRenderer> *videoView;
73
+ @property(nonatomic, readonly) __kindof UIView<RTCVideoRenderer> *videoView;
74
74
  #else
75
- @property (nonatomic, readonly) __kindof NSView<RTCVideoRenderer> *videoView;
75
+ @property(nonatomic, readonly) __kindof NSView<RTCVideoRenderer> *videoView;
76
76
  #endif
77
77
 
78
78
  /**
79
79
  * The {@link RTCVideoTrack}, if any, which this instance renders.
80
80
  */
81
- @property (nonatomic, strong) RTCVideoTrack *videoTrack;
81
+ @property(nonatomic, strong) RTCVideoTrack *videoTrack;
82
82
 
83
83
  /**
84
84
  * Reference to the main WebRTC RN module.
85
85
  */
86
- @property (nonatomic, weak) WebRTCModule *module;
86
+ @property(nonatomic, weak) WebRTCModule *module;
87
87
 
88
88
  @end
89
89
 
90
90
  @implementation RTCVideoView {
91
- /**
92
- * The width and height of the video (frames) rendered by {@link #subview}.
93
- */
94
- CGSize _videoSize;
91
+ /**
92
+ * The width and height of the video (frames) rendered by {@link #subview}.
93
+ */
94
+ CGSize _videoSize;
95
95
  }
96
96
 
97
97
  @synthesize videoView = _videoView;
@@ -100,32 +100,32 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
100
100
  * Tells this view that its window object changed.
101
101
  */
102
102
  - (void)didMoveToWindow {
103
- // XXX This RTCVideoView strongly retains its videoTrack. The latter strongly
104
- // retains the former as well though because RTCVideoTrack strongly retains
105
- // the RTCVideoRenderers added to it. In other words, there is a cycle of
106
- // strong retainments and, consequently, there is a memory leak. In order to
107
- // break the cycle, have this RTCVideoView as the RTCVideoRenderer of its
108
- // videoTrack only while this view resides in a window.
109
- RTCVideoTrack *videoTrack = self.videoTrack;
110
-
111
- if (videoTrack) {
112
- if (self.window) {
113
- dispatch_async(_module.workerQueue, ^{
114
- [videoTrack addRenderer:self.videoView];
115
- });
116
- } else {
117
- dispatch_async(_module.workerQueue, ^{
118
- [videoTrack removeRenderer:self.videoView];
119
- });
120
- _videoSize.height = 0;
121
- _videoSize.width = 0;
103
+ // XXX This RTCVideoView strongly retains its videoTrack. The latter strongly
104
+ // retains the former as well though because RTCVideoTrack strongly retains
105
+ // the RTCVideoRenderers added to it. In other words, there is a cycle of
106
+ // strong retainments and, consequently, there is a memory leak. In order to
107
+ // break the cycle, have this RTCVideoView as the RTCVideoRenderer of its
108
+ // videoTrack only while this view resides in a window.
109
+ RTCVideoTrack *videoTrack = self.videoTrack;
110
+
111
+ if (videoTrack) {
112
+ if (self.window) {
113
+ dispatch_async(_module.workerQueue, ^{
114
+ [videoTrack addRenderer:self.videoView];
115
+ });
116
+ } else {
117
+ dispatch_async(_module.workerQueue, ^{
118
+ [videoTrack removeRenderer:self.videoView];
119
+ });
120
+ _videoSize.height = 0;
121
+ _videoSize.width = 0;
122
122
  #if !TARGET_OS_OSX
123
- [self setNeedsLayout];
123
+ [self setNeedsLayout];
124
124
  #else
125
- self.needsLayout = YES;
125
+ self.needsLayout = YES;
126
126
  #endif
127
+ }
127
128
  }
128
- }
129
129
  }
130
130
 
131
131
  /**
@@ -135,28 +135,28 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
135
135
  * @param frame The frame rectangle for the view, measured in points.
136
136
  */
137
137
  - (instancetype)initWithFrame:(CGRect)frame {
138
- if (self = [super initWithFrame:frame]) {
138
+ if (self = [super initWithFrame:frame]) {
139
139
  #if !TARGET_OS_OSX
140
- RTCMTLVideoView *subview = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero];
141
- subview.delegate = self;
142
- _videoView = subview;
140
+ RTCMTLVideoView *subview = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero];
141
+ subview.delegate = self;
142
+ _videoView = subview;
143
143
  #else
144
- RTCMTLNSVideoView *subview = [[RTCMTLNSVideoView alloc] initWithFrame:CGRectZero];
145
- subview.wantsLayer = true;
146
- subview.delegate = self;
147
- _videoView = subview;
144
+ RTCMTLNSVideoView *subview = [[RTCMTLNSVideoView alloc] initWithFrame:CGRectZero];
145
+ subview.wantsLayer = true;
146
+ subview.delegate = self;
147
+ _videoView = subview;
148
148
  #endif
149
149
 
150
- _videoSize.height = 0;
151
- _videoSize.width = 0;
150
+ _videoSize.height = 0;
151
+ _videoSize.width = 0;
152
152
 
153
153
  #if !TARGET_OS_OSX
154
- self.opaque = NO;
154
+ self.opaque = NO;
155
155
  #endif
156
156
 
157
- [self addSubview:self.videoView];
158
- }
159
- return self;
157
+ [self addSubview:self.videoView];
158
+ }
159
+ return self;
160
160
  }
161
161
 
162
162
  /**
@@ -167,65 +167,57 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
167
167
  #if !TARGET_OS_OSX
168
168
  - (void)layoutSubviews {
169
169
  #else
170
- - (void)layout {
170
+ - (void)layout {
171
171
  #endif
172
172
  #if !TARGET_OS_OSX
173
- UIView *subview = self.videoView;
173
+ UIView *subview = self.videoView;
174
174
  #else
175
- NSView *subview = self.videoView;
175
+ NSView *subview = self.videoView;
176
176
  #endif
177
- if (!subview) {
178
- return;
179
- }
180
-
181
- CGFloat width = _videoSize.width, height = _videoSize.height;
182
- CGRect newValue;
183
- if (width <= 0 || height <= 0) {
184
- newValue = self.bounds;
185
- } else if (RTCVideoViewObjectFitCover == self.objectFit) { // cover
186
- newValue = self.bounds;
187
- // Is there a real need to scale subview?
188
- if (newValue.size.width != width || newValue.size.height != height) {
189
- CGFloat scaleFactor
190
- = MAX(newValue.size.width / width, newValue.size.height / height);
191
- // Scale both width and height in order to make it obvious that the aspect
192
- // ratio is preserved.
193
- width *= scaleFactor;
194
- height *= scaleFactor;
195
- newValue.origin.x += (newValue.size.width - width) / 2.0;
196
- newValue.origin.y += (newValue.size.height - height) / 2.0;
197
- newValue.size.width = width;
198
- newValue.size.height = height;
177
+ if (!subview) {
178
+ return;
199
179
  }
200
- } else { // contain
201
- // The implementation is in accord with
202
- // https://www.w3.org/TR/html5/embedded-content-0.html#the-video-element:
203
- //
204
- // In the absence of style rules to the contrary, video content should be
205
- // rendered inside the element's playback area such that the video content
206
- // is shown centered in the playback area at the largest possible size that
207
- // fits completely within it, with the video content's aspect ratio being
208
- // preserved. Thus, if the aspect ratio of the playback area does not match
209
- // the aspect ratio of the video, the video will be shown letterboxed or
210
- // pillarboxed. Areas of the element's playback area that do not contain the
211
- // video represent nothing.
212
- newValue
213
- = AVMakeRectWithAspectRatioInsideRect(
214
- CGSizeMake(width, height),
215
- self.bounds);
216
- }
217
-
218
- CGRect oldValue = subview.frame;
219
- if (newValue.origin.x != oldValue.origin.x
220
- || newValue.origin.y != oldValue.origin.y
221
- || newValue.size.width != oldValue.size.width
222
- || newValue.size.height != oldValue.size.height) {
223
- subview.frame = newValue;
224
- }
225
-
226
- [subview.layer setAffineTransform:self.mirror
227
- ? CGAffineTransformMakeScale(-1.0, 1.0)
228
- : CGAffineTransformIdentity];
180
+
181
+ CGFloat width = _videoSize.width, height = _videoSize.height;
182
+ CGRect newValue;
183
+ if (width <= 0 || height <= 0) {
184
+ newValue = self.bounds;
185
+ } else if (RTCVideoViewObjectFitCover == self.objectFit) { // cover
186
+ newValue = self.bounds;
187
+ // Is there a real need to scale subview?
188
+ if (newValue.size.width != width || newValue.size.height != height) {
189
+ CGFloat scaleFactor = MAX(newValue.size.width / width, newValue.size.height / height);
190
+ // Scale both width and height in order to make it obvious that the aspect
191
+ // ratio is preserved.
192
+ width *= scaleFactor;
193
+ height *= scaleFactor;
194
+ newValue.origin.x += (newValue.size.width - width) / 2.0;
195
+ newValue.origin.y += (newValue.size.height - height) / 2.0;
196
+ newValue.size.width = width;
197
+ newValue.size.height = height;
198
+ }
199
+ } else { // contain
200
+ // The implementation is in accord with
201
+ // https://www.w3.org/TR/html5/embedded-content-0.html#the-video-element:
202
+ //
203
+ // In the absence of style rules to the contrary, video content should be
204
+ // rendered inside the element's playback area such that the video content
205
+ // is shown centered in the playback area at the largest possible size that
206
+ // fits completely within it, with the video content's aspect ratio being
207
+ // preserved. Thus, if the aspect ratio of the playback area does not match
208
+ // the aspect ratio of the video, the video will be shown letterboxed or
209
+ // pillarboxed. Areas of the element's playback area that do not contain the
210
+ // video represent nothing.
211
+ newValue = AVMakeRectWithAspectRatioInsideRect(CGSizeMake(width, height), self.bounds);
212
+ }
213
+
214
+ CGRect oldValue = subview.frame;
215
+ if (newValue.origin.x != oldValue.origin.x || newValue.origin.y != oldValue.origin.y ||
216
+ newValue.size.width != oldValue.size.width || newValue.size.height != oldValue.size.height) {
217
+ subview.frame = newValue;
218
+ }
219
+
220
+ [subview.layer setAffineTransform:self.mirror ? CGAffineTransformMakeScale(-1.0, 1.0) : CGAffineTransformIdentity];
229
221
  }
230
222
 
231
223
  /**
@@ -236,15 +228,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
236
228
  * {@code RTCVideoView}.
237
229
  */
238
230
  - (void)setMirror:(BOOL)mirror {
239
- if (_mirror != mirror) {
240
- _mirror = mirror;
241
-
242
- #if !TARGET_OS_OSX
243
- [self setNeedsLayout];
244
- #else
245
- self.needsLayout = YES;
246
- #endif
247
- }
231
+ if (_mirror != mirror) {
232
+ _mirror = mirror;
233
+
234
+ #if !TARGET_OS_OSX
235
+ [self setNeedsLayout];
236
+ #else
237
+ self.needsLayout = YES;
238
+ #endif
239
+ }
248
240
  }
249
241
 
250
242
  /**
@@ -255,15 +247,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
255
247
  * {@code RTCVideoView}.
256
248
  */
257
249
  - (void)setObjectFit:(RTCVideoViewObjectFit)objectFit {
258
- if (_objectFit != objectFit) {
259
- _objectFit = objectFit;
260
-
261
- #if !TARGET_OS_OSX
262
- [self setNeedsLayout];
263
- #else
264
- self.needsLayout = YES;
265
- #endif
266
- }
250
+ if (_objectFit != objectFit) {
251
+ _objectFit = objectFit;
252
+
253
+ #if !TARGET_OS_OSX
254
+ [self setNeedsLayout];
255
+ #else
256
+ self.needsLayout = YES;
257
+ #endif
258
+ }
267
259
  }
268
260
 
269
261
  /**
@@ -274,69 +266,71 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
274
266
  * {@code RTCVideoView}.
275
267
  */
276
268
  - (void)setVideoTrack:(RTCVideoTrack *)videoTrack {
277
- RTCVideoTrack *oldValue = self.videoTrack;
278
-
279
- if (oldValue != videoTrack) {
280
- if (oldValue) {
281
- dispatch_async(_module.workerQueue, ^{
282
- [oldValue removeRenderer:self.videoView];
283
- });
284
- _videoSize.height = 0;
285
- _videoSize.width = 0;
286
-
287
- #if !TARGET_OS_OSX
269
+ RTCVideoTrack *oldValue = self.videoTrack;
270
+
271
+ if (oldValue != videoTrack) {
272
+ if (oldValue) {
273
+ dispatch_async(_module.workerQueue, ^{
274
+ [oldValue removeRenderer:self.videoView];
275
+ });
276
+ _videoSize.height = 0;
277
+ _videoSize.width = 0;
278
+
279
+ #if !TARGET_OS_OSX
288
280
  [self setNeedsLayout];
289
- #else
281
+ #else
290
282
  self.needsLayout = YES;
291
- #endif
292
- }
283
+ #endif
284
+ }
293
285
 
294
- _videoTrack = videoTrack;
295
-
296
- // Clear the videoView by rendering a 2x2 blank frame.
297
- CVPixelBufferRef pixelBuffer;
298
- CVReturn err = CVPixelBufferCreate(NULL, 2, 2, kCVPixelFormatType_32BGRA, NULL, &pixelBuffer);
299
- if (err == kCVReturnSuccess) {
300
- const int kBytesPerPixel = 4;
301
- CVPixelBufferLockBaseAddress(pixelBuffer, 0);
302
- int bufferWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
303
- int bufferHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
304
- size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);
305
- uint8_t *baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer);
306
-
307
- for (int row = 0; row < bufferHeight; row++) {
308
- uint8_t *pixel = baseAddress + row * bytesPerRow;
309
- for (int column = 0; column < bufferWidth; column++) {
310
- pixel[0] = 0; // BGRA, Blue value
311
- pixel[1] = 0; // Green value
312
- pixel[2] = 0; // Red value
313
- pixel[3] = 0; // Alpha value
314
- pixel += kBytesPerPixel;
286
+ _videoTrack = videoTrack;
287
+
288
+ // Clear the videoView by rendering a 2x2 blank frame.
289
+ CVPixelBufferRef pixelBuffer;
290
+ CVReturn err = CVPixelBufferCreate(NULL, 2, 2, kCVPixelFormatType_32BGRA, NULL, &pixelBuffer);
291
+ if (err == kCVReturnSuccess) {
292
+ const int kBytesPerPixel = 4;
293
+ CVPixelBufferLockBaseAddress(pixelBuffer, 0);
294
+ int bufferWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
295
+ int bufferHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
296
+ size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);
297
+ uint8_t *baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer);
298
+
299
+ for (int row = 0; row < bufferHeight; row++) {
300
+ uint8_t *pixel = baseAddress + row * bytesPerRow;
301
+ for (int column = 0; column < bufferWidth; column++) {
302
+ pixel[0] = 0; // BGRA, Blue value
303
+ pixel[1] = 0; // Green value
304
+ pixel[2] = 0; // Red value
305
+ pixel[3] = 0; // Alpha value
306
+ pixel += kBytesPerPixel;
307
+ }
308
+ }
309
+
310
+ CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
311
+ int64_t time = (int64_t)(CFAbsoluteTimeGetCurrent() * 1000000000);
312
+ RTCCVPixelBuffer *buffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
313
+ RTCVideoFrame *frame = [[[RTCVideoFrame alloc] initWithBuffer:buffer
314
+ rotation:RTCVideoRotation_0
315
+ timeStampNs:time] newI420VideoFrame];
316
+
317
+ [self.videoView renderFrame:frame];
318
+
319
+ CVPixelBufferRelease(pixelBuffer);
315
320
  }
316
- }
317
-
318
- CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
319
- int64_t time = (int64_t)(CFAbsoluteTimeGetCurrent() * 1000000000);
320
- RTCCVPixelBuffer *buffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
321
- RTCVideoFrame *frame = [[[RTCVideoFrame alloc] initWithBuffer:buffer rotation:RTCVideoRotation_0 timeStampNs:time] newI420VideoFrame];
322
-
323
- [self.videoView renderFrame: frame];
324
-
325
- CVPixelBufferRelease(pixelBuffer);
326
- }
327
321
 
328
- // XXX This RTCVideoView strongly retains its videoTrack. The latter
329
- // strongly retains the former as well though because RTCVideoTrack strongly
330
- // retains the RTCVideoRenderers added to it. In other words, there is a
331
- // cycle of strong retainments and, consequently, there is a memory leak. In
332
- // order to break the cycle, have this RTCVideoView as the RTCVideoRenderer
333
- // of its videoTrack only while this view resides in a window.
334
- if (videoTrack && self.window) {
335
- dispatch_async(_module.workerQueue, ^{
336
- [videoTrack addRenderer:self.videoView];
337
- });
322
+ // XXX This RTCVideoView strongly retains its videoTrack. The latter
323
+ // strongly retains the former as well though because RTCVideoTrack strongly
324
+ // retains the RTCVideoRenderers added to it. In other words, there is a
325
+ // cycle of strong retainments and, consequently, there is a memory leak. In
326
+ // order to break the cycle, have this RTCVideoView as the RTCVideoRenderer
327
+ // of its videoTrack only while this view resides in a window.
328
+ if (videoTrack && self.window) {
329
+ dispatch_async(_module.workerQueue, ^{
330
+ [videoTrack addRenderer:self.videoView];
331
+ });
332
+ }
338
333
  }
339
- }
340
334
  }
341
335
 
342
336
  #pragma mark - RTCVideoViewDelegate methods
@@ -352,15 +346,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
352
346
  * specified {@code videoView}.
353
347
  */
354
348
  - (void)videoView:(id<RTCVideoRenderer>)videoView didChangeVideoSize:(CGSize)size {
355
- if (videoView == self.videoView) {
356
- _videoSize = size;
357
-
358
- #if !TARGET_OS_OSX
359
- [self setNeedsLayout];
360
- #else
361
- self.needsLayout = YES;
362
- #endif
363
- }
349
+ if (videoView == self.videoView) {
350
+ _videoSize = size;
351
+
352
+ #if !TARGET_OS_OSX
353
+ [self setNeedsLayout];
354
+ #else
355
+ self.needsLayout = YES;
356
+ #endif
357
+ }
364
358
  }
365
359
 
366
360
  @end
@@ -374,16 +368,16 @@ RCT_EXPORT_MODULE()
374
368
  #else
375
369
  - (NSView *)view {
376
370
  #endif
377
- RTCVideoView *v = [[RTCVideoView alloc] init];
378
- v.module = [self.bridge moduleForName:@"WebRTCModule"];
371
+ RTCVideoView *v = [[RTCVideoView alloc] init];
372
+ v.module = [self.bridge moduleForName:@"WebRTCModule"];
379
373
  #if !TARGET_OS_OSX
380
- v.clipsToBounds = YES;
374
+ v.clipsToBounds = YES;
381
375
  #endif
382
- return v;
376
+ return v;
383
377
  }
384
378
 
385
379
  - (dispatch_queue_t)methodQueue {
386
- return dispatch_get_main_queue();
380
+ return dispatch_get_main_queue();
387
381
  }
388
382
 
389
383
  RCT_EXPORT_VIEW_PROPERTY(mirror, BOOL)
@@ -395,13 +389,11 @@ RCT_EXPORT_VIEW_PROPERTY(mirror, BOOL)
395
389
  * the CSS style {@code object-fit}.
396
390
  */
397
391
  RCT_CUSTOM_VIEW_PROPERTY(objectFit, NSString *, RTCVideoView) {
398
- NSString *s = [RCTConvert NSString:json];
399
- RTCVideoViewObjectFit e
400
- = (s && [s isEqualToString:@"cover"])
401
- ? RTCVideoViewObjectFitCover
402
- : RTCVideoViewObjectFitContain;
392
+ NSString *s = [RCTConvert NSString:json];
393
+ RTCVideoViewObjectFit e =
394
+ (s && [s isEqualToString:@"cover"]) ? RTCVideoViewObjectFitCover : RTCVideoViewObjectFitContain;
403
395
 
404
- view.objectFit = e;
396
+ view.objectFit = e;
405
397
  }
406
398
 
407
399
  RCT_CUSTOM_VIEW_PROPERTY(streamURL, NSString *, RTCVideoView) {
@@ -427,8 +419,7 @@ RCT_CUSTOM_VIEW_PROPERTY(streamURL, NSString *, RTCVideoView) {
427
419
  });
428
420
  }
429
421
 
430
- + (BOOL)requiresMainQueueSetup
431
- {
422
+ + (BOOL)requiresMainQueueSetup {
432
423
  return NO;
433
424
  }
434
425
 
@@ -1,18 +1,11 @@
1
- //
2
- // ScreenCaptureController.h
3
- // RCTWebRTC
4
- //
5
- // Created by Alex-Dan Bumbu on 06/01/2021.
6
- //
7
-
8
1
  #import <Foundation/Foundation.h>
9
2
  #import "CaptureController.h"
10
3
  #import "CapturerEventsDelegate.h"
11
4
 
12
5
  NS_ASSUME_NONNULL_BEGIN
13
6
 
14
- extern NSString* const kRTCScreensharingSocketFD;
15
- extern NSString* const kRTCAppGroupIdentifier;
7
+ extern NSString *const kRTCScreensharingSocketFD;
8
+ extern NSString *const kRTCAppGroupIdentifier;
16
9
 
17
10
  @class ScreenCapturer;
18
11
 
@@ -1,30 +1,23 @@
1
- //
2
- // ScreenCaptureController.m
3
- // RCTWebRTC
4
- //
5
- // Created by Alex-Dan Bumbu on 06/01/2021.
6
- //
7
-
8
1
  #import "ScreenCaptureController.h"
9
2
  #import "ScreenCapturer.h"
10
3
  #import "SocketConnection.h"
11
4
 
12
- NSString* const kRTCScreensharingSocketFD = @"rtc_SSFD";
13
- NSString* const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
5
+ NSString *const kRTCScreensharingSocketFD = @"rtc_SSFD";
6
+ NSString *const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
14
7
 
15
8
  @interface ScreenCaptureController ()
16
9
 
17
- @property (nonatomic, retain) ScreenCapturer *capturer;
10
+ @property(nonatomic, retain) ScreenCapturer *capturer;
18
11
 
19
12
  @end
20
13
 
21
- @interface ScreenCaptureController (CapturerEventsDelegate) <CapturerEventsDelegate>
14
+ @interface ScreenCaptureController (CapturerEventsDelegate)<CapturerEventsDelegate>
22
15
  - (void)capturerDidEnd:(RTCVideoCapturer *)capturer;
23
16
  @end
24
17
 
25
18
  @interface ScreenCaptureController (Private)
26
19
 
27
- @property (nonatomic, readonly) NSString *appGroupIdentifier;
20
+ @property(nonatomic, readonly) NSString *appGroupIdentifier;
28
21
 
29
22
  @end
30
23
 
@@ -35,7 +28,7 @@ NSString* const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
35
28
  if (self) {
36
29
  self.capturer = capturer;
37
30
  }
38
-
31
+
39
32
  return self;
40
33
  }
41
34
 
@@ -47,7 +40,7 @@ NSString* const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
47
40
  if (!self.appGroupIdentifier) {
48
41
  return;
49
42
  }
50
-
43
+
51
44
  self.capturer.eventsDelegate = self;
52
45
  NSString *socketFilePath = [self filePathForApplicationGroupIdentifier:self.appGroupIdentifier];
53
46
  SocketConnection *connection = [[SocketConnection alloc] initWithFilePath:socketFilePath];
@@ -72,9 +65,10 @@ NSString* const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
72
65
  }
73
66
 
74
67
  - (NSString *)filePathForApplicationGroupIdentifier:(nonnull NSString *)identifier {
75
- NSURL *sharedContainer = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:identifier];
68
+ NSURL *sharedContainer =
69
+ [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:identifier];
76
70
  NSString *socketFilePath = [[sharedContainer URLByAppendingPathComponent:kRTCScreensharingSocketFD] path];
77
-
71
+
78
72
  return socketFilePath;
79
73
  }
80
74
 
@@ -1,10 +1,3 @@
1
- //
2
- // ScreenCapturePickerViewManager.h
3
- // react-native-webrtc
4
- //
5
- // Created by Alex-Dan Bumbu on 20/01/2021.
6
- //
7
-
8
1
  #import <Foundation/Foundation.h>
9
2
  #import <React/RCTViewManager.h>
10
3