Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 17 | package com.android.camera.app; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 18 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 19 | import android.annotation.TargetApi; |
| 20 | import android.graphics.SurfaceTexture; |
Angus Kong | 9e76552 | 2013-07-31 14:05:20 -0700 | [diff] [blame] | 21 | import android.hardware.Camera; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 22 | import android.hardware.Camera.OnZoomChangeListener; |
| 23 | import android.hardware.Camera.Parameters; |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 24 | import android.os.Build; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 25 | import android.os.Handler; |
Angus Kong | dcb0ef1 | 2013-03-25 23:11:43 -0700 | [diff] [blame] | 26 | import android.view.SurfaceHolder; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 27 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 28 | /** |
Angus Kong | 9e76552 | 2013-07-31 14:05:20 -0700 | [diff] [blame] | 29 | * An interface which provides possible camera device operations. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 30 | * |
| 31 | * The client should call {@code CameraManager.cameraOpen} to get an instance |
| 32 | * of {@link CameraManager.CameraProxy} to control the camera. Classes |
| 33 | * implementing this interface should have its own one unique {@code Thread} |
| 34 | * other than the main thread for camera operations. Camera device callbacks |
| 35 | * are wrapped since the client should not deal with |
| 36 | * {@code android.hardware.Camera} directly. |
| 37 | * |
| 38 | * TODO: provide callback interfaces for: |
| 39 | * {@code android.hardware.Camera.ErrorCallback}, |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 40 | * {@code android.hardware.Camera.OnZoomChangeListener}, and |
| 41 | * {@code android.hardware.Camera.Parameters}. |
| 42 | */ |
| 43 | public interface CameraManager { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 44 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 45 | /** |
Erin Dahlgren | 630d55b | 2014-03-10 14:40:59 -0700 | [diff] [blame] | 46 | * A handler for all camera api runtime exceptions. |
| 47 | * The default behavior is to throw the runtime exception. |
| 48 | */ |
| 49 | public interface CameraExceptionCallback { |
| 50 | public void onCameraException(RuntimeException e); |
| 51 | } |
| 52 | |
| 53 | /** |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 54 | * An interface which wraps |
Angus Kong | 2bca210 | 2014-03-11 16:27:30 -0700 | [diff] [blame^] | 55 | * {@link android.hardware.Camera.ErrorCallback} |
| 56 | */ |
| 57 | public interface CameraErrorCallback { |
| 58 | public void onError(int error, CameraProxy camera); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * An interface which wraps |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 63 | * {@link android.hardware.Camera.AutoFocusCallback}. |
| 64 | */ |
| 65 | public interface CameraAFCallback { |
| 66 | public void onAutoFocus(boolean focused, CameraProxy camera); |
Angus Kong | dcb0ef1 | 2013-03-25 23:11:43 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 69 | /** |
| 70 | * An interface which wraps |
| 71 | * {@link android.hardware.Camera.AutoFocusMoveCallback}. |
| 72 | */ |
| 73 | public interface CameraAFMoveCallback { |
| 74 | public void onAutoFocusMoving(boolean moving, CameraProxy camera); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 77 | /** |
| 78 | * An interface which wraps |
| 79 | * {@link android.hardware.Camera.ShutterCallback}. |
| 80 | */ |
| 81 | public interface CameraShutterCallback { |
| 82 | public void onShutter(CameraProxy camera); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 85 | /** |
| 86 | * An interface which wraps |
| 87 | * {@link android.hardware.Camera.PictureCallback}. |
| 88 | */ |
| 89 | public interface CameraPictureCallback { |
| 90 | public void onPictureTaken(byte[] data, CameraProxy camera); |
| 91 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 92 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 93 | /** |
| 94 | * An interface which wraps |
| 95 | * {@link android.hardware.Camera.PreviewCallback}. |
| 96 | */ |
| 97 | public interface CameraPreviewDataCallback { |
| 98 | public void onPreviewFrame(byte[] data, CameraProxy camera); |
| 99 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 100 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 101 | /** |
Angus Kong | 9e76552 | 2013-07-31 14:05:20 -0700 | [diff] [blame] | 102 | * An interface which wraps |
| 103 | * {@link android.hardware.Camera.FaceDetectionListener}. |
| 104 | */ |
| 105 | public interface CameraFaceDetectionCallback { |
| 106 | /** |
| 107 | * Callback for face detection. |
| 108 | * |
| 109 | * @param faces Recognized face in the preview. |
| 110 | * @param camera The camera which the preview image comes from. |
| 111 | */ |
| 112 | public void onFaceDetection(Camera.Face[] faces, CameraProxy camera); |
| 113 | } |
| 114 | |
| 115 | /** |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 116 | * An interface to be called for any exception caught when opening the |
| 117 | * camera device. This error callback is different from the one defined |
| 118 | * in the framework, {@link android.hardware.Camera.ErrorCallback}, which |
| 119 | * is used after the camera is opened. |
| 120 | */ |
Angus Kong | 6284815 | 2013-11-08 17:25:29 -0800 | [diff] [blame] | 121 | public interface CameraOpenCallback { |
| 122 | /** |
| 123 | * Callback when camera open succeeds. |
| 124 | */ |
| 125 | public void onCameraOpened(CameraProxy camera); |
| 126 | |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 127 | /** |
| 128 | * Callback when {@link com.android.camera.CameraDisabledException} is |
| 129 | * caught. |
| 130 | * |
| 131 | * @param cameraId The disabled camera. |
| 132 | */ |
| 133 | public void onCameraDisabled(int cameraId); |
| 134 | |
| 135 | /** |
| 136 | * Callback when {@link com.android.camera.CameraHardwareException} is |
| 137 | * caught. |
| 138 | * |
| 139 | * @param cameraId The camera with the hardware failure. |
| 140 | */ |
| 141 | public void onDeviceOpenFailure(int cameraId); |
| 142 | |
| 143 | /** |
Angus Kong | 62753ae | 2014-02-10 10:53:54 -0800 | [diff] [blame] | 144 | * Callback when trying to open the camera which is already opened. |
| 145 | * |
| 146 | * @param cameraId The camera which is causing the open error. |
| 147 | */ |
| 148 | public void onDeviceOpenedAlready(int cameraId); |
| 149 | |
| 150 | /** |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 151 | * Callback when {@link java.io.IOException} is caught during |
| 152 | * {@link android.hardware.Camera#reconnect()}. |
| 153 | * |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 154 | * @param mgr The {@link CameraManager} |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 155 | * with the reconnect failure. |
| 156 | */ |
| 157 | public void onReconnectionFailure(CameraManager mgr); |
| 158 | } |
| 159 | |
| 160 | /** |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 161 | * Opens the camera of the specified ID asynchronously. The camera device |
| 162 | * will be opened in the camera handler thread and will be returned through |
| 163 | * the {@link CameraManager.CameraOpenCallback# |
| 164 | * onCameraOpened(com.android.camera.app.CameraManager.CameraProxy)}. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 165 | * |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 166 | * @param handler The {@link android.os.Handler} in which the callback |
| 167 | * was handled. |
| 168 | * @param callback The callback when any error happens. |
| 169 | * @param cameraId The camera ID to open. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 170 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 171 | public void cameraOpen(Handler handler, int cameraId, CameraOpenCallback callback); |
| 172 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 173 | /** |
| 174 | * An interface that takes camera operation requests and post messages to the |
| 175 | * camera handler thread. All camera operations made through this interface is |
| 176 | * asynchronous by default except those mentioned specifically. |
| 177 | */ |
| 178 | public interface CameraProxy { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 179 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 180 | /** |
| 181 | * Returns the underlying {@link android.hardware.Camera} object used |
| 182 | * by this proxy. This method should only be used when handing the |
| 183 | * camera device over to {@link android.media.MediaRecorder} for |
| 184 | * recording. |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 185 | */ |
Angus Kong | 62753ae | 2014-02-10 10:53:54 -0800 | [diff] [blame] | 186 | @Deprecated |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 187 | public android.hardware.Camera getCamera(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 188 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 189 | /** |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 190 | * Returns the camera ID associated to by this |
| 191 | * {@link CameraManager.CameraProxy}. |
| 192 | * @return |
| 193 | */ |
| 194 | public int getCameraId(); |
| 195 | |
| 196 | /** |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 197 | * Releases the camera device synchronously. |
| 198 | * This function must be synchronous so the caller knows exactly when the camera |
| 199 | * is released and can continue on. |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 200 | * TODO: make this package-private after this interface is refactored under app. |
| 201 | * |
| 202 | * @param synchronous Whether this call should be synchronous. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 203 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 204 | public void release(boolean synchronous); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 205 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 206 | /** |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 207 | * Reconnects to the camera device. On success, the camera device will |
| 208 | * be returned through {@link CameraManager |
| 209 | * .CameraOpenCallback#onCameraOpened(com.android.camera.app.CameraManager |
| 210 | * .CameraProxy)}. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 211 | * @see android.hardware.Camera#reconnect() |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 212 | * |
| 213 | * @param handler The {@link android.os.Handler} in which the callback |
| 214 | * was handled. |
| 215 | * @param cb The callback when any error happens. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 216 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 217 | public void reconnect(Handler handler, CameraOpenCallback cb); |
| 218 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 219 | /** |
| 220 | * Unlocks the camera device. |
| 221 | * |
| 222 | * @see android.hardware.Camera#unlock() |
| 223 | */ |
| 224 | public void unlock(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 225 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 226 | /** |
| 227 | * Locks the camera device. |
| 228 | * @see android.hardware.Camera#lock() |
| 229 | */ |
| 230 | public void lock(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 231 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 232 | /** |
| 233 | * Sets the {@link android.graphics.SurfaceTexture} for preview. |
| 234 | * |
| 235 | * @param surfaceTexture The {@link SurfaceTexture} for preview. |
| 236 | */ |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 237 | public void setPreviewTexture(final SurfaceTexture surfaceTexture); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 238 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 239 | /** |
Erin Dahlgren | d8de077 | 2014-02-03 10:12:27 -0800 | [diff] [blame] | 240 | * Blocks until a {@link android.graphics.SurfaceTexture} has been set |
| 241 | * for preview. |
| 242 | * |
| 243 | * @param surfaceTexture The {@link SurfaceTexture} for preview. |
| 244 | */ |
| 245 | public void setPreviewTextureSync(final SurfaceTexture surfaceTexture); |
| 246 | |
| 247 | /** |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 248 | * Sets the {@link android.view.SurfaceHolder} for preview. |
| 249 | * |
| 250 | * @param surfaceHolder The {@link SurfaceHolder} for preview. |
| 251 | */ |
| 252 | public void setPreviewDisplay(final SurfaceHolder surfaceHolder); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 253 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 254 | /** |
| 255 | * Starts the camera preview. |
| 256 | */ |
| 257 | public void startPreview(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 258 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 259 | /** |
Erin Dahlgren | d05374f | 2014-03-11 16:23:29 -0700 | [diff] [blame] | 260 | * Starts the camera preview and executes a callback on a handler once |
| 261 | * the preview starts. |
| 262 | */ |
| 263 | public void startPreviewWithCallback(Handler h, CameraStartPreviewCallback cb); |
| 264 | |
| 265 | /** |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 266 | * Stops the camera preview synchronously. |
| 267 | * {@code stopPreview()} must be synchronous to ensure that the caller can |
| 268 | * continues to release resources related to camera preview. |
| 269 | */ |
| 270 | public void stopPreview(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 271 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 272 | /** |
| 273 | * Sets the callback for preview data. |
| 274 | * |
Angus Kong | 4f795b8 | 2013-09-16 14:25:35 -0700 | [diff] [blame] | 275 | * @param handler The {@link android.os.Handler} in which the callback was handled. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 276 | * @param cb The callback to be invoked when the preview data is available. |
| 277 | * @see android.hardware.Camera#setPreviewCallback(android.hardware.Camera.PreviewCallback) |
| 278 | */ |
| 279 | public void setPreviewDataCallback(Handler handler, CameraPreviewDataCallback cb); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 280 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 281 | /** |
Doris Liu | 4d4a4bc | 2013-12-19 18:55:54 -0800 | [diff] [blame] | 282 | * Sets the one-time callback for preview data. |
| 283 | * |
| 284 | * @param handler The {@link android.os.Handler} in which the callback was handled. |
| 285 | * @param cb The callback to be invoked when the preview data for |
| 286 | * next frame is available. |
| 287 | * @see android.hardware.Camera#setPreviewCallback(android.hardware.Camera.PreviewCallback) |
| 288 | */ |
| 289 | public void setOneShotPreviewCallback(Handler handler, CameraPreviewDataCallback cb); |
| 290 | |
| 291 | /** |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 292 | * Sets the callback for preview data. |
| 293 | * |
| 294 | * @param handler The handler in which the callback will be invoked. |
| 295 | * @param cb The callback to be invoked when the preview data is available. |
| 296 | * @see android.hardware.Camera#setPreviewCallbackWithBuffer(android.hardware.Camera.PreviewCallback) |
| 297 | */ |
| 298 | public void setPreviewDataCallbackWithBuffer(Handler handler, CameraPreviewDataCallback cb); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 299 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 300 | /** |
| 301 | * Adds buffer for the preview callback. |
| 302 | * |
| 303 | * @param callbackBuffer The buffer allocated for the preview data. |
| 304 | */ |
| 305 | public void addCallbackBuffer(byte[] callbackBuffer); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 306 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 307 | /** |
| 308 | * Starts the auto-focus process. The result will be returned through the callback. |
| 309 | * |
| 310 | * @param handler The handler in which the callback will be invoked. |
| 311 | * @param cb The auto-focus callback. |
| 312 | */ |
| 313 | public void autoFocus(Handler handler, CameraAFCallback cb); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 314 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 315 | /** |
| 316 | * Cancels the auto-focus process. |
| 317 | */ |
| 318 | public void cancelAutoFocus(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 319 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 320 | /** |
| 321 | * Sets the auto-focus callback |
| 322 | * |
| 323 | * @param handler The handler in which the callback will be invoked. |
| 324 | * @param cb The callback to be invoked when the preview data is available. |
| 325 | */ |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 326 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 327 | public void setAutoFocusMoveCallback(Handler handler, CameraAFMoveCallback cb); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 328 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 329 | /** |
| 330 | * Instrument the camera to take a picture. |
| 331 | * |
| 332 | * @param handler The handler in which the callback will be invoked. |
| 333 | * @param shutter The callback for shutter action, may be null. |
| 334 | * @param raw The callback for uncompressed data, may be null. |
| 335 | * @param postview The callback for postview image data, may be null. |
| 336 | * @param jpeg The callback for jpeg image data, may be null. |
| 337 | * @see android.hardware.Camera#takePicture( |
| 338 | * android.hardware.Camera.ShutterCallback, |
| 339 | * android.hardware.Camera.PictureCallback, |
| 340 | * android.hardware.Camera.PictureCallback) |
| 341 | */ |
| 342 | public void takePicture( |
| 343 | Handler handler, |
| 344 | CameraShutterCallback shutter, |
| 345 | CameraPictureCallback raw, |
| 346 | CameraPictureCallback postview, |
| 347 | CameraPictureCallback jpeg); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 348 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 349 | /** |
| 350 | * Sets the display orientation for camera to adjust the preview orientation. |
| 351 | * |
| 352 | * @param degrees The rotation in degrees. Should be 0, 90, 180 or 270. |
| 353 | */ |
| 354 | public void setDisplayOrientation(int degrees); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 355 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 356 | /** |
| 357 | * Sets the listener for zoom change. |
| 358 | * |
| 359 | * @param listener The listener. |
| 360 | */ |
| 361 | public void setZoomChangeListener(OnZoomChangeListener listener); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 362 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 363 | /** |
| 364 | * Sets the face detection listener. |
| 365 | * |
Angus Kong | 9e76552 | 2013-07-31 14:05:20 -0700 | [diff] [blame] | 366 | * @param handler The handler in which the callback will be invoked. |
| 367 | * @param callback The callback for face detection results. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 368 | */ |
Angus Kong | 9e76552 | 2013-07-31 14:05:20 -0700 | [diff] [blame] | 369 | public void setFaceDetectionCallback(Handler handler, CameraFaceDetectionCallback callback); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 370 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 371 | /** |
| 372 | * Starts the face detection. |
| 373 | */ |
| 374 | public void startFaceDetection(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 375 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 376 | /** |
| 377 | * Stops the face detection. |
| 378 | */ |
| 379 | public void stopFaceDetection(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 380 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 381 | /** |
| 382 | * Registers an error callback. |
| 383 | * |
Angus Kong | 2bca210 | 2014-03-11 16:27:30 -0700 | [diff] [blame^] | 384 | * @param handler The handler on which the callback will be invoked. |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 385 | * @param cb The error callback. |
| 386 | * @see android.hardware.Camera#setErrorCallback(android.hardware.Camera.ErrorCallback) |
| 387 | */ |
Angus Kong | 2bca210 | 2014-03-11 16:27:30 -0700 | [diff] [blame^] | 388 | public void setErrorCallback(Handler handler, CameraErrorCallback cb); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 389 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 390 | /** |
| 391 | * Sets the camera parameters. |
| 392 | * |
| 393 | * @param params The camera parameters to use. |
| 394 | */ |
| 395 | public void setParameters(Parameters params); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 396 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 397 | /** |
| 398 | * Gets the current camera parameters synchronously. This method is |
| 399 | * synchronous since the caller has to wait for the camera to return |
| 400 | * the parameters. If the parameters are already cached, it returns |
| 401 | * immediately. |
| 402 | */ |
| 403 | public Parameters getParameters(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 404 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 405 | /** |
| 406 | * Forces {@code CameraProxy} to update the cached version of the camera |
| 407 | * parameters regardless of the dirty bit. |
| 408 | */ |
| 409 | public void refreshParameters(); |
Angus Kong | 104e001 | 2013-04-03 16:56:18 -0700 | [diff] [blame] | 410 | |
Angus Kong | 9ef9925 | 2013-07-18 18:04:19 -0700 | [diff] [blame] | 411 | /** |
| 412 | * Enables/Disables the camera shutter sound. |
| 413 | * |
| 414 | * @param enable {@code true} to enable the shutter sound, |
| 415 | * {@code false} to disable it. |
| 416 | */ |
| 417 | public void enableShutterSound(boolean enable); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 418 | } |
Erin Dahlgren | 630d55b | 2014-03-10 14:40:59 -0700 | [diff] [blame] | 419 | |
| 420 | /** |
Erin Dahlgren | d05374f | 2014-03-11 16:23:29 -0700 | [diff] [blame] | 421 | * An interface to be called when the camera preview has started. |
| 422 | */ |
| 423 | public interface CameraStartPreviewCallback { |
| 424 | /** |
| 425 | * Callback when the preview starts. |
| 426 | */ |
| 427 | public void onPreviewStarted(); |
| 428 | } |
| 429 | |
| 430 | /** |
Erin Dahlgren | 630d55b | 2014-03-10 14:40:59 -0700 | [diff] [blame] | 431 | * Sets a callback for handling camera api runtime exceptions on |
| 432 | * a handler. |
| 433 | */ |
| 434 | public void setCameraDefaultExceptionCallback(CameraExceptionCallback callback, |
| 435 | Handler handler); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 436 | } |