|
25 | 25 |
|
26 | 26 | import java.util.ArrayList;
|
27 | 27 | import java.util.HashMap;
|
| 28 | +import java.util.List; |
28 | 29 | import java.util.Map;
|
| 30 | +import java.util.Objects; |
29 | 31 | import java.util.UUID;
|
| 32 | +import java.util.stream.Collectors; |
30 | 33 |
|
31 | 34 | /**
|
32 | 35 | * The implementation of {@code getUserMedia} extracted into a separate file in
|
@@ -388,28 +391,33 @@ VideoTrack createVideoTrack(AbstractVideoCaptureController videoCaptureControlle
|
388 | 391 | }
|
389 | 392 |
|
390 | 393 | /**
|
391 |
| - * Set video effect to the TrackPrivate corresponding to the trackId with the help of VideoEffectProcessor |
392 |
| - * corresponding to the name. |
| 394 | + * Set video effects to the TrackPrivate corresponding to the trackId with the help of VideoEffectProcessor |
| 395 | + * corresponding to the names. |
393 | 396 | * @param trackId TrackPrivate id
|
394 |
| - * @param name VideoEffectProcessor name |
| 397 | + * @param names VideoEffectProcessor names |
395 | 398 | */
|
396 |
| - void setVideoEffect(String trackId, String name) { |
| 399 | + void setVideoEffects(String trackId, ReadableArray names) { |
397 | 400 | TrackPrivate track = tracks.get(trackId);
|
398 | 401 |
|
399 | 402 | if (track != null && track.videoCaptureController instanceof CameraCaptureController) {
|
400 | 403 | VideoSource videoSource = (VideoSource) track.mediaSource;
|
401 | 404 | SurfaceTextureHelper surfaceTextureHelper = track.surfaceTextureHelper;
|
402 | 405 |
|
403 |
| - if (name != null) { |
404 |
| - VideoFrameProcessor videoFrameProcessor = ProcessorProvider.getProcessor(name); |
405 |
| - |
406 |
| - if (videoFrameProcessor == null) { |
407 |
| - Log.e(TAG, "no videoFrameProcessor associated with this name"); |
408 |
| - return; |
409 |
| - } |
| 406 | + if (names != null) { |
| 407 | + List<VideoFrameProcessor> processors = names.toArrayList().stream() |
| 408 | + .filter(name -> name instanceof String) |
| 409 | + .map(name -> { |
| 410 | + VideoFrameProcessor videoFrameProcessor = ProcessorProvider.getProcessor((String) name); |
| 411 | + if (videoFrameProcessor == null) { |
| 412 | + Log.e(TAG, "no videoFrameProcessor associated with this name: " + name); |
| 413 | + } |
| 414 | + return videoFrameProcessor; |
| 415 | + }) |
| 416 | + .filter(Objects::nonNull) |
| 417 | + .collect(Collectors.toList()); |
410 | 418 |
|
411 | 419 | VideoEffectProcessor videoEffectProcessor =
|
412 |
| - new VideoEffectProcessor(videoFrameProcessor, surfaceTextureHelper); |
| 420 | + new VideoEffectProcessor(processors, surfaceTextureHelper); |
413 | 421 | videoSource.setVideoProcessor(videoEffectProcessor);
|
414 | 422 |
|
415 | 423 | } else {
|
|
0 commit comments