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