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

Unified Diff: webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java

Issue 2984633002: Add a field trial to produce VideoFrames in camera capturers. (Closed)
Patch Set: Fix error. Created 3 years, 4 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/src/java/org/webrtc/Camera2Session.java
diff --git a/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java b/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java
index 8de5be0eebef48b3cea295d1903abf9c3b105e0f..b74aaa0035abfcc2cea95d95c68d14d33a6e408a 100644
--- a/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java
+++ b/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java
@@ -12,6 +12,7 @@ package org.webrtc;
import android.annotation.TargetApi;
import android.content.Context;
+import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@@ -44,6 +45,8 @@ class Camera2Session implements CameraSession {
private static enum SessionState { RUNNING, STOPPED }
+ private final boolean videoFrameEmitTrialEnabled;
+
private final Handler cameraThreadHandler;
private final CreateSessionCallback callback;
private final Events events;
@@ -225,8 +228,17 @@ class Camera2Session implements CameraSession {
transformMatrix =
RendererCommon.rotateTextureMatrix(transformMatrix, -cameraOrientation);
- events.onTextureFrameCaptured(Camera2Session.this, captureFormat.width,
- captureFormat.height, oesTextureId, transformMatrix, rotation, timestampNs);
+ if (videoFrameEmitTrialEnabled) {
+ VideoFrame.Buffer buffer = surfaceTextureHelper.createTextureBuffer(
+ captureFormat.width, captureFormat.height,
+ RendererCommon.convertMatrixToAndroidGraphicsMatrix(transformMatrix));
+ final VideoFrame frame = new VideoFrame(buffer, rotation, timestampNs);
+ events.onFrameCaptured(Camera2Session.this, frame);
+ frame.release();
+ } else {
+ events.onTextureFrameCaptured(Camera2Session.this, captureFormat.width,
+ captureFormat.height, oesTextureId, transformMatrix, rotation, timestampNs);
+ }
}
});
Logging.d(TAG, "Camera device successfully started.");
@@ -301,6 +313,9 @@ class Camera2Session implements CameraSession {
CameraManager cameraManager, SurfaceTextureHelper surfaceTextureHelper,
MediaRecorder mediaRecorder, String cameraId, int width, int height, int framerate) {
Logging.d(TAG, "Create new camera2 session on camera " + cameraId);
+ videoFrameEmitTrialEnabled =
+ PeerConnectionFactory.fieldTrialsFindFullName(PeerConnectionFactory.VIDEO_FRAME_EMIT_TRIAL)
+ .equals(PeerConnectionFactory.TRIAL_ENABLED);
constructionTimeNs = System.nanoTime();
« no previous file with comments | « webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java ('k') | webrtc/sdk/android/src/java/org/webrtc/CameraCapturer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698