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
@@ -1,103 +1,102 @@
1
1
  #import "SerializeUtils.h"
2
2
 
3
- @implementation SerializeUtils
4
- + (NSDictionary *) transceiverToJSONWithPeerConnectionId: (NSNumber *) id
5
- transceiver:(RTCRtpTransceiver * _Nonnull) transceiver {
3
+ @implementation SerializeUtils
4
+ + (NSDictionary *)transceiverToJSONWithPeerConnectionId:(NSNumber *)id
5
+ transceiver:(RTCRtpTransceiver *_Nonnull)transceiver {
6
6
  NSMutableDictionary *result = [NSMutableDictionary new];
7
-
7
+
8
8
  result[@"id"] = transceiver.sender.senderId;
9
9
  result[@"peerConnectionId"] = id;
10
10
  result[@"mid"] = transceiver.mid;
11
- result[@"direction"] = [SerializeUtils serializeDirection: transceiver.direction];
12
-
11
+ result[@"direction"] = [SerializeUtils serializeDirection:transceiver.direction];
12
+
13
13
  RTCRtpTransceiverDirection currentDirection;
14
- if ([transceiver currentDirection: &currentDirection]) {
15
- result[@"currentDirection"] = [SerializeUtils serializeDirection: currentDirection];
14
+ if ([transceiver currentDirection:&currentDirection]) {
15
+ result[@"currentDirection"] = [SerializeUtils serializeDirection:currentDirection];
16
16
  }
17
-
17
+
18
18
  result[@"isStopped"] = [NSNumber numberWithBool:transceiver.isStopped];
19
- result[@"receiver"] = [SerializeUtils receiverToJSONWithPeerConnectionId: id receiver: transceiver.receiver];
20
- result[@"sender"] = [SerializeUtils senderToJSONWithPeerConnectionId: id sender: transceiver.sender];
21
-
19
+ result[@"receiver"] = [SerializeUtils receiverToJSONWithPeerConnectionId:id receiver:transceiver.receiver];
20
+ result[@"sender"] = [SerializeUtils senderToJSONWithPeerConnectionId:id sender:transceiver.sender];
21
+
22
22
  return result;
23
23
  }
24
24
 
25
- + (NSMutableArray *) constructTransceiversInfoArrayWithPeerConnection: (RTCPeerConnection *) peerConnection {
25
+ + (NSMutableArray *)constructTransceiversInfoArrayWithPeerConnection:(RTCPeerConnection *)peerConnection {
26
26
  NSMutableArray *transceiverUpdates = [NSMutableArray new];
27
-
27
+
28
28
  for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
29
29
  RTCRtpTransceiverDirection currentDirection;
30
- if ([transceiver currentDirection: &currentDirection]) {
31
- NSMutableDictionary *transceiverUpdate= [NSMutableDictionary new];
30
+ if ([transceiver currentDirection:&currentDirection]) {
31
+ NSMutableDictionary *transceiverUpdate = [NSMutableDictionary new];
32
32
  transceiverUpdate[@"transceiverId"] = transceiver.sender.senderId;
33
33
  transceiverUpdate[@"mid"] = transceiver.mid;
34
- NSString *currentDirectionSerialized = [SerializeUtils serializeDirection: currentDirection];
34
+ NSString *currentDirectionSerialized = [SerializeUtils serializeDirection:currentDirection];
35
35
  transceiverUpdate[@"currentDirection"] = currentDirectionSerialized;
36
+ transceiverUpdate[@"isStopped"] = [NSNumber numberWithBool:transceiver.isStopped];
36
37
  transceiverUpdate[@"senderRtpParameters"] = [SerializeUtils parametersToJSON:transceiver.sender.parameters];
37
- transceiverUpdate[@"receiverRtpParameters"] = [SerializeUtils parametersToJSON:transceiver.receiver.parameters];
38
+ transceiverUpdate[@"receiverRtpParameters"] =
39
+ [SerializeUtils parametersToJSON:transceiver.receiver.parameters];
38
40
 
39
41
  [transceiverUpdates addObject:transceiverUpdate];
40
42
  }
41
43
  }
42
-
44
+
43
45
  return transceiverUpdates;
44
46
  }
45
47
 
46
-
47
- + (NSDictionary *) senderToJSONWithPeerConnectionId: (NSNumber *) id
48
- sender: (RTCRtpSender *) sender {
49
- NSMutableDictionary *senderDictionary= [NSMutableDictionary new];
48
+ + (NSDictionary *)senderToJSONWithPeerConnectionId:(NSNumber *)id sender:(RTCRtpSender *)sender {
49
+ NSMutableDictionary *senderDictionary = [NSMutableDictionary new];
50
50
  senderDictionary[@"id"] = sender.senderId;
51
51
  senderDictionary[@"peerConnectionId"] = id;
52
52
 
53
53
  if (sender.track) {
54
- senderDictionary[@"track"] = [SerializeUtils trackToJSONWithPeerConnectionId: id track: sender.track];
54
+ senderDictionary[@"track"] = [SerializeUtils trackToJSONWithPeerConnectionId:id track:sender.track];
55
55
  }
56
56
 
57
- senderDictionary[@"rtpParameters"] = [SerializeUtils parametersToJSON: sender.parameters];
58
-
59
- return senderDictionary;
57
+ senderDictionary[@"rtpParameters"] = [SerializeUtils parametersToJSON:sender.parameters];
58
+
59
+ return senderDictionary;
60
60
  }
61
61
 
62
- + (NSDictionary *) receiverToJSONWithPeerConnectionId: (NSNumber *) id
63
- receiver: (RTCRtpReceiver *) receiver {
62
+ + (NSDictionary *)receiverToJSONWithPeerConnectionId:(NSNumber *)id receiver:(RTCRtpReceiver *)receiver {
64
63
  NSMutableDictionary *receiverDictionary = [NSMutableDictionary new];
65
64
  receiverDictionary[@"id"] = receiver.receiverId;
66
65
  receiverDictionary[@"peerConnectionId"] = id;
67
66
 
68
67
  if (receiver.track) {
69
- receiverDictionary[@"track"] = [SerializeUtils trackToJSONWithPeerConnectionId: id track: receiver.track];
68
+ receiverDictionary[@"track"] = [SerializeUtils trackToJSONWithPeerConnectionId:id track:receiver.track];
70
69
  }
71
70
 
72
- receiverDictionary[@"rtpParameters"] = [SerializeUtils parametersToJSON: receiver.parameters];
73
-
74
- return receiverDictionary;
71
+ receiverDictionary[@"rtpParameters"] = [SerializeUtils parametersToJSON:receiver.parameters];
72
+
73
+ return receiverDictionary;
75
74
  }
76
75
 
77
- + (NSDictionary *) parametersToJSON: (RTCRtpParameters *) params {
76
+ + (NSDictionary *)parametersToJSON:(RTCRtpParameters *)params {
78
77
  NSMutableDictionary *paramsDictionary = [NSMutableDictionary new];
79
-
78
+
80
79
  NSMutableDictionary *rtcpDictionary = [NSMutableDictionary new];
81
80
  rtcpDictionary[@"cname"] = params.rtcp.cname;
82
- rtcpDictionary[@"reducedSize"] = [NSNumber numberWithBool: params.rtcp.isReducedSize];
83
-
81
+ rtcpDictionary[@"reducedSize"] = [NSNumber numberWithBool:params.rtcp.isReducedSize];
82
+
84
83
  NSMutableArray *headerExtensions = [NSMutableArray new];
85
-
84
+
86
85
  for (RTCRtpHeaderExtension *extension in params.headerExtensions) {
87
86
  NSMutableDictionary *extensionDictionary = [NSMutableDictionary new];
88
- extensionDictionary[@"id"] = [NSNumber numberWithInt: extension.id];
87
+ extensionDictionary[@"id"] = [NSNumber numberWithInt:extension.id];
89
88
  extensionDictionary[@"uri"] = extension.uri;
90
- extensionDictionary[@"encrypted"] = [NSNumber numberWithBool: extension.isEncrypted];
91
-
92
- [headerExtensions addObject: extensionDictionary];
89
+ extensionDictionary[@"encrypted"] = [NSNumber numberWithBool:extension.isEncrypted];
90
+
91
+ [headerExtensions addObject:extensionDictionary];
93
92
  }
94
-
93
+
95
94
  NSMutableArray *encodings = [NSMutableArray new];
96
-
95
+
97
96
  for (RTCRtpEncodingParameters *encoding in params.encodings) {
98
97
  NSMutableDictionary *encodingDictionary = [NSMutableDictionary new];
99
98
 
100
- encodingDictionary[@"active"] = [NSNumber numberWithBool: encoding.isActive];
99
+ encodingDictionary[@"active"] = [NSNumber numberWithBool:encoding.isActive];
101
100
 
102
101
  if (encoding.rid) {
103
102
  encodingDictionary[@"rid"] = encoding.rid;
@@ -111,33 +110,34 @@
111
110
  if (encoding.scaleResolutionDownBy) {
112
111
  encodingDictionary[@"scaleResolutionDownBy"] = encoding.scaleResolutionDownBy;
113
112
  }
114
-
115
- [encodings addObject: encodingDictionary];
113
+
114
+ [encodings addObject:encodingDictionary];
116
115
  }
117
116
 
118
117
  NSMutableArray *codecs = [NSMutableArray new];
119
-
118
+
120
119
  for (RTCRtpCodecParameters *codec in params.codecs) {
121
120
  NSMutableDictionary *codecDictionary = [NSMutableDictionary new];
122
-
123
- codecDictionary[@"payloadType"] = [NSNumber numberWithInt: codec.payloadType];
121
+
122
+ codecDictionary[@"payloadType"] = [NSNumber numberWithInt:codec.payloadType];
124
123
  codecDictionary[@"mimeType"] = codec.name;
125
124
  codecDictionary[@"clockRate"] = codec.clockRate;
126
-
125
+
127
126
  if (codec.numChannels) {
128
127
  codecDictionary[@"channels"] = codec.numChannels;
129
128
  }
130
129
 
131
130
  if (codec.parameters.count) {
132
131
  NSMutableArray *parts = [NSMutableArray arrayWithCapacity:codec.parameters.count];
133
- [codec.parameters enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL * _Nonnull stop) {
134
- [parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
135
- }];
132
+ [codec.parameters
133
+ enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL *_Nonnull stop) {
134
+ [parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
135
+ }];
136
136
 
137
137
  codecDictionary[@"sdpFmtpLine"] = [parts componentsJoinedByString:@";"];
138
138
  }
139
139
 
140
- [codecs addObject: codecDictionary];
140
+ [codecs addObject:codecDictionary];
141
141
  }
142
142
 
143
143
  paramsDictionary[@"transactionId"] = params.transactionId;
@@ -145,16 +145,15 @@
145
145
  paramsDictionary[@"headerExtensions"] = headerExtensions;
146
146
  paramsDictionary[@"encodings"] = encodings;
147
147
  paramsDictionary[@"codecs"] = codecs;
148
-
148
+
149
149
  if (params.degradationPreference) {
150
150
  paramsDictionary[@"degradationPreference"] = params.degradationPreference;
151
151
  }
152
-
152
+
153
153
  return paramsDictionary;
154
154
  }
155
155
 
156
- + (NSDictionary *) trackToJSONWithPeerConnectionId: (NSNumber *) id
157
- track: (RTCMediaStreamTrack *) track {
156
+ + (NSDictionary *)trackToJSONWithPeerConnectionId:(NSNumber *)id track:(RTCMediaStreamTrack *)track {
158
157
  NSString *readyState;
159
158
  switch (track.readyState) {
160
159
  case RTCMediaStreamTrackStateLive:
@@ -164,18 +163,18 @@
164
163
  readyState = @"ended";
165
164
  break;
166
165
  }
167
-
166
+
168
167
  return @{
169
- @"id": track.trackId,
170
- @"peerConnectionId": id,
171
- @"kind": track.kind,
172
- @"enabled": [NSNumber numberWithBool:track.isEnabled],
173
- @"readyState": readyState,
174
- @"remote": [NSNumber numberWithBool:YES],
168
+ @"id" : track.trackId,
169
+ @"peerConnectionId" : id,
170
+ @"kind" : track.kind,
171
+ @"enabled" : [NSNumber numberWithBool:track.isEnabled],
172
+ @"readyState" : readyState,
173
+ @"remote" : [NSNumber numberWithBool:YES],
175
174
  };
176
175
  }
177
176
 
178
- + (NSString *) serializeDirection: (RTCRtpTransceiverDirection) direction {
177
+ + (NSString *)serializeDirection:(RTCRtpTransceiverDirection)direction {
179
178
  if (direction == RTCRtpTransceiverDirectionInactive) {
180
179
  return @"inactive";
181
180
  } else if (direction == RTCRtpTransceiverDirectionRecvOnly) {
@@ -190,89 +189,89 @@
190
189
  return nil;
191
190
  }
192
191
 
193
- + (RTCRtpTransceiverDirection) parseDirection: (NSString *) direction {
194
- if ([direction isEqual: @"inactive"]) {
192
+ + (RTCRtpTransceiverDirection)parseDirection:(NSString *)direction {
193
+ if ([direction isEqual:@"inactive"]) {
195
194
  return RTCRtpTransceiverDirectionInactive;
196
- } else if ([direction isEqual: @"recvonly"]) {
195
+ } else if ([direction isEqual:@"recvonly"]) {
197
196
  return RTCRtpTransceiverDirectionRecvOnly;
198
- } else if ([direction isEqual: @"sendonly"]) {
197
+ } else if ([direction isEqual:@"sendonly"]) {
199
198
  return RTCRtpTransceiverDirectionSendOnly;
200
- } else if ([direction isEqual: @"sendrecv"]) {
199
+ } else if ([direction isEqual:@"sendrecv"]) {
201
200
  return RTCRtpTransceiverDirectionSendRecv;
202
- } else if ([direction isEqual: @"stopped"]) {
201
+ } else if ([direction isEqual:@"stopped"]) {
203
202
  return RTCRtpTransceiverDirectionStopped;
204
203
  }
205
-
204
+
206
205
  return RTCRtpTransceiverDirectionInactive;
207
206
  }
208
207
 
209
- + (RTCRtpEncodingParameters *) parseEncoding: (NSDictionary *) params {
208
+ + (RTCRtpEncodingParameters *)parseEncoding:(NSDictionary *)params {
210
209
  RTCRtpEncodingParameters *encoding = [RTCRtpEncodingParameters new];
211
210
 
212
211
  if (params[@"rid"] != nil) {
213
- [encoding setRid: params[@"rid"]];
212
+ [encoding setRid:params[@"rid"]];
214
213
  }
215
214
  if (params[@"active"] != nil) {
216
- [encoding setIsActive: ((NSNumber *) params[@"active"]).boolValue];
215
+ [encoding setIsActive:((NSNumber *)params[@"active"]).boolValue];
217
216
  }
218
217
  if (params[@"maxBitrate"] != nil) {
219
- [encoding setMaxBitrateBps: (NSNumber *) params[@"maxBitrate"]];
218
+ [encoding setMaxBitrateBps:(NSNumber *)params[@"maxBitrate"]];
220
219
  }
221
220
  if (params[@"maxFramerate"] != nil) {
222
- [encoding setMaxFramerate: (NSNumber *) params[@"maxFramerate"]];
221
+ [encoding setMaxFramerate:(NSNumber *)params[@"maxFramerate"]];
223
222
  }
224
223
  if (params[@"scaleResolutionDownBy"] != nil) {
225
- [encoding setScaleResolutionDownBy: (NSNumber *) params[@"scaleResolutionDownBy"]];
224
+ [encoding setScaleResolutionDownBy:(NSNumber *)params[@"scaleResolutionDownBy"]];
226
225
  }
227
226
 
228
227
  return encoding;
229
228
  }
230
229
 
231
- + (RTCRtpTransceiverInit *) parseTransceiverOptions: (NSDictionary *) params {
230
+ + (RTCRtpTransceiverInit *)parseTransceiverOptions:(NSDictionary *)params {
232
231
  RTCRtpTransceiverInit *transceiverInit = [RTCRtpTransceiverInit new];
233
-
234
- NSString *direction = [params objectForKey: @"direction"];
232
+
233
+ NSString *direction = [params objectForKey:@"direction"];
235
234
  if (direction) {
236
- [transceiverInit setDirection: [SerializeUtils parseDirection: direction]];
235
+ [transceiverInit setDirection:[SerializeUtils parseDirection:direction]];
237
236
  }
238
-
239
- NSArray *streamIds = [params objectForKey: @"streamIds"];
237
+
238
+ NSArray *streamIds = [params objectForKey:@"streamIds"];
240
239
  if (streamIds) {
241
- [transceiverInit setStreamIds: streamIds];
240
+ [transceiverInit setStreamIds:streamIds];
242
241
  }
243
242
 
244
- NSArray *encodingsArray = [params objectForKey: @"sendEncodings"];
243
+ NSArray *encodingsArray = [params objectForKey:@"sendEncodings"];
245
244
  if (encodingsArray) {
246
245
  NSMutableArray<RTCRtpEncodingParameters *> *sendEncodings = [NSMutableArray new];
247
- for (NSDictionary* encoding in encodingsArray) {
248
- [sendEncodings addObject: [self parseEncoding: encoding]];
246
+ for (NSDictionary *encoding in encodingsArray) {
247
+ [sendEncodings addObject:[self parseEncoding:encoding]];
249
248
  }
250
- [transceiverInit setSendEncodings: sendEncodings];
249
+ [transceiverInit setSendEncodings:sendEncodings];
251
250
  }
252
251
 
253
252
  return transceiverInit;
254
253
  }
255
254
 
256
- + (NSDictionary *)streamToJSONWithPeerConnectionId: (NSNumber *) id
257
- stream: (RTCMediaStream *) stream
258
- streamReactTag: (NSString *) streamReactTag {
255
+ + (NSDictionary *)streamToJSONWithPeerConnectionId:(NSNumber *)id
256
+ stream:(RTCMediaStream *)stream
257
+ streamReactTag:(NSString *)streamReactTag {
259
258
  NSMutableDictionary *streamDictionary = [NSMutableDictionary new];
260
-
259
+
261
260
  streamDictionary[@"streamId"] = stream.streamId;
262
261
  streamDictionary[@"streamReactTag"] = streamReactTag;
263
262
 
264
263
  NSMutableArray *tracks = [NSMutableArray new];
265
-
264
+
266
265
  for (RTCAudioTrack *audioTrack in stream.audioTracks) {
267
266
  [tracks addObject:[SerializeUtils trackToJSONWithPeerConnectionId:id track:audioTrack]];
268
267
  }
269
-
268
+
270
269
  for (RTCVideoTrack *videoTrack in stream.videoTracks) {
271
270
  [tracks addObject:[SerializeUtils trackToJSONWithPeerConnectionId:id track:videoTrack]];
272
271
  }
273
-
272
+
274
273
  streamDictionary[@"tracks"] = tracks;
275
-
274
+
276
275
  return streamDictionary;
277
276
  }
278
277
  @end
@@ -1,10 +1,3 @@
1
- //
2
- // SocketConnection.h
3
- // RCTWebRTC
4
- //
5
- // Created by Alex-Dan Bumbu on 08/01/2021.
6
- //
7
-
8
1
  #import <Foundation/Foundation.h>
9
2
 
10
3
  NS_ASSUME_NONNULL_BEGIN
@@ -12,7 +5,7 @@ NS_ASSUME_NONNULL_BEGIN
12
5
  @interface SocketConnection : NSObject
13
6
 
14
7
  - (instancetype)initWithFilePath:(nonnull NSString *)filePath;
15
- - (void)openWithStreamDelegate:(id <NSStreamDelegate>)streamDelegate;
8
+ - (void)openWithStreamDelegate:(id<NSStreamDelegate>)streamDelegate;
16
9
  - (void)close;
17
10
 
18
11
  @end
@@ -1,10 +1,3 @@
1
- //
2
- // SocketConnection.m
3
- // RCTWebRTC
4
- //
5
- // Created by Alex-Dan Bumbu on 08/01/2021.
6
- //
7
-
8
1
  #include <sys/socket.h>
9
2
  #include <sys/un.h>
10
3
 
@@ -12,13 +5,13 @@
12
5
 
13
6
  @interface SocketConnection ()
14
7
 
15
- @property (nonatomic, assign) int serverSocket;
16
- @property (nonatomic, strong) dispatch_source_t listeningSource;
8
+ @property(nonatomic, assign) int serverSocket;
9
+ @property(nonatomic, strong) dispatch_source_t listeningSource;
17
10
 
18
- @property (nonatomic, strong) NSThread *networkThread;
11
+ @property(nonatomic, strong) NSThread *networkThread;
19
12
 
20
- @property (nonatomic, strong) NSInputStream *inputStream;
21
- @property (nonatomic, strong) NSOutputStream *outputStream;
13
+ @property(nonatomic, strong) NSInputStream *inputStream;
14
+ @property(nonatomic, strong) NSOutputStream *outputStream;
22
15
 
23
16
  @end
24
17
 
@@ -26,72 +19,72 @@
26
19
 
27
20
  - (instancetype)initWithFilePath:(nonnull NSString *)filePath {
28
21
  self = [super init];
29
-
22
+
30
23
  [self setupNetworkThread];
31
-
24
+
32
25
  self.serverSocket = socket(AF_UNIX, SOCK_STREAM, 0);
33
26
  if (self.serverSocket < 0) {
34
- NSLog(@"failure creating socket");
35
- return nil;
27
+ NSLog(@"failure creating socket");
28
+ return nil;
36
29
  }
37
-
38
- if (![self setupSocketWithFileAtPath: filePath]) {
30
+
31
+ if (![self setupSocketWithFileAtPath:filePath]) {
39
32
  close(self.serverSocket);
40
33
  return nil;
41
34
  }
42
-
35
+
43
36
  return self;
44
37
  }
45
38
 
46
- - (void)openWithStreamDelegate:(id <NSStreamDelegate>)streamDelegate {
39
+ - (void)openWithStreamDelegate:(id<NSStreamDelegate>)streamDelegate {
47
40
  int status = listen(self.serverSocket, 10);
48
41
  if (status < 0) {
49
42
  NSLog(@"failure: socket listening");
50
43
  return;
51
44
  }
52
-
45
+
53
46
  dispatch_source_t listeningSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, self.serverSocket, 0, NULL);
54
- dispatch_source_set_event_handler(listeningSource, ^ {
47
+ dispatch_source_set_event_handler(listeningSource, ^{
55
48
  int clientSocket = accept(self.serverSocket, NULL, NULL);
56
49
  if (clientSocket < 0) {
57
50
  NSLog(@"failure accepting connection");
58
51
  return;
59
52
  }
60
-
53
+
61
54
  CFReadStreamRef readStream;
62
55
  CFWriteStreamRef writeStream;
63
-
56
+
64
57
  CFStreamCreatePairWithSocket(kCFAllocatorDefault, clientSocket, &readStream, &writeStream);
65
58
 
66
59
  self.inputStream = (__bridge_transfer NSInputStream *)readStream;
67
60
  self.inputStream.delegate = streamDelegate;
68
61
  [self.inputStream setProperty:@"kCFBooleanTrue" forKey:@"kCFStreamPropertyShouldCloseNativeSocket"];
69
-
62
+
70
63
  self.outputStream = (__bridge_transfer NSOutputStream *)writeStream;
71
64
  [self.outputStream setProperty:@"kCFBooleanTrue" forKey:@"kCFStreamPropertyShouldCloseNativeSocket"];
72
-
65
+
73
66
  [self.networkThread start];
74
67
  [self performSelector:@selector(scheduleStreams) onThread:self.networkThread withObject:nil waitUntilDone:true];
75
-
68
+
76
69
  [self.inputStream open];
77
70
  [self.outputStream open];
78
71
  });
79
-
72
+
80
73
  self.listeningSource = listeningSource;
81
74
  dispatch_resume(listeningSource);
82
75
  }
83
76
 
84
- - (void)close {
77
+ - (void)close {
85
78
  [self performSelector:@selector(unscheduleStreams) onThread:self.networkThread withObject:nil waitUntilDone:true];
86
-
79
+
87
80
  self.inputStream.delegate = nil;
88
81
  self.outputStream.delegate = nil;
89
-
82
+
90
83
  [self.inputStream close];
91
84
  [self.outputStream close];
92
-
85
+
93
86
  [self.networkThread cancel];
94
-
87
+
95
88
  dispatch_source_cancel(self.listeningSource);
96
89
  close(self.serverSocket);
97
90
  }
@@ -115,20 +108,20 @@
115
108
  addr.sun_family = AF_UNIX;
116
109
 
117
110
  if (filePath.length > sizeof(addr.sun_path)) {
118
- NSLog(@"failure: path too long");
119
- return false;
111
+ NSLog(@"failure: path too long");
112
+ return false;
120
113
  }
121
114
 
122
115
  unlink(filePath.UTF8String);
123
116
  strncpy(addr.sun_path, filePath.UTF8String, sizeof(addr.sun_path) - 1);
124
-
117
+
125
118
  int status = bind(self.serverSocket, (struct sockaddr *)&addr, sizeof(addr));
126
119
  if (status < 0) {
127
120
  NSLog(@"failure: socket binding");
128
121
  return false;
129
122
  }
130
-
131
- return true;
123
+
124
+ return true;
132
125
  }
133
126
 
134
127
  - (void)scheduleStreams {
@@ -1,14 +1,14 @@
1
- #import "CapturerEventsDelegate.h"
2
1
  #import "CaptureController.h"
2
+ #import "CapturerEventsDelegate.h"
3
+ #import "WebRTCModule.h"
3
4
 
4
5
  NS_ASSUME_NONNULL_BEGIN
5
6
 
6
7
  @interface TrackCapturerEventsEmitter : NSObject<CapturerEventsDelegate>
7
8
 
8
- - (instancetype)initWith:(NSString *)trackId
9
- webRTCModule:(WebRTCModule *)module;
9
+ - (instancetype)initWith:(NSString *)trackId webRTCModule:(WebRTCModule *)module;
10
10
 
11
- - (void)capturerDidEnd:(RTCVideoCapturer *) capturer;
11
+ - (void)capturerDidEnd:(RTCVideoCapturer *)capturer;
12
12
  @end
13
13
 
14
14
  NS_ASSUME_NONNULL_END
@@ -1,20 +1,19 @@
1
- #import "WebRTCModule.h"
2
1
  #import "TrackCapturerEventsEmitter.h"
3
2
  #import "CapturerEventsDelegate.h"
3
+ #import "WebRTCModule.h"
4
4
 
5
5
  NS_ASSUME_NONNULL_BEGIN
6
6
 
7
7
  @interface TrackCapturerEventsEmitter ()
8
8
 
9
- @property (copy, nonatomic) NSString *trackId;
10
- @property (weak, nonatomic) WebRTCModule *module;
9
+ @property(copy, nonatomic) NSString *trackId;
10
+ @property(weak, nonatomic) WebRTCModule *module;
11
11
 
12
12
  @end
13
13
 
14
14
  @implementation TrackCapturerEventsEmitter
15
15
 
16
- - (instancetype)initWith:(NSString *)trackId
17
- webRTCModule:(WebRTCModule *)module {
16
+ - (instancetype)initWith:(NSString *)trackId webRTCModule:(WebRTCModule *)module {
18
17
  self = [super init];
19
18
  if (self) {
20
19
  self.trackId = trackId;
@@ -27,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
27
26
  - (void)capturerDidEnd:(RTCVideoCapturer *)capturer {
28
27
  [self.module sendEventWithName:kEventMediaStreamTrackEnded
29
28
  body:@{
30
- @"trackId": self.trackId,
29
+ @"trackId" : self.trackId,
31
30
  }];
32
31
 
33
32
  RCTLog(@"[TrackCapturerEventsEmitter] ended event for track %@", self.trackId);
@@ -6,13 +6,12 @@
6
6
 
7
7
  @interface VideoCaptureController : CaptureController
8
8
 
9
- @property (nonatomic, readonly, strong) AVCaptureDeviceFormat *selectedFormat;
10
- @property (nonatomic, readonly, assign) int frameRate;
9
+ @property(nonatomic, readonly, strong) AVCaptureDeviceFormat *selectedFormat;
10
+ @property(nonatomic, readonly, assign) int frameRate;
11
11
 
12
- -(instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer
13
- andConstraints:(NSDictionary *)constraints;
14
- -(void)startCapture;
15
- -(void)stopCapture;
16
- -(void)switchCamera;
12
+ - (instancetype)initWithCapturer:(RTCCameraVideoCapturer *)capturer andConstraints:(NSDictionary *)constraints;
13
+ - (void)startCapture;
14
+ - (void)stopCapture;
15
+ - (void)switchCamera;
17
16
 
18
17
  @end