The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 3 | ** Copyright (C) 2008, The Android Open Source Project |
| 4 | ** Copyright (C) 2008 HTC Inc. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 5 | ** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 9 | ** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 11 | ** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 20 | #define LOG_TAG "Camera" |
| 21 | #include <utils/Log.h> |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 22 | #include <utils/IServiceManager.h> |
| 23 | #include <utils/threads.h> |
| 24 | #include <utils/IMemory.h> |
| 25 | #include <ui/Surface.h> |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 26 | #include <ui/Camera.h> |
| 27 | #include <ui/ICameraService.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | // client singleton for camera service binder interface |
| 32 | Mutex Camera::mLock; |
| 33 | sp<ICameraService> Camera::mCameraService; |
| 34 | sp<Camera::DeathNotifier> Camera::mDeathNotifier; |
| 35 | |
| 36 | // establish binder interface to camera service |
| 37 | const sp<ICameraService>& Camera::getCameraService() |
| 38 | { |
| 39 | Mutex::Autolock _l(mLock); |
| 40 | if (mCameraService.get() == 0) { |
| 41 | sp<IServiceManager> sm = defaultServiceManager(); |
| 42 | sp<IBinder> binder; |
| 43 | do { |
| 44 | binder = sm->getService(String16("media.camera")); |
| 45 | if (binder != 0) |
| 46 | break; |
| 47 | LOGW("CameraService not published, waiting..."); |
| 48 | usleep(500000); // 0.5 s |
| 49 | } while(true); |
| 50 | if (mDeathNotifier == NULL) { |
| 51 | mDeathNotifier = new DeathNotifier(); |
| 52 | } |
| 53 | binder->linkToDeath(mDeathNotifier); |
| 54 | mCameraService = interface_cast<ICameraService>(binder); |
| 55 | } |
| 56 | LOGE_IF(mCameraService==0, "no CameraService!?"); |
| 57 | return mCameraService; |
| 58 | } |
| 59 | |
| 60 | // --------------------------------------------------------------------------- |
| 61 | |
| 62 | Camera::Camera() |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 63 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 64 | init(); |
| 65 | } |
| 66 | |
| 67 | Camera::Camera(const sp<ICamera>& camera) |
| 68 | { |
| 69 | init(); |
| 70 | // connect this client to existing camera remote |
| 71 | if (camera->connect(this) == NO_ERROR) { |
| 72 | mStatus = NO_ERROR; |
| 73 | mCamera = camera; |
| 74 | camera->asBinder()->linkToDeath(this); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void Camera::init() |
| 79 | { |
| 80 | mStatus = UNKNOWN_ERROR; |
| 81 | mShutterCallback = 0; |
| 82 | mShutterCallbackCookie = 0; |
| 83 | mRawCallback = 0; |
| 84 | mRawCallbackCookie = 0; |
| 85 | mJpegCallback = 0; |
| 86 | mJpegCallbackCookie = 0; |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 87 | mPreviewCallback = 0; |
| 88 | mPreviewCallbackCookie = 0; |
| 89 | mRecordingCallback = 0; |
| 90 | mRecordingCallbackCookie = 0; |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 91 | mErrorCallback = 0; |
| 92 | mErrorCallbackCookie = 0; |
| 93 | mAutoFocusCallback = 0; |
| 94 | mAutoFocusCallbackCookie = 0; |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | Camera::~Camera() |
| 98 | { |
| 99 | disconnect(); |
| 100 | } |
| 101 | |
| 102 | sp<Camera> Camera::connect() |
| 103 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 104 | LOGV("connect"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 105 | sp<Camera> c = new Camera(); |
| 106 | const sp<ICameraService>& cs = getCameraService(); |
| 107 | if (cs != 0) { |
| 108 | c->mCamera = cs->connect(c); |
| 109 | } |
| 110 | if (c->mCamera != 0) { |
| 111 | c->mCamera->asBinder()->linkToDeath(c); |
| 112 | c->mStatus = NO_ERROR; |
| 113 | } |
| 114 | return c; |
| 115 | } |
| 116 | |
| 117 | void Camera::disconnect() |
| 118 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 119 | LOGV("disconnect"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 120 | if (mCamera != 0) { |
| 121 | mErrorCallback = 0; |
| 122 | mCamera->disconnect(); |
| 123 | mCamera = 0; |
| 124 | } |
| 125 | } |
| 126 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 127 | status_t Camera::reconnect() |
| 128 | { |
| 129 | LOGV("reconnect"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 130 | sp <ICamera> c = mCamera; |
| 131 | if (c == 0) return NO_INIT; |
| 132 | return c->connect(this); |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | sp<ICamera> Camera::remote() |
| 136 | { |
| 137 | return mCamera; |
| 138 | } |
| 139 | |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 140 | status_t Camera::lock() |
| 141 | { |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 142 | sp <ICamera> c = mCamera; |
| 143 | if (c == 0) return NO_INIT; |
| 144 | return c->lock(); |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | status_t Camera::unlock() |
| 148 | { |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 149 | sp <ICamera> c = mCamera; |
| 150 | if (c == 0) return NO_INIT; |
| 151 | return c->unlock(); |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 152 | } |
| 153 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 154 | // pass the buffered ISurface to the camera service |
| 155 | status_t Camera::setPreviewDisplay(const sp<Surface>& surface) |
| 156 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 157 | LOGV("setPreviewDisplay"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 158 | if (surface == 0) { |
| 159 | LOGE("app passed NULL surface"); |
| 160 | return NO_INIT; |
| 161 | } |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 162 | sp <ICamera> c = mCamera; |
| 163 | if (c == 0) return NO_INIT; |
| 164 | return c->setPreviewDisplay(surface->getISurface()); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 165 | } |
| 166 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 167 | status_t Camera::setPreviewDisplay(const sp<ISurface>& surface) |
| 168 | { |
| 169 | LOGV("setPreviewDisplay"); |
| 170 | if (surface == 0) { |
| 171 | LOGE("app passed NULL surface"); |
| 172 | return NO_INIT; |
| 173 | } |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 174 | sp <ICamera> c = mCamera; |
| 175 | if (c == 0) return NO_INIT; |
| 176 | return c->setPreviewDisplay(surface); |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 180 | // start preview mode, must call setPreviewDisplay first |
| 181 | status_t Camera::startPreview() |
| 182 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 183 | LOGV("startPreview"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 184 | sp <ICamera> c = mCamera; |
| 185 | if (c == 0) return NO_INIT; |
| 186 | return c->startPreview(); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 187 | } |
| 188 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 189 | // start recording mode, must call setPreviewDisplay first |
| 190 | status_t Camera::startRecording() |
| 191 | { |
| 192 | LOGV("startRecording"); |
| 193 | sp <ICamera> c = mCamera; |
| 194 | if (c == 0) return NO_INIT; |
| 195 | return c->startRecording(); |
| 196 | } |
| 197 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 198 | // stop preview mode |
| 199 | void Camera::stopPreview() |
| 200 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 201 | LOGV("stopPreview"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 202 | sp <ICamera> c = mCamera; |
| 203 | if (c == 0) return; |
| 204 | c->stopPreview(); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 205 | } |
| 206 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 207 | // stop recording mode |
| 208 | void Camera::stopRecording() |
| 209 | { |
| 210 | LOGV("stopRecording"); |
| 211 | sp <ICamera> c = mCamera; |
| 212 | if (c == 0) return; |
| 213 | c->stopRecording(); |
| 214 | } |
| 215 | |
| 216 | // release a recording frame |
| 217 | void Camera::releaseRecordingFrame(const sp<IMemory>& mem) |
| 218 | { |
| 219 | LOGV("releaseRecordingFrame"); |
| 220 | sp <ICamera> c = mCamera; |
| 221 | if (c == 0) return; |
| 222 | c->releaseRecordingFrame(mem); |
| 223 | } |
| 224 | |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 225 | // get preview state |
| 226 | bool Camera::previewEnabled() |
| 227 | { |
| 228 | LOGV("previewEnabled"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 229 | sp <ICamera> c = mCamera; |
| 230 | if (c == 0) return false; |
| 231 | return c->previewEnabled(); |
The Android Open Source Project | 2762932 | 2009-01-09 17:51:23 -0800 | [diff] [blame] | 232 | } |
| 233 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 234 | // get recording state |
| 235 | bool Camera::recordingEnabled() |
| 236 | { |
| 237 | LOGV("recordingEnabled"); |
| 238 | sp <ICamera> c = mCamera; |
| 239 | if (c == 0) return false; |
| 240 | return c->recordingEnabled(); |
| 241 | } |
| 242 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 243 | status_t Camera::autoFocus() |
| 244 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 245 | LOGV("autoFocus"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 246 | sp <ICamera> c = mCamera; |
| 247 | if (c == 0) return NO_INIT; |
| 248 | return c->autoFocus(); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | // take a picture |
| 252 | status_t Camera::takePicture() |
| 253 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 254 | LOGV("takePicture"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 255 | sp <ICamera> c = mCamera; |
| 256 | if (c == 0) return NO_INIT; |
| 257 | return c->takePicture(); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // set preview/capture parameters - key/value pairs |
| 261 | status_t Camera::setParameters(const String8& params) |
| 262 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 263 | LOGV("setParameters"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 264 | sp <ICamera> c = mCamera; |
| 265 | if (c == 0) return NO_INIT; |
| 266 | return c->setParameters(params); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | // get preview/capture parameters - key/value pairs |
| 270 | String8 Camera::getParameters() const |
| 271 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 272 | LOGV("getParameters"); |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 273 | String8 params; |
| 274 | sp <ICamera> c = mCamera; |
| 275 | if (c != 0) params = mCamera->getParameters(); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 276 | return params; |
| 277 | } |
| 278 | |
| 279 | void Camera::setAutoFocusCallback(autofocus_callback cb, void *cookie) |
| 280 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 281 | LOGV("setAutoFocusCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 282 | mAutoFocusCallback = cb; |
| 283 | mAutoFocusCallbackCookie = cookie; |
| 284 | } |
| 285 | |
| 286 | void Camera::setShutterCallback(shutter_callback cb, void *cookie) |
| 287 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 288 | LOGV("setShutterCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 289 | mShutterCallback = cb; |
| 290 | mShutterCallbackCookie = cookie; |
| 291 | } |
| 292 | |
| 293 | void Camera::setRawCallback(frame_callback cb, void *cookie) |
| 294 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 295 | LOGV("setRawCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 296 | mRawCallback = cb; |
| 297 | mRawCallbackCookie = cookie; |
| 298 | } |
| 299 | |
| 300 | void Camera::setJpegCallback(frame_callback cb, void *cookie) |
| 301 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 302 | LOGV("setJpegCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 303 | mJpegCallback = cb; |
| 304 | mJpegCallbackCookie = cookie; |
| 305 | } |
| 306 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 307 | void Camera::setPreviewCallback(frame_callback cb, void *cookie, int flag) |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 308 | { |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 309 | LOGV("setPreviewCallback"); |
| 310 | mPreviewCallback = cb; |
| 311 | mPreviewCallbackCookie = cookie; |
The Android Open Source Project | 5f78a48 | 2009-01-20 14:03:58 -0800 | [diff] [blame] | 312 | sp <ICamera> c = mCamera; |
| 313 | if (c == 0) return; |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 314 | mCamera->setPreviewCallbackFlag(flag); |
| 315 | } |
| 316 | |
| 317 | void Camera::setRecordingCallback(frame_callback cb, void *cookie) |
| 318 | { |
| 319 | LOGV("setRecordingCallback"); |
| 320 | mRecordingCallback = cb; |
| 321 | mRecordingCallbackCookie = cookie; |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void Camera::setErrorCallback(error_callback cb, void *cookie) |
| 325 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 326 | LOGV("setErrorCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 327 | mErrorCallback = cb; |
| 328 | mErrorCallbackCookie = cookie; |
| 329 | } |
| 330 | |
| 331 | void Camera::autoFocusCallback(bool focused) |
| 332 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 333 | LOGV("autoFocusCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 334 | if (mAutoFocusCallback) { |
| 335 | mAutoFocusCallback(focused, mAutoFocusCallbackCookie); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | void Camera::shutterCallback() |
| 340 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 341 | LOGV("shutterCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 342 | if (mShutterCallback) { |
| 343 | mShutterCallback(mShutterCallbackCookie); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | void Camera::rawCallback(const sp<IMemory>& picture) |
| 348 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 349 | LOGV("rawCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 350 | if (mRawCallback) { |
| 351 | mRawCallback(picture, mRawCallbackCookie); |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | // callback from camera service when image is ready |
| 356 | void Camera::jpegCallback(const sp<IMemory>& picture) |
| 357 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 358 | LOGV("jpegCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 359 | if (mJpegCallback) { |
| 360 | mJpegCallback(picture, mJpegCallbackCookie); |
| 361 | } |
| 362 | } |
| 363 | |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 364 | // callback from camera service when preview frame is ready |
| 365 | void Camera::previewCallback(const sp<IMemory>& frame) |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 366 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 367 | LOGV("frameCallback"); |
The Android Open Source Project | a6938ba | 2009-02-10 15:44:00 -0800 | [diff] [blame^] | 368 | if (mPreviewCallback) { |
| 369 | mPreviewCallback(frame, mPreviewCallbackCookie); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // callback from camera service when a recording frame is ready |
| 374 | void Camera::recordingCallback(const sp<IMemory>& frame) |
| 375 | { |
| 376 | LOGV("recordingCallback"); |
| 377 | if (mRecordingCallback) { |
| 378 | mRecordingCallback(frame, mRecordingCallbackCookie); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
| 382 | // callback from camera service when an error occurs in preview or takePicture |
| 383 | void Camera::errorCallback(status_t error) |
| 384 | { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 385 | LOGV("errorCallback"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 386 | if (mErrorCallback) { |
| 387 | mErrorCallback(error, mErrorCallbackCookie); |
| 388 | } |
| 389 | } |
| 390 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 391 | void Camera::binderDied(const wp<IBinder>& who) { |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 392 | LOGW("ICamera died"); |
| 393 | if (mErrorCallback) { |
| 394 | mErrorCallback(DEAD_OBJECT, mErrorCallbackCookie); |
| 395 | } |
| 396 | } |
| 397 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 398 | void Camera::DeathNotifier::binderDied(const wp<IBinder>& who) { |
| 399 | LOGV("binderDied"); |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 400 | Mutex::Autolock _l(Camera::mLock); |
| 401 | Camera::mCameraService.clear(); |
| 402 | LOGW("Camera server died!"); |
| 403 | } |
| 404 | |
| 405 | }; // namespace android |
| 406 | |