react-native-webrtc 124.0.7 → 155.0.0
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/.claude/settings.local.json +9 -0
- package/.eslintignore +1 -0
- package/CLAUDE.md +714 -0
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +5 -3
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +84 -7
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +24 -3
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +4 -4
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +116 -27
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +56 -28
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +3 -3
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +21 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +22 -23
- package/ios/RCTWebRTC/SerializeUtils.m +6 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +40 -1
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +16 -9
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +2 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +95 -0
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +5 -1
- package/lib/commonjs/Constraints.js.map +1 -1
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +13 -12
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +14 -9
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamError.js.map +1 -1
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +28 -12
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/MediaStreamTrackEvent.js +2 -2
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
- package/lib/commonjs/MessageEvent.js +2 -2
- package/lib/commonjs/MessageEvent.js.map +1 -1
- package/lib/commonjs/Permissions.js +1 -2
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCAudioSession.js.map +1 -1
- package/lib/commonjs/RTCCertificate.js +25 -0
- package/lib/commonjs/RTCCertificate.js.map +1 -0
- package/lib/commonjs/RTCDataChannel.js +38 -13
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCDataChannelEvent.js +2 -2
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +2 -2
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCIceCandidateEvent.js +2 -2
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
- package/lib/commonjs/RTCPIPView.js +1 -2
- package/lib/commonjs/RTCPIPView.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +109 -27
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +17 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +2 -2
- package/lib/commonjs/RTCTrackEvent.js.map +1 -1
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js +1 -2
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/ScreenCapturePickerView.js +1 -2
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js +2 -1
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +22 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/vendor/event-target-shim/LICENSE +22 -0
- package/lib/commonjs/vendor/event-target-shim/index.js +1221 -0
- package/lib/commonjs/vendor/event-target-shim/index.js.map +1 -0
- package/lib/module/Constraints.js.map +1 -1
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +11 -9
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +13 -8
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamError.js.map +1 -1
- package/lib/module/MediaStreamErrorEvent.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +25 -9
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/MediaStreamTrackEvent.js +1 -1
- package/lib/module/MediaStreamTrackEvent.js.map +1 -1
- package/lib/module/MessageEvent.js +1 -1
- package/lib/module/MessageEvent.js.map +1 -1
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCAudioSession.js.map +1 -1
- package/lib/module/RTCCertificate.js +18 -0
- package/lib/module/RTCCertificate.js.map +1 -0
- package/lib/module/RTCDataChannel.js +37 -12
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCDataChannelEvent.js +1 -1
- package/lib/module/RTCDataChannelEvent.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +1 -1
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCIceCandidateEvent.js +1 -1
- package/lib/module/RTCIceCandidateEvent.js.map +1 -1
- package/lib/module/RTCPIPView.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +103 -21
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecCapability.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +17 -1
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +1 -1
- package/lib/module/RTCTrackEvent.js.map +1 -1
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/ScreenCapturePickerView.js.map +1 -1
- package/lib/module/getDisplayMedia.js +2 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/vendor/event-target-shim/LICENSE +22 -0
- package/lib/module/vendor/event-target-shim/index.js +1221 -0
- package/lib/module/vendor/event-target-shim/index.js.map +1 -0
- package/lib/typescript/MediaDevices.d.ts +8 -4
- package/lib/typescript/MediaStream.d.ts +5 -1
- package/lib/typescript/MediaStreamTrack.d.ts +7 -1
- package/lib/typescript/MediaStreamTrackEvent.d.ts +1 -1
- package/lib/typescript/MessageEvent.d.ts +1 -1
- package/lib/typescript/RTCCertificate.d.ts +16 -0
- package/lib/typescript/RTCDataChannel.d.ts +13 -1
- package/lib/typescript/RTCDataChannelEvent.d.ts +1 -1
- package/lib/typescript/RTCErrorEvent.d.ts +1 -1
- package/lib/typescript/RTCIceCandidateEvent.d.ts +1 -1
- package/lib/typescript/RTCPeerConnection.d.ts +30 -1
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +4 -0
- package/lib/typescript/RTCTrackEvent.d.ts +1 -1
- package/lib/typescript/getDisplayMedia.d.ts +7 -1
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/vendor/event-target-shim/index.d.ts +411 -0
- package/package.json +3 -4
- package/react-native-webrtc.podspec +2 -2
- package/src/MediaDevices.ts +15 -14
- package/src/MediaStream.ts +17 -9
- package/src/MediaStreamTrack.ts +30 -10
- package/src/MediaStreamTrackEvent.ts +2 -2
- package/src/MessageEvent.ts +1 -1
- package/src/RTCCertificate.ts +24 -0
- package/src/RTCDataChannel.ts +49 -14
- package/src/RTCDataChannelEvent.ts +2 -2
- package/src/RTCErrorEvent.ts +1 -1
- package/src/RTCIceCandidateEvent.ts +2 -2
- package/src/RTCPeerConnection.ts +138 -24
- package/src/RTCRtpEncodingParameters.ts +20 -0
- package/src/RTCTrackEvent.ts +1 -1
- package/src/getDisplayMedia.ts +9 -2
- package/src/index.ts +9 -2
- package/src/vendor/event-target-shim/LICENSE +22 -0
- package/src/vendor/event-target-shim/index.d.ts +411 -0
- package/src/vendor/event-target-shim/index.js +1186 -0
- package/tools/postbuild.mjs +67 -0
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Software encode/decode factories have been enabled by default.
|
|
|
39
39
|
|
|
40
40
|
## WebRTC Revision
|
|
41
41
|
|
|
42
|
-
* Currently used revision: [
|
|
42
|
+
* Currently used revision: [M155](https://github.com/jitsi/webrtc/tree/M155)
|
|
43
43
|
* Supported architectures
|
|
44
44
|
* Android: armeabi-v7a, arm64-v8a, x86, x86_64
|
|
45
45
|
* iOS: arm64, x86_64
|
package/android/build.gradle
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.oney.WebRTCModule;
|
|
2
2
|
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
3
5
|
import androidx.annotation.Nullable;
|
|
4
6
|
import androidx.core.util.Consumer;
|
|
5
7
|
|
|
@@ -10,6 +12,8 @@ import com.facebook.react.bridge.WritableMap;
|
|
|
10
12
|
import org.webrtc.VideoCapturer;
|
|
11
13
|
|
|
12
14
|
public abstract class AbstractVideoCaptureController {
|
|
15
|
+
private static final String TAG = AbstractVideoCaptureController.class.getSimpleName();
|
|
16
|
+
|
|
13
17
|
protected int targetWidth;
|
|
14
18
|
protected int targetHeight;
|
|
15
19
|
protected int targetFps;
|
|
@@ -78,9 +82,7 @@ public abstract class AbstractVideoCaptureController {
|
|
|
78
82
|
try {
|
|
79
83
|
videoCapturer.startCapture(targetWidth, targetHeight, targetFps);
|
|
80
84
|
} catch (RuntimeException e) {
|
|
81
|
-
|
|
82
|
-
// which we don't. Thus, ignore any failures here since we trust
|
|
83
|
-
// ourselves.
|
|
85
|
+
Log.e(TAG, "Failed to start capture", e);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -4,8 +4,10 @@ import android.app.Activity;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.content.Intent;
|
|
6
6
|
import android.media.projection.MediaProjectionManager;
|
|
7
|
+
import android.media.projection.MediaProjectionConfig;
|
|
7
8
|
import android.util.DisplayMetrics;
|
|
8
9
|
import android.util.Log;
|
|
10
|
+
import android.os.Build;
|
|
9
11
|
|
|
10
12
|
import androidx.core.util.Consumer;
|
|
11
13
|
|
|
@@ -16,6 +18,7 @@ import com.facebook.react.bridge.Promise;
|
|
|
16
18
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
19
|
import com.facebook.react.bridge.ReadableArray;
|
|
18
20
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.bridge.ReadableType;
|
|
19
22
|
import com.facebook.react.bridge.UiThreadUtil;
|
|
20
23
|
import com.facebook.react.bridge.WritableArray;
|
|
21
24
|
import com.facebook.react.bridge.WritableMap;
|
|
@@ -31,6 +34,7 @@ import java.util.List;
|
|
|
31
34
|
import java.util.Map;
|
|
32
35
|
import java.util.Objects;
|
|
33
36
|
import java.util.UUID;
|
|
37
|
+
import java.util.concurrent.TimeUnit;
|
|
34
38
|
import java.util.stream.Collectors;
|
|
35
39
|
|
|
36
40
|
/**
|
|
@@ -59,6 +63,8 @@ class GetUserMediaImpl {
|
|
|
59
63
|
|
|
60
64
|
private Promise displayMediaPromise;
|
|
61
65
|
private Intent mediaProjectionPermissionResultData;
|
|
66
|
+
private boolean createConfigForDefaultDisplay = false;
|
|
67
|
+
private float resolutionScale = 1.0f;
|
|
62
68
|
|
|
63
69
|
GetUserMediaImpl(WebRTCModule webRTCModule, ReactApplicationContext reactContext) {
|
|
64
70
|
this.webRTCModule = webRTCModule;
|
|
@@ -69,6 +75,15 @@ class GetUserMediaImpl {
|
|
|
69
75
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
70
76
|
super.onActivityResult(activity, requestCode, resultCode, data);
|
|
71
77
|
if (requestCode == PERMISSION_REQUEST_CODE) {
|
|
78
|
+
// Guard against a duplicate onActivityResult dispatch. Some hosts (e.g.
|
|
79
|
+
// react-native-navigation) forward the activity result to every registered
|
|
80
|
+
// ActivityEventListener more than once, so this callback can fire twice for a
|
|
81
|
+
// single getDisplayMedia() request. The first pass consumes displayMediaPromise;
|
|
82
|
+
// a second pass would call reject()/resolve() on a null promise and crash.
|
|
83
|
+
if (displayMediaPromise == null) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
72
87
|
if (resultCode != Activity.RESULT_OK) {
|
|
73
88
|
displayMediaPromise.reject("DOMException", "NotAllowedError");
|
|
74
89
|
displayMediaPromise = null;
|
|
@@ -77,10 +92,19 @@ class GetUserMediaImpl {
|
|
|
77
92
|
|
|
78
93
|
mediaProjectionPermissionResultData = data;
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
MediaProjectionService.launch(activity)
|
|
96
|
+
.orTimeout(10, TimeUnit.SECONDS)
|
|
97
|
+
.whenCompleteAsync((value, error) -> {
|
|
98
|
+
if (error != null) {
|
|
99
|
+
Log.e(TAG, "Failed to start MediaProjection service", error);
|
|
100
|
+
displayMediaPromise.reject("DOMException", "AbortError");
|
|
101
|
+
displayMediaPromise = null;
|
|
102
|
+
mediaProjectionPermissionResultData = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
createScreenStream();
|
|
107
|
+
}, ThreadUtils.getExecutor());
|
|
84
108
|
}
|
|
85
109
|
}
|
|
86
110
|
});
|
|
@@ -264,7 +288,41 @@ class GetUserMediaImpl {
|
|
|
264
288
|
}
|
|
265
289
|
}
|
|
266
290
|
|
|
267
|
-
void
|
|
291
|
+
void initializeConstraints(ReadableMap constraints) {
|
|
292
|
+
|
|
293
|
+
// Handle the incoming params
|
|
294
|
+
|
|
295
|
+
ReadableMap androidConstraints = null;
|
|
296
|
+
if (constraints.hasKey("android") && constraints.getType("android") == ReadableType.Map) {
|
|
297
|
+
androidConstraints = constraints.getMap("android");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Default values
|
|
301
|
+
boolean createConfigForDefaultDisplay = false;
|
|
302
|
+
float scale = 1.0f;
|
|
303
|
+
|
|
304
|
+
if (androidConstraints != null) {
|
|
305
|
+
// MediaProjectionConfig need API level 34
|
|
306
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
|
307
|
+
&& androidConstraints.hasKey("createConfigForDefaultDisplay")
|
|
308
|
+
&& androidConstraints.getType("createConfigForDefaultDisplay") == ReadableType.Boolean) {
|
|
309
|
+
createConfigForDefaultDisplay = androidConstraints.getBoolean("createConfigForDefaultDisplay");
|
|
310
|
+
}
|
|
311
|
+
if (androidConstraints.hasKey("resolutionScale")
|
|
312
|
+
&& androidConstraints.getType("resolutionScale") == ReadableType.Number) {
|
|
313
|
+
scale = (float) androidConstraints.getDouble("resolutionScale");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
this.createConfigForDefaultDisplay = createConfigForDefaultDisplay;
|
|
318
|
+
// Force the value in [0, 1]
|
|
319
|
+
this.resolutionScale = Math.max(0.0f, Math.min(1.0f, scale));
|
|
320
|
+
|
|
321
|
+
Log.d(TAG, "initializeConstraints: createConfigForDefaultDisplay=" + this.createConfigForDefaultDisplay
|
|
322
|
+
+ " resolutionScale=" + this.resolutionScale);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
void getDisplayMedia(final ReadableMap constraints, Promise promise) {
|
|
268
326
|
if (this.displayMediaPromise != null) {
|
|
269
327
|
promise.reject(new RuntimeException("Another operation is pending."));
|
|
270
328
|
return;
|
|
@@ -276,6 +334,8 @@ class GetUserMediaImpl {
|
|
|
276
334
|
return;
|
|
277
335
|
}
|
|
278
336
|
|
|
337
|
+
this.initializeConstraints(constraints);
|
|
338
|
+
|
|
279
339
|
this.displayMediaPromise = promise;
|
|
280
340
|
|
|
281
341
|
MediaProjectionManager mediaProjectionManager =
|
|
@@ -286,8 +346,17 @@ class GetUserMediaImpl {
|
|
|
286
346
|
UiThreadUtil.runOnUiThread(new Runnable() {
|
|
287
347
|
@Override
|
|
288
348
|
public void run() {
|
|
289
|
-
|
|
349
|
+
|
|
350
|
+
if (createConfigForDefaultDisplay == true) {
|
|
351
|
+
//MediaProjectionConfig need API level 34
|
|
352
|
+
//Return mediaProjection which restricts the user to capturing the default display
|
|
353
|
+
currentActivity.startActivityForResult(
|
|
354
|
+
mediaProjectionManager.createScreenCaptureIntent(MediaProjectionConfig.createConfigForDefaultDisplay()), PERMISSION_REQUEST_CODE);
|
|
355
|
+
} else {
|
|
356
|
+
//Return mediaProjection which allows the user to decide which region is captured
|
|
357
|
+
currentActivity.startActivityForResult(
|
|
290
358
|
mediaProjectionManager.createScreenCaptureIntent(), PERMISSION_REQUEST_CODE);
|
|
359
|
+
}
|
|
291
360
|
}
|
|
292
361
|
});
|
|
293
362
|
|
|
@@ -297,6 +366,14 @@ class GetUserMediaImpl {
|
|
|
297
366
|
}
|
|
298
367
|
|
|
299
368
|
private void createScreenStream() {
|
|
369
|
+
// A duplicate onActivityResult dispatch (see onActivityResult above) can schedule this more
|
|
370
|
+
// than once. The single-threaded executor runs them in order, so by the time a duplicate
|
|
371
|
+
// runs the first has already consumed displayMediaPromise. Bail out instead of dereferencing
|
|
372
|
+
// a null promise or creating a second screen stream.
|
|
373
|
+
if (displayMediaPromise == null) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
300
377
|
VideoTrack track = createScreenTrack();
|
|
301
378
|
|
|
302
379
|
if (track == null) {
|
|
@@ -374,7 +451,7 @@ class GetUserMediaImpl {
|
|
|
374
451
|
int width = displayMetrics.widthPixels;
|
|
375
452
|
int height = displayMetrics.heightPixels;
|
|
376
453
|
ScreenCaptureController screenCaptureController = new ScreenCaptureController(
|
|
377
|
-
reactContext.getCurrentActivity(), width, height, mediaProjectionPermissionResultData);
|
|
454
|
+
reactContext.getCurrentActivity(), width, height, mediaProjectionPermissionResultData, resolutionScale);
|
|
378
455
|
return createVideoTrack(screenCaptureController);
|
|
379
456
|
}
|
|
380
457
|
|
|
@@ -11,6 +11,7 @@ import android.os.IBinder;
|
|
|
11
11
|
import android.util.Log;
|
|
12
12
|
|
|
13
13
|
import java.util.Random;
|
|
14
|
+
import java.util.concurrent.CompletableFuture;
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* This class implements an Android {@link Service}, a foreground one specifically, and it's
|
|
@@ -24,11 +25,17 @@ public class MediaProjectionService extends Service {
|
|
|
24
25
|
|
|
25
26
|
static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
private static volatile CompletableFuture<Void> startFuture;
|
|
29
|
+
|
|
30
|
+
public static CompletableFuture<Void> launch(Context context) {
|
|
28
31
|
if (!WebRTCModuleOptions.getInstance().enableMediaProjectionService) {
|
|
29
|
-
return;
|
|
32
|
+
return CompletableFuture.completedFuture(null);
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
CompletableFuture<Void> future = new CompletableFuture<>();
|
|
36
|
+
|
|
37
|
+
startFuture = future;
|
|
38
|
+
|
|
32
39
|
MediaProjectionNotification.createNotificationChannel(context);
|
|
33
40
|
Intent intent = new Intent(context, MediaProjectionService.class);
|
|
34
41
|
ComponentName componentName;
|
|
@@ -43,14 +50,21 @@ public class MediaProjectionService extends Service {
|
|
|
43
50
|
// Avoid crashing due to ForegroundServiceStartNotAllowedException (API level 31).
|
|
44
51
|
// See: https://developer.android.com/guide/components/foreground-services#background-start-restrictions
|
|
45
52
|
Log.w(TAG, "Media projection service not started", e);
|
|
46
|
-
|
|
53
|
+
startFuture = null;
|
|
54
|
+
future.completeExceptionally(e);
|
|
55
|
+
|
|
56
|
+
return future;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
if (componentName == null) {
|
|
50
60
|
Log.w(TAG, "Media projection service not started");
|
|
61
|
+
startFuture = null;
|
|
62
|
+
future.completeExceptionally(new RuntimeException("Media projection service not started"));
|
|
51
63
|
} else {
|
|
52
64
|
Log.i(TAG, "Media projection service started");
|
|
53
65
|
}
|
|
66
|
+
|
|
67
|
+
return future;
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
public static void abort(Context context) {
|
|
@@ -77,6 +91,13 @@ public class MediaProjectionService extends Service {
|
|
|
77
91
|
startForeground(NOTIFICATION_ID, notification);
|
|
78
92
|
}
|
|
79
93
|
|
|
94
|
+
CompletableFuture<Void> fut = startFuture;
|
|
95
|
+
|
|
96
|
+
if (fut != null) {
|
|
97
|
+
startFuture = null;
|
|
98
|
+
fut.complete(null);
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
return START_NOT_STICKY;
|
|
81
102
|
}
|
|
82
103
|
}
|
|
@@ -25,8 +25,8 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
|
|
|
25
25
|
|
|
26
26
|
private final Context context;
|
|
27
27
|
|
|
28
|
-
public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData) {
|
|
29
|
-
super(width, height, DEFAULT_FPS);
|
|
28
|
+
public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData, float resolutionScale) {
|
|
29
|
+
super((int)(width * resolutionScale), (int)(height * resolutionScale), DEFAULT_FPS);
|
|
30
30
|
|
|
31
31
|
this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
|
|
32
32
|
|
|
@@ -36,8 +36,8 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
|
|
|
36
36
|
@Override
|
|
37
37
|
public void onOrientationChanged(int orientation) {
|
|
38
38
|
DisplayMetrics displayMetrics = DisplayUtils.getDisplayMetrics((Activity) context);
|
|
39
|
-
final int width = displayMetrics.widthPixels;
|
|
40
|
-
final int height = displayMetrics.heightPixels;
|
|
39
|
+
final int width = (int)(displayMetrics.widthPixels * resolutionScale);
|
|
40
|
+
final int height = (int)(displayMetrics.heightPixels * resolutionScale);
|
|
41
41
|
|
|
42
42
|
// Pivot to the executor thread because videoCapturer.changeCaptureFormat runs in the main
|
|
43
43
|
// thread and may deadlock.
|
|
@@ -150,6 +150,9 @@ public class SerializeUtils {
|
|
|
150
150
|
if (encoding.maxBitrateBps != null) {
|
|
151
151
|
encodingMap.putInt("maxBitrate", encoding.maxBitrateBps);
|
|
152
152
|
}
|
|
153
|
+
if (encoding.minBitrateBps != null) {
|
|
154
|
+
encodingMap.putInt("minBitrate", encoding.minBitrateBps);
|
|
155
|
+
}
|
|
153
156
|
if (encoding.maxFramerate != null) {
|
|
154
157
|
encodingMap.putInt("maxFramerate", encoding.maxFramerate);
|
|
155
158
|
}
|
|
@@ -238,6 +241,7 @@ public class SerializeUtils {
|
|
|
238
241
|
RtpParameters.Encoding encoding = encodings.get(i);
|
|
239
242
|
// Dealing with nullable Integers
|
|
240
243
|
Integer maxBitrate = encodingUpdate.hasKey("maxBitrate") ? encodingUpdate.getInt("maxBitrate") : null;
|
|
244
|
+
Integer minBitrate = encodingUpdate.hasKey("minBitrate") ? encodingUpdate.getInt("minBitrate") : null;
|
|
241
245
|
Integer maxFramerate = encodingUpdate.hasKey("maxFramerate") ? encodingUpdate.getInt("maxFramerate") : null;
|
|
242
246
|
Double scaleResolutionDownBy = encodingUpdate.hasKey("scaleResolutionDownBy")
|
|
243
247
|
? encodingUpdate.getDouble("scaleResolutionDownBy")
|
|
@@ -246,6 +250,7 @@ public class SerializeUtils {
|
|
|
246
250
|
encoding.active = encodingUpdate.getBoolean("active");
|
|
247
251
|
encoding.rid = encodingUpdate.getString("rid");
|
|
248
252
|
encoding.maxBitrateBps = maxBitrate;
|
|
253
|
+
encoding.minBitrateBps = minBitrate;
|
|
249
254
|
encoding.maxFramerate = maxFramerate;
|
|
250
255
|
encoding.scaleResolutionDownBy = scaleResolutionDownBy;
|
|
251
256
|
}
|
|
@@ -294,6 +299,9 @@ public class SerializeUtils {
|
|
|
294
299
|
if (params.hasKey("maxBitrate")) {
|
|
295
300
|
encoding.maxBitrateBps = params.getInt("maxBitrate");
|
|
296
301
|
}
|
|
302
|
+
if (params.hasKey("minBitrate")) {
|
|
303
|
+
encoding.minBitrateBps = params.getInt("minBitrate");
|
|
304
|
+
}
|
|
297
305
|
if (params.hasKey("maxFramerate")) {
|
|
298
306
|
encoding.maxFramerate = params.getInt("maxFramerate");
|
|
299
307
|
}
|
|
@@ -13,6 +13,14 @@ final class ThreadUtils {
|
|
|
13
13
|
*/
|
|
14
14
|
private static final ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Gets the executor used to run all WebRTC PeerConnection APIs.
|
|
18
|
+
* @return ExecutorService.
|
|
19
|
+
*/
|
|
20
|
+
public static ExecutorService getExecutor() {
|
|
21
|
+
return executor;
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* Runs the given {@link Runnable} on the executor.
|
|
18
26
|
* @param runnable
|
|
@@ -24,6 +24,11 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
24
24
|
import com.oney.WebRTCModule.webrtcutils.H264AndSoftwareVideoDecoderFactory;
|
|
25
25
|
import com.oney.WebRTCModule.webrtcutils.H264AndSoftwareVideoEncoderFactory;
|
|
26
26
|
|
|
27
|
+
import java.io.ByteArrayInputStream;
|
|
28
|
+
import java.nio.charset.StandardCharsets;
|
|
29
|
+
import java.security.MessageDigest;
|
|
30
|
+
import java.security.cert.CertificateFactory;
|
|
31
|
+
import java.security.cert.X509Certificate;
|
|
27
32
|
import org.webrtc.*;
|
|
28
33
|
import org.webrtc.audio.AudioDeviceModule;
|
|
29
34
|
import org.webrtc.audio.JavaAudioDeviceModule;
|
|
@@ -49,6 +54,9 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
49
54
|
private final SparseArray<PeerConnectionObserver> mPeerConnectionObservers;
|
|
50
55
|
final Map<String, MediaStream> localStreams;
|
|
51
56
|
|
|
57
|
+
// Store generated certificates by ID to avoid exposing private keys to JS
|
|
58
|
+
private static final Map<String, RtcCertificatePem> mCertificates = new HashMap<>();
|
|
59
|
+
|
|
52
60
|
private final GetUserMediaImpl getUserMediaImpl;
|
|
53
61
|
|
|
54
62
|
public WebRTCModule(ReactApplicationContext reactContext) {
|
|
@@ -254,7 +262,24 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
254
262
|
}
|
|
255
263
|
|
|
256
264
|
// FIXME: peerIdentity of type DOMString (public api)
|
|
257
|
-
|
|
265
|
+
|
|
266
|
+
// certificates (public api)
|
|
267
|
+
if (map.hasKey("certificates") && map.getType("certificates") == ReadableType.Array) {
|
|
268
|
+
ReadableArray certificates = map.getArray("certificates");
|
|
269
|
+
if (certificates.size() > 0) {
|
|
270
|
+
ReadableMap certMap = certificates.getMap(0);
|
|
271
|
+
if (certMap.hasKey("certificateId")) {
|
|
272
|
+
String certId = certMap.getString("certificateId");
|
|
273
|
+
RtcCertificatePem cert;
|
|
274
|
+
synchronized (mCertificates) {
|
|
275
|
+
cert = mCertificates.get(certId);
|
|
276
|
+
}
|
|
277
|
+
if (cert != null) {
|
|
278
|
+
conf.certificate = cert;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
258
283
|
|
|
259
284
|
// iceCandidatePoolSize of type unsigned short, defaulting to 0
|
|
260
285
|
if (map.hasKey("iceCandidatePoolSize") && map.getType("iceCandidatePoolSize") == ReadableType.Number) {
|
|
@@ -395,33 +420,23 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
395
420
|
}
|
|
396
421
|
}
|
|
397
422
|
|
|
423
|
+
// Must be called in the executor.
|
|
398
424
|
MediaStream getStreamForReactTag(String streamReactTag) {
|
|
399
|
-
|
|
400
|
-
// Hence make sure we run this code in the executor or we run at the risk
|
|
401
|
-
// of being out of sync.
|
|
402
|
-
try {
|
|
403
|
-
return (MediaStream) ThreadUtils
|
|
404
|
-
.submitToExecutor((Callable<Object>) () -> {
|
|
405
|
-
MediaStream stream = localStreams.get(streamReactTag);
|
|
425
|
+
MediaStream stream = localStreams.get(streamReactTag);
|
|
406
426
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
for (int i = 0, size = mPeerConnectionObservers.size(); i < size; i++) {
|
|
412
|
-
PeerConnectionObserver pco = mPeerConnectionObservers.valueAt(i);
|
|
413
|
-
stream = pco.remoteStreams.get(streamReactTag);
|
|
414
|
-
if (stream != null) {
|
|
415
|
-
return stream;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
427
|
+
if (stream != null) {
|
|
428
|
+
return stream;
|
|
429
|
+
}
|
|
418
430
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
431
|
+
for (int i = 0, size = mPeerConnectionObservers.size(); i < size; i++) {
|
|
432
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.valueAt(i);
|
|
433
|
+
stream = pco.remoteStreams.get(streamReactTag);
|
|
434
|
+
if (stream != null) {
|
|
435
|
+
return stream;
|
|
436
|
+
}
|
|
424
437
|
}
|
|
438
|
+
|
|
439
|
+
return null;
|
|
425
440
|
}
|
|
426
441
|
|
|
427
442
|
public MediaStreamTrack getTrack(int pcId, String trackId) {
|
|
@@ -760,7 +775,10 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
760
775
|
}
|
|
761
776
|
}
|
|
762
777
|
|
|
763
|
-
transceiver.setCodecPreferences(codecsToSet);
|
|
778
|
+
RtcError result = transceiver.setCodecPreferences(codecsToSet);
|
|
779
|
+
if (result.isError()) {
|
|
780
|
+
Log.d(TAG, "transceiverSetCodecPreferences(): " + result.error().getMessage());
|
|
781
|
+
}
|
|
764
782
|
} catch (Exception e) {
|
|
765
783
|
Log.d(TAG, "transceiverSetCodecPreferences(): " + e.getMessage());
|
|
766
784
|
}
|
|
@@ -769,8 +787,8 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
769
787
|
}
|
|
770
788
|
|
|
771
789
|
@ReactMethod
|
|
772
|
-
public void getDisplayMedia(Promise promise) {
|
|
773
|
-
ThreadUtils.runOnExecutor(() -> getUserMediaImpl.getDisplayMedia(promise));
|
|
790
|
+
public void getDisplayMedia(ReadableMap constraints, Promise promise) {
|
|
791
|
+
ThreadUtils.runOnExecutor(() -> getUserMediaImpl.getDisplayMedia(constraints, promise));
|
|
774
792
|
}
|
|
775
793
|
|
|
776
794
|
@ReactMethod
|
|
@@ -1418,6 +1436,77 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
1418
1436
|
});
|
|
1419
1437
|
}
|
|
1420
1438
|
|
|
1439
|
+
@ReactMethod
|
|
1440
|
+
public void generateCertificate(ReadableMap options, Promise promise) {
|
|
1441
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1442
|
+
try {
|
|
1443
|
+
PeerConnection.KeyType keyType = PeerConnection.KeyType.ECDSA;
|
|
1444
|
+
long expires = 2592000L; // Default 30 days
|
|
1445
|
+
|
|
1446
|
+
if (options.hasKey("keyType")) {
|
|
1447
|
+
String keyTypeStr = options.getString("keyType");
|
|
1448
|
+
if ("RSA".equals(keyTypeStr)) {
|
|
1449
|
+
keyType = PeerConnection.KeyType.RSA;
|
|
1450
|
+
} else if ("ECDSA".equals(keyTypeStr)) {
|
|
1451
|
+
keyType = PeerConnection.KeyType.ECDSA;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (options.hasKey("expires")) {
|
|
1456
|
+
expires = (long) options.getDouble("expires");
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
RtcCertificatePem cert = RtcCertificatePem.generateCertificate(keyType, expires);
|
|
1460
|
+
String certId = java.util.UUID.randomUUID().toString();
|
|
1461
|
+
synchronized (mCertificates) {
|
|
1462
|
+
mCertificates.put(certId, cert);
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
WritableMap params = Arguments.createMap();
|
|
1466
|
+
params.putString("certificateId", certId);
|
|
1467
|
+
// Return expires as millis since epoch
|
|
1468
|
+
params.putDouble("expires", System.currentTimeMillis() + expires * 1000);
|
|
1469
|
+
|
|
1470
|
+
// Calculate fingerprints
|
|
1471
|
+
WritableArray fingerprints = Arguments.createArray();
|
|
1472
|
+
|
|
1473
|
+
try {
|
|
1474
|
+
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
|
1475
|
+
ByteArrayInputStream is = new ByteArrayInputStream(cert.certificate.getBytes(StandardCharsets.UTF_8));
|
|
1476
|
+
X509Certificate x509Cert = (X509Certificate) cf.generateCertificate(is);
|
|
1477
|
+
|
|
1478
|
+
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
|
1479
|
+
byte[] hash = digest.digest(x509Cert.getEncoded());
|
|
1480
|
+
|
|
1481
|
+
WritableMap fingerprint = Arguments.createMap();
|
|
1482
|
+
fingerprint.putString("algorithm", "sha-256");
|
|
1483
|
+
fingerprint.putString("value", bytesToHex(hash));
|
|
1484
|
+
fingerprints.pushMap(fingerprint);
|
|
1485
|
+
} catch (Exception e) {
|
|
1486
|
+
Log.e(TAG, "Failed to calculate fingerprint: " + e.getMessage());
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
params.putArray("fingerprints", fingerprints);
|
|
1490
|
+
|
|
1491
|
+
promise.resolve(params);
|
|
1492
|
+
} catch (Exception e) {
|
|
1493
|
+
promise.reject(e);
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
private String bytesToHex(byte[] bytes) {
|
|
1499
|
+
StringBuilder sb = new StringBuilder();
|
|
1500
|
+
for (byte b : bytes) {
|
|
1501
|
+
sb.append(String.format("%02x", b));
|
|
1502
|
+
sb.append(":");
|
|
1503
|
+
}
|
|
1504
|
+
if (sb.length() > 0) {
|
|
1505
|
+
sb.setLength(sb.length() - 1);
|
|
1506
|
+
}
|
|
1507
|
+
return sb.toString();
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1421
1510
|
@ReactMethod
|
|
1422
1511
|
public void addListener(String eventName) {
|
|
1423
1512
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
@@ -173,28 +173,53 @@ public class WebRTCView extends ViewGroup {
|
|
|
173
173
|
surfaceViewRenderer.clearImage();
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Asynchronously retrieves the VideoTrack for the given streamURL.
|
|
178
|
+
* This method avoids blocking the UI thread by performing the lookup
|
|
179
|
+
* on the WebRTC executor thread and posting the result back to the UI thread.
|
|
180
|
+
*
|
|
181
|
+
* @param streamURL The stream URL to lookup
|
|
182
|
+
* @param callback Callback invoked on UI thread with the VideoTrack (or null if not found)
|
|
183
|
+
*/
|
|
184
|
+
private void getVideoTrackForStreamURL(String streamURL, java.util.function.Consumer<VideoTrack> callback) {
|
|
185
|
+
if (streamURL == null) {
|
|
186
|
+
callback.accept(null);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
178
189
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
WebRTCModule module = reactContext.getNativeModule(WebRTCModule.class);
|
|
182
|
-
MediaStream stream = module.getStreamForReactTag(streamURL);
|
|
190
|
+
ReactContext reactContext = (ReactContext) getContext();
|
|
191
|
+
WebRTCModule module = reactContext.getNativeModule(WebRTCModule.class);
|
|
183
192
|
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
// Submit lookup to executor thread to avoid blocking UI thread
|
|
194
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
195
|
+
try {
|
|
196
|
+
MediaStream stream = module.getStreamForReactTag(streamURL);
|
|
197
|
+
if (stream == null) {
|
|
198
|
+
Log.w(TAG, "Stream not found for URL: " + streamURL);
|
|
199
|
+
post(() -> callback.accept(null));
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
186
202
|
|
|
203
|
+
VideoTrack videoTrack = null;
|
|
204
|
+
List<VideoTrack> videoTracks = stream.videoTracks;
|
|
187
205
|
if (!videoTracks.isEmpty()) {
|
|
188
206
|
videoTrack = videoTracks.get(0);
|
|
189
207
|
}
|
|
190
|
-
}
|
|
191
208
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
209
|
+
if (videoTrack == null) {
|
|
210
|
+
Log.w(TAG, "No video stream for react tag: " + streamURL);
|
|
211
|
+
post(() -> callback.accept(null));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
196
214
|
|
|
197
|
-
|
|
215
|
+
// Post result back to UI thread
|
|
216
|
+
final VideoTrack result = videoTrack;
|
|
217
|
+
post(() -> callback.accept(result));
|
|
218
|
+
} catch (Throwable tr) {
|
|
219
|
+
Log.e(TAG, "Error getting video track for stream URL: " + streamURL, tr);
|
|
220
|
+
post(() -> callback.accept(null));
|
|
221
|
+
}
|
|
222
|
+
});
|
|
198
223
|
}
|
|
199
224
|
|
|
200
225
|
@Override
|
|
@@ -452,20 +477,23 @@ public class WebRTCView extends ViewGroup {
|
|
|
452
477
|
* this {@code WebRTCView} or {@code null}.
|
|
453
478
|
*/
|
|
454
479
|
void setStreamURL(String streamURL) {
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
// course, that is only necessary if the value of videoTrack will
|
|
460
|
-
// really change. Please note though that letting go of the old
|
|
461
|
-
// videoTrack before assigning to this.streamURL is vital;
|
|
462
|
-
// otherwise, removeRendererFromVideoTrack will fail to remove the
|
|
463
|
-
// old videoTrack from the associated videoRenderer, two
|
|
464
|
-
// VideoTracks (the old and the new) may start rendering and, most
|
|
465
|
-
// importantly the videoRender may eventually crash when the old
|
|
466
|
-
// videoTrack is disposed.
|
|
467
|
-
VideoTrack videoTrack = getVideoTrackForStreamURL(streamURL);
|
|
480
|
+
Log.d(TAG, "Set stream URL " + streamURL + " current: " + this.streamURL);
|
|
481
|
+
if (Objects.equals(streamURL, this.streamURL)) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
468
484
|
|
|
485
|
+
// The value of this.streamURL is really changing. Before
|
|
486
|
+
// realizing/applying the change, let go of the old videoTrack. Of
|
|
487
|
+
// course, that is only necessary if the value of videoTrack will
|
|
488
|
+
// really change. Please note though that letting go of the old
|
|
489
|
+
// videoTrack before assigning to this.streamURL is vital;
|
|
490
|
+
// otherwise, removeRendererFromVideoTrack will fail to remove the
|
|
491
|
+
// old videoTrack from the associated videoRenderer, two
|
|
492
|
+
// VideoTracks (the old and the new) may start rendering and, most
|
|
493
|
+
// importantly the videoRender may eventually crash when the old
|
|
494
|
+
// videoTrack is disposed.
|
|
495
|
+
getVideoTrackForStreamURL(streamURL, videoTrack -> {
|
|
496
|
+
Log.d(TAG, "Got video track for stream URL " + streamURL + " -> " + videoTrack);
|
|
469
497
|
if (this.videoTrack != videoTrack) {
|
|
470
498
|
setVideoTrack(null);
|
|
471
499
|
}
|
|
@@ -475,7 +503,7 @@ public class WebRTCView extends ViewGroup {
|
|
|
475
503
|
// After realizing/applying the change in the value of
|
|
476
504
|
// this.streamURL, reflect it on the value of videoTrack.
|
|
477
505
|
setVideoTrack(videoTrack);
|
|
478
|
-
}
|
|
506
|
+
});
|
|
479
507
|
}
|
|
480
508
|
|
|
481
509
|
/**
|