react-native-webrtc 106.0.5 → 106.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +11 -0
- package/LICENSE +2 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +0 -1
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +7 -15
- package/android/src/main/java/com/oney/WebRTCModule/CameraEventsHandler.java +3 -12
- package/android/src/main/java/com/oney/WebRTCModule/DataChannelWrapper.java +12 -16
- package/android/src/main/java/com/oney/WebRTCModule/DisplayUtils.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/EglUtils.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +29 -43
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +123 -116
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +60 -61
- package/android/src/main/java/com/oney/WebRTCModule/ReactBridgeUtil.java +1 -2
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +11 -13
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +116 -119
- package/android/src/main/java/com/oney/WebRTCModule/StringUtils.java +8 -14
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +1 -2
- package/android/src/main/java/com/oney/WebRTCModule/TrackCapturerEventsEmitter.java +3 -4
- package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +5 -9
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +335 -350
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModulePackage.java +4 -10
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +74 -98
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +10 -9
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +2 -6
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +4 -5
- package/ios/RCTWebRTC/CaptureController.h +2 -9
- package/ios/RCTWebRTC/CaptureController.m +0 -7
- package/ios/RCTWebRTC/DataChannelWrapper.h +9 -13
- package/ios/RCTWebRTC/DataChannelWrapper.m +4 -5
- package/ios/RCTWebRTC/RCTConvert+WebRTC.h +2 -2
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +166 -171
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.h +1 -1
- package/ios/RCTWebRTC/RTCMediaStreamTrack+React.m +1 -1
- package/ios/RCTWebRTC/RTCVideoViewManager.h +0 -8
- package/ios/RCTWebRTC/RTCVideoViewManager.m +205 -214
- package/ios/RCTWebRTC/ScreenCaptureController.h +2 -9
- package/ios/RCTWebRTC/ScreenCaptureController.m +10 -16
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.h +0 -7
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +26 -34
- package/ios/RCTWebRTC/ScreenCapturer.h +1 -8
- package/ios/RCTWebRTC/ScreenCapturer.m +56 -55
- package/ios/RCTWebRTC/SerializeUtils.h +16 -16
- package/ios/RCTWebRTC/SerializeUtils.m +98 -99
- package/ios/RCTWebRTC/SocketConnection.h +1 -8
- package/ios/RCTWebRTC/SocketConnection.m +31 -38
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.h +4 -4
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.m +5 -6
- package/ios/RCTWebRTC/VideoCaptureController.h +6 -7
- package/ios/RCTWebRTC/VideoCaptureController.m +54 -53
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +14 -13
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.h +3 -3
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +105 -100
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +3 -2
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +196 -226
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +7 -14
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +625 -603
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +128 -139
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +4 -5
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +26 -35
- package/ios/RCTWebRTC/WebRTCModule.h +13 -20
- package/ios/RCTWebRTC/WebRTCModule.m +69 -84
- package/ios/RCTWebRTC.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/RTCPeerConnection.js +79 -56
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +79 -56
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/typescript/RTCPeerConnection.d.ts +4 -4
- package/package.json +3 -2
- package/src/RTCPeerConnection.ts +70 -63
- package/src/RTCRtpTransceiver.ts +1 -1
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
package/.clang-format
ADDED
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2017-present React Native WebRTC Community
|
|
4
|
+
Copyright (c) 2015-2017 Howard Yang
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -15,8 +15,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
15
15
|
/**
|
|
16
16
|
* The {@link Log} tag with which {@code CameraCaptureController} is to log.
|
|
17
17
|
*/
|
|
18
|
-
private static final String TAG
|
|
19
|
-
= CameraCaptureController.class.getSimpleName();
|
|
18
|
+
private static final String TAG = CameraCaptureController.class.getSimpleName();
|
|
20
19
|
|
|
21
20
|
private boolean isFrontFacing;
|
|
22
21
|
|
|
@@ -32,10 +31,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
32
31
|
private final CameraEventsHandler cameraEventsHandler = new CameraEventsHandler();
|
|
33
32
|
|
|
34
33
|
public CameraCaptureController(CameraEnumerator cameraEnumerator, ReadableMap constraints) {
|
|
35
|
-
super(
|
|
36
|
-
constraints.getInt("width"),
|
|
37
|
-
constraints.getInt("height"),
|
|
38
|
-
constraints.getInt("frameRate"));
|
|
34
|
+
super(constraints.getInt("width"), constraints.getInt("height"), constraints.getInt("frameRate"));
|
|
39
35
|
|
|
40
36
|
this.cameraEnumerator = cameraEnumerator;
|
|
41
37
|
this.constraints = constraints;
|
|
@@ -95,7 +91,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
95
91
|
@Override
|
|
96
92
|
public void onCameraSwitchDone(boolean b) {
|
|
97
93
|
if (b != desiredFrontFacing) {
|
|
98
|
-
int newTries = tries-1;
|
|
94
|
+
int newTries = tries - 1;
|
|
99
95
|
if (newTries > 0) {
|
|
100
96
|
switchCamera(desiredFrontFacing, newTries);
|
|
101
97
|
}
|
|
@@ -138,8 +134,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
138
134
|
|
|
139
135
|
// If deviceId is specified, then it takes precedence over facingMode.
|
|
140
136
|
if (cameraName != null) {
|
|
141
|
-
VideoCapturer videoCapturer
|
|
142
|
-
= cameraEnumerator.createCapturer(cameraName, cameraEventsHandler);
|
|
137
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(cameraName, cameraEventsHandler);
|
|
143
138
|
String message = "Create user-specified camera " + cameraName;
|
|
144
139
|
if (videoCapturer != null) {
|
|
145
140
|
Log.d(TAG, message + " succeeded");
|
|
@@ -153,8 +148,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
// Otherwise, use facingMode (defaulting to front/user facing).
|
|
156
|
-
final boolean isFrontFacing
|
|
157
|
-
= facingMode == null || !facingMode.equals("environment");
|
|
151
|
+
final boolean isFrontFacing = facingMode == null || !facingMode.equals("environment");
|
|
158
152
|
for (String name : deviceNames) {
|
|
159
153
|
if (failedDevices.contains(name)) {
|
|
160
154
|
continue;
|
|
@@ -162,8 +156,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
162
156
|
if (cameraEnumerator.isFrontFacing(name) != isFrontFacing) {
|
|
163
157
|
continue;
|
|
164
158
|
}
|
|
165
|
-
VideoCapturer videoCapturer
|
|
166
|
-
= cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
159
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
167
160
|
String message = "Create camera " + name;
|
|
168
161
|
if (videoCapturer != null) {
|
|
169
162
|
Log.d(TAG, message + " succeeded");
|
|
@@ -178,8 +171,7 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
178
171
|
// Fallback to any available camera.
|
|
179
172
|
for (String name : deviceNames) {
|
|
180
173
|
if (!failedDevices.contains(name)) {
|
|
181
|
-
VideoCapturer videoCapturer
|
|
182
|
-
= cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
174
|
+
VideoCapturer videoCapturer = cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
183
175
|
String message = "Create fallback camera " + name;
|
|
184
176
|
if (videoCapturer != null) {
|
|
185
177
|
Log.d(TAG, message + " succeeded");
|
|
@@ -26,28 +26,19 @@ class CameraEventsHandler implements CameraVideoCapturer.CameraEventsHandler {
|
|
|
26
26
|
// camera exception happens on camera thread.
|
|
27
27
|
@Override
|
|
28
28
|
public void onCameraError(String errorDescription) {
|
|
29
|
-
Log.d(
|
|
30
|
-
TAG,
|
|
31
|
-
"CameraEventsHandler.onCameraError: errorDescription="
|
|
32
|
-
+ errorDescription);
|
|
29
|
+
Log.d(TAG, "CameraEventsHandler.onCameraError: errorDescription=" + errorDescription);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
// Invoked when camera stops receiving frames
|
|
36
33
|
@Override
|
|
37
34
|
public void onCameraFreezed(String errorDescription) {
|
|
38
|
-
Log.d(
|
|
39
|
-
TAG,
|
|
40
|
-
"CameraEventsHandler.onCameraFreezed: errorDescription="
|
|
41
|
-
+ errorDescription);
|
|
35
|
+
Log.d(TAG, "CameraEventsHandler.onCameraFreezed: errorDescription=" + errorDescription);
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
// Callback invoked when camera is opening.
|
|
45
39
|
@Override
|
|
46
40
|
public void onCameraOpening(String cameraName) {
|
|
47
|
-
Log.d(
|
|
48
|
-
TAG,
|
|
49
|
-
"CameraEventsHandler.onCameraOpening: cameraName="
|
|
50
|
-
+ cameraName);
|
|
41
|
+
Log.d(TAG, "CameraEventsHandler.onCameraOpening: cameraName=" + cameraName);
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
// Callback invoked when first camera frame is available after camera is opened.
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
package com.oney.WebRTCModule;
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import android.util.Base64;
|
|
4
4
|
|
|
5
5
|
import androidx.annotation.Nullable;
|
|
6
|
-
import android.util.Base64;
|
|
7
6
|
|
|
8
7
|
import com.facebook.react.bridge.Arguments;
|
|
9
8
|
import com.facebook.react.bridge.WritableMap;
|
|
10
9
|
|
|
11
10
|
import org.webrtc.DataChannel;
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
import java.nio.charset.StandardCharsets;
|
|
14
13
|
|
|
14
|
+
class DataChannelWrapper implements DataChannel.Observer {
|
|
15
15
|
private final String reactTag;
|
|
16
16
|
private final DataChannel mDataChannel;
|
|
17
17
|
private final int peerConnectionId;
|
|
18
18
|
private final WebRTCModule webRTCModule;
|
|
19
19
|
|
|
20
|
-
DataChannelWrapper(
|
|
21
|
-
WebRTCModule webRTCModule,
|
|
22
|
-
int peerConnectionId,
|
|
23
|
-
String reactTag,
|
|
24
|
-
DataChannel dataChannel) {
|
|
20
|
+
DataChannelWrapper(WebRTCModule webRTCModule, int peerConnectionId, String reactTag, DataChannel dataChannel) {
|
|
25
21
|
this.webRTCModule = webRTCModule;
|
|
26
22
|
this.peerConnectionId = peerConnectionId;
|
|
27
23
|
this.reactTag = reactTag;
|
|
@@ -39,14 +35,14 @@ class DataChannelWrapper implements DataChannel.Observer {
|
|
|
39
35
|
@Nullable
|
|
40
36
|
public String dataChannelStateString(DataChannel.State dataChannelState) {
|
|
41
37
|
switch (dataChannelState) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
case CONNECTING:
|
|
39
|
+
return "connecting";
|
|
40
|
+
case OPEN:
|
|
41
|
+
return "open";
|
|
42
|
+
case CLOSING:
|
|
43
|
+
return "closing";
|
|
44
|
+
case CLOSED:
|
|
45
|
+
return "closed";
|
|
50
46
|
}
|
|
51
47
|
return null;
|
|
52
48
|
}
|
|
@@ -9,7 +9,7 @@ public class DisplayUtils {
|
|
|
9
9
|
public static DisplayMetrics getDisplayMetrics(Activity activity) {
|
|
10
10
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
11
11
|
WindowManager windowManager =
|
|
12
|
-
|
|
12
|
+
(WindowManager) activity.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
|
13
13
|
windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
|
|
14
14
|
return displayMetrics;
|
|
15
15
|
}
|
|
@@ -17,18 +17,17 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
17
17
|
import com.facebook.react.bridge.UiThreadUtil;
|
|
18
18
|
import com.facebook.react.bridge.WritableArray;
|
|
19
19
|
import com.facebook.react.bridge.WritableMap;
|
|
20
|
-
|
|
21
20
|
import com.oney.WebRTCModule.videoEffects.ProcessorProvider;
|
|
22
21
|
import com.oney.WebRTCModule.videoEffects.VideoEffectProcessor;
|
|
23
22
|
import com.oney.WebRTCModule.videoEffects.VideoFrameProcessor;
|
|
24
23
|
|
|
24
|
+
import org.webrtc.*;
|
|
25
|
+
|
|
25
26
|
import java.util.ArrayList;
|
|
26
27
|
import java.util.HashMap;
|
|
27
28
|
import java.util.Map;
|
|
28
29
|
import java.util.UUID;
|
|
29
30
|
|
|
30
|
-
import org.webrtc.*;
|
|
31
|
-
|
|
32
31
|
/**
|
|
33
32
|
* The implementation of {@code getUserMedia} extracted into a separate file in
|
|
34
33
|
* order to reduce complexity and to (somewhat) separate concerns.
|
|
@@ -65,8 +64,8 @@ class GetUserMediaImpl {
|
|
|
65
64
|
try {
|
|
66
65
|
camera2supported = Camera2Enumerator.isSupported(reactContext);
|
|
67
66
|
} catch (Throwable tr) {
|
|
68
|
-
// Some devices will crash here with: Fatal Exception: java.lang.AssertionError: Supported FPS ranges cannot
|
|
69
|
-
// Make sure we don't.
|
|
67
|
+
// Some devices will crash here with: Fatal Exception: java.lang.AssertionError: Supported FPS ranges cannot
|
|
68
|
+
// be null. Make sure we don't.
|
|
70
69
|
Log.w(TAG, "Error checking for Camera2 API support.", tr);
|
|
71
70
|
}
|
|
72
71
|
|
|
@@ -105,17 +104,15 @@ class GetUserMediaImpl {
|
|
|
105
104
|
PeerConnectionFactory pcFactory = webRTCModule.mFactory;
|
|
106
105
|
MediaConstraints peerConstraints = webRTCModule.constraintsForOptions(audioConstraintsMap);
|
|
107
106
|
|
|
108
|
-
//PeerConnectionFactory.createAudioSource will throw an error when mandatory constraints contain nulls.
|
|
109
|
-
//so, let's check for nulls
|
|
107
|
+
// PeerConnectionFactory.createAudioSource will throw an error when mandatory constraints contain nulls.
|
|
108
|
+
// so, let's check for nulls
|
|
110
109
|
checkMandatoryConstraints(peerConstraints);
|
|
111
110
|
|
|
112
111
|
AudioSource audioSource = pcFactory.createAudioSource(peerConstraints);
|
|
113
112
|
AudioTrack track = pcFactory.createAudioTrack(id, audioSource);
|
|
114
|
-
|
|
113
|
+
|
|
115
114
|
// surfaceTextureHelper is initialized for videoTrack only, so its null here.
|
|
116
|
-
tracks.put(
|
|
117
|
-
id,
|
|
118
|
-
new TrackPrivate(track, audioSource, /* videoCapturer */ null, /* surfaceTextureHelper */ null));
|
|
115
|
+
tracks.put(id, new TrackPrivate(track, audioSource, /* videoCapturer */ null, /* surfaceTextureHelper */ null));
|
|
119
116
|
|
|
120
117
|
return track;
|
|
121
118
|
}
|
|
@@ -127,8 +124,7 @@ class GetUserMediaImpl {
|
|
|
127
124
|
if (constraint.getValue() != null) {
|
|
128
125
|
valid.add(constraint);
|
|
129
126
|
} else {
|
|
130
|
-
Log.d(TAG, String.format("constraint %s is null, ignoring it",
|
|
131
|
-
constraint.getKey()));
|
|
127
|
+
Log.d(TAG, String.format("constraint %s is null, ignoring it", constraint.getKey()));
|
|
132
128
|
}
|
|
133
129
|
}
|
|
134
130
|
|
|
@@ -182,11 +178,7 @@ class GetUserMediaImpl {
|
|
|
182
178
|
* if audio permission was not granted, there will be no "audio" key in
|
|
183
179
|
* the constraints map.
|
|
184
180
|
*/
|
|
185
|
-
void getUserMedia(
|
|
186
|
-
final ReadableMap constraints,
|
|
187
|
-
final Callback successCallback,
|
|
188
|
-
final Callback errorCallback) {
|
|
189
|
-
|
|
181
|
+
void getUserMedia(final ReadableMap constraints, final Callback successCallback, final Callback errorCallback) {
|
|
190
182
|
AudioTrack audioTrack = null;
|
|
191
183
|
VideoTrack videoTrack = null;
|
|
192
184
|
|
|
@@ -199,9 +191,8 @@ class GetUserMediaImpl {
|
|
|
199
191
|
|
|
200
192
|
Log.d(TAG, "getUserMedia(video): " + videoConstraintsMap);
|
|
201
193
|
|
|
202
|
-
CameraCaptureController cameraCaptureController =
|
|
203
|
-
|
|
204
|
-
videoConstraintsMap);
|
|
194
|
+
CameraCaptureController cameraCaptureController =
|
|
195
|
+
new CameraCaptureController(cameraEnumerator, videoConstraintsMap);
|
|
205
196
|
|
|
206
197
|
videoTrack = createVideoTrack(cameraCaptureController);
|
|
207
198
|
}
|
|
@@ -213,7 +204,7 @@ class GetUserMediaImpl {
|
|
|
213
204
|
return;
|
|
214
205
|
}
|
|
215
206
|
|
|
216
|
-
createStream(new MediaStreamTrack[]{audioTrack, videoTrack}, (streamId, tracksInfo) -> {
|
|
207
|
+
createStream(new MediaStreamTrack[] {audioTrack, videoTrack}, (streamId, tracksInfo) -> {
|
|
217
208
|
WritableArray tracksInfoWritableArray = Arguments.createArray();
|
|
218
209
|
|
|
219
210
|
for (WritableMap trackInfo : tracksInfo) {
|
|
@@ -265,15 +256,15 @@ class GetUserMediaImpl {
|
|
|
265
256
|
this.displayMediaPromise = promise;
|
|
266
257
|
|
|
267
258
|
MediaProjectionManager mediaProjectionManager =
|
|
268
|
-
|
|
269
|
-
|
|
259
|
+
(MediaProjectionManager) currentActivity.getApplication().getSystemService(
|
|
260
|
+
Context.MEDIA_PROJECTION_SERVICE);
|
|
270
261
|
|
|
271
262
|
if (mediaProjectionManager != null) {
|
|
272
263
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
|
273
264
|
@Override
|
|
274
265
|
public void run() {
|
|
275
266
|
currentActivity.startActivityForResult(
|
|
276
|
-
|
|
267
|
+
mediaProjectionManager.createScreenCaptureIntent(), PERMISSION_REQUEST_CODE);
|
|
277
268
|
}
|
|
278
269
|
});
|
|
279
270
|
|
|
@@ -288,7 +279,7 @@ class GetUserMediaImpl {
|
|
|
288
279
|
if (track == null) {
|
|
289
280
|
displayMediaPromise.reject(new RuntimeException("ScreenTrack is null."));
|
|
290
281
|
} else {
|
|
291
|
-
createStream(new MediaStreamTrack[]{track}, (streamId, tracksInfo) -> {
|
|
282
|
+
createStream(new MediaStreamTrack[] {track}, (streamId, tracksInfo) -> {
|
|
292
283
|
WritableMap data = Arguments.createMap();
|
|
293
284
|
|
|
294
285
|
data.putString("streamId", streamId);
|
|
@@ -357,8 +348,8 @@ class GetUserMediaImpl {
|
|
|
357
348
|
DisplayMetrics displayMetrics = DisplayUtils.getDisplayMetrics(reactContext.getCurrentActivity());
|
|
358
349
|
int width = displayMetrics.widthPixels;
|
|
359
350
|
int height = displayMetrics.heightPixels;
|
|
360
|
-
ScreenCaptureController screenCaptureController
|
|
361
|
-
|
|
351
|
+
ScreenCaptureController screenCaptureController = new ScreenCaptureController(
|
|
352
|
+
reactContext.getCurrentActivity(), width, height, mediaProjectionPermissionResultData);
|
|
362
353
|
return createVideoTrack(screenCaptureController);
|
|
363
354
|
}
|
|
364
355
|
|
|
@@ -372,8 +363,7 @@ class GetUserMediaImpl {
|
|
|
372
363
|
|
|
373
364
|
PeerConnectionFactory pcFactory = webRTCModule.mFactory;
|
|
374
365
|
EglBase.Context eglContext = EglUtils.getRootEglBaseContext();
|
|
375
|
-
SurfaceTextureHelper surfaceTextureHelper =
|
|
376
|
-
SurfaceTextureHelper.create("CaptureThread", eglContext);
|
|
366
|
+
SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglContext);
|
|
377
367
|
|
|
378
368
|
if (surfaceTextureHelper == null) {
|
|
379
369
|
Log.d(TAG, "Error creating SurfaceTextureHelper");
|
|
@@ -419,14 +409,13 @@ class GetUserMediaImpl {
|
|
|
419
409
|
return;
|
|
420
410
|
}
|
|
421
411
|
|
|
422
|
-
VideoEffectProcessor videoEffectProcessor =
|
|
423
|
-
surfaceTextureHelper);
|
|
412
|
+
VideoEffectProcessor videoEffectProcessor =
|
|
413
|
+
new VideoEffectProcessor(videoFrameProcessor, surfaceTextureHelper);
|
|
424
414
|
videoSource.setVideoProcessor(videoEffectProcessor);
|
|
425
415
|
|
|
426
416
|
} else {
|
|
427
417
|
videoSource.setVideoProcessor(null);
|
|
428
418
|
}
|
|
429
|
-
|
|
430
419
|
}
|
|
431
420
|
}
|
|
432
421
|
|
|
@@ -447,7 +436,7 @@ class GetUserMediaImpl {
|
|
|
447
436
|
* if {@link #track} is a {@link VideoTrack}.
|
|
448
437
|
*/
|
|
449
438
|
public final AbstractVideoCaptureController videoCaptureController;
|
|
450
|
-
|
|
439
|
+
|
|
451
440
|
private final SurfaceTextureHelper surfaceTextureHelper;
|
|
452
441
|
|
|
453
442
|
/**
|
|
@@ -465,11 +454,8 @@ class GetUserMediaImpl {
|
|
|
465
454
|
* specified {@code mediaSource} was created if the specified
|
|
466
455
|
* {@code track} is a {@link VideoTrack}
|
|
467
456
|
*/
|
|
468
|
-
public TrackPrivate(
|
|
469
|
-
|
|
470
|
-
MediaSource mediaSource,
|
|
471
|
-
AbstractVideoCaptureController videoCaptureController,
|
|
472
|
-
SurfaceTextureHelper surfaceTextureHelper) {
|
|
457
|
+
public TrackPrivate(MediaStreamTrack track, MediaSource mediaSource,
|
|
458
|
+
AbstractVideoCaptureController videoCaptureController, SurfaceTextureHelper surfaceTextureHelper) {
|
|
473
459
|
this.track = track;
|
|
474
460
|
this.mediaSource = mediaSource;
|
|
475
461
|
this.videoCaptureController = videoCaptureController;
|
|
@@ -484,18 +470,18 @@ class GetUserMediaImpl {
|
|
|
484
470
|
videoCaptureController.dispose();
|
|
485
471
|
}
|
|
486
472
|
}
|
|
487
|
-
|
|
473
|
+
|
|
488
474
|
/*
|
|
489
475
|
* As per webrtc library documentation - The caller still has ownership of {@code
|
|
490
476
|
* surfaceTextureHelper} and is responsible for making sure surfaceTextureHelper.dispose() is
|
|
491
477
|
* called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new
|
|
492
478
|
* VideoCapturer once the previous VideoCapturer has been disposed. */
|
|
493
|
-
|
|
494
|
-
if(surfaceTextureHelper != null) {
|
|
479
|
+
|
|
480
|
+
if (surfaceTextureHelper != null) {
|
|
495
481
|
surfaceTextureHelper.stopListening();
|
|
496
482
|
surfaceTextureHelper.dispose();
|
|
497
483
|
}
|
|
498
|
-
|
|
484
|
+
|
|
499
485
|
mediaSource.dispose();
|
|
500
486
|
track.dispose();
|
|
501
487
|
disposed = true;
|