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

Side by Side Diff: webrtc/api/android/java/src/org/webrtc/Camera2Capturer.java

Issue 2171023003: Convert Android camera tests to use the new createVideoSource API. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Style. Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/api/androidtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 throw new RuntimeException("Unknown camera state: " + cameraState); 260 throw new RuntimeException("Unknown camera state: " + cameraState);
261 } 261 }
262 closeAndRelease(); 262 closeAndRelease();
263 } 263 }
264 264
265 private void closeAndRelease() { 265 private void closeAndRelease() {
266 checkIsOnCameraThread(); 266 checkIsOnCameraThread();
267 267
268 Logging.d(TAG, "Close and release."); 268 Logging.d(TAG, "Close and release.");
269 setCameraState(CameraState.STOPPING); 269 setCameraState(CameraState.STOPPING);
270 capturerObserver.onCapturerStopped();
270 271
271 // Remove all pending Runnables posted from |this|. 272 // Remove all pending Runnables posted from |this|.
272 cameraThreadHandler.removeCallbacksAndMessages(this /* token */); 273 cameraThreadHandler.removeCallbacksAndMessages(this /* token */);
273 if (cameraStatistics != null) { 274 if (cameraStatistics != null) {
274 cameraStatistics.release(); 275 cameraStatistics.release();
275 cameraStatistics = null; 276 cameraStatistics = null;
276 } 277 }
277 if (surfaceTextureHelper != null) { 278 if (surfaceTextureHelper != null) {
278 surfaceTextureHelper.stopListening(); 279 surfaceTextureHelper.stopListening();
279 } 280 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Logging.e(TAG, "Camera state was not STOPPING in onClosed. Most likely c amera didn't stop " 569 Logging.e(TAG, "Camera state was not STOPPING in onClosed. Most likely c amera didn't stop "
569 + "within timelimit and this method was invoked twice."); 570 + "within timelimit and this method was invoked twice.");
570 return; 571 return;
571 } 572 }
572 573
573 cameraThreadHandler.removeCallbacksAndMessages(STOP_TIMEOUT_RUNNABLE_TOKEN ); 574 cameraThreadHandler.removeCallbacksAndMessages(STOP_TIMEOUT_RUNNABLE_TOKEN );
574 setCameraState(CameraState.IDLE); 575 setCameraState(CameraState.IDLE);
575 if (eventsHandler != null) { 576 if (eventsHandler != null) {
576 eventsHandler.onCameraClosed(); 577 eventsHandler.onCameraClosed();
577 } 578 }
578 capturerObserver.onCapturerStopped();
579 } 579 }
580 } 580 }
581 581
582 final class CaptureSessionCallback extends CameraCaptureSession.StateCallback { 582 final class CaptureSessionCallback extends CameraCaptureSession.StateCallback {
583 @Override 583 @Override
584 public void onConfigureFailed(CameraCaptureSession session) { 584 public void onConfigureFailed(CameraCaptureSession session) {
585 checkIsOnCameraThread(); 585 checkIsOnCameraThread();
586 captureSession = session; 586 captureSession = session;
587 reportError("Failed to configure capture session."); 587 reportError("Failed to configure capture session.");
588 } 588 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 break; 855 break;
856 } 856 }
857 return orientation; 857 return orientation;
858 } 858 }
859 859
860 @Override 860 @Override
861 public void onTextureFrameAvailable( 861 public void onTextureFrameAvailable(
862 int oesTextureId, float[] transformMatrix, long timestampNs) { 862 int oesTextureId, float[] transformMatrix, long timestampNs) {
863 checkIsOnCameraThread(); 863 checkIsOnCameraThread();
864 864
865 if (cameraState != CameraState.RUNNING) {
866 Logging.d(TAG, "Texture frame received while camera was not running.");
867 return;
868 }
869
865 if (eventsHandler != null && !firstFrameReported) { 870 if (eventsHandler != null && !firstFrameReported) {
866 eventsHandler.onFirstFrameAvailable(); 871 eventsHandler.onFirstFrameAvailable();
867 firstFrameReported = true; 872 firstFrameReported = true;
868 } 873 }
869 874
870 int rotation; 875 int rotation;
871 if (isFrontCamera) { 876 if (isFrontCamera) {
872 // Undo the mirror that the OS "helps" us with. 877 // Undo the mirror that the OS "helps" us with.
873 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int) 878 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int)
874 rotation = cameraOrientation + getDeviceOrientation(); 879 rotation = cameraOrientation + getDeviceOrientation();
875 transformMatrix = 880 transformMatrix =
876 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix()); 881 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix());
877 } else { 882 } else {
878 rotation = cameraOrientation - getDeviceOrientation(); 883 rotation = cameraOrientation - getDeviceOrientation();
879 } 884 }
880 // Make sure |rotation| is between 0 and 360. 885 // Make sure |rotation| is between 0 and 360.
881 rotation = (360 + rotation % 360) % 360; 886 rotation = (360 + rotation % 360) % 360;
882 887
883 // Undo camera orientation - we report it as rotation instead. 888 // Undo camera orientation - we report it as rotation instead.
884 transformMatrix = RendererCommon.rotateTextureMatrix(transformMatrix, -camer aOrientation); 889 transformMatrix = RendererCommon.rotateTextureMatrix(transformMatrix, -camer aOrientation);
885 890
886 cameraStatistics.addFrame(); 891 cameraStatistics.addFrame();
887 capturerObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.h eight, oesTextureId, 892 capturerObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.h eight, oesTextureId,
888 transformMatrix, rotation, timestampNs); 893 transformMatrix, rotation, timestampNs);
889 } 894 }
890 } 895 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/androidtests/src/org/webrtc/CameraVideoCapturerTestFixtures.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698