Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java

Issue 1783793002: VideoCapturer: Update interface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
diff --git a/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java b/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
index 23e2fddd4b56a770f9f33c5641c867053fae18a6..1d19d179e64520e960b6c8259b48b8083f6b9e14 100644
--- a/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
+++ b/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
@@ -81,7 +81,7 @@ public class VideoCapturerAndroid implements
private static final int NUMBER_OF_CAPTURE_BUFFERS = 3;
private final Set<byte[]> queuedBuffers = new HashSet<byte[]>();
private final boolean isCapturingToTexture;
- final SurfaceTextureHelper surfaceHelper; // Package visible for testing purposes.
+ private SurfaceTextureHelper surfaceHelper;
// The camera API can output one old frame after the camera has been switched or the resolution
// has been changed. This flag is used for dropping the first frame after camera restart.
private boolean dropNextFrame = false;
@@ -187,16 +187,22 @@ public class VideoCapturerAndroid implements
public static VideoCapturerAndroid create(String name,
CameraEventsHandler eventsHandler) {
- return VideoCapturerAndroid.create(name, eventsHandler, null);
+ return VideoCapturerAndroid.create(name, eventsHandler, false /* captureToTexture */);
}
+ // Deprecated. Use create() function below instead.
public static VideoCapturerAndroid create(String name,
CameraEventsHandler eventsHandler, EglBase.Context sharedEglContext) {
+ return create(name, eventsHandler, (sharedEglContext != null) /* captureToTexture */);
+ }
+
+ public static VideoCapturerAndroid create(String name,
+ CameraEventsHandler eventsHandler, boolean captureToTexture) {
final int cameraId = lookupDeviceName(name);
if (cameraId == -1) {
return null;
}
- return new VideoCapturerAndroid(cameraId, eventsHandler, sharedEglContext);
+ return new VideoCapturerAndroid(cameraId, eventsHandler, captureToTexture);
}
public void printStackTrace() {
@@ -297,18 +303,12 @@ public class VideoCapturerAndroid implements
return isCapturingToTexture;
}
- @Override
- public SurfaceTextureHelper getSurfaceTextureHelper() {
- return surfaceHelper;
- }
-
private VideoCapturerAndroid(int cameraId, CameraEventsHandler eventsHandler,
- EglBase.Context sharedContext) {
+ boolean captureToTexture) {
this.id = cameraId;
this.eventsHandler = eventsHandler;
- isCapturingToTexture = (sharedContext != null);
+ isCapturingToTexture = captureToTexture;
cameraStatistics = new CameraStatistics();
- surfaceHelper = SurfaceTextureHelper.create(sharedContext);
Logging.d(TAG, "VideoCapturerAndroid isCapturingToTexture : " + isCapturingToTexture);
}
@@ -361,7 +361,6 @@ public class VideoCapturerAndroid implements
throw new IllegalStateException("dispose() called while camera is running");
}
}
- surfaceHelper.dispose();
isDisposed = true;
}
@@ -375,8 +374,12 @@ public class VideoCapturerAndroid implements
@Override
public void startCapture(
final int width, final int height, final int framerate,
- final Context applicationContext, final CapturerObserver frameObserver) {
+ final SurfaceTextureHelper surfaceTextureHelper, final Context applicationContext,
+ final CapturerObserver frameObserver) {
Logging.d(TAG, "startCapture requested: " + width + "x" + height + "@" + framerate);
+ if (surfaceTextureHelper == null) {
+ throw new IllegalArgumentException("surfaceTextureHelper not set.");
+ }
if (applicationContext == null) {
throw new IllegalArgumentException("applicationContext not set.");
}
@@ -387,7 +390,8 @@ public class VideoCapturerAndroid implements
if (this.cameraThreadHandler != null) {
throw new RuntimeException("Camera has already been started.");
}
- this.cameraThreadHandler = surfaceHelper.getHandler();
+ this.cameraThreadHandler = surfaceTextureHelper.getHandler();
+ this.surfaceHelper = surfaceTextureHelper;
final boolean didPost = maybePostOnCameraThread(new Runnable() {
@Override
public void run() {
@@ -579,6 +583,7 @@ public class VideoCapturerAndroid implements
// Remove all pending Runnables posted from |this|.
cameraThreadHandler.removeCallbacksAndMessages(this /* token */);
cameraThreadHandler = null;
+ surfaceHelper = null;
}
barrier.countDown();
}

Powered by Google App Engine
This is Rietveld 408576698