react-native-webrtc 118.0.1 → 118.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +17 -3
  2. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +2 -0
  3. package/android/build/intermediates/compile_symbol_list/debug/R.txt +4344 -141
  4. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
  5. package/android/build/intermediates/incremental/debug/packageDebugResources/merged.dir/values/values.xml +9 -0
  6. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +4 -0
  7. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/AbstractVideoCaptureController$CapturerEventsListener.class +0 -0
  8. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/AbstractVideoCaptureController.class +0 -0
  9. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/BuildConfig.class +0 -0
  10. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController$1.class +0 -0
  11. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController$2.class +0 -0
  12. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraCaptureController.class +0 -0
  13. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/CameraEventsHandler.class +0 -0
  14. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DataChannelWrapper$1.class +0 -0
  15. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DataChannelWrapper.class +0 -0
  16. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/DisplayUtils.class +0 -0
  17. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/EglUtils.class +0 -0
  18. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$1.class +0 -0
  19. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$2.class +0 -0
  20. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$BiConsumer.class +0 -0
  21. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl$TrackPrivate.class +0 -0
  22. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/GetUserMediaImpl.class +0 -0
  23. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/LibraryLoader.class +0 -0
  24. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/MediaProjectionNotification.class +0 -0
  25. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/MediaProjectionService.class +0 -0
  26. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/PeerConnectionObserver$1.class +0 -0
  27. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/PeerConnectionObserver.class +0 -0
  28. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/RTCVideoViewManager.class +0 -0
  29. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ReactBridgeUtil$1.class +0 -0
  30. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ReactBridgeUtil.class +0 -0
  31. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController$1.class +0 -0
  32. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController$2.class +0 -0
  33. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ScreenCaptureController.class +0 -0
  34. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/SerializeUtils$1.class +0 -0
  35. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/SerializeUtils.class +0 -0
  36. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/StringUtils.class +0 -0
  37. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/ThreadUtils.class +0 -0
  38. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/TrackCapturerEventsEmitter.class +0 -0
  39. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCCamera2Enumerator.class +0 -0
  40. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCVideoCapturer$PreviewDataCallback.class +0 -0
  41. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/UVCVideoCapturer.class +0 -0
  42. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter$TrackMuteUnmuteImpl$1.class +0 -0
  43. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter$TrackMuteUnmuteImpl.class +0 -0
  44. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/VideoTrackAdapter.class +0 -0
  45. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$1.class +0 -0
  46. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$2.class +0 -0
  47. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$3.class +0 -0
  48. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$4.class +0 -0
  49. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$5.class +0 -0
  50. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule$6.class +0 -0
  51. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModule.class +0 -0
  52. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModuleOptions.class +0 -0
  53. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCModulePackage.class +0 -0
  54. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$1.class +0 -0
  55. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$2.class +0 -0
  56. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView$3.class +0 -0
  57. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/WebRTCView.class +0 -0
  58. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/ProcessorProvider.class +0 -0
  59. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.class +0 -0
  60. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoFrameProcessor.class +0 -0
  61. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.class +0 -0
  62. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoDecoderFactory.class +0 -0
  63. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/H264AndSoftwareVideoEncoderFactory.class +0 -0
  64. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/SoftwareVideoDecoderFactoryProxy.class +0 -0
  65. package/android/build/intermediates/javac/debug/classes/com/oney/WebRTCModule/webrtcutils/SoftwareVideoEncoderFactoryProxy.class +0 -0
  66. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +3 -0
  67. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +33 -8
  68. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +17 -3
  69. package/android/build/intermediates/packaged_res/debug/values/values.xml +4 -1
  70. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +2976 -10
  71. package/android/build/outputs/logs/manifest-merger-debug-report.txt +29 -3
  72. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  73. package/android/src/main/AndroidManifest.xml +8 -0
  74. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +6 -3
  75. package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +78 -0
  76. package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +84 -0
  77. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +25 -133
  78. package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +14 -1
  79. package/android/src/main/java/com/oney/WebRTCModule/UVCCamera2Enumerator.java +122 -111
  80. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +5 -4
  81. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModuleOptions.java +1 -0
  82. package/android/src/main/res/values/strings.xml +5 -0
  83. package/package.json +1 -1
@@ -1,14 +1,40 @@
1
1
  -- Merging decision tree log ---
2
2
  manifest
3
- ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-3:12
4
- INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-3:12
5
- INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-3:12
3
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-18:12
4
+ INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-18:12
5
+ INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:1-18:12
6
6
  package
7
7
  ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:2:11-42
8
8
  INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml
9
9
  INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml
10
+ xmlns:tools
11
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:3:11-57
10
12
  xmlns:android
11
13
  ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:1:11-69
14
+ uses-permission#android.permission.FOREGROUND_SERVICE
15
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:5:5-77
16
+ android:name
17
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:5:22-74
18
+ uses-permission#android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION
19
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:6:5-94
20
+ android:name
21
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:6:22-91
22
+ application
23
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:7:5-12:19
24
+ service#com.oney.WebRTCModule.MediaProjectionService
25
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:8:9-11:19
26
+ android:foregroundServiceType
27
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:10:17-64
28
+ android:name
29
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:9:17-55
30
+ uses-feature#android.hardware.usb.host
31
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:13:5-17:7
32
+ tools:node
33
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:16:9-29
34
+ android:required
35
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:15:9-33
36
+ android:name
37
+ ADDED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml:14:9-49
12
38
  uses-sdk
13
39
  INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml reason: use-sdk injection requested
14
40
  INJECTED from /Users/saghul/work/jitsi/jitsi-meet/node_modules/react-native-webrtc/android/src/main/AndroidManifest.xml
@@ -2,6 +2,14 @@
2
2
  package="com.oney.WebRTCModule"
3
3
  xmlns:tools="http://schemas.android.com/tools"
4
4
  >
5
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
7
+ <application>
8
+ <service
9
+ android:name=".MediaProjectionService"
10
+ android:foregroundServiceType="mediaProjection">
11
+ </service>
12
+ </application>
5
13
  <uses-feature
6
14
  android:name="android.hardware.usb.host"
7
15
  android:required="false"
@@ -3,7 +3,6 @@ package com.oney.WebRTCModule;
3
3
  import android.app.Activity;
4
4
  import android.content.Context;
5
5
  import android.content.Intent;
6
- import android.content.pm.PackageManager;
7
6
  import android.media.projection.MediaProjectionManager;
8
7
  import android.util.DisplayMetrics;
9
8
  import android.util.Log;
@@ -71,7 +70,7 @@ class GetUserMediaImpl {
71
70
  }
72
71
 
73
72
  if (camera2supported) {
74
- if (reactContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST)) {
73
+ if (UVCCamera2Enumerator.isSupported(reactContext)) {
75
74
  Log.d(TAG, "Creating video capturer using Camera2 API with UVC support.");
76
75
  cameraEnumerator = new UVCCamera2Enumerator(reactContext);
77
76
  } else {
@@ -95,7 +94,11 @@ class GetUserMediaImpl {
95
94
  }
96
95
 
97
96
  mediaProjectionPermissionResultData = data;
98
- createScreenStream();
97
+
98
+ ThreadUtils.runOnExecutor(() -> {
99
+ MediaProjectionService.launch(activity);
100
+ createScreenStream();
101
+ });
99
102
  }
100
103
  }
101
104
  });
@@ -0,0 +1,78 @@
1
+ package com.oney.WebRTCModule;
2
+
3
+ import android.app.Notification;
4
+ import android.app.Service;
5
+ import android.content.Context;
6
+
7
+ import androidx.core.app.NotificationCompat;
8
+
9
+ import android.app.NotificationChannel;
10
+ import android.app.NotificationManager;
11
+
12
+ import android.os.Build;
13
+
14
+ import android.util.Log;
15
+
16
+
17
+ /**
18
+ * Helper class for creating the media projection notification which is used with
19
+ * {@link MediaProjectionService}.
20
+ */
21
+ class MediaProjectionNotification {
22
+ private static final String TAG = MediaProjectionNotification.class.getSimpleName();
23
+
24
+ static final String ONGOING_CONFERENCE_CHANNEL_ID = "OngoingConferenceChannel";
25
+
26
+
27
+ static void createNotificationChannel(Context context) {
28
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
29
+ return;
30
+ }
31
+
32
+ if (context == null) {
33
+ Log.d(TAG, " Cannot create notification channel: no current context");
34
+ return;
35
+ }
36
+
37
+ NotificationManager notificationManager
38
+ = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
39
+
40
+ NotificationChannel channel
41
+ = notificationManager.getNotificationChannel(ONGOING_CONFERENCE_CHANNEL_ID);
42
+
43
+ if (channel != null) {
44
+ // The channel was already created, no need to do it again.
45
+ return;
46
+ }
47
+
48
+ channel = new NotificationChannel(
49
+ ONGOING_CONFERENCE_CHANNEL_ID,
50
+ context.getString(R.string.ongoing_notification_channel_name),
51
+ NotificationManager.IMPORTANCE_DEFAULT
52
+ );
53
+ channel.enableLights(false);
54
+ channel.enableVibration(false);
55
+ channel.setShowBadge(false);
56
+
57
+ notificationManager.createNotificationChannel(channel);
58
+ }
59
+
60
+ static Notification buildMediaProjectionNotification(Context context) {
61
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(context, ONGOING_CONFERENCE_CHANNEL_ID);
62
+
63
+ builder
64
+ .setCategory(NotificationCompat.CATEGORY_CALL)
65
+ .setContentTitle(context.getString(R.string.media_projection_notification_title))
66
+ .setContentText(context.getString(R.string.media_projection_notification_text))
67
+ .setPriority(NotificationCompat.PRIORITY_LOW)
68
+ .setOngoing(false)
69
+ .setUsesChronometer(false)
70
+ .setAutoCancel(true)
71
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
72
+ .setOnlyAlertOnce(true)
73
+ .setSmallIcon(context.getResources().getIdentifier("ic_notification", "drawable", context.getPackageName()))
74
+ .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE);
75
+
76
+ return builder.build();
77
+ }
78
+ }
@@ -0,0 +1,84 @@
1
+ package com.oney.WebRTCModule;
2
+
3
+ import android.app.Notification;
4
+ import android.app.Service;
5
+ import android.content.ComponentName;
6
+ import android.content.Context;
7
+ import android.content.Intent;
8
+ import android.content.pm.ServiceInfo;
9
+ import android.os.Build;
10
+ import android.os.IBinder;
11
+ import android.util.Log;
12
+
13
+ import java.util.Random;
14
+
15
+
16
+ /**
17
+ * This class implements an Android {@link Service}, a foreground one specifically, and it's
18
+ * responsible for presenting an ongoing notification when a conference is in progress.
19
+ * The service will help keep the app running while in the background.
20
+ *
21
+ * See: https://developer.android.com/guide/components/services
22
+ */
23
+ public class MediaProjectionService extends Service {
24
+ private static final String TAG = MediaProjectionService.class.getSimpleName();
25
+
26
+ static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
27
+
28
+ public static void launch(Context context) {
29
+ if (!WebRTCModuleOptions.getInstance().enableMediaProjectionService) {
30
+ return;
31
+ }
32
+
33
+ MediaProjectionNotification.createNotificationChannel(context);
34
+ Intent intent = new Intent(context, MediaProjectionService.class);
35
+ ComponentName componentName;
36
+
37
+ try {
38
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
39
+ componentName = context.startForegroundService(intent);
40
+ } else {
41
+ componentName = context.startService(intent);
42
+ }
43
+ } catch (RuntimeException e) {
44
+ // Avoid crashing due to ForegroundServiceStartNotAllowedException (API level 31).
45
+ // See: https://developer.android.com/guide/components/foreground-services#background-start-restrictions
46
+ Log.w(TAG, "Media projection service not started", e);
47
+ return;
48
+ }
49
+
50
+ if (componentName == null) {
51
+ Log.w(TAG, "Media projection service not started");
52
+ } else {
53
+ Log.i(TAG, "Media projection service started");
54
+ }
55
+ }
56
+
57
+ public static void abort(Context context) {
58
+ if (!WebRTCModuleOptions.getInstance().enableMediaProjectionService) {
59
+ return;
60
+ }
61
+
62
+ Intent intent = new Intent(context, MediaProjectionService.class);
63
+ context.stopService(intent);
64
+ }
65
+
66
+ @Override
67
+ public IBinder onBind(Intent intent) {
68
+ return null;
69
+ }
70
+
71
+ @Override
72
+ public int onStartCommand(Intent intent, int flags, int startId) {
73
+
74
+ Notification notification = MediaProjectionNotification.buildMediaProjectionNotification(this);
75
+
76
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
77
+ startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
78
+ } else {
79
+ startForeground(NOTIFICATION_ID, notification);
80
+ }
81
+
82
+ return START_NOT_STICKY;
83
+ }
84
+ }
@@ -2,24 +2,20 @@ package com.oney.WebRTCModule;
2
2
 
3
3
  import android.util.Base64;
4
4
  import android.util.Log;
5
- import android.util.SparseArray;
6
5
 
7
6
  import androidx.annotation.Nullable;
8
7
 
9
8
  import com.facebook.react.bridge.Arguments;
10
9
  import com.facebook.react.bridge.Promise;
11
- import com.facebook.react.bridge.ReadableArray;
12
10
  import com.facebook.react.bridge.ReadableMap;
13
11
  import com.facebook.react.bridge.WritableArray;
14
12
  import com.facebook.react.bridge.WritableMap;
15
13
 
16
- import org.webrtc.AudioTrack;
17
14
  import org.webrtc.DataChannel;
18
15
  import org.webrtc.IceCandidate;
19
16
  import org.webrtc.MediaStream;
20
17
  import org.webrtc.MediaStreamTrack;
21
18
  import org.webrtc.PeerConnection;
22
- import org.webrtc.RTCStats;
23
19
  import org.webrtc.RTCStatsReport;
24
20
  import org.webrtc.RtpReceiver;
25
21
  import org.webrtc.RtpSender;
@@ -27,18 +23,11 @@ import org.webrtc.RtpTransceiver;
27
23
  import org.webrtc.SessionDescription;
28
24
  import org.webrtc.VideoTrack;
29
25
 
30
- import java.io.UnsupportedEncodingException;
31
26
  import java.nio.ByteBuffer;
32
27
  import java.nio.charset.StandardCharsets;
33
- import java.util.ArrayList;
34
- import java.util.Arrays;
35
28
  import java.util.HashMap;
36
- import java.util.HashSet;
37
- import java.util.Iterator;
38
- import java.util.List;
39
29
  import java.util.Map;
40
30
  import java.util.Objects;
41
- import java.util.Set;
42
31
  import java.util.UUID;
43
32
 
44
33
  class PeerConnectionObserver implements PeerConnection.Observer {
@@ -243,140 +232,43 @@ class PeerConnectionObserver implements PeerConnection.Observer {
243
232
  }
244
233
 
245
234
  void getStats(Promise promise) {
246
- peerConnection.getStats(rtcStatsReport -> { promise.resolve(StringUtils.statsToJSON(rtcStatsReport)); });
235
+ peerConnection.getStats(rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
247
236
  }
248
237
 
249
- /**
250
- * @param trackIdentifier sender or receiver id
251
- * @param streamType "outbound-rtp" for sender or "inbound-rtp" for receiver
252
- */
253
- void getFilteredStats(String trackIdentifier, boolean isReceiver, Promise promise) {
254
- peerConnection.getStats(rtcStatsReport -> {
255
- Map<String, RTCStats> statsMap = rtcStatsReport.getStatsMap();
256
- Set<RTCStats> filteredStats = new HashSet<>();
257
- // Get track stats
258
- RTCStats trackStats = getTrackStats(trackIdentifier, statsMap);
259
- if (trackStats == null) {
260
- Log.w(TAG, "getStats: couldn't find track stats!");
261
- RTCStatsReport report = new RTCStatsReport((long) rtcStatsReport.getTimestampUs(), new HashMap<>());
262
- promise.resolve(StringUtils.statsToJSON(report));
263
- return;
264
- }
265
-
266
- filteredStats.add(trackStats);
267
- String trackId = trackStats.getId();
268
-
269
- // Get stream stats
270
- RTCStats streamStats = getStreamStats(trackId, statsMap);
271
- if (streamStats != null) {
272
- filteredStats.add(streamStats);
273
- }
274
-
275
- // Get streamType stats and associated information
276
- Set<Long> ssrcs = new HashSet<>();
277
- Set<String> codecIds = new HashSet<>();
278
-
279
- String streamType;
280
- if (isReceiver) {
281
- streamType = "inbound-rtp";
282
- } else {
283
- streamType = "outbound-rtp";
284
- }
285
-
286
- for (RTCStats stats : statsMap.values()) {
287
- if (stats.getType().equals(streamType) && trackId.equals(stats.getMembers().get("trackId"))) {
288
- ssrcs.add((Long) stats.getMembers().get("ssrc"));
289
- codecIds.add((String) stats.getMembers().get("codecId"));
290
- filteredStats.add(stats);
291
- }
292
- }
293
-
294
- // Get candidate information
295
- RTCStats candidatePairStats = null;
296
- for (RTCStats stats : statsMap.values()) {
297
- if (stats.getType().equals("candidate-pair") && stats.getMembers().get("nominated").equals(true)) {
298
- candidatePairStats = stats;
299
- break;
300
- }
301
- }
302
-
303
- String localCandidateId = null;
304
- String remoteCandidateId = null;
305
- if (candidatePairStats != null) {
306
- filteredStats.add(candidatePairStats);
307
- localCandidateId = (String) candidatePairStats.getMembers().get("localCandidateId");
308
- remoteCandidateId = (String) candidatePairStats.getMembers().get("remoteCandidateId");
309
- }
310
-
311
- // Sweep for any remaining stats we want.
312
- filteredStats.addAll(
313
- getExtraStats(trackIdentifier, ssrcs, codecIds, localCandidateId, remoteCandidateId, statsMap));
314
-
315
- Map<String, RTCStats> filteredStatsMap = new HashMap<>();
316
- for (RTCStats stats : filteredStats) {
317
- filteredStatsMap.put(stats.getId(), stats);
318
- }
319
- RTCStatsReport filteredStatsReport =
320
- new RTCStatsReport((long) rtcStatsReport.getTimestampUs(), filteredStatsMap);
321
- promise.resolve(StringUtils.statsToJSON(filteredStatsReport));
322
- });
323
- }
324
-
325
- // Note: trackIdentifier can differ from the internal stats trackId
326
- // trackIdentifier refers to the sender or receiver id
327
- @Nullable
328
- private RTCStats getTrackStats(String trackIdentifier, Map<String, RTCStats> statsMap) {
329
- for (RTCStats stats : statsMap.values()) {
330
- if (stats.getType().equals("track") && trackIdentifier.equals(stats.getMembers().get("trackIdentifier"))) {
331
- return stats;
238
+ public void receiverGetStats(String receiverId, Promise promise) {
239
+ RtpReceiver targetReceiver = null;
240
+ for (RtpReceiver r : peerConnection.getReceivers()) {
241
+ if (r.id().equals(receiverId)) {
242
+ targetReceiver = r;
243
+ break;
332
244
  }
333
245
  }
334
- return null;
335
- }
336
246
 
337
- @Nullable
338
- private RTCStats getStreamStats(String trackId, Map<String, RTCStats> statsMap) {
339
- for (RTCStats stats : statsMap.values()) {
340
- if (stats.getType().equals("stream")
341
- && Arrays.asList((String[]) stats.getMembers().get("trackIds")).contains(trackId)) {
342
- return stats;
343
- }
247
+ if (targetReceiver == null) {
248
+ Log.w(TAG, "receiverGetStats(): Receiver ID " + receiverId + " not found");
249
+ promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>())));
250
+ return;
344
251
  }
345
- return null;
346
- }
347
252
 
348
- // Note: trackIdentifier can differ from the internal stats trackId
349
- // trackIdentifier refers to the sender or receiver id
350
- public Set<RTCStats> getExtraStats(String trackIdentifier, Set<Long> ssrcs, Set<String> codecIds,
351
- @Nullable String localCandidateId, @Nullable String remoteCandidateId, Map<String, RTCStats> statsMap) {
352
- Set<RTCStats> extraStats = new HashSet<>();
353
- for (RTCStats stats : statsMap.values()) {
354
- switch (stats.getType()) {
355
- case "certificate":
356
- case "transport":
357
- extraStats.add(stats);
358
- break;
359
- }
253
+ peerConnection.getStats(targetReceiver, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
254
+ }
360
255
 
361
- if (stats.getId().equals(localCandidateId) || stats.getId().equals(remoteCandidateId)) {
362
- extraStats.add(stats);
363
- continue;
256
+ public void senderGetStats(String senderId, Promise promise) {
257
+ RtpReceiver targetSender = null;
258
+ for (RtpReceiver r : peerConnection.getReceivers()) {
259
+ if (r.id().equals(senderId)) {
260
+ targetSender = r;
261
+ break;
364
262
  }
263
+ }
365
264
 
366
- if (ssrcs.contains(stats.getMembers().get("ssrc"))) {
367
- extraStats.add(stats);
368
- continue;
369
- }
370
- if (trackIdentifier.equals(stats.getMembers().get("trackIdentifier"))) {
371
- extraStats.add(stats);
372
- continue;
373
- }
374
- if (codecIds.contains(stats.getId())) {
375
- extraStats.add(stats);
376
- }
265
+ if (targetSender == null) {
266
+ Log.w(TAG, "senderGetStats(): Sender ID " + senderId + " not found");
267
+ promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>())));
268
+ return;
377
269
  }
378
270
 
379
- return extraStats;
271
+ peerConnection.getStats(targetSender, rtcStatsReport -> promise.resolve(StringUtils.statsToJSON(rtcStatsReport)));
380
272
  }
381
273
 
382
274
  @Override
@@ -23,11 +23,18 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
23
23
 
24
24
  private final OrientationEventListener orientationListener;
25
25
 
26
- public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData) {
26
+ private final Context context;
27
+
28
+ public ScreenCaptureController(Context context,
29
+ int width,
30
+ int height,
31
+ Intent mediaProjectionPermissionResultData) {
27
32
  super(width, height, DEFAULT_FPS);
28
33
 
29
34
  this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
30
35
 
36
+ this.context = context;
37
+
31
38
  this.orientationListener = new OrientationEventListener(context) {
32
39
  @Override
33
40
  public void onOrientationChanged(int orientation) {
@@ -53,6 +60,12 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
53
60
  }
54
61
  }
55
62
 
63
+ @Override
64
+ public void dispose() {
65
+ MediaProjectionService.abort(context);
66
+ super.dispose();
67
+ }
68
+
56
69
  @Override
57
70
  protected VideoCapturer createVideoCapturer() {
58
71
  VideoCapturer videoCapturer =