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

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

Issue 1755573002: Android SurfaceTextureHelper: Add stopListening() function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change name from disconnect() to dispose() Created 4 years, 10 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 a696805b2ac08cf7422b3dc733238e8edd200ab9..be6b3e26fe6723349f525b4a35aaf47108d1df82 100644
--- a/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
+++ b/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
@@ -306,9 +306,6 @@ public class VideoCapturerAndroid implements
surfaceHelper = SurfaceTextureHelper.create(sharedContext);
cameraThreadHandler = surfaceHelper.getHandler();
cameraThread = cameraThreadHandler.getLooper().getThread();
- if (isCapturingToTexture) {
- surfaceHelper.setListener(this);
- }
Logging.d(TAG, "VideoCapturerAndroid isCapturingToTexture : " + isCapturingToTexture);
}
@@ -352,7 +349,7 @@ public class VideoCapturerAndroid implements
}
}
});
- surfaceHelper.disconnect();
+ surfaceHelper.dispose();
cameraThread = null;
}
@@ -436,6 +433,9 @@ public class VideoCapturerAndroid implements
camera.setErrorCallback(cameraErrorCallback);
startPreviewOnCameraThread(width, height, framerate);
frameObserver.onCapturerStarted(true);
+ if (isCapturingToTexture) {
+ surfaceHelper.startListening(this);
+ }
// Start camera observer.
cameraThreadHandler.postDelayed(cameraObserver, CAMERA_OBSERVER_PERIOD_MS);
@@ -544,6 +544,8 @@ public class VideoCapturerAndroid implements
final CountDownLatch barrier = new CountDownLatch(1);
cameraThreadHandler.post(new Runnable() {
@Override public void run() {
+ // Make sure onTextureFrameAvailable() is not called anymore.
+ surfaceHelper.stopListening();
stopCaptureOnCameraThread();
barrier.countDown();
}
@@ -669,12 +671,10 @@ public class VideoCapturerAndroid implements
@Override
public void onTextureFrameAvailable(
int oesTextureId, float[] transformMatrix, long timestampNs) {
- checkIsOnCameraThread();
if (camera == null) {
- // Camera is stopped, we need to return the buffer immediately.
- surfaceHelper.returnTextureFrame();
- return;
+ throw new RuntimeException("onTextureFrameAvailable() called after stopCapture().");
}
+ checkIsOnCameraThread();
if (dropNextFrame) {
surfaceHelper.returnTextureFrame();
dropNextFrame = false;

Powered by Google App Engine
This is Rietveld 408576698