react-native-webrtc 124.0.5 → 124.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/.nvmrc +1 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +2 -1
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +7 -9
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +33 -19
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +11 -19
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +0 -2
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +4 -2
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +25 -0
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +1 -4
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +16 -12
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +37 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +15 -9
- package/android/src/main/java/org/webrtc/Camera1Helper.java +0 -1
- package/android/src/main/java/org/webrtc/Camera2Helper.java +4 -3
- package/ios/RCTWebRTC/CaptureController.h +1 -1
- package/ios/RCTWebRTC/CaptureController.m +6 -7
- package/ios/RCTWebRTC/I420Converter.h +3 -2
- package/ios/RCTWebRTC/I420Converter.m +55 -47
- package/ios/RCTWebRTC/PIPController.h +2 -2
- package/ios/RCTWebRTC/PIPController.m +29 -37
- package/ios/RCTWebRTC/RTCVideoViewManager.m +38 -17
- package/ios/RCTWebRTC/SampleBufferVideoCallView.h +2 -2
- package/ios/RCTWebRTC/SampleBufferVideoCallView.m +40 -42
- package/ios/RCTWebRTC/ScreenCaptureController.m +1 -5
- package/ios/RCTWebRTC/VideoCaptureController.h +1 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +6 -7
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +4 -8
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +31 -40
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +5 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +61 -22
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +26 -55
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +11 -28
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.h +9 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.h +13 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoFrameProcessor.h +8 -0
- package/lib/commonjs/MediaStreamTrack.js +5 -2
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/RTCPIPView.js +3 -7
- package/lib/commonjs/RTCPIPView.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +2 -4
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +2 -3
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +5 -2
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/RTCPIPView.js +3 -7
- package/lib/module/RTCPIPView.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +2 -4
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCUtil.js +2 -3
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/typescript/MediaStreamTrack.d.ts +1 -0
- package/lib/typescript/RTCPIPView.d.ts +2 -1
- package/lib/typescript/RTCPeerConnection.d.ts +2 -1
- package/lib/typescript/RTCUtil.d.ts +7 -1
- package/lib/typescript/RTCView.d.ts +14 -0
- package/package.json +1 -1
- package/src/MediaStreamTrack.ts +6 -2
- package/src/RTCPIPView.tsx +3 -2
- package/src/RTCPeerConnection.ts +4 -5
- package/src/RTCUtil.ts +10 -3
- package/src/RTCView.ts +11 -1
- package/tools/release.sh +1 -1
- package/tools/build-webrtc.py +0 -344
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
#import "I420Converter.h"
|
|
2
1
|
#import "SampleBufferVideoCallView.h"
|
|
3
|
-
#import <WebRTC/WebRTC.h>
|
|
4
2
|
#import <Accelerate/Accelerate.h>
|
|
3
|
+
#import <WebRTC/WebRTC.h>
|
|
4
|
+
#import "I420Converter.h"
|
|
5
5
|
|
|
6
|
-
@protocol SampleBufferRendering
|
|
6
|
+
@protocol SampleBufferRendering<AVQueuedSampleBufferRendering>
|
|
7
7
|
|
|
8
|
-
-(BOOL)requiresFlushToResumeDecoding;
|
|
8
|
+
- (BOOL)requiresFlushToResumeDecoding;
|
|
9
9
|
|
|
10
10
|
@end
|
|
11
11
|
|
|
12
12
|
/** These classes already implement the required methods. */
|
|
13
|
-
@interface AVSampleBufferDisplayLayer ()
|
|
13
|
+
@interface AVSampleBufferDisplayLayer ()<SampleBufferRendering>
|
|
14
14
|
@end
|
|
15
|
-
@interface AVSampleBufferVideoRenderer ()
|
|
15
|
+
@interface AVSampleBufferVideoRenderer ()<SampleBufferRendering>
|
|
16
16
|
@end
|
|
17
17
|
|
|
18
18
|
@interface SampleBufferVideoCallView ()
|
|
19
19
|
|
|
20
|
-
@property
|
|
21
|
-
@property
|
|
22
|
-
@property
|
|
20
|
+
@property(nonatomic, retain) I420Converter *i420Converter;
|
|
21
|
+
@property(nonatomic, strong) id<SampleBufferRendering> renderer;
|
|
22
|
+
@property(nonatomic, assign) NSInteger currentRotation;
|
|
23
23
|
|
|
24
24
|
@end
|
|
25
25
|
|
|
@@ -31,7 +31,10 @@
|
|
|
31
31
|
|
|
32
32
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
33
33
|
if (self = [super initWithFrame:frame]) {
|
|
34
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
34
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
35
|
+
selector:@selector(layerFailedToDecode:)
|
|
36
|
+
name:AVSampleBufferDisplayLayerFailedToDecodeNotification
|
|
37
|
+
object:self.sampleBufferLayer];
|
|
35
38
|
if (@available(iOS 17.0, *)) {
|
|
36
39
|
_renderer = self.sampleBufferLayer.sampleBufferRenderer;
|
|
37
40
|
} else {
|
|
@@ -41,8 +44,7 @@
|
|
|
41
44
|
return self;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
- (void)layerFailedToDecode:(NSNotification*)note
|
|
45
|
-
{
|
|
47
|
+
- (void)layerFailedToDecode:(NSNotification *)note {
|
|
46
48
|
NSError *error = [[note userInfo] valueForKey:AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey];
|
|
47
49
|
NSLog(@"layerFailedToDecode, error: %@", [error localizedDescription]);
|
|
48
50
|
}
|
|
@@ -58,28 +60,24 @@
|
|
|
58
60
|
- (void)recalculateScale:(RTCVideoRotation)rotation {
|
|
59
61
|
if (self.currentRotation != rotation) {
|
|
60
62
|
self.currentRotation = rotation;
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
CGFloat scale = 1;
|
|
63
|
-
if(rotation == 90 || rotation == 270) {
|
|
65
|
+
if (rotation == 90 || rotation == 270) {
|
|
64
66
|
CGSize size = self.bounds.size;
|
|
65
67
|
scale = size.height / size.width;
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
|
|
68
70
|
self.sampleBufferLayer.transform = CATransform3DConcat(
|
|
69
|
-
CATransform3DMakeRotation(rotation / 180.0 * M_PI, 0.0, 0.0, 1.0),
|
|
70
|
-
CATransform3DMakeScale(scale, scale, 1)
|
|
71
|
-
);
|
|
71
|
+
CATransform3DMakeRotation(rotation / 180.0 * M_PI, 0.0, 0.0, 1.0), CATransform3DMakeScale(scale, scale, 1));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** The size of the video frame. */
|
|
76
|
-
- (void)setSize
|
|
77
|
-
|
|
76
|
+
- (void)setSize:(CGSize)size {
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
/** The frame to be displayed. */
|
|
81
80
|
- (void)renderFrame:(nullable RTC_OBJC_TYPE(RTCVideoFrame) *)frame {
|
|
82
|
-
|
|
83
81
|
if (!_shouldRender) {
|
|
84
82
|
return;
|
|
85
83
|
}
|
|
@@ -91,7 +89,6 @@
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
94
|
-
|
|
95
92
|
if (self.renderer.requiresFlushToResumeDecoding) {
|
|
96
93
|
[self.renderer flush];
|
|
97
94
|
}
|
|
@@ -110,7 +107,7 @@
|
|
|
110
107
|
|
|
111
108
|
- (CMSampleBufferRef)sampleBufferFrom:(RTCVideoFrame *)rtcVideoFrame {
|
|
112
109
|
// Convert RTCVideoFrame to CMSampleBuffer
|
|
113
|
-
|
|
110
|
+
|
|
114
111
|
// Assuming your RTCVideoFrame contains pixelBuffer
|
|
115
112
|
CVPixelBufferRef pixelBuffer = [self pixelBufferFrom:rtcVideoFrame];
|
|
116
113
|
if (!pixelBuffer) {
|
|
@@ -120,17 +117,18 @@
|
|
|
120
117
|
// Create a CMVideoFormatDescription
|
|
121
118
|
CMVideoFormatDescriptionRef formatDescription;
|
|
122
119
|
CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, &formatDescription);
|
|
123
|
-
|
|
120
|
+
|
|
124
121
|
// Create CMSampleTimingInfo
|
|
125
122
|
// Timescale is 90khz according to RTCVideoFrame.h
|
|
126
123
|
CMSampleTimingInfo timingInfo;
|
|
127
124
|
timingInfo.presentationTimeStamp = CMTimeMake(rtcVideoFrame.timeStamp, 90000);
|
|
128
125
|
timingInfo.decodeTimeStamp = CMTimeMake(rtcVideoFrame.timeStamp, 90000);
|
|
129
|
-
|
|
126
|
+
|
|
130
127
|
// Create CMSampleBuffer
|
|
131
128
|
CMSampleBufferRef sampleBuffer;
|
|
132
|
-
CMSampleBufferCreateForImageBuffer(
|
|
133
|
-
|
|
129
|
+
CMSampleBufferCreateForImageBuffer(
|
|
130
|
+
kCFAllocatorDefault, pixelBuffer, true, nil, nil, formatDescription, &timingInfo, &sampleBuffer);
|
|
131
|
+
|
|
134
132
|
CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, YES);
|
|
135
133
|
CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);
|
|
136
134
|
|
|
@@ -140,40 +138,40 @@
|
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-(CVPixelBufferRef)pixelBufferFrom:(RTCVideoFrame *)videoFrame {
|
|
141
|
+
* The CVPixelBufferRef returned from this function must be released when finished using it.
|
|
142
|
+
*/
|
|
143
|
+
- (CVPixelBufferRef)pixelBufferFrom:(RTCVideoFrame *)videoFrame {
|
|
146
144
|
if ([videoFrame.buffer isKindOfClass:[RTCCVPixelBuffer class]]) {
|
|
147
|
-
CVPixelBufferRef pixelBuffer = [((RTCCVPixelBuffer *)
|
|
145
|
+
CVPixelBufferRef pixelBuffer = [((RTCCVPixelBuffer *)videoFrame.buffer) pixelBuffer];
|
|
148
146
|
CVPixelBufferRetain(pixelBuffer);
|
|
149
|
-
return [((RTCCVPixelBuffer *)
|
|
147
|
+
return [((RTCCVPixelBuffer *)videoFrame.buffer) pixelBuffer];
|
|
150
148
|
} else {
|
|
151
149
|
return [self pixelBufferFromI420:[videoFrame.buffer toI420]];
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
|
|
155
153
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-(CVPixelBufferRef)pixelBufferFromI420:(RTCI420Buffer *)i420Buffer {
|
|
154
|
+
* The CVPixelBufferRef returned from this function must be released when finished using it.
|
|
155
|
+
*/
|
|
156
|
+
- (CVPixelBufferRef)pixelBufferFromI420:(RTCI420Buffer *)i420Buffer {
|
|
159
157
|
if (_i420Converter == nil) {
|
|
160
|
-
I420Converter *
|
|
158
|
+
I420Converter *converter = [[I420Converter alloc] init];
|
|
161
159
|
vImage_Error err = [converter prepareForAccelerateConversion];
|
|
162
|
-
|
|
163
|
-
if(err != kvImageNoError) {
|
|
160
|
+
|
|
161
|
+
if (err != kvImageNoError) {
|
|
164
162
|
NSLog(@"Error when preparing i420Converter: %ld", err);
|
|
165
163
|
return NULL;
|
|
166
164
|
}
|
|
167
|
-
|
|
165
|
+
|
|
168
166
|
_i420Converter = converter;
|
|
169
167
|
}
|
|
170
|
-
|
|
168
|
+
|
|
171
169
|
CVPixelBufferRef convertedPixelBuffer = [_i420Converter convertI420ToPixelBuffer:i420Buffer];
|
|
172
|
-
|
|
170
|
+
|
|
173
171
|
return convertedPixelBuffer;
|
|
174
172
|
}
|
|
175
173
|
|
|
176
|
-
-(void)dealloc {
|
|
174
|
+
- (void)dealloc {
|
|
177
175
|
[_i420Converter unprepareForAccelerateConversion];
|
|
178
176
|
}
|
|
179
177
|
|
|
@@ -55,11 +55,7 @@ NSString *const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
- (NSDictionary *)getSettings {
|
|
58
|
-
return @{
|
|
59
|
-
@"deviceId": self.deviceId,
|
|
60
|
-
@"groupId": @"",
|
|
61
|
-
@"frameRate" : @(30)
|
|
62
|
-
};
|
|
58
|
+
return @{@"deviceId" : self.deviceId, @"groupId" : @"", @"frameRate" : @(30)};
|
|
63
59
|
}
|
|
64
60
|
// MARK: CapturerEventsDelegate Methods
|
|
65
61
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#import "CaptureController.h"
|
|
7
7
|
|
|
8
8
|
@interface VideoCaptureController : CaptureController
|
|
9
|
+
@property(nonatomic, readonly, strong) RTCCameraVideoCapturer *capturer;
|
|
9
10
|
@property(nonatomic, readonly, strong) AVCaptureDeviceFormat *selectedFormat;
|
|
10
11
|
@property(nonatomic, readonly, assign) int frameRate;
|
|
11
12
|
@property(nonatomic, assign) BOOL enableMultitaskingCameraAccess;
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
BOOL shouldChange = session.multitaskingCameraAccessEnabled != enable;
|
|
69
69
|
BOOL canChange = !enable || (enable && session.isMultitaskingCameraAccessSupported);
|
|
70
70
|
|
|
71
|
-
if(shouldChange && canChange) {
|
|
71
|
+
if (shouldChange && canChange) {
|
|
72
72
|
[session beginConfiguration];
|
|
73
73
|
[session setMultitaskingCameraAccessEnabled:enable];
|
|
74
74
|
[session commitConfiguration];
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
self.device = nil;
|
|
123
123
|
|
|
124
124
|
BOOL hasChanged = NO;
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
NSString *deviceId = constraints[@"deviceId"];
|
|
127
127
|
int width = [constraints[@"width"] intValue];
|
|
128
128
|
int height = [constraints[@"height"] intValue];
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
hasChanged = YES;
|
|
133
133
|
self.width = width;
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
if (self.height != height) {
|
|
137
137
|
hasChanged = YES;
|
|
138
138
|
self.height = height;
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
if (self.frameRate != frameRate) {
|
|
142
142
|
hasChanged = YES;
|
|
143
143
|
self.frameRate = frameRate;
|
|
@@ -174,13 +174,12 @@
|
|
|
174
174
|
self.usingFrontCamera ? AVCaptureDevicePositionFront : AVCaptureDevicePositionBack;
|
|
175
175
|
deviceId = [self findDeviceForPosition:position].uniqueID;
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
if (self.deviceId != deviceId && ![self.deviceId isEqualToString:deviceId]) {
|
|
179
179
|
hasChanged = YES;
|
|
180
180
|
self.deviceId = deviceId;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
183
|
if (self.running && hasChanged) {
|
|
185
184
|
[self startCapture];
|
|
186
185
|
}
|
|
@@ -190,7 +189,7 @@
|
|
|
190
189
|
AVCaptureDeviceFormat *format = self.selectedFormat;
|
|
191
190
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
|
|
192
191
|
NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithDictionary:@{
|
|
193
|
-
@"groupId": @"",
|
|
192
|
+
@"groupId" : @"",
|
|
194
193
|
@"height" : @(dimensions.height),
|
|
195
194
|
@"width" : @(dimensions.width),
|
|
196
195
|
@"frameRate" : @(30),
|
|
@@ -19,10 +19,8 @@ static NSString *const PERMISSION_PROMPT = @"prompt";
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
RCT_EXPORT_METHOD(checkPermission
|
|
23
|
-
|
|
24
|
-
: (RCTPromiseResolveBlock)resolve rejecter
|
|
25
|
-
: (RCTPromiseRejectBlock)reject) {
|
|
22
|
+
RCT_EXPORT_METHOD(checkPermission : (NSString *)mediaType resolver : (RCTPromiseResolveBlock)
|
|
23
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
26
24
|
#if TARGET_OS_TV
|
|
27
25
|
resolve(@"tvOS is not supported");
|
|
28
26
|
return;
|
|
@@ -50,10 +48,8 @@ RCT_EXPORT_METHOD(checkPermission
|
|
|
50
48
|
#endif
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
RCT_EXPORT_METHOD(requestPermission
|
|
54
|
-
|
|
55
|
-
: (RCTPromiseResolveBlock)resolve rejecter
|
|
56
|
-
: (RCTPromiseRejectBlock)reject) {
|
|
51
|
+
RCT_EXPORT_METHOD(requestPermission : (NSString *)mediaType resolver : (RCTPromiseResolveBlock)
|
|
52
|
+
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
57
53
|
#if TARGET_OS_TV
|
|
58
54
|
resolve(@"tvOS is not supported");
|
|
59
55
|
return;
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* Thuis methos is implemented synchronously since we need to create the DataChannel on the spot
|
|
15
15
|
* and where is no good way to report an error at creation time.
|
|
16
16
|
*/
|
|
17
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createDataChannel
|
|
18
|
-
|
|
19
|
-
: (NSString *)label config
|
|
20
|
-
: (RTCDataChannelConfiguration *)config) {
|
|
17
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createDataChannel : (nonnull NSNumber *)peerConnectionId label : (NSString *)
|
|
18
|
+
label config : (RTCDataChannelConfiguration *)config) {
|
|
21
19
|
__block id channelInfo;
|
|
22
20
|
|
|
23
21
|
dispatch_sync(self.workerQueue, ^{
|
|
@@ -59,42 +57,35 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(createDataChannel
|
|
|
59
57
|
return channelInfo;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
RCT_EXPORT_METHOD(dataChannelClose
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
BOOL isBinary = [type isEqualToString:@"binary"];
|
|
92
|
-
NSData *bytes = isBinary ? [[NSData alloc] initWithBase64EncodedString:data options:0]
|
|
93
|
-
: [data dataUsingEncoding:NSUTF8StringEncoding];
|
|
94
|
-
RTCDataBuffer *buffer = [[RTCDataBuffer alloc] initWithData:bytes isBinary:isBinary];
|
|
95
|
-
[dcw.channel sendData:buffer];
|
|
96
|
-
}
|
|
97
|
-
})
|
|
60
|
+
RCT_EXPORT_METHOD(dataChannelClose : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)tag {
|
|
61
|
+
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
|
|
62
|
+
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
|
|
63
|
+
if (dcw) {
|
|
64
|
+
[dcw.channel close];
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
RCT_EXPORT_METHOD(dataChannelDispose : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)tag {
|
|
69
|
+
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
|
|
70
|
+
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
|
|
71
|
+
if (dcw) {
|
|
72
|
+
dcw.delegate = nil;
|
|
73
|
+
[peerConnection.dataChannels removeObjectForKey:tag];
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
RCT_EXPORT_METHOD(dataChannelSend : (nonnull NSNumber *)peerConnectionId reactTag : (nonnull NSString *)
|
|
78
|
+
tag data : (NSString *)data type : (NSString *)type {
|
|
79
|
+
RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
|
|
80
|
+
DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
|
|
81
|
+
if (dcw) {
|
|
82
|
+
BOOL isBinary = [type isEqualToString:@"binary"];
|
|
83
|
+
NSData *bytes = isBinary ? [[NSData alloc] initWithBase64EncodedString:data options:0]
|
|
84
|
+
: [data dataUsingEncoding:NSUTF8StringEncoding];
|
|
85
|
+
RTCDataBuffer *buffer = [[RTCDataBuffer alloc] initWithData:bytes isBinary:isBinary];
|
|
86
|
+
[dcw.channel sendData:buffer];
|
|
87
|
+
}
|
|
88
|
+
})
|
|
98
89
|
|
|
99
90
|
- (NSString *)stringForDataChannelState:(RTCDataChannelState)state {
|
|
100
91
|
switch (state) {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#import "CaptureController.h"
|
|
2
|
+
#import "VideoEffectProcessor.h"
|
|
2
3
|
#import "WebRTCModule.h"
|
|
3
4
|
|
|
4
5
|
@interface WebRTCModule (RTCMediaStream)
|
|
6
|
+
|
|
7
|
+
@property(nonatomic, strong) VideoEffectProcessor *videoEffectProcessor;
|
|
8
|
+
|
|
5
9
|
- (RTCVideoTrack *)createVideoTrackWithCaptureController:
|
|
6
10
|
(CaptureController * (^)(RTCVideoSource *))captureControllerCreator;
|
|
7
11
|
- (NSArray *)createMediaStream:(NSArray<RTCMediaStreamTrack *> *)tracks;
|
|
12
|
+
|
|
8
13
|
@end
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
#import <WebRTC/RTCVideoTrack.h>
|
|
7
7
|
|
|
8
8
|
#import "RTCMediaStreamTrack+React.h"
|
|
9
|
-
#import "WebRTCModuleOptions.h"
|
|
10
9
|
#import "WebRTCModule+RTCMediaStream.h"
|
|
11
10
|
#import "WebRTCModule+RTCPeerConnection.h"
|
|
11
|
+
#import "WebRTCModuleOptions.h"
|
|
12
12
|
|
|
13
|
+
#import "ProcessorProvider.h"
|
|
13
14
|
#import "ScreenCaptureController.h"
|
|
14
15
|
#import "ScreenCapturer.h"
|
|
15
16
|
#import "TrackCapturerEventsEmitter.h"
|
|
@@ -17,6 +18,15 @@
|
|
|
17
18
|
|
|
18
19
|
@implementation WebRTCModule (RTCMediaStream)
|
|
19
20
|
|
|
21
|
+
- (VideoEffectProcessor *)videoEffectProcessor {
|
|
22
|
+
return objc_getAssociatedObject(self, _cmd);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor {
|
|
26
|
+
objc_setAssociatedObject(
|
|
27
|
+
self, @selector(videoEffectProcessor), videoEffectProcessor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
#pragma mark - getUserMedia
|
|
21
31
|
|
|
22
32
|
/**
|
|
@@ -83,8 +93,8 @@
|
|
|
83
93
|
}
|
|
84
94
|
} else if ([track.kind isEqualToString:@"audio"]) {
|
|
85
95
|
settings = @{
|
|
86
|
-
@"deviceId": @"audio",
|
|
87
|
-
@"groupId": @"",
|
|
96
|
+
@"deviceId" : @"audio",
|
|
97
|
+
@"groupId" : @"",
|
|
88
98
|
};
|
|
89
99
|
}
|
|
90
100
|
|
|
@@ -119,7 +129,8 @@
|
|
|
119
129
|
RTCCameraVideoCapturer *videoCapturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:videoSource];
|
|
120
130
|
VideoCaptureController *videoCaptureController =
|
|
121
131
|
[[VideoCaptureController alloc] initWithCapturer:videoCapturer andConstraints:constraints[@"video"]];
|
|
122
|
-
videoCaptureController.enableMultitaskingCameraAccess =
|
|
132
|
+
videoCaptureController.enableMultitaskingCameraAccess =
|
|
133
|
+
[WebRTCModuleOptions sharedInstance].enableMultitaskingCameraAccess;
|
|
123
134
|
videoTrack.captureController = videoCaptureController;
|
|
124
135
|
[videoCaptureController startCapture];
|
|
125
136
|
#endif
|
|
@@ -190,10 +201,8 @@ RCT_EXPORT_METHOD(getDisplayMedia : (RCTPromiseResolveBlock)resolve rejecter : (
|
|
|
190
201
|
* if audio permission was not granted, there will be no "audio" key in
|
|
191
202
|
* the constraints dictionary.
|
|
192
203
|
*/
|
|
193
|
-
RCT_EXPORT_METHOD(getUserMedia
|
|
194
|
-
|
|
195
|
-
: (RCTResponseSenderBlock)successCallback errorCallback
|
|
196
|
-
: (RCTResponseSenderBlock)errorCallback) {
|
|
204
|
+
RCT_EXPORT_METHOD(getUserMedia : (NSDictionary *)constraints successCallback : (RCTResponseSenderBlock)
|
|
205
|
+
successCallback errorCallback : (RCTResponseSenderBlock)errorCallback) {
|
|
197
206
|
#if TARGET_OS_TV
|
|
198
207
|
errorCallback(@[ @"PlatformNotSupported", @"getUserMedia is not supported on tvOS." ]);
|
|
199
208
|
return;
|
|
@@ -243,8 +252,8 @@ RCT_EXPORT_METHOD(getUserMedia
|
|
|
243
252
|
}
|
|
244
253
|
} else if ([track.kind isEqualToString:@"audio"]) {
|
|
245
254
|
settings = @{
|
|
246
|
-
@"deviceId": @"audio",
|
|
247
|
-
@"groupId": @"",
|
|
255
|
+
@"deviceId" : @"audio",
|
|
256
|
+
@"groupId" : @"",
|
|
248
257
|
};
|
|
249
258
|
}
|
|
250
259
|
|
|
@@ -271,7 +280,14 @@ RCT_EXPORT_METHOD(enumerateDevices : (RCTResponseSenderBlock)callback) {
|
|
|
271
280
|
#else
|
|
272
281
|
NSMutableArray *devices = [NSMutableArray array];
|
|
273
282
|
NSMutableArray *deviceTypes = [NSMutableArray array];
|
|
274
|
-
[deviceTypes addObjectsFromArray:@[
|
|
283
|
+
[deviceTypes addObjectsFromArray:@[
|
|
284
|
+
AVCaptureDeviceTypeBuiltInWideAngleCamera,
|
|
285
|
+
AVCaptureDeviceTypeBuiltInUltraWideCamera,
|
|
286
|
+
AVCaptureDeviceTypeBuiltInTelephotoCamera,
|
|
287
|
+
AVCaptureDeviceTypeBuiltInDualCamera,
|
|
288
|
+
AVCaptureDeviceTypeBuiltInDualWideCamera,
|
|
289
|
+
AVCaptureDeviceTypeBuiltInTripleCamera
|
|
290
|
+
]];
|
|
275
291
|
if (@available(macos 14.0, ios 17.0, tvos 17.0, *)) {
|
|
276
292
|
[deviceTypes addObject:AVCaptureDeviceTypeExternal];
|
|
277
293
|
}
|
|
@@ -290,7 +306,7 @@ RCT_EXPORT_METHOD(enumerateDevices : (RCTResponseSenderBlock)callback) {
|
|
|
290
306
|
if (device.localizedName != nil) {
|
|
291
307
|
label = device.localizedName;
|
|
292
308
|
}
|
|
293
|
-
|
|
309
|
+
|
|
294
310
|
[devices addObject:@{
|
|
295
311
|
@"facing" : position,
|
|
296
312
|
@"deviceId" : device.uniqueID,
|
|
@@ -324,10 +340,8 @@ RCT_EXPORT_METHOD(mediaStreamCreate : (nonnull NSString *)streamID) {
|
|
|
324
340
|
self.localStreams[streamID] = mediaStream;
|
|
325
341
|
}
|
|
326
342
|
|
|
327
|
-
RCT_EXPORT_METHOD(mediaStreamAddTrack
|
|
328
|
-
|
|
329
|
-
: (nonnull NSNumber *)pcId
|
|
330
|
-
: (nonnull NSString *)trackID) {
|
|
343
|
+
RCT_EXPORT_METHOD(mediaStreamAddTrack : (nonnull NSString *)streamID : (nonnull NSNumber *)pcId : (nonnull NSString *)
|
|
344
|
+
trackID) {
|
|
331
345
|
RTCMediaStream *mediaStream = self.localStreams[streamID];
|
|
332
346
|
if (mediaStream == nil) {
|
|
333
347
|
return;
|
|
@@ -345,10 +359,8 @@ RCT_EXPORT_METHOD(mediaStreamAddTrack
|
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
|
|
348
|
-
RCT_EXPORT_METHOD(mediaStreamRemoveTrack
|
|
349
|
-
|
|
350
|
-
: (nonnull NSNumber *)pcId
|
|
351
|
-
: (nonnull NSString *)trackID) {
|
|
362
|
+
RCT_EXPORT_METHOD(mediaStreamRemoveTrack : (nonnull NSString *)streamID : (nonnull NSNumber *)
|
|
363
|
+
pcId : (nonnull NSString *)trackID) {
|
|
352
364
|
RTCMediaStream *mediaStream = self.localStreams[streamID];
|
|
353
365
|
if (mediaStream == nil) {
|
|
354
366
|
return;
|
|
@@ -405,7 +417,8 @@ RCT_EXPORT_METHOD(mediaStreamTrackSetEnabled : (nonnull NSNumber *)pcId : (nonnu
|
|
|
405
417
|
#endif
|
|
406
418
|
}
|
|
407
419
|
|
|
408
|
-
RCT_EXPORT_METHOD(mediaStreamTrackApplyConstraints : (nonnull NSString *)trackID : (NSDictionary *)
|
|
420
|
+
RCT_EXPORT_METHOD(mediaStreamTrackApplyConstraints : (nonnull NSString *)trackID : (NSDictionary *)
|
|
421
|
+
constraints : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
|
|
409
422
|
#if TARGET_OS_TV
|
|
410
423
|
reject(@"unsupported_platform", @"tvOS is not supported", nil);
|
|
411
424
|
return;
|
|
@@ -416,7 +429,7 @@ RCT_EXPORT_METHOD(mediaStreamTrackApplyConstraints : (nonnull NSString *)trackID
|
|
|
416
429
|
RTCVideoTrack *videoTrack = (RTCVideoTrack *)track;
|
|
417
430
|
if ([videoTrack.captureController isKindOfClass:[CaptureController class]]) {
|
|
418
431
|
CaptureController *vcc = (CaptureController *)videoTrack.captureController;
|
|
419
|
-
NSError*
|
|
432
|
+
NSError *error = nil;
|
|
420
433
|
[vcc applyConstraints:constraints error:&error];
|
|
421
434
|
if (error) {
|
|
422
435
|
reject(@"E_INVALID", error.localizedDescription, error);
|
|
@@ -443,6 +456,32 @@ RCT_EXPORT_METHOD(mediaStreamTrackSetVolume : (nonnull NSNumber *)pcId : (nonnul
|
|
|
443
456
|
}
|
|
444
457
|
}
|
|
445
458
|
|
|
459
|
+
RCT_EXPORT_METHOD(mediaStreamTrackSetVideoEffects : (nonnull NSString *)trackID names : (nonnull NSArray<NSString *> *)
|
|
460
|
+
names) {
|
|
461
|
+
RTCMediaStreamTrack *track = self.localTracks[trackID];
|
|
462
|
+
if (track == nil) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
RTCVideoTrack *videoTrack = (RTCVideoTrack *)track;
|
|
467
|
+
RTCVideoSource *videoSource = videoTrack.source;
|
|
468
|
+
|
|
469
|
+
NSMutableArray *processors = [[NSMutableArray alloc] init];
|
|
470
|
+
for (NSString *name in names) {
|
|
471
|
+
NSObject<VideoFrameProcessorDelegate> *processor = [ProcessorProvider getProcessor:name];
|
|
472
|
+
if (processor != nil) {
|
|
473
|
+
[processors addObject:processor];
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
self.videoEffectProcessor = [[VideoEffectProcessor alloc] initWithProcessors:processors videoSource:videoSource];
|
|
478
|
+
|
|
479
|
+
VideoCaptureController *vcc = (VideoCaptureController *)videoTrack.captureController;
|
|
480
|
+
RTCVideoCapturer *capturer = vcc.capturer;
|
|
481
|
+
|
|
482
|
+
capturer.delegate = self.videoEffectProcessor;
|
|
483
|
+
}
|
|
484
|
+
|
|
446
485
|
#pragma mark - Helpers
|
|
447
486
|
|
|
448
487
|
- (RTCMediaStreamTrack *)trackForId:(nonnull NSString *)trackId pcId:(nonnull NSNumber *)pcId {
|