react-native-webrtc 124.0.4 → 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.
Files changed (104) hide show
  1. package/.nvmrc +1 -0
  2. package/android/build.gradle +3 -2
  3. package/android/consumer-rules.pro +2 -0
  4. package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +30 -3
  5. package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +180 -73
  6. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +53 -24
  7. package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +11 -19
  8. package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +0 -2
  9. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +4 -2
  10. package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +25 -0
  11. package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +6 -4
  12. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +20 -14
  13. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +37 -0
  14. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +15 -9
  15. package/android/src/main/java/org/webrtc/Camera1Helper.java +0 -1
  16. package/android/src/main/java/org/webrtc/Camera2Helper.java +4 -3
  17. package/ios/RCTWebRTC/CaptureController.h +3 -0
  18. package/ios/RCTWebRTC/CaptureController.m +12 -0
  19. package/ios/RCTWebRTC/I420Converter.h +22 -0
  20. package/ios/RCTWebRTC/I420Converter.m +164 -0
  21. package/ios/RCTWebRTC/PIPController.h +24 -0
  22. package/ios/RCTWebRTC/PIPController.m +234 -0
  23. package/ios/RCTWebRTC/RTCVideoViewManager.h +23 -0
  24. package/ios/RCTWebRTC/RTCVideoViewManager.m +131 -28
  25. package/ios/RCTWebRTC/SampleBufferVideoCallView.h +12 -0
  26. package/ios/RCTWebRTC/SampleBufferVideoCallView.m +178 -0
  27. package/ios/RCTWebRTC/ScreenCaptureController.m +4 -0
  28. package/ios/RCTWebRTC/VideoCaptureController.h +3 -0
  29. package/ios/RCTWebRTC/VideoCaptureController.m +95 -30
  30. package/ios/RCTWebRTC/WebRTCModule+Permissions.m +4 -8
  31. package/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m +20 -0
  32. package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +31 -40
  33. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +5 -0
  34. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +93 -28
  35. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +26 -55
  36. package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +11 -28
  37. package/ios/RCTWebRTC/WebRTCModuleOptions.h +1 -0
  38. package/ios/RCTWebRTC/videoEffects/ProcessorProvider.h +9 -0
  39. package/ios/RCTWebRTC/videoEffects/ProcessorProvider.m +23 -0
  40. package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.h +13 -0
  41. package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.m +23 -0
  42. package/ios/RCTWebRTC/videoEffects/VideoFrameProcessor.h +8 -0
  43. package/ios/RCTWebRTC.xcodeproj/project.pbxproj +4 -0
  44. package/lib/commonjs/Constraints.js +2 -0
  45. package/lib/commonjs/Constraints.js.map +1 -0
  46. package/lib/commonjs/MediaDevices.js.map +1 -1
  47. package/lib/commonjs/MediaStreamTrack.js +31 -5
  48. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  49. package/lib/commonjs/RTCAudioSession.js +33 -0
  50. package/lib/commonjs/RTCAudioSession.js.map +1 -0
  51. package/lib/commonjs/RTCPIPView.js +38 -0
  52. package/lib/commonjs/RTCPIPView.js.map +1 -0
  53. package/lib/commonjs/RTCPeerConnection.js +2 -4
  54. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  55. package/lib/commonjs/RTCUtil.js +2 -3
  56. package/lib/commonjs/RTCUtil.js.map +1 -1
  57. package/lib/commonjs/RTCView.js.map +1 -1
  58. package/lib/commonjs/getUserMedia.js.map +1 -1
  59. package/lib/commonjs/index.js +28 -0
  60. package/lib/commonjs/index.js.map +1 -1
  61. package/lib/module/Constraints.js +2 -0
  62. package/lib/module/Constraints.js.map +1 -0
  63. package/lib/module/MediaDevices.js.map +1 -1
  64. package/lib/module/MediaStreamTrack.js +32 -6
  65. package/lib/module/MediaStreamTrack.js.map +1 -1
  66. package/lib/module/RTCAudioSession.js +26 -0
  67. package/lib/module/RTCAudioSession.js.map +1 -0
  68. package/lib/module/RTCPIPView.js +26 -0
  69. package/lib/module/RTCPIPView.js.map +1 -0
  70. package/lib/module/RTCPeerConnection.js +2 -4
  71. package/lib/module/RTCPeerConnection.js.map +1 -1
  72. package/lib/module/RTCUtil.js +2 -3
  73. package/lib/module/RTCUtil.js.map +1 -1
  74. package/lib/module/RTCView.js.map +1 -1
  75. package/lib/module/getUserMedia.js.map +1 -1
  76. package/lib/module/index.js +3 -1
  77. package/lib/module/index.js.map +1 -1
  78. package/lib/typescript/Constraints.d.ts +19 -0
  79. package/lib/typescript/MediaDevices.d.ts +2 -1
  80. package/lib/typescript/MediaStreamTrack.d.ts +27 -5
  81. package/lib/typescript/RTCAudioSession.d.ts +10 -0
  82. package/lib/typescript/RTCPIPView.d.ts +15 -0
  83. package/lib/typescript/RTCPeerConnection.d.ts +2 -1
  84. package/lib/typescript/RTCUtil.d.ts +7 -1
  85. package/lib/typescript/RTCView.d.ts +58 -1
  86. package/lib/typescript/getUserMedia.d.ts +4 -4
  87. package/lib/typescript/index.d.ts +5 -3
  88. package/package.json +2 -1
  89. package/src/.eslintrc.cjs +1 -1
  90. package/src/Constraints.ts +21 -0
  91. package/src/MediaDevices.ts +2 -2
  92. package/src/MediaStreamTrack.ts +47 -9
  93. package/src/RTCAudioSession.ts +25 -0
  94. package/src/RTCPIPView.tsx +47 -0
  95. package/src/RTCPeerConnection.ts +4 -5
  96. package/src/RTCUtil.ts +10 -3
  97. package/src/RTCView.ts +60 -2
  98. package/src/getUserMedia.ts +4 -3
  99. package/src/index.ts +12 -3
  100. package/tools/release.sh +1 -1
  101. package/tsconfig.json +3 -1
  102. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  103. package/ios/RCTWebRTC.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  104. package/tools/build-webrtc.py +0 -344
@@ -0,0 +1,178 @@
1
+ #import "SampleBufferVideoCallView.h"
2
+ #import <Accelerate/Accelerate.h>
3
+ #import <WebRTC/WebRTC.h>
4
+ #import "I420Converter.h"
5
+
6
+ @protocol SampleBufferRendering<AVQueuedSampleBufferRendering>
7
+
8
+ - (BOOL)requiresFlushToResumeDecoding;
9
+
10
+ @end
11
+
12
+ /** These classes already implement the required methods. */
13
+ @interface AVSampleBufferDisplayLayer ()<SampleBufferRendering>
14
+ @end
15
+ @interface AVSampleBufferVideoRenderer ()<SampleBufferRendering>
16
+ @end
17
+
18
+ @interface SampleBufferVideoCallView ()
19
+
20
+ @property(nonatomic, retain) I420Converter *i420Converter;
21
+ @property(nonatomic, strong) id<SampleBufferRendering> renderer;
22
+ @property(nonatomic, assign) NSInteger currentRotation;
23
+
24
+ @end
25
+
26
+ @implementation SampleBufferVideoCallView
27
+
28
+ + (Class)layerClass {
29
+ return [AVSampleBufferDisplayLayer class];
30
+ }
31
+
32
+ - (instancetype)initWithFrame:(CGRect)frame {
33
+ if (self = [super initWithFrame:frame]) {
34
+ [[NSNotificationCenter defaultCenter] addObserver:self
35
+ selector:@selector(layerFailedToDecode:)
36
+ name:AVSampleBufferDisplayLayerFailedToDecodeNotification
37
+ object:self.sampleBufferLayer];
38
+ if (@available(iOS 17.0, *)) {
39
+ _renderer = self.sampleBufferLayer.sampleBufferRenderer;
40
+ } else {
41
+ _renderer = self.sampleBufferLayer;
42
+ }
43
+ }
44
+ return self;
45
+ }
46
+
47
+ - (void)layerFailedToDecode:(NSNotification *)note {
48
+ NSError *error = [[note userInfo] valueForKey:AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey];
49
+ NSLog(@"layerFailedToDecode, error: %@", [error localizedDescription]);
50
+ }
51
+
52
+ - (AVSampleBufferDisplayLayer *)sampleBufferLayer {
53
+ return (AVSampleBufferDisplayLayer *)self.layer;
54
+ }
55
+
56
+ - (void)requestScaleRecalculation {
57
+ _currentRotation = -1;
58
+ }
59
+
60
+ - (void)recalculateScale:(RTCVideoRotation)rotation {
61
+ if (self.currentRotation != rotation) {
62
+ self.currentRotation = rotation;
63
+
64
+ CGFloat scale = 1;
65
+ if (rotation == 90 || rotation == 270) {
66
+ CGSize size = self.bounds.size;
67
+ scale = size.height / size.width;
68
+ }
69
+
70
+ self.sampleBufferLayer.transform = CATransform3DConcat(
71
+ CATransform3DMakeRotation(rotation / 180.0 * M_PI, 0.0, 0.0, 1.0), CATransform3DMakeScale(scale, scale, 1));
72
+ }
73
+ }
74
+
75
+ /** The size of the video frame. */
76
+ - (void)setSize:(CGSize)size {
77
+ }
78
+
79
+ /** The frame to be displayed. */
80
+ - (void)renderFrame:(nullable RTC_OBJC_TYPE(RTCVideoFrame) *)frame {
81
+ if (!_shouldRender) {
82
+ return;
83
+ }
84
+
85
+ // Convert RTCVideoFrame to CMSampleBuffer
86
+ CMSampleBufferRef sampleBuffer = [self sampleBufferFrom:frame];
87
+ if (sampleBuffer == nil) {
88
+ return;
89
+ }
90
+
91
+ dispatch_async(dispatch_get_main_queue(), ^{
92
+ if (self.renderer.requiresFlushToResumeDecoding) {
93
+ [self.renderer flush];
94
+ }
95
+
96
+ if (!self.renderer.readyForMoreMediaData) {
97
+ return;
98
+ }
99
+
100
+ [self recalculateScale:frame.rotation];
101
+
102
+ // Display the CMSampleBuffer using AVSampleBufferDisplayLayer
103
+ [self.renderer enqueueSampleBuffer:sampleBuffer];
104
+ CFRelease(sampleBuffer);
105
+ });
106
+ }
107
+
108
+ - (CMSampleBufferRef)sampleBufferFrom:(RTCVideoFrame *)rtcVideoFrame {
109
+ // Convert RTCVideoFrame to CMSampleBuffer
110
+
111
+ // Assuming your RTCVideoFrame contains pixelBuffer
112
+ CVPixelBufferRef pixelBuffer = [self pixelBufferFrom:rtcVideoFrame];
113
+ if (!pixelBuffer) {
114
+ return nil;
115
+ }
116
+
117
+ // Create a CMVideoFormatDescription
118
+ CMVideoFormatDescriptionRef formatDescription;
119
+ CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, &formatDescription);
120
+
121
+ // Create CMSampleTimingInfo
122
+ // Timescale is 90khz according to RTCVideoFrame.h
123
+ CMSampleTimingInfo timingInfo;
124
+ timingInfo.presentationTimeStamp = CMTimeMake(rtcVideoFrame.timeStamp, 90000);
125
+ timingInfo.decodeTimeStamp = CMTimeMake(rtcVideoFrame.timeStamp, 90000);
126
+
127
+ // Create CMSampleBuffer
128
+ CMSampleBufferRef sampleBuffer;
129
+ CMSampleBufferCreateForImageBuffer(
130
+ kCFAllocatorDefault, pixelBuffer, true, nil, nil, formatDescription, &timingInfo, &sampleBuffer);
131
+
132
+ CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, YES);
133
+ CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);
134
+
135
+ CFDictionarySetValue(dict, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
136
+ CVPixelBufferRelease(pixelBuffer);
137
+ return sampleBuffer;
138
+ }
139
+
140
+ /**
141
+ * The CVPixelBufferRef returned from this function must be released when finished using it.
142
+ */
143
+ - (CVPixelBufferRef)pixelBufferFrom:(RTCVideoFrame *)videoFrame {
144
+ if ([videoFrame.buffer isKindOfClass:[RTCCVPixelBuffer class]]) {
145
+ CVPixelBufferRef pixelBuffer = [((RTCCVPixelBuffer *)videoFrame.buffer) pixelBuffer];
146
+ CVPixelBufferRetain(pixelBuffer);
147
+ return [((RTCCVPixelBuffer *)videoFrame.buffer) pixelBuffer];
148
+ } else {
149
+ return [self pixelBufferFromI420:[videoFrame.buffer toI420]];
150
+ }
151
+ }
152
+
153
+ /**
154
+ * The CVPixelBufferRef returned from this function must be released when finished using it.
155
+ */
156
+ - (CVPixelBufferRef)pixelBufferFromI420:(RTCI420Buffer *)i420Buffer {
157
+ if (_i420Converter == nil) {
158
+ I420Converter *converter = [[I420Converter alloc] init];
159
+ vImage_Error err = [converter prepareForAccelerateConversion];
160
+
161
+ if (err != kvImageNoError) {
162
+ NSLog(@"Error when preparing i420Converter: %ld", err);
163
+ return NULL;
164
+ }
165
+
166
+ _i420Converter = converter;
167
+ }
168
+
169
+ CVPixelBufferRef convertedPixelBuffer = [_i420Converter convertI420ToPixelBuffer:i420Buffer];
170
+
171
+ return convertedPixelBuffer;
172
+ }
173
+
174
+ - (void)dealloc {
175
+ [_i420Converter unprepareForAccelerateConversion];
176
+ }
177
+
178
+ @end
@@ -29,6 +29,7 @@ NSString *const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
29
29
  self = [super init];
30
30
  if (self) {
31
31
  self.capturer = capturer;
32
+ self.deviceId = @"screen-capture";
32
33
  }
33
34
 
34
35
  return self;
@@ -53,6 +54,9 @@ NSString *const kRTCAppGroupIdentifier = @"RTCAppGroupIdentifier";
53
54
  [self.capturer stopCapture];
54
55
  }
55
56
 
57
+ - (NSDictionary *)getSettings {
58
+ return @{@"deviceId" : self.deviceId, @"groupId" : @"", @"frameRate" : @(30)};
59
+ }
56
60
  // MARK: CapturerEventsDelegate Methods
57
61
 
58
62
  - (void)capturerDidEnd:(RTCVideoCapturer *)capturer {
@@ -6,13 +6,16 @@
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;
12
+ @property(nonatomic, assign) BOOL enableMultitaskingCameraAccess;
11
13
 
12
14
  - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer andConstraints:(NSDictionary *)constraints;
13
15
  - (void)startCapture;
14
16
  - (void)stopCapture;
15
17
  - (void)switchCamera;
18
+ - (void)applyConstraints:(NSDictionary *)constraints error:(NSError **)outError;
16
19
 
17
20
  @end
18
21
  #endif
@@ -9,7 +9,6 @@
9
9
  @property(nonatomic, strong) RTCCameraVideoCapturer *capturer;
10
10
  @property(nonatomic, strong) AVCaptureDeviceFormat *selectedFormat;
11
11
  @property(nonatomic, strong) AVCaptureDevice *device;
12
- @property(nonatomic, copy) NSString *deviceId;
13
12
  @property(nonatomic, assign) BOOL running;
14
13
  @property(nonatomic, assign) BOOL usingFrontCamera;
15
14
  @property(nonatomic, assign) int width;
@@ -25,31 +24,7 @@
25
24
  if (self) {
26
25
  self.capturer = capturer;
27
26
  self.running = NO;
28
-
29
- // Default to the front camera.
30
- self.usingFrontCamera = YES;
31
-
32
- self.deviceId = constraints[@"deviceId"];
33
- self.width = [constraints[@"width"] intValue];
34
- self.height = [constraints[@"height"] intValue];
35
- self.frameRate = [constraints[@"frameRate"] intValue];
36
-
37
- id facingMode = constraints[@"facingMode"];
38
-
39
- if (facingMode && [facingMode isKindOfClass:[NSString class]]) {
40
- AVCaptureDevicePosition position;
41
- if ([facingMode isEqualToString:@"environment"]) {
42
- position = AVCaptureDevicePositionBack;
43
- } else if ([facingMode isEqualToString:@"user"]) {
44
- position = AVCaptureDevicePositionFront;
45
- } else {
46
- // If the specified facingMode value is not supported, fall back
47
- // to the front camera.
48
- position = AVCaptureDevicePositionFront;
49
- }
50
-
51
- self.usingFrontCamera = position == AVCaptureDevicePositionFront;
52
- }
27
+ [self applyConstraints:constraints error:nil];
53
28
  }
54
29
 
55
30
  return self;
@@ -67,6 +42,7 @@
67
42
  AVCaptureDevicePosition position =
68
43
  self.usingFrontCamera ? AVCaptureDevicePositionFront : AVCaptureDevicePositionBack;
69
44
  self.device = [self findDeviceForPosition:position];
45
+ self.deviceId = self.device.uniqueID;
70
46
  }
71
47
 
72
48
  if (!self.device) {
@@ -86,6 +62,19 @@
86
62
 
87
63
  self.selectedFormat = format;
88
64
 
65
+ AVCaptureSession *session = self.capturer.captureSession;
66
+ if (@available(iOS 16.0, *)) {
67
+ BOOL enable = self.enableMultitaskingCameraAccess;
68
+ BOOL shouldChange = session.multitaskingCameraAccessEnabled != enable;
69
+ BOOL canChange = !enable || (enable && session.isMultitaskingCameraAccessSupported);
70
+
71
+ if (shouldChange && canChange) {
72
+ [session beginConfiguration];
73
+ [session setMultitaskingCameraAccessEnabled:enable];
74
+ [session commitConfiguration];
75
+ }
76
+ }
77
+
89
78
  RCTLog(@"[VideoCaptureController] Capture will start");
90
79
 
91
80
  // Starting the capture happens on another thread. Wait for it.
@@ -128,14 +117,90 @@
128
117
  dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
129
118
  }
130
119
 
131
- - (void)switchCamera {
132
- self.usingFrontCamera = !self.usingFrontCamera;
133
- self.deviceId = nil;
120
+ - (void)applyConstraints:(NSDictionary *)constraints error:(NSError **)outError {
121
+ // Clear device to prepare for starting camera with new constraints.
134
122
  self.device = nil;
135
123
 
136
- [self startCapture];
124
+ BOOL hasChanged = NO;
125
+
126
+ NSString *deviceId = constraints[@"deviceId"];
127
+ int width = [constraints[@"width"] intValue];
128
+ int height = [constraints[@"height"] intValue];
129
+ int frameRate = [constraints[@"frameRate"] intValue];
130
+
131
+ if (self.width != width) {
132
+ hasChanged = YES;
133
+ self.width = width;
134
+ }
135
+
136
+ if (self.height != height) {
137
+ hasChanged = YES;
138
+ self.height = height;
139
+ }
140
+
141
+ if (self.frameRate != frameRate) {
142
+ hasChanged = YES;
143
+ self.frameRate = frameRate;
144
+ }
145
+
146
+ id facingMode = constraints[@"facingMode"];
147
+
148
+ if (!facingMode && !deviceId) {
149
+ // Default to front camera.
150
+ facingMode = @"user";
151
+ }
152
+
153
+ if (facingMode && [facingMode isKindOfClass:[NSString class]]) {
154
+ AVCaptureDevicePosition position;
155
+ if ([facingMode isEqualToString:@"environment"]) {
156
+ position = AVCaptureDevicePositionBack;
157
+ } else if ([facingMode isEqualToString:@"user"]) {
158
+ position = AVCaptureDevicePositionFront;
159
+ } else {
160
+ // If the specified facingMode value is not supported, fall back
161
+ // to the front camera.
162
+ position = AVCaptureDevicePositionFront;
163
+ }
164
+
165
+ BOOL usingFrontCamera = position == AVCaptureDevicePositionFront;
166
+ if (self.usingFrontCamera != usingFrontCamera) {
167
+ hasChanged = YES;
168
+ self.usingFrontCamera = usingFrontCamera;
169
+ }
170
+ }
171
+
172
+ if (!deviceId) {
173
+ AVCaptureDevicePosition position =
174
+ self.usingFrontCamera ? AVCaptureDevicePositionFront : AVCaptureDevicePositionBack;
175
+ deviceId = [self findDeviceForPosition:position].uniqueID;
176
+ }
177
+
178
+ if (self.deviceId != deviceId && ![self.deviceId isEqualToString:deviceId]) {
179
+ hasChanged = YES;
180
+ self.deviceId = deviceId;
181
+ }
182
+
183
+ if (self.running && hasChanged) {
184
+ [self startCapture];
185
+ }
137
186
  }
138
187
 
188
+ - (NSDictionary *)getSettings {
189
+ AVCaptureDeviceFormat *format = self.selectedFormat;
190
+ CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
191
+ NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithDictionary:@{
192
+ @"groupId" : @"",
193
+ @"height" : @(dimensions.height),
194
+ @"width" : @(dimensions.width),
195
+ @"frameRate" : @(30),
196
+ @"facingMode" : self.usingFrontCamera ? @"user" : @"environment"
197
+ }];
198
+
199
+ if (self.deviceId) {
200
+ settings[@"deviceId"] = self.deviceId;
201
+ }
202
+ return settings;
203
+ }
139
204
  #pragma mark NSKeyValueObserving
140
205
 
141
206
  - (void)observeValueForKeyPath:(NSString *)keyPath
@@ -19,10 +19,8 @@ static NSString *const PERMISSION_PROMPT = @"prompt";
19
19
  }
20
20
  }
21
21
 
22
- RCT_EXPORT_METHOD(checkPermission
23
- : (NSString *)mediaType resolver
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
- : (NSString *)mediaType resolver
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;
@@ -0,0 +1,20 @@
1
+ #import <objc/runtime.h>
2
+
3
+ #import <React/RCTBridge.h>
4
+ #import <React/RCTBridgeModule.h>
5
+
6
+ #import "WebRTCModule.h"
7
+
8
+ @implementation WebRTCModule (RTCAudioSession)
9
+
10
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(audioSessionDidActivate) {
11
+ [[RTCAudioSession sharedInstance] audioSessionDidActivate:[AVAudioSession sharedInstance]];
12
+ return nil;
13
+ }
14
+
15
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(audioSessionDidDeactivate) {
16
+ [[RTCAudioSession sharedInstance] audioSessionDidDeactivate:[AVAudioSession sharedInstance]];
17
+ return nil;
18
+ }
19
+
20
+ @end
@@ -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
- : (nonnull NSNumber *)peerConnectionId label
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
- : (nonnull NSNumber *)peerConnectionId reactTag
64
- : (nonnull NSString *)tag {
65
- RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
66
- DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
67
- if (dcw) {
68
- [dcw.channel close];
69
- }
70
- })
71
-
72
- RCT_EXPORT_METHOD(dataChannelDispose
73
- : (nonnull NSNumber *)peerConnectionId reactTag
74
- : (nonnull NSString *)tag {
75
- RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
76
- DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
77
- if (dcw) {
78
- dcw.delegate = nil;
79
- [peerConnection.dataChannels removeObjectForKey:tag];
80
- }
81
- })
82
-
83
- RCT_EXPORT_METHOD(dataChannelSend
84
- : (nonnull NSNumber *)peerConnectionId reactTag
85
- : (nonnull NSString *)tag data
86
- : (NSString *)data type
87
- : (NSString *)type {
88
- RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
89
- DataChannelWrapper *dcw = peerConnection.dataChannels[tag];
90
- if (dcw) {
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