Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2013, 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 "ICameraDeviceUser" |
| 20 | #include <utils/Log.h> |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <binder/Parcel.h> |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 24 | #include <camera/camera2/ICameraDeviceUser.h> |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 25 | #include <gui/IGraphicBufferProducer.h> |
| 26 | #include <gui/Surface.h> |
| 27 | #include <camera/CameraMetadata.h> |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 28 | #include <camera/camera2/CaptureRequest.h> |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 29 | #include <camera/camera2/OutputConfiguration.h> |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | typedef Parcel::WritableBlob WritableBlob; |
| 34 | typedef Parcel::ReadableBlob ReadableBlob; |
| 35 | |
| 36 | enum { |
| 37 | DISCONNECT = IBinder::FIRST_CALL_TRANSACTION, |
| 38 | SUBMIT_REQUEST, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 39 | SUBMIT_REQUEST_LIST, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 40 | CANCEL_REQUEST, |
Ruben Brunk | 2947840 | 2014-05-22 13:09:57 -0700 | [diff] [blame] | 41 | BEGIN_CONFIGURE, |
| 42 | END_CONFIGURE, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 43 | DELETE_STREAM, |
| 44 | CREATE_STREAM, |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 45 | CREATE_INPUT_STREAM, |
| 46 | GET_INPUT_SURFACE, |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 47 | CREATE_DEFAULT_REQUEST, |
| 48 | GET_CAMERA_INFO, |
Zhijun He | 2ab500c | 2013-07-23 08:02:53 -0700 | [diff] [blame] | 49 | WAIT_UNTIL_IDLE, |
Ruben Brunk | 2947840 | 2014-05-22 13:09:57 -0700 | [diff] [blame] | 50 | FLUSH |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Igor Murashkin | 88aef23 | 2013-08-23 17:47:06 -0700 | [diff] [blame] | 53 | namespace { |
| 54 | // Read empty strings without printing a false error message. |
| 55 | String16 readMaybeEmptyString16(const Parcel& parcel) { |
| 56 | size_t len; |
| 57 | const char16_t* str = parcel.readString16Inplace(&len); |
| 58 | if (str != NULL) { |
| 59 | return String16(str, len); |
| 60 | } else { |
| 61 | return String16(); |
| 62 | } |
| 63 | } |
| 64 | }; |
| 65 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 66 | class BpCameraDeviceUser : public BpInterface<ICameraDeviceUser> |
| 67 | { |
| 68 | public: |
| 69 | BpCameraDeviceUser(const sp<IBinder>& impl) |
| 70 | : BpInterface<ICameraDeviceUser>(impl) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | // disconnect from camera service |
| 75 | void disconnect() |
| 76 | { |
| 77 | ALOGV("disconnect"); |
| 78 | Parcel data, reply; |
| 79 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 80 | remote()->transact(DISCONNECT, data, &reply); |
| 81 | reply.readExceptionCode(); |
| 82 | } |
| 83 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 84 | virtual status_t submitRequest(sp<CaptureRequest> request, bool repeating, |
| 85 | int64_t *lastFrameNumber) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 86 | { |
| 87 | Parcel data, reply; |
| 88 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 89 | |
| 90 | // arg0 = CaptureRequest |
| 91 | if (request != 0) { |
| 92 | data.writeInt32(1); |
| 93 | request->writeToParcel(&data); |
| 94 | } else { |
| 95 | data.writeInt32(0); |
| 96 | } |
| 97 | |
| 98 | // arg1 = streaming (bool) |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 99 | data.writeInt32(repeating); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 100 | |
| 101 | remote()->transact(SUBMIT_REQUEST, data, &reply); |
| 102 | |
| 103 | reply.readExceptionCode(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 104 | status_t res = reply.readInt32(); |
| 105 | |
| 106 | status_t resFrameNumber = BAD_VALUE; |
| 107 | if (reply.readInt32() != 0) { |
| 108 | if (lastFrameNumber != NULL) { |
| 109 | resFrameNumber = reply.readInt64(lastFrameNumber); |
| 110 | } |
| 111 | } |
| 112 | |
John Lin | 19fa0fe | 2015-02-02 18:10:42 +0800 | [diff] [blame] | 113 | if ((res < NO_ERROR) || (resFrameNumber != NO_ERROR)) { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 114 | res = FAILED_TRANSACTION; |
| 115 | } |
| 116 | return res; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 119 | virtual status_t submitRequestList(List<sp<CaptureRequest> > requestList, bool repeating, |
| 120 | int64_t *lastFrameNumber) |
| 121 | { |
| 122 | Parcel data, reply; |
| 123 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 124 | |
| 125 | data.writeInt32(requestList.size()); |
| 126 | |
| 127 | for (List<sp<CaptureRequest> >::iterator it = requestList.begin(); |
| 128 | it != requestList.end(); ++it) { |
| 129 | sp<CaptureRequest> request = *it; |
| 130 | if (request != 0) { |
| 131 | data.writeInt32(1); |
| 132 | if (request->writeToParcel(&data) != OK) { |
| 133 | return BAD_VALUE; |
| 134 | } |
| 135 | } else { |
| 136 | data.writeInt32(0); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | data.writeInt32(repeating); |
| 141 | |
| 142 | remote()->transact(SUBMIT_REQUEST_LIST, data, &reply); |
| 143 | |
| 144 | reply.readExceptionCode(); |
| 145 | status_t res = reply.readInt32(); |
| 146 | |
| 147 | status_t resFrameNumber = BAD_VALUE; |
| 148 | if (reply.readInt32() != 0) { |
| 149 | if (lastFrameNumber != NULL) { |
| 150 | resFrameNumber = reply.readInt64(lastFrameNumber); |
| 151 | } |
| 152 | } |
John Lin | 19fa0fe | 2015-02-02 18:10:42 +0800 | [diff] [blame] | 153 | if ((res < NO_ERROR) || (resFrameNumber != NO_ERROR)) { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 154 | res = FAILED_TRANSACTION; |
| 155 | } |
| 156 | return res; |
| 157 | } |
| 158 | |
| 159 | virtual status_t cancelRequest(int requestId, int64_t *lastFrameNumber) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 160 | { |
| 161 | Parcel data, reply; |
| 162 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 163 | data.writeInt32(requestId); |
| 164 | |
| 165 | remote()->transact(CANCEL_REQUEST, data, &reply); |
| 166 | |
| 167 | reply.readExceptionCode(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 168 | status_t res = reply.readInt32(); |
| 169 | |
| 170 | status_t resFrameNumber = BAD_VALUE; |
| 171 | if (reply.readInt32() != 0) { |
| 172 | if (lastFrameNumber != NULL) { |
John Lin | 19fa0fe | 2015-02-02 18:10:42 +0800 | [diff] [blame] | 173 | resFrameNumber = reply.readInt64(lastFrameNumber); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | if ((res != NO_ERROR) || (resFrameNumber != NO_ERROR)) { |
| 177 | res = FAILED_TRANSACTION; |
| 178 | } |
| 179 | return res; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Ruben Brunk | 2947840 | 2014-05-22 13:09:57 -0700 | [diff] [blame] | 182 | virtual status_t beginConfigure() |
| 183 | { |
| 184 | ALOGV("beginConfigure"); |
| 185 | Parcel data, reply; |
| 186 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 187 | remote()->transact(BEGIN_CONFIGURE, data, &reply); |
| 188 | reply.readExceptionCode(); |
| 189 | return reply.readInt32(); |
| 190 | } |
| 191 | |
| 192 | virtual status_t endConfigure() |
| 193 | { |
| 194 | ALOGV("endConfigure"); |
| 195 | Parcel data, reply; |
| 196 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 197 | remote()->transact(END_CONFIGURE, data, &reply); |
| 198 | reply.readExceptionCode(); |
| 199 | return reply.readInt32(); |
| 200 | } |
| 201 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 202 | virtual status_t deleteStream(int streamId) |
| 203 | { |
| 204 | Parcel data, reply; |
| 205 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 206 | data.writeInt32(streamId); |
| 207 | |
| 208 | remote()->transact(DELETE_STREAM, data, &reply); |
| 209 | |
| 210 | reply.readExceptionCode(); |
| 211 | return reply.readInt32(); |
| 212 | } |
| 213 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 214 | virtual status_t createStream(const OutputConfiguration& outputConfiguration) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 215 | { |
| 216 | Parcel data, reply; |
| 217 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 218 | if (outputConfiguration.getGraphicBufferProducer() != NULL) { |
| 219 | data.writeInt32(1); // marker that OutputConfiguration is not null. Mimic aidl behavior |
| 220 | outputConfiguration.writeToParcel(data); |
| 221 | } else { |
| 222 | data.writeInt32(0); |
| 223 | } |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 224 | remote()->transact(CREATE_STREAM, data, &reply); |
| 225 | |
| 226 | reply.readExceptionCode(); |
| 227 | return reply.readInt32(); |
| 228 | } |
| 229 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 230 | virtual status_t createInputStream(int width, int height, int format) |
| 231 | { |
| 232 | Parcel data, reply; |
| 233 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 234 | data.writeInt32(width); |
| 235 | data.writeInt32(height); |
| 236 | data.writeInt32(format); |
| 237 | |
| 238 | remote()->transact(CREATE_INPUT_STREAM, data, &reply); |
| 239 | |
| 240 | reply.readExceptionCode(); |
| 241 | return reply.readInt32(); |
| 242 | } |
| 243 | |
| 244 | // get the buffer producer of the input stream |
| 245 | virtual status_t getInputBufferProducer( |
| 246 | sp<IGraphicBufferProducer> *producer) { |
| 247 | if (producer == NULL) { |
| 248 | return BAD_VALUE; |
| 249 | } |
| 250 | |
| 251 | Parcel data, reply; |
| 252 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 253 | |
| 254 | remote()->transact(GET_INPUT_SURFACE, data, &reply); |
| 255 | |
| 256 | reply.readExceptionCode(); |
| 257 | status_t result = reply.readInt32() ; |
| 258 | if (result != OK) { |
| 259 | return result; |
| 260 | } |
| 261 | |
| 262 | sp<IGraphicBufferProducer> bp = NULL; |
| 263 | if (reply.readInt32() != 0) { |
| 264 | String16 name = readMaybeEmptyString16(reply); |
| 265 | bp = interface_cast<IGraphicBufferProducer>( |
| 266 | reply.readStrongBinder()); |
| 267 | } |
| 268 | |
| 269 | *producer = bp; |
| 270 | |
| 271 | return *producer == NULL ? INVALID_OPERATION : OK; |
| 272 | } |
| 273 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 274 | // Create a request object from a template. |
| 275 | virtual status_t createDefaultRequest(int templateId, |
| 276 | /*out*/ |
| 277 | CameraMetadata* request) |
| 278 | { |
| 279 | Parcel data, reply; |
| 280 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 281 | data.writeInt32(templateId); |
| 282 | remote()->transact(CREATE_DEFAULT_REQUEST, data, &reply); |
| 283 | |
| 284 | reply.readExceptionCode(); |
| 285 | status_t result = reply.readInt32(); |
| 286 | |
| 287 | CameraMetadata out; |
| 288 | if (reply.readInt32() != 0) { |
| 289 | out.readFromParcel(&reply); |
| 290 | } |
| 291 | |
| 292 | if (request != NULL) { |
| 293 | request->swap(out); |
| 294 | } |
| 295 | return result; |
| 296 | } |
| 297 | |
| 298 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 299 | virtual status_t getCameraInfo(CameraMetadata* info) |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 300 | { |
| 301 | Parcel data, reply; |
| 302 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 303 | remote()->transact(GET_CAMERA_INFO, data, &reply); |
| 304 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 305 | reply.readExceptionCode(); |
| 306 | status_t result = reply.readInt32(); |
| 307 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 308 | CameraMetadata out; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 309 | if (reply.readInt32() != 0) { |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 310 | out.readFromParcel(&reply); |
| 311 | } |
| 312 | |
| 313 | if (info != NULL) { |
| 314 | info->swap(out); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | return result; |
| 318 | } |
| 319 | |
Zhijun He | 2ab500c | 2013-07-23 08:02:53 -0700 | [diff] [blame] | 320 | virtual status_t waitUntilIdle() |
| 321 | { |
| 322 | ALOGV("waitUntilIdle"); |
| 323 | Parcel data, reply; |
| 324 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 325 | remote()->transact(WAIT_UNTIL_IDLE, data, &reply); |
| 326 | reply.readExceptionCode(); |
| 327 | return reply.readInt32(); |
| 328 | } |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 329 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 330 | virtual status_t flush(int64_t *lastFrameNumber) |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 331 | { |
| 332 | ALOGV("flush"); |
| 333 | Parcel data, reply; |
| 334 | data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); |
| 335 | remote()->transact(FLUSH, data, &reply); |
| 336 | reply.readExceptionCode(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 337 | status_t res = reply.readInt32(); |
| 338 | |
| 339 | status_t resFrameNumber = BAD_VALUE; |
| 340 | if (reply.readInt32() != 0) { |
| 341 | if (lastFrameNumber != NULL) { |
John Lin | 19fa0fe | 2015-02-02 18:10:42 +0800 | [diff] [blame] | 342 | resFrameNumber = reply.readInt64(lastFrameNumber); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | if ((res != NO_ERROR) || (resFrameNumber != NO_ERROR)) { |
| 346 | res = FAILED_TRANSACTION; |
| 347 | } |
| 348 | return res; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 351 | private: |
| 352 | |
| 353 | |
| 354 | }; |
| 355 | |
| 356 | IMPLEMENT_META_INTERFACE(CameraDeviceUser, |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 357 | "android.hardware.camera2.ICameraDeviceUser"); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 358 | |
| 359 | // ---------------------------------------------------------------------- |
| 360 | |
| 361 | status_t BnCameraDeviceUser::onTransact( |
| 362 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 363 | { |
| 364 | switch(code) { |
| 365 | case DISCONNECT: { |
| 366 | ALOGV("DISCONNECT"); |
| 367 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 368 | disconnect(); |
| 369 | reply->writeNoException(); |
| 370 | return NO_ERROR; |
| 371 | } break; |
| 372 | case SUBMIT_REQUEST: { |
| 373 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 374 | |
| 375 | // arg0 = request |
| 376 | sp<CaptureRequest> request; |
| 377 | if (data.readInt32() != 0) { |
| 378 | request = new CaptureRequest(); |
| 379 | request->readFromParcel(const_cast<Parcel*>(&data)); |
| 380 | } |
| 381 | |
| 382 | // arg1 = streaming (bool) |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 383 | bool repeating = data.readInt32(); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 384 | |
| 385 | // return code: requestId (int32) |
| 386 | reply->writeNoException(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 387 | int64_t lastFrameNumber = -1; |
| 388 | reply->writeInt32(submitRequest(request, repeating, &lastFrameNumber)); |
| 389 | reply->writeInt32(1); |
| 390 | reply->writeInt64(lastFrameNumber); |
| 391 | |
| 392 | return NO_ERROR; |
| 393 | } break; |
| 394 | case SUBMIT_REQUEST_LIST: { |
| 395 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 396 | |
| 397 | List<sp<CaptureRequest> > requestList; |
| 398 | int requestListSize = data.readInt32(); |
| 399 | for (int i = 0; i < requestListSize; i++) { |
| 400 | if (data.readInt32() != 0) { |
| 401 | sp<CaptureRequest> request = new CaptureRequest(); |
| 402 | if (request->readFromParcel(const_cast<Parcel*>(&data)) != OK) { |
| 403 | return BAD_VALUE; |
| 404 | } |
| 405 | requestList.push_back(request); |
| 406 | } else { |
| 407 | sp<CaptureRequest> request = 0; |
| 408 | requestList.push_back(request); |
| 409 | ALOGE("A request is missing. Sending in null request."); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | bool repeating = data.readInt32(); |
| 414 | |
| 415 | reply->writeNoException(); |
| 416 | int64_t lastFrameNumber = -1; |
| 417 | reply->writeInt32(submitRequestList(requestList, repeating, &lastFrameNumber)); |
| 418 | reply->writeInt32(1); |
| 419 | reply->writeInt64(lastFrameNumber); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 420 | |
| 421 | return NO_ERROR; |
| 422 | } break; |
| 423 | case CANCEL_REQUEST: { |
| 424 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 425 | int requestId = data.readInt32(); |
| 426 | reply->writeNoException(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 427 | int64_t lastFrameNumber = -1; |
| 428 | reply->writeInt32(cancelRequest(requestId, &lastFrameNumber)); |
| 429 | reply->writeInt32(1); |
| 430 | reply->writeInt64(lastFrameNumber); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 431 | return NO_ERROR; |
| 432 | } break; |
| 433 | case DELETE_STREAM: { |
| 434 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 435 | int streamId = data.readInt32(); |
| 436 | reply->writeNoException(); |
| 437 | reply->writeInt32(deleteStream(streamId)); |
| 438 | return NO_ERROR; |
| 439 | } break; |
| 440 | case CREATE_STREAM: { |
| 441 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 442 | |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 443 | status_t ret = BAD_VALUE; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 444 | if (data.readInt32() != 0) { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 445 | OutputConfiguration outputConfiguration(data); |
| 446 | ret = createStream(outputConfiguration); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 447 | } else { |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 448 | ALOGE("%s: cannot take an empty OutputConfiguration", __FUNCTION__); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 451 | reply->writeNoException(); |
| 452 | ALOGV("%s: CREATE_STREAM: write noException", __FUNCTION__); |
| 453 | reply->writeInt32(ret); |
| 454 | ALOGV("%s: CREATE_STREAM: write ret = %d", __FUNCTION__, ret); |
| 455 | |
| 456 | return NO_ERROR; |
| 457 | } break; |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 458 | case CREATE_INPUT_STREAM: { |
| 459 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 460 | int width, height, format; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 461 | |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 462 | width = data.readInt32(); |
| 463 | height = data.readInt32(); |
| 464 | format = data.readInt32(); |
| 465 | status_t ret = createInputStream(width, height, format); |
| 466 | |
| 467 | reply->writeNoException(); |
| 468 | reply->writeInt32(ret); |
| 469 | return NO_ERROR; |
| 470 | |
| 471 | } break; |
| 472 | case GET_INPUT_SURFACE: { |
| 473 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 474 | |
| 475 | sp<IGraphicBufferProducer> bp; |
| 476 | status_t ret = getInputBufferProducer(&bp); |
| 477 | sp<IBinder> b(IInterface::asBinder(ret == OK ? bp : NULL)); |
| 478 | |
| 479 | reply->writeNoException(); |
| 480 | reply->writeInt32(ret); |
| 481 | reply->writeInt32(1); |
| 482 | reply->writeString16(String16("camera input")); // name of surface |
| 483 | reply->writeStrongBinder(b); |
| 484 | |
| 485 | return NO_ERROR; |
| 486 | } break; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 487 | case CREATE_DEFAULT_REQUEST: { |
| 488 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 489 | |
| 490 | int templateId = data.readInt32(); |
| 491 | |
| 492 | CameraMetadata request; |
| 493 | status_t ret; |
| 494 | ret = createDefaultRequest(templateId, &request); |
| 495 | |
| 496 | reply->writeNoException(); |
| 497 | reply->writeInt32(ret); |
| 498 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 499 | // out-variables are after exception and return value |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 500 | reply->writeInt32(1); // to mark presence of metadata object |
| 501 | request.writeToParcel(const_cast<Parcel*>(reply)); |
| 502 | |
| 503 | return NO_ERROR; |
| 504 | } break; |
| 505 | case GET_CAMERA_INFO: { |
| 506 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 507 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 508 | CameraMetadata info; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 509 | status_t ret; |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 510 | ret = getCameraInfo(&info); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 511 | |
| 512 | reply->writeNoException(); |
| 513 | reply->writeInt32(ret); |
| 514 | |
Igor Murashkin | 099b457 | 2013-07-12 17:52:16 -0700 | [diff] [blame] | 515 | // out-variables are after exception and return value |
| 516 | reply->writeInt32(1); // to mark presence of metadata object |
| 517 | info.writeToParcel(reply); |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 518 | |
| 519 | return NO_ERROR; |
| 520 | } break; |
Zhijun He | 2ab500c | 2013-07-23 08:02:53 -0700 | [diff] [blame] | 521 | case WAIT_UNTIL_IDLE: { |
| 522 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 523 | reply->writeNoException(); |
| 524 | reply->writeInt32(waitUntilIdle()); |
| 525 | return NO_ERROR; |
| 526 | } break; |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 527 | case FLUSH: { |
| 528 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 529 | reply->writeNoException(); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 530 | int64_t lastFrameNumber = -1; |
| 531 | reply->writeInt32(flush(&lastFrameNumber)); |
| 532 | reply->writeInt32(1); |
| 533 | reply->writeInt64(lastFrameNumber); |
Eino-Ville Talvala | abaa51d | 2013-08-14 11:37:00 -0700 | [diff] [blame] | 534 | return NO_ERROR; |
| 535 | } |
Ruben Brunk | b2119af | 2014-05-09 19:57:56 -0700 | [diff] [blame] | 536 | case BEGIN_CONFIGURE: { |
| 537 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 538 | reply->writeNoException(); |
| 539 | reply->writeInt32(beginConfigure()); |
| 540 | return NO_ERROR; |
| 541 | } break; |
| 542 | case END_CONFIGURE: { |
| 543 | CHECK_INTERFACE(ICameraDeviceUser, data, reply); |
| 544 | reply->writeNoException(); |
| 545 | reply->writeInt32(endConfigure()); |
| 546 | return NO_ERROR; |
| 547 | } break; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 548 | default: |
| 549 | return BBinder::onTransact(code, data, reply, flags); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | // ---------------------------------------------------------------------------- |
| 554 | |
| 555 | }; // namespace android |