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

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

Issue 2377003002: Format all Java in WebRTC. (Closed)
Patch Set: Manual changes. Created 4 years, 3 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/android/java/src/org/webrtc/VideoCapturerAndroid.java
diff --git a/webrtc/api/android/java/src/org/webrtc/VideoCapturerAndroid.java b/webrtc/api/android/java/src/org/webrtc/VideoCapturerAndroid.java
index 9f90f5381ff0c7d68f0090cce67f2b2317afd75c..17c793a87ef53eeb2c16e51826c0623d78abf2de 100644
--- a/webrtc/api/android/java/src/org/webrtc/VideoCapturerAndroid.java
+++ b/webrtc/api/android/java/src/org/webrtc/VideoCapturerAndroid.java
@@ -40,14 +40,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
// the camera has been stopped.
// TODO(magjed): This class name is now confusing - rename to Camera1VideoCapturer.
@SuppressWarnings("deprecation")
-public class VideoCapturerAndroid implements
- CameraVideoCapturer,
- android.hardware.Camera.PreviewCallback,
- SurfaceTextureHelper.OnTextureFrameAvailableListener {
+public class VideoCapturerAndroid
+ implements CameraVideoCapturer, android.hardware.Camera.PreviewCallback,
+ SurfaceTextureHelper.OnTextureFrameAvailableListener {
private static final String TAG = "VideoCapturerAndroid";
private static final int CAMERA_STOP_TIMEOUT_MS = 7000;
- private android.hardware.Camera camera; // Only non-null while capturing.
+ private android.hardware.Camera camera; // Only non-null while capturing.
private final AtomicBoolean isCameraRunning = new AtomicBoolean();
// Use maybePostOnCameraThread() instead of posting directly to the handler - this way all
// callbacks with a specifed token can be removed at once.
@@ -83,30 +82,29 @@ public class VideoCapturerAndroid implements
// Camera error callback.
private final android.hardware.Camera.ErrorCallback cameraErrorCallback =
new android.hardware.Camera.ErrorCallback() {
- @Override
- public void onError(int error, android.hardware.Camera camera) {
- String errorMessage;
- if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
- errorMessage = "Camera server died!";
- } else {
- errorMessage = "Camera error: " + error;
- }
- Logging.e(TAG, errorMessage);
- if (eventsHandler != null) {
- eventsHandler.onCameraError(errorMessage);
- }
- }
- };
+ @Override
+ public void onError(int error, android.hardware.Camera camera) {
+ String errorMessage;
+ if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
+ errorMessage = "Camera server died!";
+ } else {
+ errorMessage = "Camera error: " + error;
+ }
+ Logging.e(TAG, errorMessage);
+ if (eventsHandler != null) {
+ eventsHandler.onCameraError(errorMessage);
+ }
+ }
+ };
- public static VideoCapturerAndroid create(String name,
- CameraEventsHandler eventsHandler) {
+ public static VideoCapturerAndroid create(String name, CameraEventsHandler eventsHandler) {
return VideoCapturerAndroid.create(name, eventsHandler, false /* captureToTexture */);
}
// Use ctor directly instead.
@Deprecated
- public static VideoCapturerAndroid create(String name,
- CameraEventsHandler eventsHandler, boolean captureToTexture) {
+ public static VideoCapturerAndroid create(
+ String name, CameraEventsHandler eventsHandler, boolean captureToTexture) {
try {
return new VideoCapturerAndroid(name, eventsHandler, captureToTexture);
} catch (RuntimeException e) {
@@ -179,7 +177,8 @@ public class VideoCapturerAndroid implements
@Override
public void onOutputFormatRequest(final int width, final int height, final int framerate) {
maybePostOnCameraThread(new Runnable() {
- @Override public void run() {
+ @Override
+ public void run() {
onOutputFormatRequestOnCameraThread(width, height, framerate);
}
});
@@ -190,7 +189,8 @@ public class VideoCapturerAndroid implements
@Override
public void changeCaptureFormat(final int width, final int height, final int framerate) {
maybePostOnCameraThread(new Runnable() {
- @Override public void run() {
+ @Override
+ public void run() {
startPreviewOnCameraThread(width, height, framerate);
}
});
@@ -209,8 +209,8 @@ public class VideoCapturerAndroid implements
return isCapturingToTexture;
}
- public VideoCapturerAndroid(String cameraName, CameraEventsHandler eventsHandler,
- boolean captureToTexture) {
+ public VideoCapturerAndroid(
+ String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) {
if (android.hardware.Camera.getNumberOfCameras() == 0) {
throw new RuntimeException("No cameras available");
}
@@ -239,7 +239,7 @@ public class VideoCapturerAndroid implements
private boolean maybePostDelayedOnCameraThread(int delayMs, Runnable runnable) {
return cameraThreadHandler != null && isCameraRunning.get()
&& cameraThreadHandler.postAtTime(
- runnable, this /* token */, SystemClock.uptimeMillis() + delayMs);
+ runnable, this /* token */, SystemClock.uptimeMillis() + delayMs);
}
@Override
@@ -346,8 +346,8 @@ public class VideoCapturerAndroid implements
camera.setPreviewTexture(surfaceHelper.getSurfaceTexture());
- Logging.d(TAG, "Camera orientation: " + info.orientation +
- " .Device orientation: " + getDeviceOrientation());
+ Logging.d(TAG, "Camera orientation: " + info.orientation + " .Device orientation: "
+ + getDeviceOrientation());
camera.setErrorCallback(cameraErrorCallback);
startPreviewOnCameraThread(width, height, framerate);
frameObserver.onCapturerStarted(true);
@@ -357,7 +357,7 @@ public class VideoCapturerAndroid implements
// Start camera observer.
cameraStatistics = new CameraStatistics(surfaceHelper, eventsHandler);
- } catch (IOException|RuntimeException e) {
+ } catch (IOException | RuntimeException e) {
Logging.e(TAG, "startCapture failed", e);
// Make sure the camera is released.
stopCaptureOnCameraThread(true /* stopHandler */);
@@ -365,7 +365,7 @@ public class VideoCapturerAndroid implements
if (eventsHandler != null) {
eventsHandler.onCameraError("Camera can not be started.");
}
- }
+ }
}
// (Re)start preview with the closest supported format to |width| x |height| @ |framerate|.
@@ -406,8 +406,7 @@ public class VideoCapturerAndroid implements
}
// Update camera parameters.
- Logging.d(TAG, "isVideoStabilizationSupported: " +
- parameters.isVideoStabilizationSupported());
+ Logging.d(TAG, "isVideoStabilizationSupported: " + parameters.isVideoStabilizationSupported());
if (parameters.isVideoStabilizationSupported()) {
parameters.setVideoStabilization(true);
}
@@ -467,7 +466,8 @@ public class VideoCapturerAndroid implements
Logging.d(TAG, "stopCapture");
final CountDownLatch barrier = new CountDownLatch(1);
final boolean didPost = maybePostOnCameraThread(new Runnable() {
- @Override public void run() {
+ @Override
+ public void run() {
stopCaptureOnCameraThread(true /* stopHandler */);
barrier.countDown();
}
@@ -548,17 +548,16 @@ public class VideoCapturerAndroid implements
private void onOutputFormatRequestOnCameraThread(int width, int height, int framerate) {
checkIsOnCameraThread();
- Logging.d(TAG, "onOutputFormatRequestOnCameraThread: " + width + "x" + height +
- "@" + framerate);
+ Logging.d(
+ TAG, "onOutputFormatRequestOnCameraThread: " + width + "x" + height + "@" + framerate);
frameObserver.onOutputFormatRequest(width, height, framerate);
}
private int getDeviceOrientation() {
int orientation = 0;
- WindowManager wm = (WindowManager) applicationContext.getSystemService(
- Context.WINDOW_SERVICE);
- switch(wm.getDefaultDisplay().getRotation()) {
+ WindowManager wm = (WindowManager) applicationContext.getSystemService(Context.WINDOW_SERVICE);
+ switch (wm.getDefaultDisplay().getRotation()) {
case Surface.ROTATION_90:
orientation = 90;
break;
@@ -600,8 +599,7 @@ public class VideoCapturerAndroid implements
throw new RuntimeException("Unexpected camera in callback!");
}
- final long captureTimeNs =
- TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
+ final long captureTimeNs = TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
if (eventsHandler != null && !firstFrameReported) {
eventsHandler.onFirstFrameAvailable();
@@ -609,14 +607,13 @@ public class VideoCapturerAndroid implements
}
cameraStatistics.addFrame();
- frameObserver.onByteBufferFrameCaptured(data, captureFormat.width, captureFormat.height,
- getFrameOrientation(), captureTimeNs);
+ frameObserver.onByteBufferFrameCaptured(
+ data, captureFormat.width, captureFormat.height, getFrameOrientation(), captureTimeNs);
camera.addCallbackBuffer(data);
}
@Override
- public void onTextureFrameAvailable(
- int oesTextureId, float[] transformMatrix, long timestampNs) {
+ public void onTextureFrameAvailable(int oesTextureId, float[] transformMatrix, long timestampNs) {
checkIsOnCameraThread();
if (!isCameraRunning.get()) {
Logging.e(TAG, "onTextureFrameAvailable: Camera is stopped");

Powered by Google App Engine
This is Rietveld 408576698