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