react-native-webrtc 124.0.2 → 124.0.4

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 (112) hide show
  1. package/android/src/main/AndroidManifest.xml +0 -5
  2. package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +17 -10
  3. package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +43 -8
  4. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +1 -1
  5. package/android/src/main/java/org/webrtc/Camera1Helper.java +55 -0
  6. package/android/src/main/java/org/webrtc/Camera2Helper.java +51 -0
  7. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +7 -1
  8. package/lib/commonjs/RTCPeerConnection.js +5 -2
  9. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  10. package/lib/commonjs/RTCRtpParameters.js +4 -3
  11. package/lib/commonjs/RTCRtpParameters.js.map +1 -1
  12. package/lib/commonjs/RTCRtpSendParameters.js +2 -1
  13. package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
  14. package/lib/module/RTCPeerConnection.js +5 -2
  15. package/lib/module/RTCPeerConnection.js.map +1 -1
  16. package/lib/module/RTCRtpParameters.js +4 -3
  17. package/lib/module/RTCRtpParameters.js.map +1 -1
  18. package/lib/module/RTCRtpSendParameters.js +2 -1
  19. package/lib/module/RTCRtpSendParameters.js.map +1 -1
  20. package/lib/typescript/RTCRtpParameters.d.ts +6 -2
  21. package/lib/typescript/RTCRtpSendParameters.d.ts +6 -2
  22. package/package.json +1 -1
  23. package/src/RTCPeerConnection.ts +6 -2
  24. package/src/RTCRtpParameters.ts +6 -5
  25. package/src/RTCRtpSendParameters.ts +5 -5
  26. package/.github/stale.yml +0 -15
  27. package/.github/workflows/android_ci.yml +0 -36
  28. package/.github/workflows/ci.yml +0 -17
  29. package/.github/workflows/ios_ci.yml +0 -54
  30. package/android/build/generated/source/buildConfig/debug/com/oney/WebRTCModule/BuildConfig.java +0 -10
  31. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -23
  32. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  33. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -5
  34. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  35. package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -6064
  36. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  37. package/android/build/intermediates/incremental/debug/packageDebugResources/merged.dir/values/values.xml +0 -9
  38. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -4
  39. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  40. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  41. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  42. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -1
  43. package/android/build/intermediates/incremental/packageDebugResources/merged.dir/values/values.xml +0 -6
  44. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -4
  45. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/AbstractVideoCaptureController$CapturerEventsListener.class +0 -0
  46. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/AbstractVideoCaptureController.class +0 -0
  47. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/BuildConfig.class +0 -0
  48. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController$1.class +0 -0
  49. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController$2.class +0 -0
  50. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController.class +0 -0
  51. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraEventsHandler.class +0 -0
  52. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DataChannelWrapper$1.class +0 -0
  53. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DataChannelWrapper.class +0 -0
  54. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DisplayUtils.class +0 -0
  55. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/EglUtils.class +0 -0
  56. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$1.class +0 -0
  57. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$2.class +0 -0
  58. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$BiConsumer.class +0 -0
  59. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$TrackPrivate.class +0 -0
  60. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl.class +0 -0
  61. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/LibraryLoader.class +0 -0
  62. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/MediaProjectionNotification.class +0 -0
  63. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/MediaProjectionService.class +0 -0
  64. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/PeerConnectionObserver$1.class +0 -0
  65. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/PeerConnectionObserver.class +0 -0
  66. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/RTCVideoViewManager.class +0 -0
  67. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ReactBridgeUtil$1.class +0 -0
  68. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ReactBridgeUtil.class +0 -0
  69. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController$1.class +0 -0
  70. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController$2.class +0 -0
  71. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController.class +0 -0
  72. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/SerializeUtils$1.class +0 -0
  73. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/SerializeUtils.class +0 -0
  74. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/StringUtils.class +0 -0
  75. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ThreadUtils.class +0 -0
  76. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/TrackCapturerEventsEmitter.class +0 -0
  77. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCCamera2Enumerator.class +0 -0
  78. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCVideoCapturer$PreviewDataCallback.class +0 -0
  79. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCVideoCapturer.class +0 -0
  80. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter$TrackMuteUnmuteImpl$1.class +0 -0
  81. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter$TrackMuteUnmuteImpl.class +0 -0
  82. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter.class +0 -0
  83. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$1.class +0 -0
  84. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$2.class +0 -0
  85. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$3.class +0 -0
  86. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$4.class +0 -0
  87. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$5.class +0 -0
  88. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$6.class +0 -0
  89. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule.class +0 -0
  90. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModuleOptions.class +0 -0
  91. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModulePackage.class +0 -0
  92. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$1.class +0 -0
  93. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$2.class +0 -0
  94. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$3.class +0 -0
  95. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView.class +0 -0
  96. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/ProcessorProvider.class +0 -0
  97. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.class +0 -0
  98. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoFrameProcessor.class +0 -0
  99. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.class +0 -0
  100. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoDecoderFactory.class +0 -0
  101. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoEncoderFactory.class +0 -0
  102. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/SoftwareVideoDecoderFactoryProxy.class +0 -0
  103. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/SoftwareVideoEncoderFactoryProxy.class +0 -0
  104. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -6
  105. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -36
  106. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -23
  107. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  108. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
  109. package/android/build/intermediates/packaged_res/debug/values/values.xml +0 -9
  110. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -4347
  111. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -51
  112. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
@@ -8,9 +8,4 @@
8
8
  android:foregroundServiceType="mediaProjection">
9
9
  </service>
10
10
  </application>
11
- <uses-feature
12
- android:name="android.hardware.usb.host"
13
- android:required="false"
14
- tools:node="replace"
15
- />
16
11
  </manifest>
@@ -3,9 +3,13 @@ package com.oney.WebRTCModule;
3
3
  import org.webrtc.VideoCapturer;
4
4
 
5
5
  public abstract class AbstractVideoCaptureController {
6
- private final int width;
7
- private final int height;
8
- private final int fps;
6
+ protected final int targetWidth;
7
+ protected final int targetHeight;
8
+ protected final int targetFps;
9
+
10
+ protected int actualWidth;
11
+ protected int actualHeight;
12
+ protected int actualFps;
9
13
 
10
14
  /**
11
15
  * {@link VideoCapturer} which this controller manages.
@@ -15,9 +19,12 @@ public abstract class AbstractVideoCaptureController {
15
19
  protected CapturerEventsListener capturerEventsListener;
16
20
 
17
21
  public AbstractVideoCaptureController(int width, int height, int fps) {
18
- this.width = width;
19
- this.height = height;
20
- this.fps = fps;
22
+ this.targetWidth = width;
23
+ this.targetHeight = height;
24
+ this.targetFps = fps;
25
+ this.actualWidth = width;
26
+ this.actualHeight = height;
27
+ this.actualFps = fps;
21
28
  }
22
29
 
23
30
  public void initializeVideoCapturer() {
@@ -32,15 +39,15 @@ public abstract class AbstractVideoCaptureController {
32
39
  }
33
40
 
34
41
  public int getHeight() {
35
- return height;
42
+ return actualHeight;
36
43
  }
37
44
 
38
45
  public int getWidth() {
39
- return width;
46
+ return actualWidth;
40
47
  }
41
48
 
42
49
  public int getFrameRate() {
43
- return fps;
50
+ return actualFps;
44
51
  }
45
52
 
46
53
  public VideoCapturer getVideoCapturer() {
@@ -49,7 +56,7 @@ public abstract class AbstractVideoCaptureController {
49
56
 
50
57
  public void startCapture() {
51
58
  try {
52
- videoCapturer.startCapture(width, height, fps);
59
+ videoCapturer.startCapture(targetWidth, targetHeight, targetFps);
53
60
  } catch (RuntimeException e) {
54
61
  // XXX This can only fail if we initialize the capturer incorrectly,
55
62
  // which we don't. Thus, ignore any failures here since we trust
@@ -1,11 +1,20 @@
1
1
  package com.oney.WebRTCModule;
2
2
 
3
+ import android.content.Context;
4
+ import android.hardware.camera2.CameraManager;
3
5
  import android.util.Log;
6
+ import android.util.Pair;
7
+ import androidx.annotation.Nullable;
4
8
 
5
9
  import com.facebook.react.bridge.ReadableMap;
6
10
 
11
+ import org.webrtc.Camera1Capturer;
12
+ import org.webrtc.Camera1Helper;
13
+ import org.webrtc.Camera2Capturer;
14
+ import org.webrtc.Camera2Helper;
7
15
  import org.webrtc.CameraEnumerator;
8
16
  import org.webrtc.CameraVideoCapturer;
17
+ import org.webrtc.Size;
9
18
  import org.webrtc.VideoCapturer;
10
19
 
11
20
  import java.util.ArrayList;
@@ -19,6 +28,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
19
28
 
20
29
  private boolean isFrontFacing;
21
30
 
31
+ private final Context context;
22
32
  private final CameraEnumerator cameraEnumerator;
23
33
  private final ReadableMap constraints;
24
34
 
@@ -30,9 +40,10 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
30
40
  */
31
41
  private final CameraEventsHandler cameraEventsHandler = new CameraEventsHandler();
32
42
 
33
- public CameraCaptureController(CameraEnumerator cameraEnumerator, ReadableMap constraints) {
43
+ public CameraCaptureController(Context context, CameraEnumerator cameraEnumerator, ReadableMap constraints) {
34
44
  super(constraints.getInt("width"), constraints.getInt("height"), constraints.getInt("frameRate"));
35
45
 
46
+ this.context = context;
36
47
  this.cameraEnumerator = cameraEnumerator;
37
48
  this.constraints = constraints;
38
49
  }
@@ -75,7 +86,30 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
75
86
  String deviceId = ReactBridgeUtil.getMapStrValue(this.constraints, "deviceId");
76
87
  String facingMode = ReactBridgeUtil.getMapStrValue(this.constraints, "facingMode");
77
88
 
78
- return createVideoCapturer(deviceId, facingMode);
89
+ Pair<String, VideoCapturer> result = createVideoCapturer(deviceId, facingMode);
90
+ if(result == null) {
91
+ return null;
92
+ }
93
+
94
+ String cameraName = result.first;
95
+ VideoCapturer videoCapturer = result.second;
96
+
97
+ // Find actual capture format.
98
+ Size actualSize = null;
99
+ if (videoCapturer instanceof Camera1Capturer) {
100
+ int cameraId = Camera1Helper.getCameraId(cameraName);
101
+ actualSize = Camera1Helper.findClosestCaptureFormat(cameraId, targetWidth, targetHeight);
102
+ } else if (videoCapturer instanceof Camera2Capturer) {
103
+ CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
104
+ actualSize = Camera2Helper.findClosestCaptureFormat(cameraManager, cameraName, targetWidth, targetHeight);
105
+ }
106
+
107
+ if (actualSize != null) {
108
+ actualWidth = actualSize.width;
109
+ actualHeight = actualSize.height;
110
+ }
111
+
112
+ return videoCapturer;
79
113
  }
80
114
 
81
115
  /**
@@ -117,10 +151,11 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
117
151
  * @param facingMode the facing of the requested video source such as
118
152
  * {@code user} and {@code environment}. If {@code null}, "user" is
119
153
  * presumed.
120
- * @return a {@code VideoCapturer} satisfying the {@code facingMode} or
121
- * {@code deviceId} constraint
154
+ * @return a pair containing the deviceId and {@code VideoCapturer} satisfying the {@code facingMode} or
155
+ * {@code deviceId} constraint, or null.
122
156
  */
123
- private VideoCapturer createVideoCapturer(String deviceId, String facingMode) {
157
+ @Nullable
158
+ private Pair<String, VideoCapturer> createVideoCapturer(String deviceId, String facingMode) {
124
159
  String[] deviceNames = cameraEnumerator.getDeviceNames();
125
160
  List<String> failedDevices = new ArrayList<>();
126
161
 
@@ -139,7 +174,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
139
174
  if (videoCapturer != null) {
140
175
  Log.d(TAG, message + " succeeded");
141
176
  this.isFrontFacing = cameraEnumerator.isFrontFacing(cameraName);
142
- return videoCapturer;
177
+ return new Pair(cameraName, videoCapturer);
143
178
  } else {
144
179
  // fallback to facingMode
145
180
  Log.d(TAG, message + " failed");
@@ -161,7 +196,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
161
196
  if (videoCapturer != null) {
162
197
  Log.d(TAG, message + " succeeded");
163
198
  this.isFrontFacing = cameraEnumerator.isFrontFacing(name);
164
- return videoCapturer;
199
+ return new Pair(name, videoCapturer);
165
200
  } else {
166
201
  Log.d(TAG, message + " failed");
167
202
  failedDevices.add(name);
@@ -176,7 +211,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
176
211
  if (videoCapturer != null) {
177
212
  Log.d(TAG, message + " succeeded");
178
213
  this.isFrontFacing = cameraEnumerator.isFrontFacing(name);
179
- return videoCapturer;
214
+ return new Pair(name, videoCapturer);
180
215
  } else {
181
216
  Log.d(TAG, message + " failed");
182
217
  failedDevices.add(name);
@@ -192,7 +192,7 @@ class GetUserMediaImpl {
192
192
  Log.d(TAG, "getUserMedia(video): " + videoConstraintsMap);
193
193
 
194
194
  CameraCaptureController cameraCaptureController =
195
- new CameraCaptureController(getCameraEnumerator(), videoConstraintsMap);
195
+ new CameraCaptureController(reactContext.getCurrentActivity(), getCameraEnumerator(), videoConstraintsMap);
196
196
 
197
197
  videoTrack = createVideoTrack(cameraCaptureController);
198
198
  }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright 2023-2024 LiveKit, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.webrtc;
18
+
19
+ import androidx.annotation.Nullable;
20
+
21
+ import java.util.ArrayList;
22
+ import java.util.List;
23
+
24
+ /**
25
+ * A helper to access package-protected methods used in [Camera2Session]
26
+ * <p>
27
+ * Note: cameraId as used in the Camera1XXX classes refers to the index within the list of cameras.
28
+ *
29
+ * @suppress
30
+ */
31
+
32
+ public class Camera1Helper {
33
+
34
+ public static int getCameraId(String deviceName) {
35
+ return Camera1Enumerator.getCameraIndex(deviceName);
36
+ }
37
+
38
+ @Nullable
39
+ public static List<CameraEnumerationAndroid.CaptureFormat> getSupportedFormats(int cameraId) {
40
+ return Camera1Enumerator.getSupportedFormats(cameraId);
41
+ }
42
+
43
+ public static Size findClosestCaptureFormat(int cameraId, int width, int height) {
44
+ List<CameraEnumerationAndroid.CaptureFormat> formats = getSupportedFormats(cameraId);
45
+
46
+ List<Size> sizes = new ArrayList<>();
47
+ if (formats != null) {
48
+ for (CameraEnumerationAndroid.CaptureFormat format : formats) {
49
+ sizes.add(new Size(format.width, format.height));
50
+ }
51
+ }
52
+
53
+ return CameraEnumerationAndroid.getClosestSupportedSize(sizes, width, height);
54
+ }
55
+ }
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright 2023-2024 LiveKit, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.webrtc;
18
+
19
+ import android.hardware.camera2.CameraManager;
20
+
21
+ import androidx.annotation.Nullable;
22
+
23
+ import java.util.ArrayList;
24
+ import java.util.List;
25
+
26
+ /**
27
+ * A helper to access package-protected methods used in [Camera2Session]
28
+ * <p>
29
+ * Note: cameraId as used in the Camera2XXX classes refers to the id returned
30
+ * by [CameraManager.getCameraIdList].
31
+ */
32
+ public class Camera2Helper {
33
+
34
+ @Nullable
35
+ public static List<CameraEnumerationAndroid.CaptureFormat> getSupportedFormats(CameraManager cameraManager, @Nullable String cameraId) {
36
+ return Camera2Enumerator.getSupportedFormats(cameraManager, cameraId);
37
+ }
38
+
39
+ public static Size findClosestCaptureFormat(CameraManager cameraManager, @Nullable String cameraId, int width, int height) {
40
+ List<CameraEnumerationAndroid.CaptureFormat> formats = getSupportedFormats(cameraManager, cameraId);
41
+
42
+ List<Size> sizes = new ArrayList<>();
43
+ if (formats != null) {
44
+ for (CameraEnumerationAndroid.CaptureFormat format : formats) {
45
+ sizes.add(new Size(format.width, format.height));
46
+ }
47
+ }
48
+
49
+ return CameraEnumerationAndroid.getClosestSupportedSize(sizes, width, height);
50
+ }
51
+ }
@@ -262,8 +262,13 @@ RCT_EXPORT_METHOD(enumerateDevices : (RCTResponseSenderBlock)callback) {
262
262
  callback(@[]);
263
263
  #else
264
264
  NSMutableArray *devices = [NSMutableArray array];
265
+ NSMutableArray *deviceTypes = [NSMutableArray array];
266
+ [deviceTypes addObjectsFromArray:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInUltraWideCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera, AVCaptureDeviceTypeBuiltInDualCamera, AVCaptureDeviceTypeBuiltInDualWideCamera, AVCaptureDeviceTypeBuiltInTripleCamera]];
267
+ if (@available(macos 14.0, ios 17.0, tvos 17.0, *)) {
268
+ [deviceTypes addObject:AVCaptureDeviceTypeExternal];
269
+ }
265
270
  AVCaptureDeviceDiscoverySession *videoevicesSession =
266
- [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInUltraWideCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera, AVCaptureDeviceTypeBuiltInDualCamera, AVCaptureDeviceTypeBuiltInDualWideCamera, AVCaptureDeviceTypeBuiltInTripleCamera]
271
+ [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:deviceTypes
267
272
  mediaType:AVMediaTypeVideo
268
273
  position:AVCaptureDevicePositionUnspecified];
269
274
  for (AVCaptureDevice *device in videoevicesSession.devices) {
@@ -277,6 +282,7 @@ RCT_EXPORT_METHOD(enumerateDevices : (RCTResponseSenderBlock)callback) {
277
282
  if (device.localizedName != nil) {
278
283
  label = device.localizedName;
279
284
  }
285
+
280
286
  [devices addObject:@{
281
287
  @"facing" : position,
282
288
  @"deviceId" : device.uniqueID,
@@ -257,7 +257,7 @@ class RTCPeerConnection extends _index.EventTarget {
257
257
  if ((candidate.sdpMLineIndex === null || candidate.sdpMLineIndex === undefined) && (candidate.sdpMid === null || candidate.sdpMid === undefined)) {
258
258
  throw new TypeError('`sdpMLineIndex` and `sdpMid` must not be both null or undefined');
259
259
  }
260
- const newSdp = await WebRTCModule.peerConnectionAddICECandidate(this._pcId, candidate.toJSON ? candidate.toJSON() : candidate);
260
+ const newSdp = await WebRTCModule.peerConnectionAddICECandidate(this._pcId, RTCUtil.deepClone(candidate));
261
261
  this.remoteDescription = new _RTCSessionDescription.default(newSdp);
262
262
  }
263
263
 
@@ -611,13 +611,16 @@ class RTCPeerConnection extends _index.EventTarget {
611
611
  * instance such as id
612
612
  */
613
613
  createDataChannel(label, dataChannelDict) {
614
+ if (arguments.length === 0) {
615
+ throw new TypeError('1 argument required, but 0 present');
616
+ }
614
617
  if (dataChannelDict && 'id' in dataChannelDict) {
615
618
  const id = dataChannelDict.id;
616
619
  if (typeof id !== 'number') {
617
620
  throw new TypeError('DataChannel id must be a number: ' + id);
618
621
  }
619
622
  }
620
- const channelInfo = WebRTCModule.createDataChannel(this._pcId, label, dataChannelDict);
623
+ const channelInfo = WebRTCModule.createDataChannel(this._pcId, String(label), dataChannelDict);
621
624
  if (channelInfo === null) {
622
625
  throw new TypeError('Failed to create new DataChannel');
623
626
  }