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