react-native-webrtc 124.0.5 → 124.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.
- package/.nvmrc +1 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +2 -1
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +7 -9
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +39 -19
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +11 -19
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +0 -2
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +4 -2
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +25 -0
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +1 -4
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +16 -12
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +37 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +15 -9
- package/android/src/main/java/org/webrtc/Camera1Helper.java +0 -1
- package/android/src/main/java/org/webrtc/Camera2Helper.java +4 -3
- package/ios/RCTWebRTC/CaptureController.h +1 -1
- package/ios/RCTWebRTC/CaptureController.m +6 -7
- package/ios/RCTWebRTC/I420Converter.h +3 -2
- package/ios/RCTWebRTC/I420Converter.m +55 -47
- package/ios/RCTWebRTC/PIPController.h +2 -2
- package/ios/RCTWebRTC/PIPController.m +29 -37
- package/ios/RCTWebRTC/RTCVideoViewManager.m +38 -17
- package/ios/RCTWebRTC/SampleBufferVideoCallView.h +2 -2
- package/ios/RCTWebRTC/SampleBufferVideoCallView.m +40 -42
- package/ios/RCTWebRTC/ScreenCaptureController.m +1 -5
- package/ios/RCTWebRTC/VideoCaptureController.h +1 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +6 -7
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +4 -8
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +31 -40
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +5 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +68 -22
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +26 -55
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +11 -28
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.h +9 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.h +13 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoFrameProcessor.h +8 -0
- package/lib/commonjs/MediaStreamTrack.js +5 -2
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/Permissions.js +3 -3
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCPIPView.js +3 -7
- package/lib/commonjs/RTCPIPView.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +2 -4
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +2 -3
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +5 -2
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/Permissions.js +3 -3
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCPIPView.js +3 -7
- package/lib/module/RTCPIPView.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +2 -4
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCUtil.js +2 -3
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/typescript/MediaStreamTrack.d.ts +1 -0
- package/lib/typescript/Permissions.d.ts +1 -1
- package/lib/typescript/RTCPIPView.d.ts +2 -1
- package/lib/typescript/RTCPeerConnection.d.ts +2 -1
- package/lib/typescript/RTCUtil.d.ts +7 -1
- package/lib/typescript/RTCView.d.ts +14 -0
- package/package.json +1 -1
- package/src/MediaStreamTrack.ts +6 -2
- package/src/Permissions.ts +3 -3
- package/src/RTCPIPView.tsx +3 -2
- package/src/RTCPeerConnection.ts +4 -5
- package/src/RTCUtil.ts +10 -3
- package/src/RTCView.ts +11 -1
- package/tools/release.sh +1 -1
- package/tools/build-webrtc.py +0 -344
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22
|
package/android/build.gradle
CHANGED
|
@@ -95,7 +95,8 @@ public abstract class AbstractVideoCaptureController {
|
|
|
95
95
|
|
|
96
96
|
public void applyConstraints(ReadableMap constraints, @Nullable Consumer<Exception> onFinishedCallback) {
|
|
97
97
|
if (onFinishedCallback != null) {
|
|
98
|
-
onFinishedCallback.accept(
|
|
98
|
+
onFinishedCallback.accept(
|
|
99
|
+
new UnsupportedOperationException("This video track does not support applyConstraints."));
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -4,6 +4,7 @@ import android.content.Context;
|
|
|
4
4
|
import android.hardware.camera2.CameraManager;
|
|
5
5
|
import android.util.Log;
|
|
6
6
|
import android.util.Pair;
|
|
7
|
+
|
|
7
8
|
import androidx.annotation.Nullable;
|
|
8
9
|
import androidx.core.util.Consumer;
|
|
9
10
|
|
|
@@ -46,7 +47,6 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
46
47
|
* {@link CameraEnumerator#createCapturer}.
|
|
47
48
|
*/
|
|
48
49
|
private final CameraEventsHandler cameraEventsHandler = new CameraEventsHandler() {
|
|
49
|
-
|
|
50
50
|
@Override
|
|
51
51
|
public void onCameraOpening(String cameraName) {
|
|
52
52
|
super.onCameraOpening(cameraName);
|
|
@@ -128,7 +128,6 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
132
131
|
// Otherwise, use facingMode (defaulting to front/user facing).
|
|
133
132
|
if (cameraName == null) {
|
|
134
133
|
cameraIndex = -1;
|
|
@@ -144,11 +143,12 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
144
143
|
|
|
145
144
|
if (cameraName == null) {
|
|
146
145
|
if (onFinishedCallback != null) {
|
|
147
|
-
onFinishedCallback.accept(new Exception("OverconstrainedError: could not find camera with deviceId: "
|
|
146
|
+
onFinishedCallback.accept(new Exception("OverconstrainedError: could not find camera with deviceId: "
|
|
147
|
+
+ deviceId + " or facingMode: " + facingMode));
|
|
148
148
|
}
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
// For lambda reference
|
|
153
153
|
final int finalCameraIndex = cameraIndex;
|
|
154
154
|
final String finalCameraName = cameraName;
|
|
@@ -164,9 +164,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
164
164
|
CameraVideoCapturer capturer = (CameraVideoCapturer) videoCapturer;
|
|
165
165
|
Runnable changeFormatIfNeededAndFinish = () -> {
|
|
166
166
|
saveConstraints.run();
|
|
167
|
-
if (targetWidth != oldTargetWidth ||
|
|
168
|
-
targetHeight != oldTargetHeight ||
|
|
169
|
-
targetFps != oldTargetFps) {
|
|
167
|
+
if (targetWidth != oldTargetWidth || targetHeight != oldTargetHeight || targetFps != oldTargetFps) {
|
|
170
168
|
updateActualSize(finalCameraIndex, finalCameraName, videoCapturer);
|
|
171
169
|
capturer.changeCaptureFormat(targetWidth, targetHeight, targetFps);
|
|
172
170
|
}
|
|
@@ -204,7 +202,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
204
202
|
String facingMode = ReactBridgeUtil.getMapStrValue(this.constraints, "facingMode");
|
|
205
203
|
|
|
206
204
|
CreateCapturerResult result = createVideoCapturer(deviceId, facingMode);
|
|
207
|
-
if(result == null) {
|
|
205
|
+
if (result == null) {
|
|
208
206
|
return null;
|
|
209
207
|
}
|
|
210
208
|
|
|
@@ -325,7 +323,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
325
323
|
public final int cameraIndex;
|
|
326
324
|
public final String cameraName;
|
|
327
325
|
public final VideoCapturer videoCapturer;
|
|
328
|
-
|
|
326
|
+
|
|
329
327
|
public CreateCapturerResult(int cameraIndex, String cameraName, VideoCapturer videoCapturer) {
|
|
330
328
|
this.cameraIndex = cameraIndex;
|
|
331
329
|
this.cameraName = cameraName;
|
|
@@ -6,6 +6,7 @@ import android.content.Intent;
|
|
|
6
6
|
import android.media.projection.MediaProjectionManager;
|
|
7
7
|
import android.util.DisplayMetrics;
|
|
8
8
|
import android.util.Log;
|
|
9
|
+
|
|
9
10
|
import androidx.core.util.Consumer;
|
|
10
11
|
|
|
11
12
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -26,8 +27,11 @@ import org.webrtc.*;
|
|
|
26
27
|
|
|
27
28
|
import java.util.ArrayList;
|
|
28
29
|
import java.util.HashMap;
|
|
30
|
+
import java.util.List;
|
|
29
31
|
import java.util.Map;
|
|
32
|
+
import java.util.Objects;
|
|
30
33
|
import java.util.UUID;
|
|
34
|
+
import java.util.stream.Collectors;
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* The implementation of {@code getUserMedia} extracted into a separate file in
|
|
@@ -192,8 +196,14 @@ class GetUserMediaImpl {
|
|
|
192
196
|
|
|
193
197
|
Log.d(TAG, "getUserMedia(video): " + videoConstraintsMap);
|
|
194
198
|
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
Activity currentActivity = this.reactContext.getCurrentActivity();
|
|
200
|
+
if (currentActivity == null) {
|
|
201
|
+
errorCallback.invoke("Error", "No current Activity.");
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
CameraCaptureController cameraCaptureController = new CameraCaptureController(
|
|
206
|
+
currentActivity, getCameraEnumerator(), videoConstraintsMap);
|
|
197
207
|
|
|
198
208
|
videoTrack = createVideoTrack(cameraCaptureController);
|
|
199
209
|
}
|
|
@@ -237,10 +247,11 @@ class GetUserMediaImpl {
|
|
|
237
247
|
void applyConstraints(String trackId, ReadableMap constraints, Promise promise) {
|
|
238
248
|
TrackPrivate track = tracks.get(trackId);
|
|
239
249
|
if (track != null && track.videoCaptureController instanceof AbstractVideoCaptureController) {
|
|
240
|
-
AbstractVideoCaptureController captureController =
|
|
250
|
+
AbstractVideoCaptureController captureController =
|
|
251
|
+
(AbstractVideoCaptureController) track.videoCaptureController;
|
|
241
252
|
captureController.applyConstraints(constraints, new Consumer<Exception>() {
|
|
242
253
|
public void accept(Exception e) {
|
|
243
|
-
if(e != null) {
|
|
254
|
+
if (e != null) {
|
|
244
255
|
promise.reject(e);
|
|
245
256
|
return;
|
|
246
257
|
}
|
|
@@ -403,28 +414,35 @@ class GetUserMediaImpl {
|
|
|
403
414
|
}
|
|
404
415
|
|
|
405
416
|
/**
|
|
406
|
-
* Set video
|
|
407
|
-
* corresponding to the
|
|
417
|
+
* Set video effects to the TrackPrivate corresponding to the trackId with the help of VideoEffectProcessor
|
|
418
|
+
* corresponding to the names.
|
|
408
419
|
* @param trackId TrackPrivate id
|
|
409
|
-
* @param
|
|
420
|
+
* @param names VideoEffectProcessor names
|
|
410
421
|
*/
|
|
411
|
-
void
|
|
422
|
+
void setVideoEffects(String trackId, ReadableArray names) {
|
|
412
423
|
TrackPrivate track = tracks.get(trackId);
|
|
413
424
|
|
|
414
425
|
if (track != null && track.videoCaptureController instanceof CameraCaptureController) {
|
|
415
426
|
VideoSource videoSource = (VideoSource) track.mediaSource;
|
|
416
427
|
SurfaceTextureHelper surfaceTextureHelper = track.surfaceTextureHelper;
|
|
417
428
|
|
|
418
|
-
if (
|
|
419
|
-
VideoFrameProcessor
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
429
|
+
if (names != null) {
|
|
430
|
+
List<VideoFrameProcessor> processors =
|
|
431
|
+
names.toArrayList()
|
|
432
|
+
.stream()
|
|
433
|
+
.filter(name -> name instanceof String)
|
|
434
|
+
.map(name -> {
|
|
435
|
+
VideoFrameProcessor videoFrameProcessor =
|
|
436
|
+
ProcessorProvider.getProcessor((String) name);
|
|
437
|
+
if (videoFrameProcessor == null) {
|
|
438
|
+
Log.e(TAG, "no videoFrameProcessor associated with this name: " + name);
|
|
439
|
+
}
|
|
440
|
+
return videoFrameProcessor;
|
|
441
|
+
})
|
|
442
|
+
.filter(Objects::nonNull)
|
|
443
|
+
.collect(Collectors.toList());
|
|
444
|
+
|
|
445
|
+
VideoEffectProcessor videoEffectProcessor = new VideoEffectProcessor(processors, surfaceTextureHelper);
|
|
428
446
|
videoSource.setVideoProcessor(videoEffectProcessor);
|
|
429
447
|
|
|
430
448
|
} else {
|
|
@@ -503,5 +521,7 @@ class GetUserMediaImpl {
|
|
|
503
521
|
}
|
|
504
522
|
}
|
|
505
523
|
|
|
506
|
-
public interface BiConsumer<T, U> {
|
|
524
|
+
public interface BiConsumer<T, U> {
|
|
525
|
+
void accept(T t, U u);
|
|
526
|
+
}
|
|
507
527
|
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
package com.oney.WebRTCModule;
|
|
2
2
|
|
|
3
3
|
import android.app.Notification;
|
|
4
|
-
import android.app.Service;
|
|
5
|
-
import android.content.Context;
|
|
6
|
-
|
|
7
|
-
import androidx.core.app.NotificationCompat;
|
|
8
|
-
|
|
9
4
|
import android.app.NotificationChannel;
|
|
10
5
|
import android.app.NotificationManager;
|
|
11
|
-
|
|
6
|
+
import android.app.Service;
|
|
7
|
+
import android.content.Context;
|
|
12
8
|
import android.os.Build;
|
|
13
|
-
|
|
14
9
|
import android.util.Log;
|
|
15
10
|
|
|
11
|
+
import androidx.core.app.NotificationCompat;
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Helper class for creating the media projection notification which is used with
|
|
@@ -23,7 +19,6 @@ class MediaProjectionNotification {
|
|
|
23
19
|
|
|
24
20
|
static final String ONGOING_CONFERENCE_CHANNEL_ID = "OngoingConferenceChannel";
|
|
25
21
|
|
|
26
|
-
|
|
27
22
|
static void createNotificationChannel(Context context) {
|
|
28
23
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
29
24
|
return;
|
|
@@ -34,22 +29,19 @@ class MediaProjectionNotification {
|
|
|
34
29
|
return;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
NotificationManager notificationManager
|
|
38
|
-
|
|
32
|
+
NotificationManager notificationManager =
|
|
33
|
+
(NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
|
|
39
34
|
|
|
40
|
-
NotificationChannel channel
|
|
41
|
-
= notificationManager.getNotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID);
|
|
35
|
+
NotificationChannel channel = notificationManager.getNotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID);
|
|
42
36
|
|
|
43
37
|
if (channel != null) {
|
|
44
38
|
// The channel was already created, no need to do it again.
|
|
45
39
|
return;
|
|
46
40
|
}
|
|
47
41
|
|
|
48
|
-
channel = new NotificationChannel(
|
|
49
|
-
ONGOING_CONFERENCE_CHANNEL_ID,
|
|
42
|
+
channel = new NotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID,
|
|
50
43
|
context.getString(R.string.ongoing_notification_channel_name),
|
|
51
|
-
NotificationManager.IMPORTANCE_DEFAULT
|
|
52
|
-
);
|
|
44
|
+
NotificationManager.IMPORTANCE_DEFAULT);
|
|
53
45
|
channel.enableLights(false);
|
|
54
46
|
channel.enableVibration(false);
|
|
55
47
|
channel.setShowBadge(false);
|
|
@@ -60,8 +52,7 @@ class MediaProjectionNotification {
|
|
|
60
52
|
static Notification buildMediaProjectionNotification(Context context) {
|
|
61
53
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, ONGOING_CONFERENCE_CHANNEL_ID);
|
|
62
54
|
|
|
63
|
-
builder
|
|
64
|
-
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
55
|
+
builder.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
65
56
|
.setContentTitle(context.getString(R.string.media_projection_notification_title))
|
|
66
57
|
.setContentText(context.getString(R.string.media_projection_notification_text))
|
|
67
58
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
|
@@ -70,7 +61,8 @@ class MediaProjectionNotification {
|
|
|
70
61
|
.setAutoCancel(true)
|
|
71
62
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
|
72
63
|
.setOnlyAlertOnce(true)
|
|
73
|
-
.setSmallIcon(
|
|
64
|
+
.setSmallIcon(
|
|
65
|
+
context.getResources().getIdentifier("ic_notification", "drawable", context.getPackageName()))
|
|
74
66
|
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE);
|
|
75
67
|
|
|
76
68
|
return builder.build();
|
|
@@ -12,7 +12,6 @@ import android.util.Log;
|
|
|
12
12
|
|
|
13
13
|
import java.util.Random;
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
/**
|
|
17
16
|
* This class implements an Android {@link Service}, a foreground one specifically, and it's
|
|
18
17
|
* responsible for presenting an ongoing notification when a conference is in progress.
|
|
@@ -70,7 +69,6 @@ public class MediaProjectionService extends Service {
|
|
|
70
69
|
|
|
71
70
|
@Override
|
|
72
71
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
73
|
-
|
|
74
72
|
Notification notification = MediaProjectionNotification.buildMediaProjectionNotification(this);
|
|
75
73
|
|
|
76
74
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
@@ -250,7 +250,8 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
peerConnection.getStats(
|
|
253
|
+
peerConnection.getStats(
|
|
254
|
+
targetReceiver, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
public void senderGetStats(String senderId, Promise promise) {
|
|
@@ -268,7 +269,8 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
268
269
|
return;
|
|
269
270
|
}
|
|
270
271
|
|
|
271
|
-
peerConnection.getStats(
|
|
272
|
+
peerConnection.getStats(
|
|
273
|
+
targetSender, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
@Override
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
package com.oney.WebRTCModule;
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
3
4
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
4
5
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
5
6
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
7
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
8
|
+
|
|
9
|
+
import java.util.HashMap;
|
|
10
|
+
import java.util.Map;
|
|
6
11
|
|
|
7
12
|
public class RTCVideoViewManager extends SimpleViewManager<WebRTCView> {
|
|
8
13
|
private static final String REACT_CLASS = "RTCVideoView";
|
|
@@ -70,4 +75,24 @@ public class RTCVideoViewManager extends SimpleViewManager<WebRTCView> {
|
|
|
70
75
|
public void setZOrder(WebRTCView view, int zOrder) {
|
|
71
76
|
view.setZOrder(zOrder);
|
|
72
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Sets the callback for when video dimensions change.
|
|
81
|
+
*
|
|
82
|
+
* @param view The {@code WebRTCView} on which the callback is to be set.
|
|
83
|
+
* @param onDimensionsChange The callback to be called when video dimensions change.
|
|
84
|
+
*/
|
|
85
|
+
@ReactProp(name = "onDimensionsChange")
|
|
86
|
+
public void setOnDimensionsChange(WebRTCView view, boolean onDimensionsChange) {
|
|
87
|
+
view.setOnDimensionsChange(onDimensionsChange);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
92
|
+
Map<String, Object> eventTypeConstants = new HashMap<>();
|
|
93
|
+
Map<String, String> dimensionsChangeEvent = new HashMap<>();
|
|
94
|
+
dimensionsChangeEvent.put("registrationName", "onDimensionsChange");
|
|
95
|
+
eventTypeConstants.put("onDimensionsChange", dimensionsChangeEvent);
|
|
96
|
+
return eventTypeConstants;
|
|
97
|
+
}
|
|
73
98
|
}
|
|
@@ -25,10 +25,7 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
|
|
|
25
25
|
|
|
26
26
|
private final Context context;
|
|
27
27
|
|
|
28
|
-
public ScreenCaptureController(Context context,
|
|
29
|
-
int width,
|
|
30
|
-
int height,
|
|
31
|
-
Intent mediaProjectionPermissionResultData) {
|
|
28
|
+
public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData) {
|
|
32
29
|
super(width, height, DEFAULT_FPS);
|
|
33
30
|
|
|
34
31
|
this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
|
|
@@ -67,10 +67,10 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
67
67
|
String fieldTrials = options.fieldTrials;
|
|
68
68
|
|
|
69
69
|
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(reactContext)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
.setFieldTrials(fieldTrials)
|
|
71
|
+
.setNativeLibraryLoader(new LibraryLoader())
|
|
72
|
+
.setInjectableLogger(injectableLogger, loggingSeverity)
|
|
73
|
+
.createInitializationOptions());
|
|
74
74
|
|
|
75
75
|
if (injectableLogger == null && loggingSeverity != null) {
|
|
76
76
|
Logging.enableLogToDebugOutput(loggingSeverity);
|
|
@@ -706,7 +706,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
709
|
-
public
|
|
709
|
+
public boolean transceiverSetCodecPreferences(int id, String senderId, ReadableArray codecPreferences) {
|
|
710
710
|
ThreadUtils.runOnExecutor(() -> {
|
|
711
711
|
WritableMap identifier = Arguments.createMap();
|
|
712
712
|
WritableMap params = Arguments.createMap();
|
|
@@ -765,6 +765,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
765
765
|
Log.d(TAG, "transceiverSetCodecPreferences(): " + e.getMessage());
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
|
+
return true;
|
|
768
769
|
}
|
|
769
770
|
|
|
770
771
|
@ReactMethod
|
|
@@ -940,8 +941,8 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
940
941
|
}
|
|
941
942
|
|
|
942
943
|
@ReactMethod
|
|
943
|
-
public void
|
|
944
|
-
ThreadUtils.runOnExecutor(() -> { getUserMediaImpl.
|
|
944
|
+
public void mediaStreamTrackSetVideoEffects(String id, ReadableArray names) {
|
|
945
|
+
ThreadUtils.runOnExecutor(() -> { getUserMediaImpl.setVideoEffects(id, names); });
|
|
945
946
|
}
|
|
946
947
|
|
|
947
948
|
@ReactMethod
|
|
@@ -1277,11 +1278,14 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
1277
1278
|
return;
|
|
1278
1279
|
}
|
|
1279
1280
|
|
|
1280
|
-
IceCandidate candidate = new IceCandidate(
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1281
|
+
IceCandidate candidate = new IceCandidate(candidateMap.hasKey("sdpMid") && !candidateMap.isNull("sdpMid")
|
|
1282
|
+
? candidateMap.getString("sdpMid")
|
|
1283
|
+
: "",
|
|
1284
|
+
candidateMap.hasKey("sdpMLineIndex") && !candidateMap.isNull("sdpMLineIndex")
|
|
1285
|
+
? candidateMap.getInt("sdpMLineIndex")
|
|
1286
|
+
: 0,
|
|
1287
|
+
candidateMap.getString("candidate"));
|
|
1288
|
+
|
|
1285
1289
|
peerConnection.addIceCandidate(candidate, new AddIceObserver() {
|
|
1286
1290
|
@Override
|
|
1287
1291
|
public void onAddSuccess() {
|
|
@@ -10,7 +10,12 @@ import android.view.ViewGroup;
|
|
|
10
10
|
|
|
11
11
|
import androidx.core.view.ViewCompat;
|
|
12
12
|
|
|
13
|
+
import com.facebook.react.bridge.Arguments;
|
|
14
|
+
import com.facebook.react.bridge.Callback;
|
|
13
15
|
import com.facebook.react.bridge.ReactContext;
|
|
16
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
17
|
+
import com.facebook.react.bridge.WritableMap;
|
|
18
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
14
19
|
|
|
15
20
|
import org.webrtc.EglBase;
|
|
16
21
|
import org.webrtc.Logging;
|
|
@@ -144,6 +149,11 @@ public class WebRTCView extends ViewGroup {
|
|
|
144
149
|
*/
|
|
145
150
|
private VideoTrack videoTrack;
|
|
146
151
|
|
|
152
|
+
/**
|
|
153
|
+
* The callback to be called when video dimensions change.
|
|
154
|
+
*/
|
|
155
|
+
private boolean onDimensionsChangeEnabled = false;
|
|
156
|
+
|
|
147
157
|
public WebRTCView(Context context) {
|
|
148
158
|
super(context);
|
|
149
159
|
|
|
@@ -257,6 +267,24 @@ public class WebRTCView extends ViewGroup {
|
|
|
257
267
|
// The onFrameResolutionChanged method call executes on the
|
|
258
268
|
// surfaceViewRenderer's render Thread.
|
|
259
269
|
post(requestSurfaceViewRendererLayoutRunnable);
|
|
270
|
+
|
|
271
|
+
// Call the onDimensionsChange callback if it's enabled
|
|
272
|
+
if (onDimensionsChangeEnabled) {
|
|
273
|
+
post(() -> {
|
|
274
|
+
try {
|
|
275
|
+
ReactContext reactContext = (ReactContext) getContext();
|
|
276
|
+
WritableMap params = Arguments.createMap();
|
|
277
|
+
params.putInt("width", videoWidth);
|
|
278
|
+
params.putInt("height", videoHeight);
|
|
279
|
+
|
|
280
|
+
// Send the event through React Native's event system
|
|
281
|
+
reactContext.getJSModule(RCTEventEmitter.class)
|
|
282
|
+
.receiveEvent(getId(), "onDimensionsChange", params);
|
|
283
|
+
} catch (Exception e) {
|
|
284
|
+
Log.e(TAG, "Error calling onDimensionsChange callback", e);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
260
288
|
}
|
|
261
289
|
}
|
|
262
290
|
|
|
@@ -543,4 +571,13 @@ public class WebRTCView extends ViewGroup {
|
|
|
543
571
|
rendererAttached = true;
|
|
544
572
|
}
|
|
545
573
|
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Sets whether the onDimensionsChange callback should be called.
|
|
577
|
+
*
|
|
578
|
+
* @param enabled Whether the callback should be enabled.
|
|
579
|
+
*/
|
|
580
|
+
public void setOnDimensionsChange(boolean enabled) {
|
|
581
|
+
this.onDimensionsChangeEnabled = enabled;
|
|
582
|
+
}
|
|
546
583
|
}
|
|
@@ -5,6 +5,8 @@ import org.webrtc.VideoFrame;
|
|
|
5
5
|
import org.webrtc.VideoProcessor;
|
|
6
6
|
import org.webrtc.VideoSink;
|
|
7
7
|
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Lightweight abstraction for an object that can receive video frames, process and add effects in
|
|
10
12
|
* them, and pass them on to another object.
|
|
@@ -12,11 +14,11 @@ import org.webrtc.VideoSink;
|
|
|
12
14
|
public class VideoEffectProcessor implements VideoProcessor {
|
|
13
15
|
private VideoSink mSink;
|
|
14
16
|
final private SurfaceTextureHelper textureHelper;
|
|
15
|
-
final private VideoFrameProcessor
|
|
17
|
+
final private List<VideoFrameProcessor> videoFrameProcessors;
|
|
16
18
|
|
|
17
|
-
public VideoEffectProcessor(VideoFrameProcessor
|
|
19
|
+
public VideoEffectProcessor(List<VideoFrameProcessor> processors, SurfaceTextureHelper textureHelper) {
|
|
18
20
|
this.textureHelper = textureHelper;
|
|
19
|
-
this.
|
|
21
|
+
this.videoFrameProcessors = processors;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@Override
|
|
@@ -39,13 +41,17 @@ public class VideoEffectProcessor implements VideoProcessor {
|
|
|
39
41
|
@Override
|
|
40
42
|
public void onFrameCaptured(VideoFrame frame) {
|
|
41
43
|
frame.retain();
|
|
42
|
-
VideoFrame outputFrame =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
VideoFrame outputFrame = frame;
|
|
45
|
+
for (VideoFrameProcessor processor : this.videoFrameProcessors) {
|
|
46
|
+
outputFrame = processor.process(outputFrame, textureHelper);
|
|
47
|
+
|
|
48
|
+
if (outputFrame == null) {
|
|
49
|
+
mSink.onFrame(frame);
|
|
50
|
+
frame.release();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
48
53
|
}
|
|
54
|
+
|
|
49
55
|
mSink.onFrame(outputFrame);
|
|
50
56
|
outputFrame.release();
|
|
51
57
|
frame.release();
|
|
@@ -30,13 +30,14 @@ import java.util.List;
|
|
|
30
30
|
* by [CameraManager.getCameraIdList].
|
|
31
31
|
*/
|
|
32
32
|
public class Camera2Helper {
|
|
33
|
-
|
|
34
33
|
@Nullable
|
|
35
|
-
public static List<CameraEnumerationAndroid.CaptureFormat> getSupportedFormats(
|
|
34
|
+
public static List<CameraEnumerationAndroid.CaptureFormat> getSupportedFormats(
|
|
35
|
+
CameraManager cameraManager, @Nullable String cameraId) {
|
|
36
36
|
return Camera2Enumerator.getSupportedFormats(cameraManager, cameraId);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
public static Size findClosestCaptureFormat(
|
|
39
|
+
public static Size findClosestCaptureFormat(
|
|
40
|
+
CameraManager cameraManager, @Nullable String cameraId, int width, int height) {
|
|
40
41
|
List<CameraEnumerationAndroid.CaptureFormat> formats = getSupportedFormats(cameraManager, cameraId);
|
|
41
42
|
|
|
42
43
|
List<Size> sizes = new ArrayList<>();
|
|
@@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
6
6
|
@interface CaptureController : NSObject
|
|
7
7
|
|
|
8
8
|
@property(nonatomic, strong) id<CapturerEventsDelegate> eventsDelegate;
|
|
9
|
-
@property(nonatomic, copy, nullable) NSString*
|
|
9
|
+
@property(nonatomic, copy, nullable) NSString *deviceId;
|
|
10
10
|
|
|
11
11
|
- (void)startCapture;
|
|
12
12
|
- (void)stopCapture;
|
|
@@ -12,17 +12,16 @@
|
|
|
12
12
|
// subclasses needs to override
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
- (NSDictionary *)
|
|
15
|
+
- (NSDictionary *)getSettings {
|
|
16
16
|
// subclasses needs to override
|
|
17
|
-
return @{
|
|
18
|
-
@"deviceId": self.deviceId
|
|
19
|
-
};
|
|
17
|
+
return @{@"deviceId" : self.deviceId};
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
- (void)applyConstraints:(NSDictionary *)constraints error:(NSError **)outError {
|
|
23
|
-
*outError =
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
*outError =
|
|
22
|
+
[NSError errorWithDomain:@"react-native-webrtc"
|
|
23
|
+
code:0
|
|
24
|
+
userInfo:@{NSLocalizedDescriptionKey : @"This video track does not support applyConstraints."}];
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
@end
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// I420Converter.h
|
|
3
3
|
// VideoSampleCaptureRender
|
|
4
4
|
//
|
|
5
|
-
// Adapted from:
|
|
5
|
+
// Adapted from:
|
|
6
|
+
// https://github.com/twilio/video-ios-affectiva/blob/ed2e864324c40ad25e5a06cc2b05298b03caed09/EmoCall/I420Converter.h
|
|
6
7
|
// Created by Boisy Pitre on 5/21/16.
|
|
7
8
|
// Copyright © 2016 Twilio. All rights reserved.
|
|
8
9
|
//
|
|
9
10
|
|
|
10
|
-
#import <UIKit/UIKit.h>
|
|
11
11
|
#import <Accelerate/Accelerate.h>
|
|
12
|
+
#import <UIKit/UIKit.h>
|
|
12
13
|
#import <WebRTC/WebRTC.h>
|
|
13
14
|
|
|
14
15
|
@interface I420Converter : NSObject
|