| Index: talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
|
| diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
|
| index ebd858a962799a13d9ebc875a5a98781fdeb79fa..dc3f8e87009827c76accc5dfe017cd63706d6df1 100644
|
| --- a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
|
| +++ b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
|
| @@ -36,13 +36,12 @@ import android.opengl.GLES20;
|
| import android.os.Handler;
|
| import android.os.Looper;
|
| import android.os.SystemClock;
|
| +import android.util.Log;
|
| import android.view.Surface;
|
| import android.view.WindowManager;
|
|
|
| import org.json.JSONException;
|
| -
|
| import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
| -import org.webrtc.Logging;
|
|
|
| import java.io.IOException;
|
| import java.nio.ByteBuffer;
|
| @@ -106,7 +105,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| } else {
|
| errorMessage = "Camera error: " + error;
|
| }
|
| - Logging.e(TAG, errorMessage);
|
| + Log.e(TAG, errorMessage);
|
| if (errorHandler != null) {
|
| errorHandler.onCameraError(errorMessage);
|
| }
|
| @@ -125,11 +124,11 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| averageCaptureBuffersCount =
|
| (double)captureBuffersCount / cameraFramesCount;
|
| }
|
| - Logging.d(TAG, "Camera fps: " + cameraFps + ". CaptureBuffers: " +
|
| + Log.d(TAG, "Camera fps: " + cameraFps + ". CaptureBuffers: " +
|
| String.format("%.1f", averageCaptureBuffersCount) +
|
| ". Pending buffers: " + videoBuffers.pendingFramesTimeStamps());
|
| if (cameraFramesCount == 0) {
|
| - Logging.e(TAG, "Camera freezed.");
|
| + Log.e(TAG, "Camera freezed.");
|
| if (errorHandler != null) {
|
| errorHandler.onCameraError("Camera failure.");
|
| }
|
| @@ -169,13 +168,13 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| return false;
|
|
|
| if (cameraThreadHandler == null) {
|
| - Logging.e(TAG, "Calling switchCamera() for stopped camera.");
|
| + Log.e(TAG, "Calling switchCamera() for stopped camera.");
|
| return false;
|
| }
|
| if (pendingCameraSwitch) {
|
| // Do not handle multiple camera switch request to avoid blocking
|
| // camera thread by handling too many switch request from a queue.
|
| - Logging.w(TAG, "Ignoring camera switch request.");
|
| + Log.w(TAG, "Ignoring camera switch request.");
|
| return false;
|
| }
|
|
|
| @@ -194,7 +193,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| public synchronized void onOutputFormatRequest(
|
| final int width, final int height, final int fps) {
|
| if (cameraThreadHandler == null) {
|
| - Logging.e(TAG, "Calling onOutputFormatRequest() for already stopped camera.");
|
| + Log.e(TAG, "Calling onOutputFormatRequest() for already stopped camera.");
|
| return;
|
| }
|
| cameraThreadHandler.post(new Runnable() {
|
| @@ -209,7 +208,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| public synchronized void changeCaptureFormat(
|
| final int width, final int height, final int framerate) {
|
| if (cameraThreadHandler == null) {
|
| - Logging.e(TAG, "Calling changeCaptureFormat() for already stopped camera.");
|
| + Log.e(TAG, "Calling changeCaptureFormat() for already stopped camera.");
|
| return;
|
| }
|
| cameraThreadHandler.post(new Runnable() {
|
| @@ -230,14 +229,14 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| }
|
|
|
| private VideoCapturerAndroid() {
|
| - Logging.d(TAG, "VideoCapturerAndroid");
|
| + Log.d(TAG, "VideoCapturerAndroid");
|
| }
|
|
|
| // Called by native code.
|
| // Initializes local variables for the camera named |deviceName|. If |deviceName| is empty, the
|
| // first available device is used in order to be compatible with the generic VideoCapturer class.
|
| synchronized boolean init(String deviceName) {
|
| - Logging.d(TAG, "init: " + deviceName);
|
| + Log.d(TAG, "init: " + deviceName);
|
| if (deviceName == null)
|
| return false;
|
|
|
| @@ -282,7 +281,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| synchronized void startCapture(
|
| final int width, final int height, final int framerate,
|
| final Context applicationContext, final CapturerObserver frameObserver) {
|
| - Logging.d(TAG, "startCapture requested: " + width + "x" + height
|
| + Log.d(TAG, "startCapture requested: " + width + "x" + height
|
| + "@" + framerate);
|
| if (applicationContext == null) {
|
| throw new RuntimeException("applicationContext not set.");
|
| @@ -313,7 +312,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| this.applicationContext = applicationContext;
|
| this.frameObserver = frameObserver;
|
| try {
|
| - Logging.d(TAG, "Opening camera " + id);
|
| + Log.d(TAG, "Opening camera " + id);
|
| camera = Camera.open(id);
|
| info = new Camera.CameraInfo();
|
| Camera.getCameraInfo(id, info);
|
| @@ -329,11 +328,11 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
|
|
| camera.setPreviewTexture(cameraSurfaceTexture);
|
| } catch (IOException e) {
|
| - Logging.e(TAG, "setPreviewTexture failed", error);
|
| + Log.e(TAG, "setPreviewTexture failed", error);
|
| throw new RuntimeException(e);
|
| }
|
|
|
| - Logging.d(TAG, "Camera orientation: " + info.orientation +
|
| + Log.d(TAG, "Camera orientation: " + info.orientation +
|
| " .Device orientation: " + getDeviceOrientation());
|
| camera.setErrorCallback(cameraErrorCallback);
|
| startPreviewOnCameraThread(width, height, framerate);
|
| @@ -347,7 +346,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| } catch (RuntimeException e) {
|
| error = e;
|
| }
|
| - Logging.e(TAG, "startCapture failed", error);
|
| + Log.e(TAG, "startCapture failed", error);
|
| stopCaptureOnCameraThread();
|
| cameraThreadHandler = null;
|
| frameObserver.OnCapturerStarted(false);
|
| @@ -359,10 +358,10 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
|
|
| // (Re)start preview with the closest supported format to |width| x |height| @ |framerate|.
|
| private void startPreviewOnCameraThread(int width, int height, int framerate) {
|
| - Logging.d(
|
| + Log.d(
|
| TAG, "startPreviewOnCameraThread requested: " + width + "x" + height + "@" + framerate);
|
| if (camera == null) {
|
| - Logging.e(TAG, "Calling startPreviewOnCameraThread on stopped camera.");
|
| + Log.e(TAG, "Calling startPreviewOnCameraThread on stopped camera.");
|
| return;
|
| }
|
|
|
| @@ -386,7 +385,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| }
|
|
|
| // Update camera parameters.
|
| - Logging.d(TAG, "isVideoStabilizationSupported: " +
|
| + Log.d(TAG, "isVideoStabilizationSupported: " +
|
| parameters.isVideoStabilizationSupported());
|
| if (parameters.isVideoStabilizationSupported()) {
|
| parameters.setVideoStabilization(true);
|
| @@ -413,7 +412,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| }
|
|
|
| // (Re)start preview.
|
| - Logging.d(TAG, "Start capturing: " + captureFormat);
|
| + Log.d(TAG, "Start capturing: " + captureFormat);
|
| this.captureFormat = captureFormat;
|
| camera.setParameters(parameters);
|
| videoBuffers.queueCameraBuffers(captureFormat.frameSize(), camera);
|
| @@ -424,10 +423,10 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| // Called by native code. Returns true when camera is known to be stopped.
|
| synchronized void stopCapture() throws InterruptedException {
|
| if (cameraThreadHandler == null) {
|
| - Logging.e(TAG, "Calling stopCapture() for already stopped camera.");
|
| + Log.e(TAG, "Calling stopCapture() for already stopped camera.");
|
| return;
|
| }
|
| - Logging.d(TAG, "stopCapture");
|
| + Log.d(TAG, "stopCapture");
|
| cameraThreadHandler.post(new Runnable() {
|
| @Override public void run() {
|
| stopCaptureOnCameraThread();
|
| @@ -435,7 +434,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| });
|
| cameraThread.join();
|
| cameraThreadHandler = null;
|
| - Logging.d(TAG, "stopCapture done");
|
| + Log.d(TAG, "stopCapture done");
|
| }
|
|
|
| private void stopCaptureOnCameraThread() {
|
| @@ -445,13 +444,13 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| }
|
|
|
| private void doStopCaptureOnCameraThread() {
|
| - Logging.d(TAG, "stopCaptureOnCameraThread");
|
| + Log.d(TAG, "stopCaptureOnCameraThread");
|
| if (camera == null) {
|
| return;
|
| }
|
| try {
|
| cameraThreadHandler.removeCallbacks(cameraObserver);
|
| - Logging.d(TAG, "Stop preview.");
|
| + Log.d(TAG, "Stop preview.");
|
| camera.stopPreview();
|
| camera.setPreviewCallbackWithBuffer(null);
|
| videoBuffers.stopReturnBuffersToCamera();
|
| @@ -463,22 +462,22 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| GLES20.glDeleteTextures(1, new int[] {cameraGlTexture}, 0);
|
| cameraGlTexture = 0;
|
| }
|
| - Logging.d(TAG, "Release camera.");
|
| + Log.d(TAG, "Release camera.");
|
| camera.release();
|
| camera = null;
|
| } catch (IOException e) {
|
| - Logging.e(TAG, "Failed to stop camera", e);
|
| + Log.e(TAG, "Failed to stop camera", e);
|
| }
|
| }
|
|
|
| private void switchCameraOnCameraThread(Runnable switchDoneEvent) {
|
| - Logging.d(TAG, "switchCameraOnCameraThread");
|
| + Log.d(TAG, "switchCameraOnCameraThread");
|
|
|
| doStopCaptureOnCameraThread();
|
| startCaptureOnCameraThread(requestedWidth, requestedHeight, requestedFramerate, frameObserver,
|
| applicationContext);
|
| pendingCameraSwitch = false;
|
| - Logging.d(TAG, "switchCameraOnCameraThread done");
|
| + Log.d(TAG, "switchCameraOnCameraThread done");
|
| if (switchDoneEvent != null) {
|
| switchDoneEvent.run();
|
| }
|
| @@ -489,7 +488,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| if (camera == null) {
|
| return;
|
| }
|
| - Logging.d(TAG, "onOutputFormatRequestOnCameraThread: " + width + "x" + height +
|
| + Log.d(TAG, "onOutputFormatRequestOnCameraThread: " + width + "x" + height +
|
| "@" + fps);
|
| frameObserver.OnOutputFormatRequest(width, height, fps);
|
| }
|
| @@ -551,7 +550,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| frameObserver.OnFrameCaptured(data, videoBuffers.frameSize, captureFormat.width,
|
| captureFormat.height, rotation, captureTimeNs);
|
| } else {
|
| - Logging.w(TAG, "reserveByteBuffer failed - dropping frame.");
|
| + Log.w(TAG, "reserveByteBuffer failed - dropping frame.");
|
| }
|
| }
|
|
|
| @@ -614,7 +613,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| camera.addCallbackBuffer(buffer.array());
|
| queuedBuffers.put(buffer.array(), buffer);
|
| }
|
| - Logging.d(TAG, "queueCameraBuffers enqueued " + numCaptureBuffers
|
| + Log.d(TAG, "queueCameraBuffers enqueued " + numCaptureBuffers
|
| + " buffers of size " + frameSize + ".");
|
| }
|
|
|
| @@ -630,7 +629,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| this.camera = null;
|
| queuedBuffers.clear();
|
| // Frames in |pendingBuffers| need to be kept alive until they are returned.
|
| - Logging.d(TAG, "stopReturnBuffersToCamera called."
|
| + Log.d(TAG, "stopReturnBuffersToCamera called."
|
| + (pendingBuffers.isEmpty() ?
|
| " All buffers have been returned."
|
| : " Pending buffers: " + pendingFramesTimeStamps() + "."));
|
| @@ -641,7 +640,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| if (buffer == null) {
|
| // Frames might be posted to |onPreviewFrame| with the previous format while changing
|
| // capture format in |startPreviewOnCameraThread|. Drop these old frames.
|
| - Logging.w(TAG, "Received callback buffer from previous configuration with length: "
|
| + Log.w(TAG, "Received callback buffer from previous configuration with length: "
|
| + (data == null ? "null" : data.length));
|
| return false;
|
| }
|
| @@ -649,12 +648,12 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| throw new IllegalStateException("Callback buffer has unexpected frame size");
|
| }
|
| if (pendingBuffers.containsKey(timeStamp)) {
|
| - Logging.e(TAG, "Timestamp already present in pending buffers - they need to be unique");
|
| + Log.e(TAG, "Timestamp already present in pending buffers - they need to be unique");
|
| return false;
|
| }
|
| pendingBuffers.put(timeStamp, buffer);
|
| if (queuedBuffers.isEmpty()) {
|
| - Logging.v(TAG, "Camera is running out of capture buffers."
|
| + Log.v(TAG, "Camera is running out of capture buffers."
|
| + " Pending buffers: " + pendingFramesTimeStamps());
|
| }
|
| return true;
|
| @@ -670,7 +669,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| if (camera != null && returnedFrame.capacity() == frameSize) {
|
| camera.addCallbackBuffer(returnedFrame.array());
|
| if (queuedBuffers.isEmpty()) {
|
| - Logging.v(TAG, "Frame returned when camera is running out of capture"
|
| + Log.v(TAG, "Frame returned when camera is running out of capture"
|
| + " buffers for TS " + TimeUnit.NANOSECONDS.toMillis(timeStamp));
|
| }
|
| queuedBuffers.put(returnedFrame.array(), returnedFrame);
|
| @@ -678,7 +677,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| }
|
|
|
| if (returnedFrame.capacity() != frameSize) {
|
| - Logging.d(TAG, "returnBuffer with time stamp "
|
| + Log.d(TAG, "returnBuffer with time stamp "
|
| + TimeUnit.NANOSECONDS.toMillis(timeStamp)
|
| + " called with old frame size, " + returnedFrame.capacity() + ".");
|
| // Since this frame has the wrong size, don't requeue it. Frames with the correct size are
|
| @@ -686,7 +685,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
|
| return;
|
| }
|
|
|
| - Logging.d(TAG, "returnBuffer with time stamp "
|
| + Log.d(TAG, "returnBuffer with time stamp "
|
| + TimeUnit.NANOSECONDS.toMillis(timeStamp)
|
| + " called after camera has been stopped.");
|
| }
|
|
|