react-native-webrtc 106.0.0-beta.1 → 106.0.0-beta.3

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 (147) hide show
  1. package/.eslintignore +6 -0
  2. package/.github/stale.yml +15 -0
  3. package/.github/workflows/ci.yml +17 -0
  4. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +36 -0
  5. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +27 -1
  6. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +37 -0
  7. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +57 -0
  8. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessor.java +19 -0
  9. package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +13 -0
  10. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +19 -3
  11. package/ios/RCTWebRTC.xcodeproj/project.pbxproj +46 -9
  12. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  13. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  14. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  15. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  16. package/ios/RCTWebRTC.xcworkspace/contents.xcworkspacedata +10 -0
  17. package/lib/commonjs/EventEmitter.js.map +1 -1
  18. package/lib/commonjs/Logger.js.map +1 -1
  19. package/lib/commonjs/MediaDevices.js +2 -2
  20. package/lib/commonjs/MediaDevices.js.map +1 -1
  21. package/lib/commonjs/MediaStream.js +3 -3
  22. package/lib/commonjs/MediaStream.js.map +1 -1
  23. package/lib/commonjs/MediaStreamTrack.js +15 -3
  24. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  25. package/lib/commonjs/Permissions.js +3 -3
  26. package/lib/commonjs/Permissions.js.map +1 -1
  27. package/lib/commonjs/RTCDataChannel.js +6 -5
  28. package/lib/commonjs/RTCDataChannel.js.map +1 -1
  29. package/lib/commonjs/RTCErrorEvent.js +1 -1
  30. package/lib/commonjs/RTCErrorEvent.js.map +1 -1
  31. package/lib/commonjs/RTCPeerConnection.js +166 -61
  32. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  33. package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
  34. package/lib/commonjs/RTCRtpCapabilities.js +10 -2
  35. package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
  36. package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
  37. package/lib/commonjs/RTCRtpEncodingParameters.js +9 -9
  38. package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
  39. package/lib/commonjs/RTCRtpParameters.js.map +1 -1
  40. package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
  41. package/lib/commonjs/RTCRtpReceiver.js +5 -8
  42. package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
  43. package/lib/commonjs/RTCRtpSendParameters.js +1 -1
  44. package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
  45. package/lib/commonjs/RTCRtpSender.js +2 -2
  46. package/lib/commonjs/RTCRtpSender.js.map +1 -1
  47. package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
  48. package/lib/commonjs/RTCSessionDescription.js.map +1 -1
  49. package/lib/commonjs/RTCUtil.js +13 -0
  50. package/lib/commonjs/RTCUtil.js.map +1 -1
  51. package/lib/commonjs/getDisplayMedia.js.map +1 -1
  52. package/lib/commonjs/getUserMedia.js +3 -3
  53. package/lib/commonjs/getUserMedia.js.map +1 -1
  54. package/lib/commonjs/index.js +22 -22
  55. package/lib/commonjs/index.js.map +1 -1
  56. package/lib/module/EventEmitter.js.map +1 -1
  57. package/lib/module/Logger.js.map +1 -1
  58. package/lib/module/MediaDevices.js +1 -1
  59. package/lib/module/MediaDevices.js.map +1 -1
  60. package/lib/module/MediaStream.js +2 -2
  61. package/lib/module/MediaStream.js.map +1 -1
  62. package/lib/module/MediaStreamTrack.js +14 -2
  63. package/lib/module/MediaStreamTrack.js.map +1 -1
  64. package/lib/module/Permissions.js +3 -3
  65. package/lib/module/Permissions.js.map +1 -1
  66. package/lib/module/RTCDataChannel.js +4 -3
  67. package/lib/module/RTCDataChannel.js.map +1 -1
  68. package/lib/module/RTCErrorEvent.js +2 -2
  69. package/lib/module/RTCErrorEvent.js.map +1 -1
  70. package/lib/module/RTCPeerConnection.js +163 -59
  71. package/lib/module/RTCPeerConnection.js.map +1 -1
  72. package/lib/module/RTCRtcpParameters.js.map +1 -1
  73. package/lib/module/RTCRtpCapabilities.js +10 -2
  74. package/lib/module/RTCRtpCapabilities.js.map +1 -1
  75. package/lib/module/RTCRtpCodecParameters.js.map +1 -1
  76. package/lib/module/RTCRtpEncodingParameters.js +9 -9
  77. package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
  78. package/lib/module/RTCRtpParameters.js.map +1 -1
  79. package/lib/module/RTCRtpReceiveParameters.js +1 -1
  80. package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
  81. package/lib/module/RTCRtpReceiver.js +5 -6
  82. package/lib/module/RTCRtpReceiver.js.map +1 -1
  83. package/lib/module/RTCRtpSendParameters.js +2 -2
  84. package/lib/module/RTCRtpSendParameters.js.map +1 -1
  85. package/lib/module/RTCRtpSender.js +2 -2
  86. package/lib/module/RTCRtpSender.js.map +1 -1
  87. package/lib/module/RTCRtpTransceiver.js.map +1 -1
  88. package/lib/module/RTCSessionDescription.js.map +1 -1
  89. package/lib/module/RTCUtil.js +11 -0
  90. package/lib/module/RTCUtil.js.map +1 -1
  91. package/lib/module/getDisplayMedia.js.map +1 -1
  92. package/lib/module/getUserMedia.js +1 -1
  93. package/lib/module/getUserMedia.js.map +1 -1
  94. package/lib/module/index.js +14 -14
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/typescript/EventEmitter.d.ts +4 -3
  97. package/lib/typescript/MediaStreamTrack.d.ts +1 -0
  98. package/lib/typescript/Permissions.d.ts +1 -1
  99. package/lib/typescript/RTCDataChannel.d.ts +2 -1
  100. package/lib/typescript/RTCErrorEvent.d.ts +1 -1
  101. package/lib/typescript/RTCPeerConnection.d.ts +6 -7
  102. package/lib/typescript/RTCRtpCodecParameters.d.ts +2 -2
  103. package/lib/typescript/RTCRtpEncodingParameters.d.ts +2 -2
  104. package/lib/typescript/RTCRtpParameters.d.ts +3 -3
  105. package/lib/typescript/RTCRtpReceiveParameters.d.ts +1 -1
  106. package/lib/typescript/RTCRtpReceiver.d.ts +1 -1
  107. package/lib/typescript/RTCRtpSendParameters.d.ts +2 -2
  108. package/lib/typescript/RTCRtpSender.d.ts +1 -1
  109. package/lib/typescript/RTCRtpTransceiver.d.ts +1 -1
  110. package/lib/typescript/RTCSessionDescription.d.ts +6 -8
  111. package/lib/typescript/RTCUtil.d.ts +7 -0
  112. package/lib/typescript/index.d.ts +12 -12
  113. package/package.json +7 -4
  114. package/react-native-webrtc.podspec +1 -2
  115. package/src/.eslintrc.cjs +67 -0
  116. package/src/EventEmitter.ts +5 -4
  117. package/src/Logger.ts +1 -1
  118. package/src/MediaDevices.ts +2 -2
  119. package/src/MediaStream.ts +13 -4
  120. package/src/MediaStreamTrack.ts +21 -5
  121. package/src/Permissions.ts +12 -5
  122. package/src/RTCDataChannel.ts +17 -5
  123. package/src/RTCErrorEvent.ts +9 -9
  124. package/src/RTCPeerConnection.ts +213 -92
  125. package/src/RTCRtcpParameters.ts +7 -7
  126. package/src/RTCRtpCapabilities.ts +15 -4
  127. package/src/RTCRtpCodecParameters.ts +2 -2
  128. package/src/RTCRtpEncodingParameters.ts +19 -17
  129. package/src/RTCRtpParameters.ts +3 -3
  130. package/src/RTCRtpReceiveParameters.ts +1 -2
  131. package/src/RTCRtpReceiver.ts +7 -7
  132. package/src/RTCRtpSendParameters.ts +10 -8
  133. package/src/RTCRtpSender.ts +11 -9
  134. package/src/RTCRtpTransceiver.ts +11 -7
  135. package/src/RTCSessionDescription.ts +7 -2
  136. package/src/RTCUtil.ts +24 -4
  137. package/src/getDisplayMedia.ts +1 -1
  138. package/src/getUserMedia.ts +9 -2
  139. package/src/index.ts +16 -14
  140. package/tools/downloadWebRTC.js +7 -5
  141. package/.prettierignore +0 -9
  142. package/.prettierrc.json +0 -10
  143. package/lib/commonjs/typings.d.js +0 -2
  144. package/lib/commonjs/typings.d.js.map +0 -1
  145. package/lib/module/typings.d.js +0 -2
  146. package/lib/module/typings.d.js.map +0 -1
  147. package/src/typings.d.ts +0 -1
package/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ examples
2
+ lib
3
+ tools
4
+
5
+ metro.*.js
6
+ react-native.config.js
@@ -0,0 +1,15 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - confirmed
8
+ staleLabel: wontfix
9
+ # Comment to post when marking an issue as stale. Set to `false` to disable
10
+ markComment: >
11
+ This issue has been automatically marked as stale because it has not had
12
+ recent activity. It will be closed if no further activity occurs. Thank you
13
+ for your contributions.
14
+ # Comment to post when closing a stale issue. Set to `false` to disable
15
+ closeComment: false
@@ -0,0 +1,17 @@
1
+ name: Simple CI
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ run-ci:
7
+ name: Lint
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - uses: actions/setup-node@v3
12
+ with:
13
+ node-version: 16
14
+ - run: npm install
15
+ - name: Check if the git repository is clean
16
+ run: $(exit $(git status --porcelain --untracked-files=no | head -255 | wc -l)) || (echo "Dirty git tree"; git diff; exit 1)
17
+ - run: npm run lint
@@ -18,6 +18,10 @@ import com.facebook.react.bridge.UiThreadUtil;
18
18
  import com.facebook.react.bridge.WritableArray;
19
19
  import com.facebook.react.bridge.WritableMap;
20
20
 
21
+ import com.oney.WebRTCModule.videoEffects.ProcessorProvider;
22
+ import com.oney.WebRTCModule.videoEffects.VideoEffectProcessor;
23
+ import com.oney.WebRTCModule.videoEffects.VideoFrameProcessor;
24
+
21
25
  import java.util.ArrayList;
22
26
  import java.util.HashMap;
23
27
  import java.util.Map;
@@ -390,6 +394,38 @@ class GetUserMediaImpl {
390
394
  return track;
391
395
  }
392
396
 
397
+ /**
398
+ * Set video effect to the TrackPrivate corresponding to the trackId with the help of VideoEffectProcessor
399
+ * corresponding to the name.
400
+ * @param trackId TrackPrivate id
401
+ * @param name VideoEffectProcessor name
402
+ */
403
+ void setVideoEffect(String trackId, String name) {
404
+ TrackPrivate track = tracks.get(trackId);
405
+
406
+ if (track != null && track.videoCaptureController instanceof CameraCaptureController) {
407
+ VideoSource videoSource = (VideoSource) track.mediaSource;
408
+ SurfaceTextureHelper surfaceTextureHelper = track.surfaceTextureHelper;
409
+
410
+ if (name != null) {
411
+ VideoFrameProcessor videoFrameProcessor = ProcessorProvider.getProcessor(name);
412
+
413
+ if (videoFrameProcessor == null) {
414
+ Log.e(TAG, "no videoFrameProcessor associated with this name");
415
+ return;
416
+ }
417
+
418
+ VideoEffectProcessor videoEffectProcessor = new VideoEffectProcessor(videoFrameProcessor,
419
+ surfaceTextureHelper);
420
+ videoSource.setVideoProcessor(videoEffectProcessor);
421
+
422
+ } else {
423
+ videoSource.setVideoProcessor(null);
424
+ }
425
+
426
+ }
427
+ }
428
+
393
429
  /**
394
430
  * Application/library-specific private members of local
395
431
  * {@code MediaStreamTrack}s created by {@code GetUserMediaImpl}.
@@ -894,6 +894,13 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
894
894
  return transceiverUpdates;
895
895
  }
896
896
 
897
+ @ReactMethod
898
+ public void mediaStreamTrackSetVideoEffect(String id, String name) {
899
+ ThreadUtils.runOnExecutor(() -> {
900
+ getUserMediaImpl.setVideoEffect(id, name);
901
+ });
902
+ }
903
+
897
904
  @ReactMethod
898
905
  public void peerConnectionSetConfiguration(ReadableMap configuration,
899
906
  int id) {
@@ -1042,7 +1049,9 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
1042
1049
  int id,
1043
1050
  Callback callback) {
1044
1051
  ThreadUtils.runOnExecutor(() -> {
1045
- PeerConnection peerConnection = getPeerConnection(id);
1052
+ PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
1053
+ PeerConnection peerConnection = pco.getPeerConnection();
1054
+
1046
1055
  if (peerConnection == null) {
1047
1056
  Log.d(TAG, "peerConnectionSetRemoteDescription() peerConnection is null");
1048
1057
  callback.invoke(false, "peerConnection is null");
@@ -1054,6 +1063,10 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
1054
1063
  sdpMap.getString("sdp")
1055
1064
  );
1056
1065
 
1066
+ List<String> receiversIds = new ArrayList<>();
1067
+ for(RtpTransceiver transceiver: peerConnection.getTransceivers()) {
1068
+ receiversIds.add(transceiver.getReceiver().id());
1069
+ }
1057
1070
  peerConnection.setRemoteDescription(new SdpObserver() {
1058
1071
  @Override
1059
1072
  public void onCreateSuccess(final SessionDescription sdp) {
@@ -1068,6 +1081,19 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
1068
1081
  newSdpMap.putString("sdp", newSdp.description);
1069
1082
  params.putArray("transceiversInfo", getTransceiversInfo(id));
1070
1083
  params.putMap("sdpInfo", newSdpMap);
1084
+
1085
+ WritableArray newTransceivers = Arguments.createArray();
1086
+ for(RtpTransceiver transceiver: peerConnection.getTransceivers()) {
1087
+ if(!receiversIds.contains(transceiver.getReceiver().id())) {
1088
+ WritableMap newTransceiver = Arguments.createMap();
1089
+ newTransceiver.putInt("transceiverOrder", pco.getNextTransceiverId());
1090
+ newTransceiver.putMap("transceiver", SerializeUtils.serializeTransceiver(id, transceiver));
1091
+ newTransceivers.pushMap(newTransceiver);
1092
+ }
1093
+ }
1094
+
1095
+ params.putArray("newTransceivers", newTransceivers);
1096
+
1071
1097
  callback.invoke(true, params);
1072
1098
  }
1073
1099
 
@@ -0,0 +1,37 @@
1
+ package com.oney.WebRTCModule.videoEffects;
2
+
3
+ import java.util.HashMap;
4
+ import java.util.Map;
5
+
6
+ /**
7
+ * Manages VideoFrameProcessorFactoryInterfaces corresponding to name using hashmap, and provides
8
+ * get, add and remove functionality.
9
+ */
10
+ public class ProcessorProvider {
11
+ private static Map<String, VideoFrameProcessorFactoryInterface> methodMap = new HashMap<String, VideoFrameProcessorFactoryInterface>();
12
+
13
+ public static VideoFrameProcessor getProcessor(String name) {
14
+ if (methodMap.containsKey(name)) {
15
+ return methodMap.get(name).build();
16
+ } else{
17
+ return null;
18
+ }
19
+ }
20
+
21
+ public static void addProcessor(String name,
22
+ VideoFrameProcessorFactoryInterface videoFrameProcessorFactoryInterface) {
23
+ if (name != null && videoFrameProcessorFactoryInterface != null) {
24
+ methodMap.put(name, videoFrameProcessorFactoryInterface);
25
+ } else{
26
+ throw new NullPointerException("Name or VideoFrameProcessorFactry can not be null");
27
+ }
28
+ }
29
+
30
+ public static void removeProcessor(String name) {
31
+ if (name != null && methodMap.containsKey(name)) {
32
+ methodMap.remove(name);
33
+ } else{
34
+ throw new RuntimeException("VideoFrameProcessorFactry with " + name + " does not exist");
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,57 @@
1
+ package com.oney.WebRTCModule.videoEffects;
2
+
3
+ import org.webrtc.SurfaceTextureHelper;
4
+ import org.webrtc.VideoFrame;
5
+ import org.webrtc.VideoProcessor;
6
+ import org.webrtc.VideoSink;
7
+
8
+ /**
9
+ * Lightweight abstraction for an object that can receive video frames, process and add effects in
10
+ * them, and pass them on to another object.
11
+ */
12
+ public class VideoEffectProcessor implements VideoProcessor {
13
+ private VideoSink mSink;
14
+ final private SurfaceTextureHelper textureHelper;
15
+ final private VideoFrameProcessor videoFrameProcessor;
16
+
17
+ public VideoEffectProcessor(VideoFrameProcessor processor, SurfaceTextureHelper textureHelper) {
18
+ this.textureHelper = textureHelper;
19
+ this.videoFrameProcessor = processor;
20
+ }
21
+
22
+ @Override
23
+ public void onCapturerStarted(boolean success) {
24
+
25
+ }
26
+
27
+ @Override
28
+ public void onCapturerStopped() {
29
+
30
+ }
31
+
32
+ @Override
33
+ public void setSink(VideoSink sink) {
34
+ mSink = sink;
35
+ }
36
+
37
+ /**
38
+ * Called just after the frame is captured.
39
+ * Will process the VideoFrame with the help of VideoFrameProcessor and send the processed
40
+ * VideoFrame back to webrtc using onFrame method in VideoSink.
41
+ * @param frame raw VideoFrame received from webrtc.
42
+ */
43
+ @Override
44
+ public void onFrameCaptured(VideoFrame frame) {
45
+ frame.retain();
46
+ VideoFrame outputFrame = videoFrameProcessor.process(frame, textureHelper);
47
+
48
+ if (outputFrame == null) {
49
+ mSink.onFrame(frame);
50
+ frame.release();
51
+ return;
52
+ }
53
+ mSink.onFrame(outputFrame);
54
+ outputFrame.release();
55
+ frame.release();
56
+ }
57
+ }
@@ -0,0 +1,19 @@
1
+ package com.oney.WebRTCModule.videoEffects;
2
+
3
+ import org.webrtc.SurfaceTextureHelper;
4
+ import org.webrtc.VideoFrame;
5
+
6
+ /**
7
+ * Interface contains process method to process VideoFrame.
8
+ * The caller takes ownership of the object.
9
+ */
10
+ public interface VideoFrameProcessor {
11
+ /**
12
+ * Applies the image processing algorithms to the frame. Returns the processed frame.
13
+ * The caller is responsible for releasing the returned frame.
14
+ * @param frame raw videoframe which need to be processed
15
+ * @param textureHelper
16
+ * @return processed videoframe which will rendered
17
+ */
18
+ public VideoFrame process(VideoFrame frame, SurfaceTextureHelper textureHelper);
19
+ }
@@ -0,0 +1,13 @@
1
+ package com.oney.WebRTCModule.videoEffects;
2
+
3
+ /**
4
+ * Factory for creating VideoFrameProcessor instances.
5
+ */
6
+ public interface VideoFrameProcessorFactoryInterface {
7
+
8
+ /**
9
+ * Dynamically allocates a VideoFrameProcessor instance and returns a pointer to it.
10
+ * The caller takes ownership of the object.
11
+ */
12
+ public VideoFrameProcessor build();
13
+ }
@@ -240,6 +240,11 @@ RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription:(RTCSessionDescription *)sd
240
240
  return;
241
241
  }
242
242
 
243
+ NSMutableArray *receiversIds = [NSMutableArray new];
244
+ for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
245
+ [receiversIds addObject:transceiver.receiver.receiverId];
246
+ }
247
+
243
248
  [peerConnection setRemoteDescription: sdp completionHandler: ^(NSError *error) {
244
249
  if (error) {
245
250
  id errorResponse = @{
@@ -248,11 +253,22 @@ RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription:(RTCSessionDescription *)sd
248
253
  };
249
254
  callback(@[@(NO), errorResponse]);
250
255
  } else {
256
+ NSMutableArray *newTransceivers = [NSMutableArray new];
257
+ for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
258
+ if (![receiversIds containsObject:transceiver.receiver.receiverId]) {
259
+ NSMutableDictionary *newTransceiver = [NSMutableDictionary new];
260
+ newTransceiver[@"transceiverOrder"] = [NSNumber numberWithInt:_transceiverNextId++];
261
+ newTransceiver[@"transceiver"] = [SerializeUtils transceiverToJSONWithPeerConnectionId:objectID transceiver:transceiver];
262
+ [newTransceivers addObject:newTransceiver];
263
+ }
264
+ }
265
+
251
266
  id newSdp = @{
252
267
  @"sdpInfo": @{
253
268
  @"type": [RTCSessionDescription stringForType:peerConnection.remoteDescription.type],
254
269
  @"sdp": peerConnection.remoteDescription.sdp},
255
- @"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection peerConnectionId: objectID]
270
+ @"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection peerConnectionId: objectID],
271
+ @"newTransceivers": newTransceivers
256
272
  };
257
273
  callback(@[@(YES), newSdp]);
258
274
  }
@@ -348,7 +364,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTrack:(nonnull NSNumber
348
364
  trackId:(NSString *)trackId
349
365
  options:(NSDictionary *)options)
350
366
  {
351
- __block id params;
367
+ __block id params = nil;
352
368
 
353
369
  dispatch_sync(self.workerQueue, ^{
354
370
  RTCPeerConnection *peerConnection = self.peerConnections[objectID];
@@ -388,7 +404,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTrack:(nonnull NSNumber
388
404
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionAddTransceiver:(nonnull NSNumber *)objectID
389
405
  options:(NSDictionary *)options)
390
406
  {
391
- __block id params;
407
+ __block id params = nil;
392
408
 
393
409
  dispatch_sync(self.workerQueue, ^{
394
410
  RTCPeerConnection *peerConnection = self.peerConnections[objectID];
@@ -3,7 +3,7 @@
3
3
  archiveVersion = 1;
4
4
  classes = {
5
5
  };
6
- objectVersion = 52;
6
+ objectVersion = 46;
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
@@ -22,8 +22,8 @@
22
22
  4EE3A8D225B841DD00FAA24A /* CaptureController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE3A8C925B841DD00FAA24A /* CaptureController.m */; };
23
23
  4EE3A8D325B841DD00FAA24A /* ScreenCaptureController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE3A8CC25B841DD00FAA24A /* ScreenCaptureController.m */; };
24
24
  4EE3A8D425B841DD00FAA24A /* ScreenCapturer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EE3A8CD25B841DD00FAA24A /* ScreenCapturer.m */; };
25
+ D3FF699919D2664B25C9D458 /* Pods_RCTWebRTC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A20F721AD842563B66292D5B /* Pods_RCTWebRTC.framework */; };
25
26
  DEC96577264176C10052DB35 /* DataChannelWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC96576264176C10052DB35 /* DataChannelWrapper.m */; };
26
- DECBD39D256D3A2D00B987E5 /* WebRTC.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = DECBD39C256D3A2D00B987E5 /* WebRTC.xcframework */; platformFilter = ios; };
27
27
  /* End PBXBuildFile section */
28
28
 
29
29
  /* Begin PBXCopyFilesBuildPhase section */
@@ -40,6 +40,8 @@
40
40
 
41
41
  /* Begin PBXFileReference section */
42
42
  0BDDA6DF20C18B6B00B38B45 /* VideoCaptureController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VideoCaptureController.m; path = RCTWebRTC/VideoCaptureController.m; sourceTree = "<group>"; };
43
+ 131131FC732883F1EF6F2CA3 /* Pods-RCTWebRTC.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RCTWebRTC.release.xcconfig"; path = "Target Support Files/Pods-RCTWebRTC/Pods-RCTWebRTC.release.xcconfig"; sourceTree = "<group>"; };
44
+ 1A7E646283326F2A95C8C1FA /* Pods-RCTWebRTC.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RCTWebRTC.debug.xcconfig"; path = "Target Support Files/Pods-RCTWebRTC/Pods-RCTWebRTC.debug.xcconfig"; sourceTree = "<group>"; };
43
45
  35A2221F1CB493700015FD5C /* libRCTWebRTC.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebRTC.a; sourceTree = BUILT_PRODUCTS_DIR; };
44
46
  4EC498BA25B8777F00E76218 /* ScreenCapturePickerViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ScreenCapturePickerViewManager.m; path = RCTWebRTC/ScreenCapturePickerViewManager.m; sourceTree = SOURCE_ROOT; };
45
47
  4EC498BB25B8777F00E76218 /* ScreenCapturePickerViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScreenCapturePickerViewManager.h; path = RCTWebRTC/ScreenCapturePickerViewManager.h; sourceTree = SOURCE_ROOT; };
@@ -68,10 +70,9 @@
68
70
  4EE3A8CC25B841DD00FAA24A /* ScreenCaptureController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ScreenCaptureController.m; path = RCTWebRTC/ScreenCaptureController.m; sourceTree = SOURCE_ROOT; };
69
71
  4EE3A8CD25B841DD00FAA24A /* ScreenCapturer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ScreenCapturer.m; path = RCTWebRTC/ScreenCapturer.m; sourceTree = SOURCE_ROOT; };
70
72
  4EE3A8CE25B841DD00FAA24A /* SocketConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocketConnection.h; path = RCTWebRTC/SocketConnection.h; sourceTree = SOURCE_ROOT; };
73
+ A20F721AD842563B66292D5B /* Pods_RCTWebRTC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RCTWebRTC.framework; sourceTree = BUILT_PRODUCTS_DIR; };
71
74
  DEC96576264176C10052DB35 /* DataChannelWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = DataChannelWrapper.m; path = RCTWebRTC/DataChannelWrapper.m; sourceTree = "<group>"; };
72
75
  DEC96579264176DF0052DB35 /* DataChannelWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataChannelWrapper.h; path = RCTWebRTC/DataChannelWrapper.h; sourceTree = "<group>"; };
73
- DECBD39C256D3A2D00B987E5 /* WebRTC.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebRTC.xcframework; path = ../apple/WebRTC.xcframework; sourceTree = "<group>"; };
74
- DEFDBC26256574F500344B23 /* WebRTC.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = WebRTC.xcframework; sourceTree = "<group>"; };
75
76
  /* End PBXFileReference section */
76
77
 
77
78
  /* Begin PBXFrameworksBuildPhase section */
@@ -79,19 +80,30 @@
79
80
  isa = PBXFrameworksBuildPhase;
80
81
  buildActionMask = 2147483647;
81
82
  files = (
82
- DECBD39D256D3A2D00B987E5 /* WebRTC.xcframework in Frameworks */,
83
+ D3FF699919D2664B25C9D458 /* Pods_RCTWebRTC.framework in Frameworks */,
83
84
  );
84
85
  runOnlyForDeploymentPostprocessing = 0;
85
86
  };
86
87
  /* End PBXFrameworksBuildPhase section */
87
88
 
88
89
  /* Begin PBXGroup section */
90
+ 22DE4ED9F87C796C5D0480DC /* Pods */ = {
91
+ isa = PBXGroup;
92
+ children = (
93
+ 1A7E646283326F2A95C8C1FA /* Pods-RCTWebRTC.debug.xcconfig */,
94
+ 131131FC732883F1EF6F2CA3 /* Pods-RCTWebRTC.release.xcconfig */,
95
+ );
96
+ name = Pods;
97
+ path = Pods;
98
+ sourceTree = "<group>";
99
+ };
89
100
  35A222161CB493700015FD5C = {
90
101
  isa = PBXGroup;
91
102
  children = (
92
103
  35A222311CB493C00015FD5C /* RCTWebRTC */,
93
104
  35A222201CB493700015FD5C /* Products */,
94
105
  DEFDBC25256574F500344B23 /* Frameworks */,
106
+ 22DE4ED9F87C796C5D0480DC /* Pods */,
95
107
  );
96
108
  sourceTree = "<group>";
97
109
  };
@@ -144,8 +156,7 @@
144
156
  DEFDBC25256574F500344B23 /* Frameworks */ = {
145
157
  isa = PBXGroup;
146
158
  children = (
147
- DECBD39C256D3A2D00B987E5 /* WebRTC.xcframework */,
148
- DEFDBC26256574F500344B23 /* WebRTC.xcframework */,
159
+ A20F721AD842563B66292D5B /* Pods_RCTWebRTC.framework */,
149
160
  );
150
161
  name = Frameworks;
151
162
  sourceTree = "<group>";
@@ -157,6 +168,7 @@
157
168
  isa = PBXNativeTarget;
158
169
  buildConfigurationList = 35A222281CB493700015FD5C /* Build configuration list for PBXNativeTarget "RCTWebRTC" */;
159
170
  buildPhases = (
171
+ B1E831D2F95BE8EA21E91593 /* [CP] Check Pods Manifest.lock */,
160
172
  35A2221B1CB493700015FD5C /* Sources */,
161
173
  35A2221C1CB493700015FD5C /* Frameworks */,
162
174
  35A2221D1CB493700015FD5C /* CopyFiles */,
@@ -201,6 +213,31 @@
201
213
  };
202
214
  /* End PBXProject section */
203
215
 
216
+ /* Begin PBXShellScriptBuildPhase section */
217
+ B1E831D2F95BE8EA21E91593 /* [CP] Check Pods Manifest.lock */ = {
218
+ isa = PBXShellScriptBuildPhase;
219
+ buildActionMask = 2147483647;
220
+ files = (
221
+ );
222
+ inputFileListPaths = (
223
+ );
224
+ inputPaths = (
225
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
226
+ "${PODS_ROOT}/Manifest.lock",
227
+ );
228
+ name = "[CP] Check Pods Manifest.lock";
229
+ outputFileListPaths = (
230
+ );
231
+ outputPaths = (
232
+ "$(DERIVED_FILE_DIR)/Pods-RCTWebRTC-checkManifestLockResult.txt",
233
+ );
234
+ runOnlyForDeploymentPostprocessing = 0;
235
+ shellPath = /bin/sh;
236
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
237
+ showEnvVarsInLog = 0;
238
+ };
239
+ /* End PBXShellScriptBuildPhase section */
240
+
204
241
  /* Begin PBXSourcesBuildPhase section */
205
242
  35A2221B1CB493700015FD5C /* Sources */ = {
206
243
  isa = PBXSourcesBuildPhase;
@@ -306,8 +343,8 @@
306
343
  };
307
344
  35A222291CB493700015FD5C /* Debug */ = {
308
345
  isa = XCBuildConfiguration;
346
+ baseConfigurationReference = 1A7E646283326F2A95C8C1FA /* Pods-RCTWebRTC.debug.xcconfig */;
309
347
  buildSettings = {
310
- FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../apple/";
311
348
  LIBRARY_SEARCH_PATHS = "$(inherited)";
312
349
  OTHER_LDFLAGS = "-ObjC";
313
350
  PRODUCT_NAME = "$(TARGET_NAME)";
@@ -317,8 +354,8 @@
317
354
  };
318
355
  35A2222A1CB493700015FD5C /* Release */ = {
319
356
  isa = XCBuildConfiguration;
357
+ baseConfigurationReference = 131131FC732883F1EF6F2CA3 /* Pods-RCTWebRTC.release.xcconfig */;
320
358
  buildSettings = {
321
- FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../apple/";
322
359
  LIBRARY_SEARCH_PATHS = "$(inherited)";
323
360
  OTHER_LDFLAGS = "-ObjC";
324
361
  PRODUCT_NAME = "$(TARGET_NAME)";
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RCTWebRTC.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:RCTWebRTC.xcodeproj">
6
+ </FileRef>
7
+ <FileRef
8
+ location = "group:Pods/Pods.xcodeproj">
9
+ </FileRef>
10
+ </Workspace>
@@ -1 +1 @@
1
- {"version":3,"sources":["EventEmitter.ts"],"names":["WebRTCModule","NativeModules","EventEmitter","NativeEventEmitter","_subscriptions","Map","addListener","listener","eventName","eventHandler","has","set","get","push","removeListener","forEach","sub","remove","delete"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuBH,YAAvB,CAArB;eAEeE,Y;;;AAEf,MAAME,cAA+C,GAAG,IAAIC,GAAJ,EAAxD;;AAIO,SAASC,WAAT,CAAqBC,QAArB,EAAoCC,SAApC,EAAuDC,YAAvD,EAAyF;AAAA;;AAC5F,MAAI,CAACL,cAAc,CAACM,GAAf,CAAmBH,QAAnB,CAAL,EAAmC;AAC/BH,IAAAA,cAAc,CAACO,GAAf,CAAmBJ,QAAnB,EAA6B,EAA7B;AACH;;AAED,wBAAAH,cAAc,CAACQ,GAAf,CAAmBL,QAAnB,2EAA8BM,IAA9B,CAAmCX,YAAY,CAACI,WAAb,CAAyBE,SAAzB,EAAoCC,YAApC,CAAnC;AACH;;AAEM,SAASK,cAAT,CAAwBP,QAAxB,EAA6C;AAAA;;AAChD,yBAAAH,cAAc,CAACQ,GAAf,CAAmBL,QAAnB,6EAA8BQ,OAA9B,CAAsCC,GAAG,IAAI;AACzCA,IAAAA,GAAG,CAACC,MAAJ;AACH,GAFD;;AAIAb,EAAAA,cAAc,CAACc,MAAf,CAAsBX,QAAtB;AACH","sourcesContent":["import { NativeModules, NativeEventEmitter, EmitterSubscription } from 'react-native';\n\nconst { WebRTCModule } = NativeModules;\n\nconst EventEmitter = new NativeEventEmitter(WebRTCModule);\n\nexport default EventEmitter;\n\nconst _subscriptions: Map<any, EmitterSubscription[]> = new Map(); \n\ntype EventHandler = (event: any) => void;\n\nexport function addListener(listener: any, eventName: string, eventHandler: EventHandler): void {\n if (!_subscriptions.has(listener)) {\n _subscriptions.set(listener, []);\n }\n\n _subscriptions.get(listener)?.push(EventEmitter.addListener(eventName, eventHandler));\n}\n\nexport function removeListener(listener: any): void {\n _subscriptions.get(listener)?.forEach(sub => {\n sub.remove();\n });\n\n _subscriptions.delete(listener);\n}\n"]}
1
+ {"version":3,"sources":["EventEmitter.ts"],"names":["WebRTCModule","NativeModules","EventEmitter","NativeEventEmitter","_subscriptions","Map","addListener","listener","eventName","eventHandler","has","set","get","push","removeListener","forEach","sub","remove","delete"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuBH,YAAvB,CAArB;eAEeE,Y;;;AAKf,MAAME,cAAoD,GAAG,IAAIC,GAAJ,EAA7D;;AAEO,SAASC,WAAT,CAAqBC,QAArB,EAAyCC,SAAzC,EAA4DC,YAA5D,EAA8F;AAAA;;AACjG,MAAI,CAACL,cAAc,CAACM,GAAf,CAAmBH,QAAnB,CAAL,EAAmC;AAC/BH,IAAAA,cAAc,CAACO,GAAf,CAAmBJ,QAAnB,EAA6B,EAA7B;AACH;;AAED,wBAAAH,cAAc,CAACQ,GAAf,CAAmBL,QAAnB,2EAA8BM,IAA9B,CAAmCX,YAAY,CAACI,WAAb,CAAyBE,SAAzB,EAAoCC,YAApC,CAAnC;AACH;;AAEM,SAASK,cAAT,CAAwBP,QAAxB,EAAkD;AAAA;;AACrD,yBAAAH,cAAc,CAACQ,GAAf,CAAmBL,QAAnB,6EAA8BQ,OAA9B,CAAsCC,GAAG,IAAI;AACzCA,IAAAA,GAAG,CAACC,MAAJ;AACH,GAFD;;AAIAb,EAAAA,cAAc,CAACc,MAAf,CAAsBX,QAAtB;AACH","sourcesContent":["import { NativeModules, NativeEventEmitter, EmitterSubscription } from 'react-native';\n\nconst { WebRTCModule } = NativeModules;\n\nconst EventEmitter = new NativeEventEmitter(WebRTCModule);\n\nexport default EventEmitter;\n\ntype EventHandler = (event: unknown) => void;\ntype Listener = unknown;\n\nconst _subscriptions: Map<Listener, EmitterSubscription[]> = new Map();\n\nexport function addListener(listener: Listener, eventName: string, eventHandler: EventHandler): void {\n if (!_subscriptions.has(listener)) {\n _subscriptions.set(listener, []);\n }\n\n _subscriptions.get(listener)?.push(EventEmitter.addListener(eventName, eventHandler));\n}\n\nexport function removeListener(listener: Listener): void {\n _subscriptions.get(listener)?.forEach(sub => {\n sub.remove();\n });\n\n _subscriptions.delete(listener);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Logger.ts"],"names":["Logger","enable","ns","debug","constructor","prefix","_prefix","ROOT_PREFIX","_debug","_info","_warn","_error","log","console","bind","msg","info","warn","error","err","trace","stack"],"mappings":";;;;;;;AAAA;;;;;;AAGe,MAAMA,MAAN,CAAa;AAQX,SAANC,MAAM,CAACC,EAAD,EAAmB;AAC5BC,mBAAMF,MAAN,CAAaC,EAAb;AACH;;AAEDE,EAAAA,WAAW,CAACC,MAAD,EAAiB;AAAA;;AAAA;;AAAA;;AAAA;;AACxB,UAAMC,OAAO,GAAI,GAAEN,MAAM,CAACO,WAAY,IAAGF,MAAO,EAAhD;AAEA,SAAKG,MAAL,GAAc,oBAAO,GAAEF,OAAQ,QAAjB,CAAd;AACA,SAAKG,KAAL,GAAa,oBAAO,GAAEH,OAAQ,OAAjB,CAAb;AACA,SAAKI,KAAL,GAAa,oBAAO,GAAEJ,OAAQ,OAAjB,CAAb;AACA,SAAKK,MAAL,GAAc,oBAAO,GAAEL,OAAQ,QAAjB,CAAd;AAEA,UAAMM,GAAG,GAAGC,OAAO,CAACD,GAAR,CAAYE,IAAZ,CAAiBD,OAAjB,CAAZ;AAEA,SAAKL,MAAL,CAAYI,GAAZ,GAAkBA,GAAlB;AACA,SAAKH,KAAL,CAAWG,GAAX,GAAiBA,GAAjB;AACA,SAAKF,KAAL,CAAWE,GAAX,GAAiBA,GAAjB;AACA,SAAKD,MAAL,CAAYC,GAAZ,GAAkBA,GAAlB;AACH;;AAEDT,EAAAA,KAAK,CAACY,GAAD,EAAoB;AACrB,SAAKP,MAAL,CAAYO,GAAZ;AACH;;AAEDC,EAAAA,IAAI,CAACD,GAAD,EAAoB;AACpB,SAAKN,KAAL,CAAWM,GAAX;AACH;;AAEDE,EAAAA,IAAI,CAACF,GAAD,EAAoB;AACpB,SAAKL,KAAL,CAAWK,GAAX;AACH;;AAEDG,EAAAA,KAAK,CAACH,GAAD,EAAcI,GAAd,EAAiC;AAAA;;AAClC,UAAMC,KAAK,iBAAGD,GAAH,aAAGA,GAAH,uBAAGA,GAAG,CAAEE,KAAR,mDAAiB,KAA5B;;AAEA,SAAKV,MAAL,CAAa,GAAEI,GAAI,WAAUK,KAAM,EAAnC;AACH;;AA5CuB;;;;gBAAPpB,M,iBACI,W","sourcesContent":["import debug from 'debug';\n\n\nexport default class Logger {\n static ROOT_PREFIX = 'rn-webrtc';\n \n private _debug: debug.Debugger;\n private _info: debug.Debugger;\n private _warn: debug.Debugger;\n private _error: debug.Debugger;\n\n static enable(ns: string): void {\n debug.enable(ns);\n }\n\n constructor(prefix: string) {\n const _prefix = `${Logger.ROOT_PREFIX}:${prefix}`;\n\n this._debug = debug(`${_prefix}:DEBUG`);\n this._info = debug(`${_prefix}:INFO`);\n this._warn = debug(`${_prefix}:WARN`);\n this._error = debug(`${_prefix}:ERROR`);\n\n const log = console.log.bind(console);\n\n this._debug.log = log;\n this._info.log = log;\n this._warn.log = log;\n this._error.log = log;\n }\n\n debug(msg: string): void {\n this._debug(msg);\n }\n\n info(msg: string): void {\n this._info(msg);\n }\n\n warn(msg: string): void {\n this._warn(msg);\n }\n\n error(msg: string, err?: Error): void {\n const trace = err?.stack ?? 'N/A';\n\n this._error(`${msg} Trace: ${trace}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["Logger.ts"],"names":["Logger","enable","ns","debug","constructor","prefix","_prefix","ROOT_PREFIX","_debug","_info","_warn","_error","log","console","bind","msg","info","warn","error","err","trace","stack"],"mappings":";;;;;;;AAAA;;;;;;AAGe,MAAMA,MAAN,CAAa;AAQX,SAANC,MAAM,CAACC,EAAD,EAAmB;AAC5BC,mBAAMF,MAAN,CAAaC,EAAb;AACH;;AAEDE,EAAAA,WAAW,CAACC,MAAD,EAAiB;AAAA;;AAAA;;AAAA;;AAAA;;AACxB,UAAMC,OAAO,GAAI,GAAEN,MAAM,CAACO,WAAY,IAAGF,MAAO,EAAhD;AAEA,SAAKG,MAAL,GAAc,oBAAO,GAAEF,OAAQ,QAAjB,CAAd;AACA,SAAKG,KAAL,GAAa,oBAAO,GAAEH,OAAQ,OAAjB,CAAb;AACA,SAAKI,KAAL,GAAa,oBAAO,GAAEJ,OAAQ,OAAjB,CAAb;AACA,SAAKK,MAAL,GAAc,oBAAO,GAAEL,OAAQ,QAAjB,CAAd;AAEA,UAAMM,GAAG,GAAGC,OAAO,CAACD,GAAR,CAAYE,IAAZ,CAAiBD,OAAjB,CAAZ;AAEA,SAAKL,MAAL,CAAYI,GAAZ,GAAkBA,GAAlB;AACA,SAAKH,KAAL,CAAWG,GAAX,GAAiBA,GAAjB;AACA,SAAKF,KAAL,CAAWE,GAAX,GAAiBA,GAAjB;AACA,SAAKD,MAAL,CAAYC,GAAZ,GAAkBA,GAAlB;AACH;;AAEDT,EAAAA,KAAK,CAACY,GAAD,EAAoB;AACrB,SAAKP,MAAL,CAAYO,GAAZ;AACH;;AAEDC,EAAAA,IAAI,CAACD,GAAD,EAAoB;AACpB,SAAKN,KAAL,CAAWM,GAAX;AACH;;AAEDE,EAAAA,IAAI,CAACF,GAAD,EAAoB;AACpB,SAAKL,KAAL,CAAWK,GAAX;AACH;;AAEDG,EAAAA,KAAK,CAACH,GAAD,EAAcI,GAAd,EAAiC;AAAA;;AAClC,UAAMC,KAAK,iBAAGD,GAAH,aAAGA,GAAH,uBAAGA,GAAG,CAAEE,KAAR,mDAAiB,KAA5B;;AAEA,SAAKV,MAAL,CAAa,GAAEI,GAAI,WAAUK,KAAM,EAAnC;AACH;;AA5CuB;;;;gBAAPpB,M,iBACI,W","sourcesContent":["import debug from 'debug';\n\n\nexport default class Logger {\n static ROOT_PREFIX = 'rn-webrtc';\n\n private _debug: debug.Debugger;\n private _info: debug.Debugger;\n private _warn: debug.Debugger;\n private _error: debug.Debugger;\n\n static enable(ns: string): void {\n debug.enable(ns);\n }\n\n constructor(prefix: string) {\n const _prefix = `${Logger.ROOT_PREFIX}:${prefix}`;\n\n this._debug = debug(`${_prefix}:DEBUG`);\n this._info = debug(`${_prefix}:INFO`);\n this._warn = debug(`${_prefix}:WARN`);\n this._error = debug(`${_prefix}:ERROR`);\n\n const log = console.log.bind(console);\n\n this._debug.log = log;\n this._info.log = log;\n this._warn.log = log;\n this._error.log = log;\n }\n\n debug(msg: string): void {\n this._debug(msg);\n }\n\n info(msg: string): void {\n this._info(msg);\n }\n\n warn(msg: string): void {\n this._warn(msg);\n }\n\n error(msg: string, err?: Error): void {\n const trace = err?.stack ?? 'N/A';\n\n this._error(`${msg} Trace: ${trace}`);\n }\n}\n"]}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _reactNative = require("react-native");
9
-
10
8
  var _eventTargetShim = require("event-target-shim");
11
9
 
10
+ var _reactNative = require("react-native");
11
+
12
12
  var _getDisplayMedia = _interopRequireDefault(require("./getDisplayMedia"));
13
13
 
14
14
  var _getUserMedia = _interopRequireDefault(require("./getUserMedia"));
@@ -1 +1 @@
1
- {"version":3,"sources":["MediaDevices.ts"],"names":["WebRTCModule","NativeModules","MEDIA_DEVICES_EVENTS","MediaDevices","enumerateDevices","Promise","resolve","getDisplayMedia","getUserMedia","constraints"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,oBAAoB,GAAG,CAAC,cAAD,CAA7B;;AAEA,MAAMC,YAAN,SAA2B,8CAAwB,GAAGD,oBAA3B,CAA3B,CAA4E;AACxE;AACJ;AACA;AACA;AACIE,EAAAA,gBAAgB,GAAG;AACf,WAAO,IAAIC,OAAJ,CAAYC,OAAO,IAAIN,YAAY,CAACI,gBAAb,CAA8BE,OAA9B,CAAvB,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,eAAe,GAAG;AACd,WAAO,+BAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,YAAY,CAACC,WAAD,EAAc;AACtB,WAAO,2BAAaA,WAAb,CAAP;AACH;;AA7BuE;;eAgC7D,IAAIN,YAAJ,E","sourcesContent":["\nimport { NativeModules } from 'react-native';\nimport { defineCustomEventTarget } from 'event-target-shim';\n\nimport getDisplayMedia from './getDisplayMedia';\nimport getUserMedia from './getUserMedia';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_DEVICES_EVENTS = ['devicechange'];\n\nclass MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {\n /**\n * W3C \"Media Capture and Streams\" compatible {@code enumerateDevices}\n * implementation.\n */\n enumerateDevices() {\n return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));\n }\n\n /**\n * W3C \"Screen Capture\" compatible {@code getDisplayMedia} implementation.\n * See: https://w3c.github.io/mediacapture-screen-share/\n *\n * @returns {Promise}\n */\n getDisplayMedia() {\n return getDisplayMedia();\n }\n\n /**\n * W3C \"Media Capture and Streams\" compatible {@code getUserMedia}\n * implementation.\n * See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices\n *\n * @param {*} constraints\n * @returns {Promise}\n */\n getUserMedia(constraints) {\n return getUserMedia(constraints);\n }\n}\n\nexport default new MediaDevices();\n"]}
1
+ {"version":3,"sources":["MediaDevices.ts"],"names":["WebRTCModule","NativeModules","MEDIA_DEVICES_EVENTS","MediaDevices","enumerateDevices","Promise","resolve","getDisplayMedia","getUserMedia","constraints"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,oBAAoB,GAAG,CAAE,cAAF,CAA7B;;AAEA,MAAMC,YAAN,SAA2B,8CAAwB,GAAGD,oBAA3B,CAA3B,CAA4E;AACxE;AACJ;AACA;AACA;AACIE,EAAAA,gBAAgB,GAAG;AACf,WAAO,IAAIC,OAAJ,CAAYC,OAAO,IAAIN,YAAY,CAACI,gBAAb,CAA8BE,OAA9B,CAAvB,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,eAAe,GAAG;AACd,WAAO,+BAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,YAAY,CAACC,WAAD,EAAc;AACtB,WAAO,2BAAaA,WAAb,CAAP;AACH;;AA7BuE;;eAgC7D,IAAIN,YAAJ,E","sourcesContent":["\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport getDisplayMedia from './getDisplayMedia';\nimport getUserMedia from './getUserMedia';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_DEVICES_EVENTS = [ 'devicechange' ];\n\nclass MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {\n /**\n * W3C \"Media Capture and Streams\" compatible {@code enumerateDevices}\n * implementation.\n */\n enumerateDevices() {\n return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));\n }\n\n /**\n * W3C \"Screen Capture\" compatible {@code getDisplayMedia} implementation.\n * See: https://w3c.github.io/mediacapture-screen-share/\n *\n * @returns {Promise}\n */\n getDisplayMedia() {\n return getDisplayMedia();\n }\n\n /**\n * W3C \"Media Capture and Streams\" compatible {@code getUserMedia}\n * implementation.\n * See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices\n *\n * @param {*} constraints\n * @returns {Promise}\n */\n getUserMedia(constraints) {\n return getUserMedia(constraints);\n }\n}\n\nexport default new MediaDevices();\n"]}
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _reactNative = require("react-native");
9
-
10
8
  var _eventTargetShim = require("event-target-shim");
11
9
 
12
- var _RTCUtil = require("./RTCUtil");
10
+ var _reactNative = require("react-native");
13
11
 
14
12
  var _MediaStreamTrack = _interopRequireDefault(require("./MediaStreamTrack"));
15
13
 
14
+ var _RTCUtil = require("./RTCUtil");
15
+
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -1 +1 @@
1
- {"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","id","_reactTag","mediaStreamCreate","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","index","indexOf","mediaStreamAddTrack","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":"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","sourcesContent":["\nimport { NativeModules } from 'react-native';\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { uniqueID } from './RTCUtil';\n\nimport MediaStreamTrack from './MediaStreamTrack';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = ['active', 'inactive', 'addtrack', 'removetrack'];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n id: string;\n active = true;\n\n _tracks: MediaStreamTrack[] = [];\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the parameters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assigm a UUID to start with. It may get overridden for remote streams.\n this.id = uniqueID();\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this.id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this.id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n addTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n if (index !== -1) {\n return;\n }\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);\n }\n\n removeTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n if (index === -1) {\n return;\n }\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);\n }\n\n getTracks(): MediaStreamTrack[] {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n toURL(): string {\n return this._reactTag;\n }\n\n release(releaseTracks = true): void {\n const tracks = [...this._tracks];\n for (const track of tracks) {\n this.removeTrack(track);\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}
1
+ {"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","id","_reactTag","mediaStreamCreate","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","index","indexOf","mediaStreamAddTrack","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":"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","sourcesContent":["\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport MediaStreamTrack from './MediaStreamTrack';\nimport { uniqueID } from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = [ 'active', 'inactive', 'addtrack', 'removetrack' ];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n id: string;\n active = true;\n\n _tracks: MediaStreamTrack[] = [];\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the parameters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assigm a UUID to start with. It may get overridden for remote streams.\n this.id = uniqueID();\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this.id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this.id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n addTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index !== -1) {\n return;\n }\n\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);\n }\n\n removeTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index === -1) {\n return;\n }\n\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);\n }\n\n getTracks(): MediaStreamTrack[] {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n toURL(): string {\n return this._reactTag;\n }\n\n release(releaseTracks = true): void {\n const tracks = [ ...this._tracks ];\n\n for (const track of tracks) {\n this.removeTrack(track);\n\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}