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

Unified Diff: webrtc/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java

Issue 2984633002: Add a field trial to produce VideoFrames in camera capturers. (Closed)
Patch Set: Update log message. Created 3 years, 5 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/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java
diff --git a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java
index d9af85b96c74641dd5d84d2a699c2cbb6ac8dd34..0ff3a758714f09adcb5516a88b0f5d4e1cda92b3 100644
--- a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java
+++ b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java
@@ -100,9 +100,7 @@ class CameraVideoCapturerTestFixtures {
static private class FakeCapturerObserver implements CameraVideoCapturer.CapturerObserver {
private int framesCaptured = 0;
- private int frameSize = 0;
- private int frameWidth = 0;
- private int frameHeight = 0;
+ private VideoFrame videoFrame;
final private Object frameLock = new Object();
final private Object capturerStartLock = new Object();
private boolean capturerStartResult = false;
@@ -126,32 +124,27 @@ class CameraVideoCapturerTestFixtures {
@Override
public void onByteBufferFrameCaptured(
byte[] frame, int width, int height, int rotation, long timeStamp) {
- synchronized (frameLock) {
- ++framesCaptured;
- frameSize = frame.length;
- frameWidth = width;
- frameHeight = height;
- timestamps.add(timeStamp);
- frameLock.notify();
- }
+ // Empty on purpose.
}
@Override
public void onTextureFrameCaptured(int width, int height, int oesTextureId,
float[] transformMatrix, int rotation, long timeStamp) {
- synchronized (frameLock) {
- ++framesCaptured;
- frameWidth = width;
- frameHeight = height;
- frameSize = 0;
- timestamps.add(timeStamp);
- frameLock.notify();
- }
+ // Empty on purpose.
}
@Override
public void onFrameCaptured(VideoFrame frame) {
- // Empty on purpose.
+ synchronized (frameLock) {
+ ++framesCaptured;
+ if (videoFrame != null) {
+ videoFrame.release();
+ }
+ videoFrame = frame;
+ videoFrame.retain();
+ timestamps.add(videoFrame.getTimestampNs());
+ frameLock.notify();
+ }
}
public boolean waitForCapturerToStart() throws InterruptedException {
@@ -172,19 +165,34 @@ class CameraVideoCapturerTestFixtures {
int frameSize() {
synchronized (frameLock) {
- return frameSize;
+ if (videoFrame.getBuffer() instanceof VideoFrame.I420Buffer) {
+ VideoFrame.I420Buffer buffer = (VideoFrame.I420Buffer) videoFrame.getBuffer();
+ return buffer.getDataY().remaining() + buffer.getDataU().remaining()
+ + buffer.getDataV().remaining();
+ } else {
+ return 0;
+ }
}
}
int frameWidth() {
synchronized (frameLock) {
- return frameWidth;
+ return videoFrame.getWidth();
}
}
int frameHeight() {
synchronized (frameLock) {
- return frameHeight;
+ return videoFrame.getHeight();
+ }
+ }
+
+ void releaseFrame() {
+ synchronized (frameLock) {
+ if (videoFrame != null) {
+ videoFrame.release();
+ videoFrame = null;
+ }
}
}
@@ -385,7 +393,7 @@ class CameraVideoCapturerTestFixtures {
instance.capturer.stopCapture();
instance.cameraEvents.waitForCameraClosed();
instance.capturer.dispose();
- instance.surfaceTextureHelper.returnTextureFrame();
+ instance.observer.releaseFrame();
instance.surfaceTextureHelper.dispose();
}
@@ -637,7 +645,7 @@ class CameraVideoCapturerTestFixtures {
// Make sure camera is started and then stop it.
assertTrue(capturerInstance.observer.waitForCapturerToStart());
capturerInstance.capturer.stopCapture();
- capturerInstance.surfaceTextureHelper.returnTextureFrame();
+ capturerInstance.observer.releaseFrame();
// We can't change |capturer| at this point, but we should not crash.
capturerInstance.capturer.switchCamera(null /* switchEventsHandler */);
@@ -693,7 +701,7 @@ class CameraVideoCapturerTestFixtures {
assertTrue(capturerInstance.format.frameSize() <= capturerInstance.observer.frameSize());
}
capturerInstance.capturer.stopCapture();
- capturerInstance.surfaceTextureHelper.returnTextureFrame();
+ capturerInstance.observer.releaseFrame();
}
disposeCapturer(capturerInstance);
}
@@ -710,7 +718,7 @@ class CameraVideoCapturerTestFixtures {
startCapture(capturerInstance, 1);
capturerInstance.observer.waitForCapturerToStart();
- capturerInstance.surfaceTextureHelper.returnTextureFrame();
+ capturerInstance.observer.releaseFrame();
capturerInstance.observer.waitForNextCapturedFrame();
capturerInstance.capturer.stopCapture();

Powered by Google App Engine
This is Rietveld 408576698