Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 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 "ICamera" |
| 20 | #include <utils/Log.h> |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <binder/Parcel.h> |
| 24 | #include <camera/ICamera.h> |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 25 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | df712ea | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 26 | #include <gui/Surface.h> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | enum { |
| 31 | DISCONNECT = IBinder::FIRST_CALL_TRANSACTION, |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 32 | SET_PREVIEW_TEXTURE, |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 33 | SET_PREVIEW_CALLBACK_FLAG, |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 34 | SET_PREVIEW_CALLBACK_TARGET, |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 35 | START_PREVIEW, |
| 36 | STOP_PREVIEW, |
| 37 | AUTO_FOCUS, |
| 38 | CANCEL_AUTO_FOCUS, |
| 39 | TAKE_PICTURE, |
| 40 | SET_PARAMETERS, |
| 41 | GET_PARAMETERS, |
| 42 | SEND_COMMAND, |
| 43 | CONNECT, |
| 44 | LOCK, |
| 45 | UNLOCK, |
| 46 | PREVIEW_ENABLED, |
| 47 | START_RECORDING, |
| 48 | STOP_RECORDING, |
| 49 | RECORDING_ENABLED, |
| 50 | RELEASE_RECORDING_FRAME, |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 51 | STORE_META_DATA_IN_BUFFERS, |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | class BpCamera: public BpInterface<ICamera> |
| 55 | { |
| 56 | public: |
| 57 | BpCamera(const sp<IBinder>& impl) |
| 58 | : BpInterface<ICamera>(impl) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | // disconnect from camera service |
| 63 | void disconnect() |
| 64 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 65 | ALOGV("disconnect"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 66 | Parcel data, reply; |
| 67 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 68 | remote()->transact(DISCONNECT, data, &reply); |
| 69 | } |
| 70 | |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 71 | // pass the buffered IGraphicBufferProducer to the camera service |
| 72 | status_t setPreviewTexture(const sp<IGraphicBufferProducer>& bufferProducer) |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 73 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 74 | ALOGV("setPreviewTexture"); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 75 | Parcel data, reply; |
| 76 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 77 | sp<IBinder> b(bufferProducer->asBinder()); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 78 | data.writeStrongBinder(b); |
| 79 | remote()->transact(SET_PREVIEW_TEXTURE, data, &reply); |
| 80 | return reply.readInt32(); |
| 81 | } |
| 82 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 83 | // set the preview callback flag to affect how the received frames from |
| 84 | // preview are handled. See Camera.h for details. |
| 85 | void setPreviewCallbackFlag(int flag) |
| 86 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 87 | ALOGV("setPreviewCallbackFlag(%d)", flag); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 88 | Parcel data, reply; |
| 89 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 90 | data.writeInt32(flag); |
| 91 | remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply); |
| 92 | } |
| 93 | |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 94 | status_t setPreviewCallbackTarget( |
| 95 | const sp<IGraphicBufferProducer>& callbackProducer) |
| 96 | { |
| 97 | ALOGV("setPreviewCallbackTarget"); |
| 98 | Parcel data, reply; |
| 99 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 100 | sp<IBinder> b(callbackProducer->asBinder()); |
| 101 | data.writeStrongBinder(b); |
| 102 | remote()->transact(SET_PREVIEW_CALLBACK_TARGET, data, &reply); |
| 103 | return reply.readInt32(); |
| 104 | } |
| 105 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 106 | // start preview mode, must call setPreviewDisplay first |
| 107 | status_t startPreview() |
| 108 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 109 | ALOGV("startPreview"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 110 | Parcel data, reply; |
| 111 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 112 | remote()->transact(START_PREVIEW, data, &reply); |
| 113 | return reply.readInt32(); |
| 114 | } |
| 115 | |
| 116 | // start recording mode, must call setPreviewDisplay first |
| 117 | status_t startRecording() |
| 118 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 119 | ALOGV("startRecording"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 120 | Parcel data, reply; |
| 121 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 122 | remote()->transact(START_RECORDING, data, &reply); |
| 123 | return reply.readInt32(); |
| 124 | } |
| 125 | |
| 126 | // stop preview mode |
| 127 | void stopPreview() |
| 128 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 129 | ALOGV("stopPreview"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 130 | Parcel data, reply; |
| 131 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 132 | remote()->transact(STOP_PREVIEW, data, &reply); |
| 133 | } |
| 134 | |
| 135 | // stop recording mode |
| 136 | void stopRecording() |
| 137 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 138 | ALOGV("stopRecording"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 139 | Parcel data, reply; |
| 140 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 141 | remote()->transact(STOP_RECORDING, data, &reply); |
| 142 | } |
| 143 | |
| 144 | void releaseRecordingFrame(const sp<IMemory>& mem) |
| 145 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 146 | ALOGV("releaseRecordingFrame"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 147 | Parcel data, reply; |
| 148 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 149 | data.writeStrongBinder(mem->asBinder()); |
| 150 | remote()->transact(RELEASE_RECORDING_FRAME, data, &reply); |
| 151 | } |
| 152 | |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 153 | status_t storeMetaDataInBuffers(bool enabled) |
| 154 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 155 | ALOGV("storeMetaDataInBuffers: %s", enabled? "true": "false"); |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 156 | Parcel data, reply; |
| 157 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 158 | data.writeInt32(enabled); |
| 159 | remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply); |
| 160 | return reply.readInt32(); |
| 161 | } |
| 162 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 163 | // check preview state |
| 164 | bool previewEnabled() |
| 165 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 166 | ALOGV("previewEnabled"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 167 | Parcel data, reply; |
| 168 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 169 | remote()->transact(PREVIEW_ENABLED, data, &reply); |
| 170 | return reply.readInt32(); |
| 171 | } |
| 172 | |
| 173 | // check recording state |
| 174 | bool recordingEnabled() |
| 175 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 176 | ALOGV("recordingEnabled"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 177 | Parcel data, reply; |
| 178 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 179 | remote()->transact(RECORDING_ENABLED, data, &reply); |
| 180 | return reply.readInt32(); |
| 181 | } |
| 182 | |
| 183 | // auto focus |
| 184 | status_t autoFocus() |
| 185 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 186 | ALOGV("autoFocus"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 187 | Parcel data, reply; |
| 188 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 189 | remote()->transact(AUTO_FOCUS, data, &reply); |
| 190 | status_t ret = reply.readInt32(); |
| 191 | return ret; |
| 192 | } |
| 193 | |
| 194 | // cancel focus |
| 195 | status_t cancelAutoFocus() |
| 196 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 197 | ALOGV("cancelAutoFocus"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 198 | Parcel data, reply; |
| 199 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 200 | remote()->transact(CANCEL_AUTO_FOCUS, data, &reply); |
| 201 | status_t ret = reply.readInt32(); |
| 202 | return ret; |
| 203 | } |
| 204 | |
| 205 | // take a picture - returns an IMemory (ref-counted mmap) |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 206 | status_t takePicture(int msgType) |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 207 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 208 | ALOGV("takePicture: 0x%x", msgType); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 209 | Parcel data, reply; |
| 210 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 211 | data.writeInt32(msgType); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 212 | remote()->transact(TAKE_PICTURE, data, &reply); |
| 213 | status_t ret = reply.readInt32(); |
| 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | // set preview/capture parameters - key/value pairs |
| 218 | status_t setParameters(const String8& params) |
| 219 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 220 | ALOGV("setParameters"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 221 | Parcel data, reply; |
| 222 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 223 | data.writeString8(params); |
| 224 | remote()->transact(SET_PARAMETERS, data, &reply); |
| 225 | return reply.readInt32(); |
| 226 | } |
| 227 | |
| 228 | // get preview/capture parameters - key/value pairs |
| 229 | String8 getParameters() const |
| 230 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 231 | ALOGV("getParameters"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 232 | Parcel data, reply; |
| 233 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 234 | remote()->transact(GET_PARAMETERS, data, &reply); |
| 235 | return reply.readString8(); |
| 236 | } |
| 237 | virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) |
| 238 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 239 | ALOGV("sendCommand"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 240 | Parcel data, reply; |
| 241 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 242 | data.writeInt32(cmd); |
| 243 | data.writeInt32(arg1); |
| 244 | data.writeInt32(arg2); |
| 245 | remote()->transact(SEND_COMMAND, data, &reply); |
| 246 | return reply.readInt32(); |
| 247 | } |
| 248 | virtual status_t connect(const sp<ICameraClient>& cameraClient) |
| 249 | { |
| 250 | Parcel data, reply; |
| 251 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 252 | data.writeStrongBinder(cameraClient->asBinder()); |
| 253 | remote()->transact(CONNECT, data, &reply); |
| 254 | return reply.readInt32(); |
| 255 | } |
| 256 | virtual status_t lock() |
| 257 | { |
| 258 | Parcel data, reply; |
| 259 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 260 | remote()->transact(LOCK, data, &reply); |
| 261 | return reply.readInt32(); |
| 262 | } |
| 263 | virtual status_t unlock() |
| 264 | { |
| 265 | Parcel data, reply; |
| 266 | data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); |
| 267 | remote()->transact(UNLOCK, data, &reply); |
| 268 | return reply.readInt32(); |
| 269 | } |
| 270 | }; |
| 271 | |
| 272 | IMPLEMENT_META_INTERFACE(Camera, "android.hardware.ICamera"); |
| 273 | |
| 274 | // ---------------------------------------------------------------------- |
| 275 | |
| 276 | status_t BnCamera::onTransact( |
| 277 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 278 | { |
| 279 | switch(code) { |
| 280 | case DISCONNECT: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 281 | ALOGV("DISCONNECT"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 282 | CHECK_INTERFACE(ICamera, data, reply); |
| 283 | disconnect(); |
| 284 | return NO_ERROR; |
| 285 | } break; |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 286 | case SET_PREVIEW_TEXTURE: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 287 | ALOGV("SET_PREVIEW_TEXTURE"); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 288 | CHECK_INTERFACE(ICamera, data, reply); |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 289 | sp<IGraphicBufferProducer> st = |
| 290 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 291 | reply->writeInt32(setPreviewTexture(st)); |
| 292 | return NO_ERROR; |
| 293 | } break; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 294 | case SET_PREVIEW_CALLBACK_FLAG: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 295 | ALOGV("SET_PREVIEW_CALLBACK_TYPE"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 296 | CHECK_INTERFACE(ICamera, data, reply); |
| 297 | int callback_flag = data.readInt32(); |
| 298 | setPreviewCallbackFlag(callback_flag); |
| 299 | return NO_ERROR; |
| 300 | } break; |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 301 | case SET_PREVIEW_CALLBACK_TARGET: { |
| 302 | ALOGV("SET_PREVIEW_CALLBACK_TARGET"); |
| 303 | CHECK_INTERFACE(ICamera, data, reply); |
| 304 | sp<IGraphicBufferProducer> cp = |
| 305 | interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); |
| 306 | reply->writeInt32(setPreviewCallbackTarget(cp)); |
| 307 | return NO_ERROR; |
| 308 | } |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 309 | case START_PREVIEW: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 310 | ALOGV("START_PREVIEW"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 311 | CHECK_INTERFACE(ICamera, data, reply); |
| 312 | reply->writeInt32(startPreview()); |
| 313 | return NO_ERROR; |
| 314 | } break; |
| 315 | case START_RECORDING: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 316 | ALOGV("START_RECORDING"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 317 | CHECK_INTERFACE(ICamera, data, reply); |
| 318 | reply->writeInt32(startRecording()); |
| 319 | return NO_ERROR; |
| 320 | } break; |
| 321 | case STOP_PREVIEW: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 322 | ALOGV("STOP_PREVIEW"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 323 | CHECK_INTERFACE(ICamera, data, reply); |
| 324 | stopPreview(); |
| 325 | return NO_ERROR; |
| 326 | } break; |
| 327 | case STOP_RECORDING: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 328 | ALOGV("STOP_RECORDING"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 329 | CHECK_INTERFACE(ICamera, data, reply); |
| 330 | stopRecording(); |
| 331 | return NO_ERROR; |
| 332 | } break; |
| 333 | case RELEASE_RECORDING_FRAME: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 334 | ALOGV("RELEASE_RECORDING_FRAME"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 335 | CHECK_INTERFACE(ICamera, data, reply); |
| 336 | sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder()); |
| 337 | releaseRecordingFrame(mem); |
| 338 | return NO_ERROR; |
| 339 | } break; |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 340 | case STORE_META_DATA_IN_BUFFERS: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 341 | ALOGV("STORE_META_DATA_IN_BUFFERS"); |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 342 | CHECK_INTERFACE(ICamera, data, reply); |
| 343 | bool enabled = data.readInt32(); |
| 344 | reply->writeInt32(storeMetaDataInBuffers(enabled)); |
| 345 | return NO_ERROR; |
| 346 | } break; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 347 | case PREVIEW_ENABLED: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 348 | ALOGV("PREVIEW_ENABLED"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 349 | CHECK_INTERFACE(ICamera, data, reply); |
| 350 | reply->writeInt32(previewEnabled()); |
| 351 | return NO_ERROR; |
| 352 | } break; |
| 353 | case RECORDING_ENABLED: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 354 | ALOGV("RECORDING_ENABLED"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 355 | CHECK_INTERFACE(ICamera, data, reply); |
| 356 | reply->writeInt32(recordingEnabled()); |
| 357 | return NO_ERROR; |
| 358 | } break; |
| 359 | case AUTO_FOCUS: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 360 | ALOGV("AUTO_FOCUS"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 361 | CHECK_INTERFACE(ICamera, data, reply); |
| 362 | reply->writeInt32(autoFocus()); |
| 363 | return NO_ERROR; |
| 364 | } break; |
| 365 | case CANCEL_AUTO_FOCUS: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 366 | ALOGV("CANCEL_AUTO_FOCUS"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 367 | CHECK_INTERFACE(ICamera, data, reply); |
| 368 | reply->writeInt32(cancelAutoFocus()); |
| 369 | return NO_ERROR; |
| 370 | } break; |
| 371 | case TAKE_PICTURE: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 372 | ALOGV("TAKE_PICTURE"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 373 | CHECK_INTERFACE(ICamera, data, reply); |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 374 | int msgType = data.readInt32(); |
| 375 | reply->writeInt32(takePicture(msgType)); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 376 | return NO_ERROR; |
| 377 | } break; |
| 378 | case SET_PARAMETERS: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 379 | ALOGV("SET_PARAMETERS"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 380 | CHECK_INTERFACE(ICamera, data, reply); |
| 381 | String8 params(data.readString8()); |
| 382 | reply->writeInt32(setParameters(params)); |
| 383 | return NO_ERROR; |
| 384 | } break; |
| 385 | case GET_PARAMETERS: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 386 | ALOGV("GET_PARAMETERS"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 387 | CHECK_INTERFACE(ICamera, data, reply); |
| 388 | reply->writeString8(getParameters()); |
| 389 | return NO_ERROR; |
| 390 | } break; |
| 391 | case SEND_COMMAND: { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 392 | ALOGV("SEND_COMMAND"); |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 393 | CHECK_INTERFACE(ICamera, data, reply); |
| 394 | int command = data.readInt32(); |
| 395 | int arg1 = data.readInt32(); |
| 396 | int arg2 = data.readInt32(); |
| 397 | reply->writeInt32(sendCommand(command, arg1, arg2)); |
| 398 | return NO_ERROR; |
| 399 | } break; |
| 400 | case CONNECT: { |
| 401 | CHECK_INTERFACE(ICamera, data, reply); |
| 402 | sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder()); |
| 403 | reply->writeInt32(connect(cameraClient)); |
| 404 | return NO_ERROR; |
| 405 | } break; |
| 406 | case LOCK: { |
| 407 | CHECK_INTERFACE(ICamera, data, reply); |
| 408 | reply->writeInt32(lock()); |
| 409 | return NO_ERROR; |
| 410 | } break; |
| 411 | case UNLOCK: { |
| 412 | CHECK_INTERFACE(ICamera, data, reply); |
| 413 | reply->writeInt32(unlock()); |
| 414 | return NO_ERROR; |
| 415 | } break; |
| 416 | default: |
| 417 | return BBinder::onTransact(code, data, reply, flags); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | // ---------------------------------------------------------------------------- |
| 422 | |
| 423 | }; // namespace android |