summaryrefslogtreecommitdiffstats
path: root/dom/media/systemservices/android_video_capture/java/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /dom/media/systemservices/android_video_capture/java/src
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/systemservices/android_video_capture/java/src')
-rw-r--r--dom/media/systemservices/android_video_capture/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/dom/media/systemservices/android_video_capture/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java b/dom/media/systemservices/android_video_capture/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
index cc54009a7b..b4cc65ec9c 100644
--- a/dom/media/systemservices/android_video_capture/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
+++ b/dom/media/systemservices/android_video_capture/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
@@ -17,6 +17,7 @@ import android.content.Context;
import android.util.Log;
import android.view.Surface;
import android.view.WindowManager;
+import androidx.annotation.NonNull;
import java.util.concurrent.CountDownLatch;
@@ -37,10 +38,8 @@ public class VideoCaptureAndroid implements CameraVideoCapturer.CameraEventsHand
private final String deviceName;
private volatile long native_capturer; // |VideoCaptureAndroid*| in C++.
- private Context context;
+ private final Context context;
private CameraVideoCapturer cameraVideoCapturer;
- private EglBase eglBase;
- private SurfaceTextureHelper surfaceTextureHelper;
// This class is recreated everytime we start/stop capture, so we
// can safely create the CountDownLatches here.
@@ -48,8 +47,16 @@ public class VideoCaptureAndroid implements CameraVideoCapturer.CameraEventsHand
private boolean capturerStartedSucceeded = false;
private final CountDownLatch capturerStopped = new CountDownLatch(1);
- @WebRTCJNITarget
- public VideoCaptureAndroid(String deviceName) {
+ @WebRTCJNITarget
+ public static VideoCaptureAndroid create(@NonNull final String deviceName) {
+ final Context context = GetContext();
+ return new VideoCaptureAndroid(context, deviceName,
+ Camera2Enumerator.isSupported(context)
+ ? new Camera2Enumerator(context)
+ : new Camera1Enumerator());
+ }
+
+ private VideoCaptureAndroid(@NonNull final Context context, @NonNull final String deviceName, @NonNull final CameraEnumerator enumerator) {
// Remove the camera facing information from the name.
String[] parts = deviceName.split("Facing (front|back):");
if (parts.length == 2) {
@@ -58,20 +65,14 @@ public class VideoCaptureAndroid implements CameraVideoCapturer.CameraEventsHand
Log.e(TAG, "VideoCaptureAndroid: Expected facing mode as part of name: " + deviceName);
this.deviceName = deviceName;
}
- this.context = GetContext();
+ this.context = context;
- CameraEnumerator enumerator;
- if (Camera2Enumerator.isSupported(context)) {
- enumerator = new Camera2Enumerator(context);
- } else {
- enumerator = new Camera1Enumerator();
- }
try {
cameraVideoCapturer = enumerator.createCapturer(this.deviceName, this);
- eglBase = EglBase.create();
- surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureAndroidSurfaceTextureHelper", eglBase.getEglBaseContext());
+ final EglBase eglBase = EglBase.create();
+ final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureAndroidSurfaceTextureHelper", eglBase.getEglBaseContext());
cameraVideoCapturer.initialize(surfaceTextureHelper, context, this);
- } catch (java.lang.IllegalArgumentException e) {
+ } catch (java.lang.RuntimeException e) {
Log.e(TAG, "VideoCaptureAndroid: Exception while creating capturer: " + e);
}
}
@@ -80,6 +81,10 @@ public class VideoCaptureAndroid implements CameraVideoCapturer.CameraEventsHand
@WebRTCJNITarget
private static native Context GetContext();
+ public boolean canCapture() {
+ return cameraVideoCapturer != null;
+ }
+
// Called by native code. Returns true if capturer is started.
//
// Note that this actually opens the camera, and Camera callbacks run on the