OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 final SurfaceTextureHelper surfaceTextureHelper, final int cameraId, final
int width, | 58 final SurfaceTextureHelper surfaceTextureHelper, final int cameraId, final
int width, |
59 final int height, final int framerate) { | 59 final int height, final int framerate) { |
60 final long constructionTimeNs = System.nanoTime(); | 60 final long constructionTimeNs = System.nanoTime(); |
61 Logging.d(TAG, "Open camera " + cameraId); | 61 Logging.d(TAG, "Open camera " + cameraId); |
62 events.onCameraOpening(); | 62 events.onCameraOpening(); |
63 | 63 |
64 final android.hardware.Camera camera; | 64 final android.hardware.Camera camera; |
65 try { | 65 try { |
66 camera = android.hardware.Camera.open(cameraId); | 66 camera = android.hardware.Camera.open(cameraId); |
67 } catch (RuntimeException e) { | 67 } catch (RuntimeException e) { |
68 callback.onFailure(e.getMessage()); | 68 callback.onFailure(FailureType.ERROR, e.getMessage()); |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 try { | 72 try { |
73 camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture()); | 73 camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture()); |
74 } catch (IOException e) { | 74 } catch (IOException e) { |
75 camera.release(); | 75 camera.release(); |
76 callback.onFailure(e.getMessage()); | 76 callback.onFailure(FailureType.ERROR, e.getMessage()); |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
80 final android.hardware.Camera.CameraInfo info = new android.hardware.Camera.
CameraInfo(); | 80 final android.hardware.Camera.CameraInfo info = new android.hardware.Camera.
CameraInfo(); |
81 android.hardware.Camera.getCameraInfo(cameraId, info); | 81 android.hardware.Camera.getCameraInfo(cameraId, info); |
82 | 82 |
83 final android.hardware.Camera.Parameters parameters = camera.getParameters()
; | 83 final android.hardware.Camera.Parameters parameters = camera.getParameters()
; |
84 final CaptureFormat captureFormat = | 84 final CaptureFormat captureFormat = |
85 findClosestCaptureFormat(parameters, width, height, framerate); | 85 findClosestCaptureFormat(parameters, width, height, framerate); |
86 final Size pictureSize = findClosestPictureSize(parameters, width, height); | 86 final Size pictureSize = findClosestPictureSize(parameters, width, height); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 return (info.orientation + rotation) % 360; | 335 return (info.orientation + rotation) % 360; |
336 } | 336 } |
337 | 337 |
338 private void checkIsOnCameraThread() { | 338 private void checkIsOnCameraThread() { |
339 if (Thread.currentThread() != cameraThreadHandler.getLooper().getThread()) { | 339 if (Thread.currentThread() != cameraThreadHandler.getLooper().getThread()) { |
340 throw new IllegalStateException("Wrong thread"); | 340 throw new IllegalStateException("Wrong thread"); |
341 } | 341 } |
342 } | 342 } |
343 } | 343 } |
OLD | NEW |