react-native-webrtc 106.0.4 → 106.0.6
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/.clang-format +11 -0
- package/.github/workflows/android_ci.yml +29 -0
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/ios_ci.yml +50 -0
- package/LICENSE +2 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +11 -1
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +7 -15
- package/android/src/main/java/com/oney/WebRTCModule/CameraEventsHandler.java +4 -13
- package/android/src/main/java/com/oney/WebRTCModule/DataChannelWrapper.java +12 -16
- package/android/src/main/java/com/oney/WebRTCModule/DisplayUtils.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/EglUtils.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +37 -47
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +123 -116
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +60 -61
- package/android/src/main/java/com/oney/WebRTCModule/ReactBridgeUtil.java +1 -2
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +12 -9
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +116 -121
- package/android/src/main/java/com/oney/WebRTCModule/StringUtils.java +8 -14
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +1 -2
- package/android/src/main/java/com/oney/WebRTCModule/TrackCapturerEventsEmitter.java +34 -0
- package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +5 -9
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +383 -378
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModulePackage.java +4 -10
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +74 -98
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +10 -9
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +2 -6
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +4 -5
- package/ios/RCTWebRTC/CaptureController.h +4 -8
- package/ios/RCTWebRTC/CaptureController.m +0 -7
- package/ios/RCTWebRTC/CapturerEventsDelegate.h +12 -0
- package/ios/RCTWebRTC/DataChannelWrapper.h +9 -13
- package/ios/RCTWebRTC/DataChannelWrapper.m +4 -5
- package/ios/RCTWebRTC/RCTConvert+WebRTC.h +2 -2
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +166 -171
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.h +1 -1
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.m +1 -1
- package/ios/RCTWebRTC/RTCVideoViewManager.h +0 -8
- package/ios/RCTWebRTC/RTCVideoViewManager.m +207 -239
- package/ios/RCTWebRTC/ScreenCaptureController.h +3 -9
- package/ios/RCTWebRTC/ScreenCaptureController.m +20 -15
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.h +0 -7
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +26 -34
- package/ios/RCTWebRTC/ScreenCapturer.h +4 -8
- package/ios/RCTWebRTC/ScreenCapturer.m +57 -55
- package/ios/RCTWebRTC/SerializeUtils.h +16 -16
- package/ios/RCTWebRTC/SerializeUtils.m +98 -99
- package/ios/RCTWebRTC/SocketConnection.h +1 -8
- package/ios/RCTWebRTC/SocketConnection.m +31 -38
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.h +14 -0
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.m +37 -0
- package/ios/RCTWebRTC/VideoCaptureController.h +6 -7
- package/ios/RCTWebRTC/VideoCaptureController.m +54 -53
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +14 -13
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.h +3 -3
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +105 -100
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +8 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +218 -173
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +7 -14
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +625 -595
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +128 -139
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +4 -5
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +26 -35
- package/ios/RCTWebRTC/WebRTCModule.h +14 -20
- package/ios/RCTWebRTC/WebRTCModule.m +69 -83
- package/ios/RCTWebRTC.xcodeproj/project.pbxproj +10 -1
- package/ios/RCTWebRTC.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/EventEmitter.js +1 -1
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +25 -0
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +169 -162
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/EventEmitter.js +1 -1
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +21 -0
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +169 -162
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/typescript/MediaStreamTrack.d.ts +1 -0
- package/lib/typescript/RTCPeerConnection.d.ts +5 -4
- package/package.json +3 -2
- package/src/EventEmitter.ts +1 -0
- package/src/MediaStreamTrack.ts +23 -0
- package/src/RTCPeerConnection.ts +168 -174
- package/src/RTCRtpTransceiver.ts +1 -1
- 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
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
//
|
|
2
|
-
// RTCVideoViewManager.m
|
|
3
|
-
// TestReact
|
|
4
|
-
//
|
|
5
|
-
// Created by one on 2015/9/25.
|
|
6
|
-
// Copyright © 2015年 Facebook. All rights reserved.
|
|
7
|
-
//
|
|
8
1
|
#import <AVFoundation/AVFoundation.h>
|
|
9
2
|
#import <objc/runtime.h>
|
|
10
3
|
|
|
11
4
|
#import <React/RCTLog.h>
|
|
12
|
-
#if !TARGET_OS_OSX
|
|
13
|
-
#import <WebRTC/RTCEAGLVideoView.h>
|
|
14
|
-
#endif
|
|
15
5
|
#import <WebRTC/RTCMediaStream.h>
|
|
16
6
|
#if !TARGET_OS_OSX
|
|
17
7
|
#import <WebRTC/RTCMTLVideoView.h>
|
|
18
8
|
#else
|
|
19
9
|
#import <WebRTC/RTCMTLNSVideoView.h>
|
|
20
10
|
#endif
|
|
21
|
-
#import <WebRTC/RTCVideoTrack.h>
|
|
22
11
|
#import <WebRTC/RTCCVPixelBuffer.h>
|
|
23
12
|
#import <WebRTC/RTCVideoFrame.h>
|
|
13
|
+
#import <WebRTC/RTCVideoTrack.h>
|
|
24
14
|
|
|
25
15
|
#import "RTCVideoViewManager.h"
|
|
26
16
|
#import "WebRTCModule.h"
|
|
@@ -32,20 +22,20 @@
|
|
|
32
22
|
* the CSS style {@code object-fit}.
|
|
33
23
|
*/
|
|
34
24
|
typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
49
39
|
};
|
|
50
40
|
|
|
51
41
|
/**
|
|
@@ -54,9 +44,9 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
54
44
|
*/
|
|
55
45
|
|
|
56
46
|
#if !TARGET_OS_OSX
|
|
57
|
-
@interface RTCVideoView : UIView
|
|
47
|
+
@interface RTCVideoView : UIView<RTCVideoViewDelegate>
|
|
58
48
|
#else
|
|
59
|
-
@interface RTCVideoView : NSView
|
|
49
|
+
@interface RTCVideoView : NSView<RTCVideoViewDelegate>
|
|
60
50
|
#endif
|
|
61
51
|
|
|
62
52
|
/**
|
|
@@ -64,7 +54,7 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
64
54
|
* the video specified by {@link #videoTrack} during its rendering. Typically,
|
|
65
55
|
* applications choose to mirror the front/user-facing camera.
|
|
66
56
|
*/
|
|
67
|
-
@property
|
|
57
|
+
@property(nonatomic) BOOL mirror;
|
|
68
58
|
|
|
69
59
|
/**
|
|
70
60
|
* In the fashion of
|
|
@@ -72,7 +62,7 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
72
62
|
* and https://www.w3.org/TR/html5/rendering.html#video-object-fit, resembles
|
|
73
63
|
* the CSS style {@code object-fit}.
|
|
74
64
|
*/
|
|
75
|
-
@property
|
|
65
|
+
@property(nonatomic) RTCVideoViewObjectFit objectFit;
|
|
76
66
|
|
|
77
67
|
/**
|
|
78
68
|
* The {@link RRTCVideoRenderer} which implements the actual rendering and which
|
|
@@ -80,28 +70,28 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
80
70
|
* {@link #_videoSize}.
|
|
81
71
|
*/
|
|
82
72
|
#if !TARGET_OS_OSX
|
|
83
|
-
@property
|
|
73
|
+
@property(nonatomic, readonly) __kindof UIView<RTCVideoRenderer> *videoView;
|
|
84
74
|
#else
|
|
85
|
-
@property
|
|
75
|
+
@property(nonatomic, readonly) __kindof NSView<RTCVideoRenderer> *videoView;
|
|
86
76
|
#endif
|
|
87
77
|
|
|
88
78
|
/**
|
|
89
79
|
* The {@link RTCVideoTrack}, if any, which this instance renders.
|
|
90
80
|
*/
|
|
91
|
-
@property
|
|
81
|
+
@property(nonatomic, strong) RTCVideoTrack *videoTrack;
|
|
92
82
|
|
|
93
83
|
/**
|
|
94
84
|
* Reference to the main WebRTC RN module.
|
|
95
85
|
*/
|
|
96
|
-
@property
|
|
86
|
+
@property(nonatomic, weak) WebRTCModule *module;
|
|
97
87
|
|
|
98
88
|
@end
|
|
99
89
|
|
|
100
90
|
@implementation RTCVideoView {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
/**
|
|
92
|
+
* The width and height of the video (frames) rendered by {@link #subview}.
|
|
93
|
+
*/
|
|
94
|
+
CGSize _videoSize;
|
|
105
95
|
}
|
|
106
96
|
|
|
107
97
|
@synthesize videoView = _videoView;
|
|
@@ -110,32 +100,32 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
110
100
|
* Tells this view that its window object changed.
|
|
111
101
|
*/
|
|
112
102
|
- (void)didMoveToWindow {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
|
132
122
|
#if !TARGET_OS_OSX
|
|
133
|
-
|
|
123
|
+
[self setNeedsLayout];
|
|
134
124
|
#else
|
|
135
|
-
|
|
125
|
+
self.needsLayout = YES;
|
|
136
126
|
#endif
|
|
127
|
+
}
|
|
137
128
|
}
|
|
138
|
-
}
|
|
139
129
|
}
|
|
140
130
|
|
|
141
131
|
/**
|
|
@@ -145,41 +135,28 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
145
135
|
* @param frame The frame rectangle for the view, measured in points.
|
|
146
136
|
*/
|
|
147
137
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
148
|
-
|
|
149
|
-
#if defined(RTC_SUPPORTS_METAL)
|
|
150
|
-
#if !TARGET_OS_OSX
|
|
151
|
-
RTCMTLVideoView *subview = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero];
|
|
152
|
-
subview.delegate = self;
|
|
153
|
-
_videoView = subview;
|
|
154
|
-
#else
|
|
155
|
-
RTCMTLNSVideoView *subview = [[RTCMTLNSVideoView alloc] initWithFrame:CGRectZero];
|
|
156
|
-
subview.wantsLayer = true;
|
|
157
|
-
subview.delegate = self;
|
|
158
|
-
_videoView = subview;
|
|
159
|
-
#endif
|
|
160
|
-
#else
|
|
138
|
+
if (self = [super initWithFrame:frame]) {
|
|
161
139
|
#if !TARGET_OS_OSX
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
140
|
+
RTCMTLVideoView *subview = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero];
|
|
141
|
+
subview.delegate = self;
|
|
142
|
+
_videoView = subview;
|
|
165
143
|
#else
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
#endif
|
|
144
|
+
RTCMTLNSVideoView *subview = [[RTCMTLNSVideoView alloc] initWithFrame:CGRectZero];
|
|
145
|
+
subview.wantsLayer = true;
|
|
146
|
+
subview.delegate = self;
|
|
147
|
+
_videoView = subview;
|
|
171
148
|
#endif
|
|
172
149
|
|
|
173
|
-
|
|
174
|
-
|
|
150
|
+
_videoSize.height = 0;
|
|
151
|
+
_videoSize.width = 0;
|
|
175
152
|
|
|
153
|
+
#if !TARGET_OS_OSX
|
|
154
|
+
self.opaque = NO;
|
|
155
|
+
#endif
|
|
176
156
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
[self addSubview:self.videoView];
|
|
181
|
-
}
|
|
182
|
-
return self;
|
|
157
|
+
[self addSubview:self.videoView];
|
|
158
|
+
}
|
|
159
|
+
return self;
|
|
183
160
|
}
|
|
184
161
|
|
|
185
162
|
/**
|
|
@@ -190,65 +167,57 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
190
167
|
#if !TARGET_OS_OSX
|
|
191
168
|
- (void)layoutSubviews {
|
|
192
169
|
#else
|
|
193
|
-
|
|
170
|
+
- (void)layout {
|
|
194
171
|
#endif
|
|
195
172
|
#if !TARGET_OS_OSX
|
|
196
|
-
|
|
173
|
+
UIView *subview = self.videoView;
|
|
197
174
|
#else
|
|
198
|
-
|
|
175
|
+
NSView *subview = self.videoView;
|
|
199
176
|
#endif
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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 = 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);
|
|
222
212
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// preserved. Thus, if the aspect ratio of the playback area does not match
|
|
232
|
-
// the aspect ratio of the video, the video will be shown letterboxed or
|
|
233
|
-
// pillarboxed. Areas of the element's playback area that do not contain the
|
|
234
|
-
// video represent nothing.
|
|
235
|
-
newValue
|
|
236
|
-
= AVMakeRectWithAspectRatioInsideRect(
|
|
237
|
-
CGSizeMake(width, height),
|
|
238
|
-
self.bounds);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
CGRect oldValue = subview.frame;
|
|
242
|
-
if (newValue.origin.x != oldValue.origin.x
|
|
243
|
-
|| newValue.origin.y != oldValue.origin.y
|
|
244
|
-
|| newValue.size.width != oldValue.size.width
|
|
245
|
-
|| newValue.size.height != oldValue.size.height) {
|
|
246
|
-
subview.frame = newValue;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
[subview.layer setAffineTransform:self.mirror
|
|
250
|
-
? CGAffineTransformMakeScale(-1.0, 1.0)
|
|
251
|
-
: CGAffineTransformIdentity];
|
|
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];
|
|
252
221
|
}
|
|
253
222
|
|
|
254
223
|
/**
|
|
@@ -259,15 +228,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
259
228
|
* {@code RTCVideoView}.
|
|
260
229
|
*/
|
|
261
230
|
- (void)setMirror:(BOOL)mirror {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
}
|
|
271
240
|
}
|
|
272
241
|
|
|
273
242
|
/**
|
|
@@ -278,15 +247,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
278
247
|
* {@code RTCVideoView}.
|
|
279
248
|
*/
|
|
280
249
|
- (void)setObjectFit:(RTCVideoViewObjectFit)objectFit {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
+
}
|
|
290
259
|
}
|
|
291
260
|
|
|
292
261
|
/**
|
|
@@ -297,69 +266,71 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
297
266
|
* {@code RTCVideoView}.
|
|
298
267
|
*/
|
|
299
268
|
- (void)setVideoTrack:(RTCVideoTrack *)videoTrack {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
|
311
280
|
[self setNeedsLayout];
|
|
312
|
-
|
|
281
|
+
#else
|
|
313
282
|
self.needsLayout = YES;
|
|
314
|
-
|
|
315
|
-
|
|
283
|
+
#endif
|
|
284
|
+
}
|
|
316
285
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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);
|
|
338
320
|
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
|
|
342
|
-
int64_t time = (int64_t)(CFAbsoluteTimeGetCurrent() * 1000000000);
|
|
343
|
-
RTCCVPixelBuffer *buffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
|
|
344
|
-
RTCVideoFrame *frame = [[[RTCVideoFrame alloc] initWithBuffer:buffer rotation:RTCVideoRotation_0 timeStampNs:time] newI420VideoFrame];
|
|
345
|
-
|
|
346
|
-
[self.videoView renderFrame: frame];
|
|
347
|
-
|
|
348
|
-
CVPixelBufferRelease(pixelBuffer);
|
|
349
|
-
}
|
|
350
321
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
+
}
|
|
361
333
|
}
|
|
362
|
-
}
|
|
363
334
|
}
|
|
364
335
|
|
|
365
336
|
#pragma mark - RTCVideoViewDelegate methods
|
|
@@ -375,15 +346,15 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
375
346
|
* specified {@code videoView}.
|
|
376
347
|
*/
|
|
377
348
|
- (void)videoView:(id<RTCVideoRenderer>)videoView didChangeVideoSize:(CGSize)size {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
+
}
|
|
387
358
|
}
|
|
388
359
|
|
|
389
360
|
@end
|
|
@@ -397,16 +368,16 @@ RCT_EXPORT_MODULE()
|
|
|
397
368
|
#else
|
|
398
369
|
- (NSView *)view {
|
|
399
370
|
#endif
|
|
400
|
-
|
|
401
|
-
|
|
371
|
+
RTCVideoView *v = [[RTCVideoView alloc] init];
|
|
372
|
+
v.module = [self.bridge moduleForName:@"WebRTCModule"];
|
|
402
373
|
#if !TARGET_OS_OSX
|
|
403
|
-
|
|
374
|
+
v.clipsToBounds = YES;
|
|
404
375
|
#endif
|
|
405
|
-
|
|
376
|
+
return v;
|
|
406
377
|
}
|
|
407
378
|
|
|
408
379
|
- (dispatch_queue_t)methodQueue {
|
|
409
|
-
|
|
380
|
+
return dispatch_get_main_queue();
|
|
410
381
|
}
|
|
411
382
|
|
|
412
383
|
RCT_EXPORT_VIEW_PROPERTY(mirror, BOOL)
|
|
@@ -418,13 +389,11 @@ RCT_EXPORT_VIEW_PROPERTY(mirror, BOOL)
|
|
|
418
389
|
* the CSS style {@code object-fit}.
|
|
419
390
|
*/
|
|
420
391
|
RCT_CUSTOM_VIEW_PROPERTY(objectFit, NSString *, RTCVideoView) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
? RTCVideoViewObjectFitCover
|
|
425
|
-
: RTCVideoViewObjectFitContain;
|
|
392
|
+
NSString *s = [RCTConvert NSString:json];
|
|
393
|
+
RTCVideoViewObjectFit e =
|
|
394
|
+
(s && [s isEqualToString:@"cover"]) ? RTCVideoViewObjectFitCover : RTCVideoViewObjectFitContain;
|
|
426
395
|
|
|
427
|
-
|
|
396
|
+
view.objectFit = e;
|
|
428
397
|
}
|
|
429
398
|
|
|
430
399
|
RCT_CUSTOM_VIEW_PROPERTY(streamURL, NSString *, RTCVideoView) {
|
|
@@ -450,8 +419,7 @@ RCT_CUSTOM_VIEW_PROPERTY(streamURL, NSString *, RTCVideoView) {
|
|
|
450
419
|
});
|
|
451
420
|
}
|
|
452
421
|
|
|
453
|
-
+ (BOOL)requiresMainQueueSetup
|
|
454
|
-
{
|
|
422
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
455
423
|
return NO;
|
|
456
424
|
}
|
|
457
425
|
|
|
@@ -1,17 +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"
|
|
3
|
+
#import "CapturerEventsDelegate.h"
|
|
10
4
|
|
|
11
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
12
6
|
|
|
13
|
-
extern NSString*
|
|
14
|
-
extern NSString*
|
|
7
|
+
extern NSString *const kRTCScreensharingSocketFD;
|
|
8
|
+
extern NSString *const kRTCAppGroupIdentifier;
|
|
15
9
|
|
|
16
10
|
@class ScreenCapturer;
|
|
17
11
|
|