Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright (C) 2008, The Android Open Source Project |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | #define LOG_TAG "Camera" |
| 20 | #include <utils/Log.h> |
| 21 | #include <utils/threads.h> |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 22 | #include <utils/String16.h> |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 23 | #include <binder/IPCThreadState.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 24 | #include <binder/IServiceManager.h> |
| 25 | #include <binder/IMemory.h> |
| 26 | |
| 27 | #include <camera/Camera.h> |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 28 | #include <camera/ICameraRecordingProxyListener.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 29 | #include <camera/ICameraService.h> |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 30 | #include <camera/ICamera.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 31 | |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 32 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | df712ea | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 33 | #include <gui/Surface.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 34 | |
| 35 | namespace android { |
| 36 | |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 37 | Camera::Camera(int cameraId) |
| 38 | : CameraBase(cameraId) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 39 | { |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 40 | } |
| 41 | |
Ruben Brunk | 0f61d8f | 2013-08-08 13:07:18 -0700 | [diff] [blame] | 42 | CameraTraits<Camera>::TCamConnectService CameraTraits<Camera>::fnConnectService = |
| 43 | &ICameraService::connect; |
| 44 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 45 | // construct a camera client from an existing camera remote |
| 46 | sp<Camera> Camera::create(const sp<ICamera>& camera) |
| 47 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 48 | ALOGV("create"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 49 | if (camera == 0) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 50 | ALOGE("camera remote is a NULL pointer"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 54 | sp<Camera> c = new Camera(-1); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 55 | if (camera->connect(c) == NO_ERROR) { |
| 56 | c->mStatus = NO_ERROR; |
| 57 | c->mCamera = camera; |
| 58 | camera->asBinder()->linkToDeath(c); |
Wu-cheng Li | 627baac | 2011-01-04 20:00:55 +0800 | [diff] [blame] | 59 | return c; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 60 | } |
Wu-cheng Li | 627baac | 2011-01-04 20:00:55 +0800 | [diff] [blame] | 61 | return 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 64 | Camera::~Camera() |
| 65 | { |
Chih-Chung Chang | d06618e | 2010-05-13 15:14:24 +0800 | [diff] [blame] | 66 | // We don't need to call disconnect() here because if the CameraService |
| 67 | // thinks we are the owner of the hardware, it will hold a (strong) |
| 68 | // reference to us, and we can't possibly be here. We also don't want to |
| 69 | // call disconnect() here if we are in the same process as mediaserver, |
| 70 | // because we may be invoked by CameraService::Client::connect() and will |
| 71 | // deadlock if we call any method of ICamera here. |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 72 | } |
| 73 | |
Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 74 | sp<Camera> Camera::connect(int cameraId, const String16& clientPackageName, |
| 75 | int clientUid) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 76 | { |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 77 | return CameraBaseT::connect(cameraId, clientPackageName, clientUid); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Zhijun He | b10cdad | 2014-06-16 16:38:35 -0700 | [diff] [blame^] | 80 | status_t Camera::connectLegacy(int cameraId, int halVersion, |
| 81 | const String16& clientPackageName, |
| 82 | int clientUid, |
| 83 | sp<Camera>& camera) |
| 84 | { |
| 85 | ALOGV("%s: connect legacy camera device", __FUNCTION__); |
| 86 | sp<Camera> c = new Camera(cameraId); |
| 87 | sp<ICameraClient> cl = c; |
| 88 | status_t status = NO_ERROR; |
| 89 | const sp<ICameraService>& cs = CameraBaseT::getCameraService(); |
| 90 | |
| 91 | if (cs != 0) { |
| 92 | status = cs.get()->connectLegacy(cl, cameraId, halVersion, clientPackageName, |
| 93 | clientUid, /*out*/c->mCamera); |
| 94 | } |
| 95 | if (status == OK && c->mCamera != 0) { |
| 96 | c->mCamera->asBinder()->linkToDeath(c); |
| 97 | c->mStatus = NO_ERROR; |
| 98 | camera = c; |
| 99 | } else { |
| 100 | ALOGW("An error occurred while connecting to camera: %d", cameraId); |
| 101 | c.clear(); |
| 102 | } |
| 103 | return status; |
| 104 | } |
| 105 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 106 | status_t Camera::reconnect() |
| 107 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 108 | ALOGV("reconnect"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 109 | sp <ICamera> c = mCamera; |
| 110 | if (c == 0) return NO_INIT; |
| 111 | return c->connect(this); |
| 112 | } |
| 113 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 114 | status_t Camera::lock() |
| 115 | { |
| 116 | sp <ICamera> c = mCamera; |
| 117 | if (c == 0) return NO_INIT; |
| 118 | return c->lock(); |
| 119 | } |
| 120 | |
| 121 | status_t Camera::unlock() |
| 122 | { |
| 123 | sp <ICamera> c = mCamera; |
| 124 | if (c == 0) return NO_INIT; |
| 125 | return c->unlock(); |
| 126 | } |
| 127 | |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 128 | // pass the buffered IGraphicBufferProducer to the camera service |
Eino-Ville Talvala | 4b820b0 | 2013-08-21 14:39:05 -0700 | [diff] [blame] | 129 | status_t Camera::setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer) |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 130 | { |
Eino-Ville Talvala | 4b820b0 | 2013-08-21 14:39:05 -0700 | [diff] [blame] | 131 | ALOGV("setPreviewTarget(%p)", bufferProducer.get()); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 132 | sp <ICamera> c = mCamera; |
| 133 | if (c == 0) return NO_INIT; |
Mathias Agopian | 99617ad | 2013-03-12 18:42:23 -0700 | [diff] [blame] | 134 | ALOGD_IF(bufferProducer == 0, "app passed NULL surface"); |
Eino-Ville Talvala | 1ce7c34 | 2013-08-21 13:57:21 -0700 | [diff] [blame] | 135 | return c->setPreviewTarget(bufferProducer); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 138 | // start preview mode |
| 139 | status_t Camera::startPreview() |
| 140 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 141 | ALOGV("startPreview"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 142 | sp <ICamera> c = mCamera; |
| 143 | if (c == 0) return NO_INIT; |
| 144 | return c->startPreview(); |
| 145 | } |
| 146 | |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 147 | status_t Camera::storeMetaDataInBuffers(bool enabled) |
| 148 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 149 | ALOGV("storeMetaDataInBuffers: %s", |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 150 | enabled? "true": "false"); |
| 151 | sp <ICamera> c = mCamera; |
| 152 | if (c == 0) return NO_INIT; |
| 153 | return c->storeMetaDataInBuffers(enabled); |
| 154 | } |
| 155 | |
Eino-Ville Talvala | 4b820b0 | 2013-08-21 14:39:05 -0700 | [diff] [blame] | 156 | // start recording mode, must call setPreviewTarget first |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 157 | status_t Camera::startRecording() |
| 158 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 159 | ALOGV("startRecording"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 160 | sp <ICamera> c = mCamera; |
| 161 | if (c == 0) return NO_INIT; |
| 162 | return c->startRecording(); |
| 163 | } |
| 164 | |
| 165 | // stop preview mode |
| 166 | void Camera::stopPreview() |
| 167 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 168 | ALOGV("stopPreview"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 169 | sp <ICamera> c = mCamera; |
| 170 | if (c == 0) return; |
| 171 | c->stopPreview(); |
| 172 | } |
| 173 | |
| 174 | // stop recording mode |
| 175 | void Camera::stopRecording() |
| 176 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 177 | ALOGV("stopRecording"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 178 | { |
| 179 | Mutex::Autolock _l(mLock); |
| 180 | mRecordingProxyListener.clear(); |
| 181 | } |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 182 | sp <ICamera> c = mCamera; |
| 183 | if (c == 0) return; |
| 184 | c->stopRecording(); |
| 185 | } |
| 186 | |
| 187 | // release a recording frame |
| 188 | void Camera::releaseRecordingFrame(const sp<IMemory>& mem) |
| 189 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 190 | ALOGV("releaseRecordingFrame"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 191 | sp <ICamera> c = mCamera; |
| 192 | if (c == 0) return; |
| 193 | c->releaseRecordingFrame(mem); |
| 194 | } |
| 195 | |
| 196 | // get preview state |
| 197 | bool Camera::previewEnabled() |
| 198 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 199 | ALOGV("previewEnabled"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 200 | sp <ICamera> c = mCamera; |
| 201 | if (c == 0) return false; |
| 202 | return c->previewEnabled(); |
| 203 | } |
| 204 | |
| 205 | // get recording state |
| 206 | bool Camera::recordingEnabled() |
| 207 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 208 | ALOGV("recordingEnabled"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 209 | sp <ICamera> c = mCamera; |
| 210 | if (c == 0) return false; |
| 211 | return c->recordingEnabled(); |
| 212 | } |
| 213 | |
| 214 | status_t Camera::autoFocus() |
| 215 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 216 | ALOGV("autoFocus"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 217 | sp <ICamera> c = mCamera; |
| 218 | if (c == 0) return NO_INIT; |
| 219 | return c->autoFocus(); |
| 220 | } |
| 221 | |
| 222 | status_t Camera::cancelAutoFocus() |
| 223 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 224 | ALOGV("cancelAutoFocus"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 225 | sp <ICamera> c = mCamera; |
| 226 | if (c == 0) return NO_INIT; |
| 227 | return c->cancelAutoFocus(); |
| 228 | } |
| 229 | |
| 230 | // take a picture |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 231 | status_t Camera::takePicture(int msgType) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 232 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 233 | ALOGV("takePicture: 0x%x", msgType); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 234 | sp <ICamera> c = mCamera; |
| 235 | if (c == 0) return NO_INIT; |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 236 | return c->takePicture(msgType); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | // set preview/capture parameters - key/value pairs |
| 240 | status_t Camera::setParameters(const String8& params) |
| 241 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 242 | ALOGV("setParameters"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 243 | sp <ICamera> c = mCamera; |
| 244 | if (c == 0) return NO_INIT; |
| 245 | return c->setParameters(params); |
| 246 | } |
| 247 | |
| 248 | // get preview/capture parameters - key/value pairs |
| 249 | String8 Camera::getParameters() const |
| 250 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 251 | ALOGV("getParameters"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 252 | String8 params; |
| 253 | sp <ICamera> c = mCamera; |
| 254 | if (c != 0) params = mCamera->getParameters(); |
| 255 | return params; |
| 256 | } |
| 257 | |
| 258 | // send command to camera driver |
| 259 | status_t Camera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) |
| 260 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 261 | ALOGV("sendCommand"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 262 | sp <ICamera> c = mCamera; |
| 263 | if (c == 0) return NO_INIT; |
| 264 | return c->sendCommand(cmd, arg1, arg2); |
| 265 | } |
| 266 | |
| 267 | void Camera::setListener(const sp<CameraListener>& listener) |
| 268 | { |
| 269 | Mutex::Autolock _l(mLock); |
| 270 | mListener = listener; |
| 271 | } |
| 272 | |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 273 | void Camera::setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener) |
| 274 | { |
| 275 | Mutex::Autolock _l(mLock); |
| 276 | mRecordingProxyListener = listener; |
| 277 | } |
| 278 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 279 | void Camera::setPreviewCallbackFlags(int flag) |
| 280 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 281 | ALOGV("setPreviewCallbackFlags"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 282 | sp <ICamera> c = mCamera; |
| 283 | if (c == 0) return; |
| 284 | mCamera->setPreviewCallbackFlag(flag); |
| 285 | } |
| 286 | |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 287 | status_t Camera::setPreviewCallbackTarget( |
| 288 | const sp<IGraphicBufferProducer>& callbackProducer) |
| 289 | { |
| 290 | sp <ICamera> c = mCamera; |
| 291 | if (c == 0) return NO_INIT; |
| 292 | return c->setPreviewCallbackTarget(callbackProducer); |
| 293 | } |
| 294 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 295 | // callback from camera service |
| 296 | void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) |
| 297 | { |
Igor Murashkin | c073ba5 | 2013-02-26 14:32:34 -0800 | [diff] [blame] | 298 | return CameraBaseT::notifyCallback(msgType, ext1, ext2); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | // callback from camera service when frame or image is ready |
Wu-cheng Li | 57c8618 | 2011-07-30 05:00:37 +0800 | [diff] [blame] | 302 | void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, |
| 303 | camera_frame_metadata_t *metadata) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 304 | { |
Igor Murashkin | fa4cf9d | 2013-03-04 16:14:23 -0800 | [diff] [blame] | 305 | sp<CameraListener> listener; |
| 306 | { |
| 307 | Mutex::Autolock _l(mLock); |
| 308 | listener = mListener; |
| 309 | } |
| 310 | if (listener != NULL) { |
| 311 | listener->postData(msgType, dataPtr, metadata); |
| 312 | } |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | // callback from camera service when timestamped frame is ready |
| 316 | void Camera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) |
| 317 | { |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 318 | // If recording proxy listener is registered, forward the frame and return. |
| 319 | // The other listener (mListener) is ignored because the receiver needs to |
| 320 | // call releaseRecordingFrame. |
| 321 | sp<ICameraRecordingProxyListener> proxylistener; |
| 322 | { |
| 323 | Mutex::Autolock _l(mLock); |
| 324 | proxylistener = mRecordingProxyListener; |
| 325 | } |
| 326 | if (proxylistener != NULL) { |
| 327 | proxylistener->dataCallbackTimestamp(timestamp, msgType, dataPtr); |
| 328 | return; |
| 329 | } |
| 330 | |
Igor Murashkin | fa4cf9d | 2013-03-04 16:14:23 -0800 | [diff] [blame] | 331 | sp<CameraListener> listener; |
| 332 | { |
| 333 | Mutex::Autolock _l(mLock); |
| 334 | listener = mListener; |
| 335 | } |
| 336 | |
| 337 | if (listener != NULL) { |
| 338 | listener->postDataTimestamp(timestamp, msgType, dataPtr); |
| 339 | } else { |
Steve Block | 5ff1dd5 | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 340 | ALOGW("No listener was set. Drop a recording frame."); |
James Dong | c42478e | 2010-11-15 10:38:37 -0800 | [diff] [blame] | 341 | releaseRecordingFrame(dataPtr); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 342 | } |
| 343 | } |
| 344 | |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 345 | sp<ICameraRecordingProxy> Camera::getRecordingProxy() { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 346 | ALOGV("getProxy"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 347 | return new RecordingProxy(this); |
| 348 | } |
| 349 | |
| 350 | status_t Camera::RecordingProxy::startRecording(const sp<ICameraRecordingProxyListener>& listener) |
| 351 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 352 | ALOGV("RecordingProxy::startRecording"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 353 | mCamera->setRecordingProxyListener(listener); |
| 354 | mCamera->reconnect(); |
| 355 | return mCamera->startRecording(); |
| 356 | } |
| 357 | |
| 358 | void Camera::RecordingProxy::stopRecording() |
| 359 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 360 | ALOGV("RecordingProxy::stopRecording"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 361 | mCamera->stopRecording(); |
| 362 | } |
| 363 | |
| 364 | void Camera::RecordingProxy::releaseRecordingFrame(const sp<IMemory>& mem) |
| 365 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 366 | ALOGV("RecordingProxy::releaseRecordingFrame"); |
Wu-cheng Li | 4ca2c7c | 2011-06-01 17:22:24 +0800 | [diff] [blame] | 367 | mCamera->releaseRecordingFrame(mem); |
| 368 | } |
| 369 | |
| 370 | Camera::RecordingProxy::RecordingProxy(const sp<Camera>& camera) |
| 371 | { |
| 372 | mCamera = camera; |
| 373 | } |
| 374 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 375 | }; // namespace android |