| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2015 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 | #ifndef _ACAMERA_DEVICE_H | 
|  | 17 | #define _ACAMERA_DEVICE_H | 
|  | 18 |  | 
|  | 19 | #include <memory> | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 20 | #include <map> | 
|  | 21 | #include <set> | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 22 | #include <atomic> | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 23 | #include <utility> | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 24 | #include <utils/StrongPointer.h> | 
|  | 25 | #include <utils/Mutex.h> | 
|  | 26 | #include <utils/String8.h> | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 27 | #include <utils/List.h> | 
|  | 28 | #include <utils/Vector.h> | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 29 |  | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 30 | #include <android/hardware/camera2/BnCameraDeviceCallbacks.h> | 
|  | 31 | #include <android/hardware/camera2/ICameraDeviceUser.h> | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 32 | #include <media/stagefright/foundation/ALooper.h> | 
|  | 33 | #include <media/stagefright/foundation/AHandler.h> | 
|  | 34 | #include <media/stagefright/foundation/AMessage.h> | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 35 | #include <camera/CaptureResult.h> | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 36 | #include <camera/camera2/OutputConfiguration.h> | 
|  | 37 | #include <camera/camera2/CaptureRequest.h> | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 38 |  | 
|  | 39 | #include <NdkCameraDevice.h> | 
|  | 40 | #include "ACameraMetadata.h" | 
|  | 41 |  | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 42 | namespace android { | 
|  | 43 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 44 | // Wrap ACameraCaptureFailure so it can be ref-counter | 
|  | 45 | struct CameraCaptureFailure : public RefBase, public ACameraCaptureFailure {}; | 
|  | 46 |  | 
|  | 47 | class CameraDevice final : public RefBase { | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 48 | public: | 
|  | 49 | CameraDevice(const char* id, ACameraDevice_StateCallbacks* cb, | 
|  | 50 | std::unique_ptr<ACameraMetadata> chars, | 
|  | 51 | ACameraDevice* wrapper); | 
|  | 52 | ~CameraDevice(); | 
|  | 53 |  | 
|  | 54 | inline const char* getId() const { return mCameraId.string(); } | 
|  | 55 |  | 
|  | 56 | camera_status_t createCaptureRequest( | 
|  | 57 | ACameraDevice_request_template templateId, | 
|  | 58 | ACaptureRequest** request) const; | 
|  | 59 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 60 | camera_status_t createCaptureSession( | 
|  | 61 | const ACaptureSessionOutputContainer*       outputs, | 
|  | 62 | const ACameraCaptureSession_stateCallbacks* callbacks, | 
|  | 63 | /*out*/ACameraCaptureSession** session); | 
|  | 64 |  | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 65 | // Callbacks from camera service | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 66 | class ServiceCallback : public hardware::camera2::BnCameraDeviceCallbacks { | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 67 | public: | 
| Chih-Hung Hsieh | d19d994 | 2016-08-29 14:21:14 -0700 | [diff] [blame] | 68 | explicit ServiceCallback(CameraDevice* device) : mDevice(device) {} | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 69 | binder::Status onDeviceError(int32_t errorCode, | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 70 | const CaptureResultExtras& resultExtras) override; | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 71 | binder::Status onDeviceIdle() override; | 
|  | 72 | binder::Status onCaptureStarted(const CaptureResultExtras& resultExtras, | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 73 | int64_t timestamp) override; | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 74 | binder::Status onResultReceived(const CameraMetadata& metadata, | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 75 | const CaptureResultExtras& resultExtras) override; | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 76 | binder::Status onPrepared(int streamId) override; | 
| Shuzhen Wang | 9d06601 | 2016-09-30 11:30:20 -0700 | [diff] [blame] | 77 | binder::Status onRequestQueueEmpty() override; | 
| Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 78 | binder::Status onRepeatingRequestError(int64_t lastFrameNumber) override; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 79 | private: | 
|  | 80 | const wp<CameraDevice> mDevice; | 
|  | 81 | }; | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 82 | inline sp<hardware::camera2::ICameraDeviceCallbacks> getServiceCallback() { | 
|  | 83 | return mServiceCallback; | 
|  | 84 | }; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 85 |  | 
|  | 86 | // Camera device is only functional after remote being set | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 87 | void setRemoteDevice(sp<hardware::camera2::ICameraDeviceUser> remote); | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 88 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 89 | inline ACameraDevice* getWrapper() const { return mWrapper; }; | 
|  | 90 |  | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 91 | private: | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 92 | friend ACameraCaptureSession; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 93 | camera_status_t checkCameraClosedOrErrorLocked() const; | 
|  | 94 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 95 | // device goes into fatal error state after this | 
|  | 96 | void setCameraDeviceErrorLocked(camera_status_t error); | 
|  | 97 |  | 
|  | 98 | void disconnectLocked(); // disconnect from camera service | 
|  | 99 |  | 
|  | 100 | camera_status_t stopRepeatingLocked(); | 
|  | 101 |  | 
| Yin-Chia Yeh | 309d05d | 2016-03-28 10:15:31 -0700 | [diff] [blame] | 102 | camera_status_t flushLocked(ACameraCaptureSession*); | 
|  | 103 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 104 | camera_status_t waitUntilIdleLocked(); | 
|  | 105 |  | 
|  | 106 |  | 
|  | 107 | camera_status_t captureLocked(sp<ACameraCaptureSession> session, | 
|  | 108 | /*optional*/ACameraCaptureSession_captureCallbacks* cbs, | 
|  | 109 | int numRequests, ACaptureRequest** requests, | 
|  | 110 | /*optional*/int* captureSequenceId); | 
|  | 111 |  | 
|  | 112 | camera_status_t setRepeatingRequestsLocked(sp<ACameraCaptureSession> session, | 
|  | 113 | /*optional*/ACameraCaptureSession_captureCallbacks* cbs, | 
|  | 114 | int numRequests, ACaptureRequest** requests, | 
|  | 115 | /*optional*/int* captureSequenceId); | 
|  | 116 |  | 
|  | 117 | camera_status_t submitRequestsLocked( | 
|  | 118 | sp<ACameraCaptureSession> session, | 
|  | 119 | /*optional*/ACameraCaptureSession_captureCallbacks* cbs, | 
|  | 120 | int numRequests, ACaptureRequest** requests, | 
|  | 121 | /*out*/int* captureSequenceId, | 
|  | 122 | bool isRepeating); | 
|  | 123 |  | 
|  | 124 | static camera_status_t allocateCaptureRequest( | 
|  | 125 | const ACaptureRequest* request, sp<CaptureRequest>& outReq); | 
|  | 126 |  | 
|  | 127 | static ACaptureRequest* allocateACaptureRequest(sp<CaptureRequest>& req); | 
|  | 128 | static void freeACaptureRequest(ACaptureRequest*); | 
|  | 129 |  | 
|  | 130 | // only For session to hold device lock | 
|  | 131 | // Always grab device lock before grabbing session lock | 
|  | 132 | void lockDeviceForSessionOps() const { mDeviceLock.lock(); }; | 
|  | 133 | void unlockDevice() const { mDeviceLock.unlock(); }; | 
|  | 134 |  | 
|  | 135 | // For capture session to notify its end of life | 
|  | 136 | void notifySessionEndOfLifeLocked(ACameraCaptureSession* session); | 
|  | 137 |  | 
|  | 138 | camera_status_t configureStreamsLocked(const ACaptureSessionOutputContainer* outputs); | 
|  | 139 |  | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 140 | static camera_status_t getIGBPfromAnw( | 
|  | 141 | ANativeWindow* anw, sp<IGraphicBufferProducer>& out); | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 142 |  | 
|  | 143 | static camera_status_t getSurfaceFromANativeWindow( | 
|  | 144 | ANativeWindow* anw, sp<Surface>& out); | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 145 |  | 
|  | 146 | mutable Mutex mDeviceLock; | 
|  | 147 | const String8 mCameraId;                          // Camera ID | 
|  | 148 | const ACameraDevice_StateCallbacks mAppCallbacks; // Callback to app | 
|  | 149 | const std::unique_ptr<ACameraMetadata> mChars;    // Camera characteristics | 
|  | 150 | const sp<ServiceCallback> mServiceCallback; | 
|  | 151 | ACameraDevice* mWrapper; | 
|  | 152 |  | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 153 | // stream id -> pair of (ANW* from application, OutputConfiguration used for camera service) | 
|  | 154 | std::map<int, std::pair<ANativeWindow*, OutputConfiguration>> mConfiguredOutputs; | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 155 |  | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 156 | // TODO: maybe a bool will suffice for synchronous implementation? | 
|  | 157 | std::atomic_bool mClosing; | 
|  | 158 | inline bool isClosed() { return mClosing; } | 
|  | 159 |  | 
| Yin-Chia Yeh | 309d05d | 2016-03-28 10:15:31 -0700 | [diff] [blame] | 160 | bool mInError = false; | 
|  | 161 | camera_status_t mError = ACAMERA_OK; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 162 | void onCaptureErrorLocked( | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 163 | int32_t errorCode, | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 164 | const CaptureResultExtras& resultExtras); | 
|  | 165 |  | 
| Yin-Chia Yeh | 309d05d | 2016-03-28 10:15:31 -0700 | [diff] [blame] | 166 | bool mIdle = true; | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 167 | // This will avoid a busy session being deleted before it's back to idle state | 
|  | 168 | sp<ACameraCaptureSession> mBusySession; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 169 |  | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 170 | sp<hardware::camera2::ICameraDeviceUser> mRemote; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 171 |  | 
|  | 172 | // Looper thread to handle callback to app | 
|  | 173 | sp<ALooper> mCbLooper; | 
|  | 174 | // definition of handler and message | 
|  | 175 | enum { | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 176 | // Device state callbacks | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 177 | kWhatOnDisconnected,   // onDisconnected | 
|  | 178 | kWhatOnError,          // onError | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 179 | // Session state callbacks | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 180 | kWhatSessionStateCb,   // onReady, onActive | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 181 | // Capture callbacks | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 182 | kWhatCaptureStart,     // onCaptureStarted | 
|  | 183 | kWhatCaptureResult,    // onCaptureProgressed, onCaptureCompleted | 
|  | 184 | kWhatCaptureFail,      // onCaptureFailed | 
|  | 185 | kWhatCaptureSeqEnd,    // onCaptureSequenceCompleted | 
|  | 186 | kWhatCaptureSeqAbort,  // onCaptureSequenceAborted | 
|  | 187 | kWhatCaptureBufferLost // onCaptureBufferLost | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 188 | }; | 
|  | 189 | static const char* kContextKey; | 
|  | 190 | static const char* kDeviceKey; | 
|  | 191 | static const char* kErrorCodeKey; | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 192 | static const char* kCallbackFpKey; | 
|  | 193 | static const char* kSessionSpKey; | 
|  | 194 | static const char* kCaptureRequestKey; | 
|  | 195 | static const char* kTimeStampKey; | 
|  | 196 | static const char* kCaptureResultKey; | 
|  | 197 | static const char* kCaptureFailureKey; | 
|  | 198 | static const char* kSequenceIdKey; | 
|  | 199 | static const char* kFrameNumberKey; | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 200 | static const char* kAnwKey; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 201 | class CallbackHandler : public AHandler { | 
|  | 202 | public: | 
|  | 203 | CallbackHandler() {} | 
|  | 204 | void onMessageReceived(const sp<AMessage> &msg) override; | 
|  | 205 | }; | 
|  | 206 | sp<CallbackHandler> mHandler; | 
|  | 207 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 208 | /*********************************** | 
|  | 209 | * Capture session related members * | 
|  | 210 | ***********************************/ | 
|  | 211 | // The current active session | 
|  | 212 | ACameraCaptureSession* mCurrentSession = nullptr; | 
| Yin-Chia Yeh | 309d05d | 2016-03-28 10:15:31 -0700 | [diff] [blame] | 213 | bool mFlushing = false; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 214 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 215 | int mNextSessionId = 0; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 216 | // TODO: might need another looper/handler to handle callbacks from service | 
|  | 217 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 218 | static const int REQUEST_ID_NONE = -1; | 
|  | 219 | int mRepeatingSequenceId = REQUEST_ID_NONE; | 
|  | 220 |  | 
|  | 221 | // sequence id -> last frame number map | 
|  | 222 | std::map<int, int64_t> mSequenceLastFrameNumberMap; | 
|  | 223 |  | 
|  | 224 | struct CallbackHolder { | 
|  | 225 | CallbackHolder(sp<ACameraCaptureSession>          session, | 
|  | 226 | const Vector<sp<CaptureRequest> >& requests, | 
|  | 227 | bool                               isRepeating, | 
|  | 228 | ACameraCaptureSession_captureCallbacks* cbs); | 
|  | 229 |  | 
|  | 230 | static ACameraCaptureSession_captureCallbacks fillCb( | 
|  | 231 | ACameraCaptureSession_captureCallbacks* cbs) { | 
|  | 232 | if (cbs != nullptr) { | 
|  | 233 | return *cbs; | 
|  | 234 | } | 
| Yin-Chia Yeh | e081c59 | 2016-03-29 18:26:44 -0700 | [diff] [blame] | 235 | return { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 236 | } | 
|  | 237 |  | 
|  | 238 | sp<ACameraCaptureSession>   mSession; | 
|  | 239 | Vector<sp<CaptureRequest> > mRequests; | 
|  | 240 | const bool                  mIsRepeating; | 
|  | 241 | ACameraCaptureSession_captureCallbacks mCallbacks; | 
|  | 242 | }; | 
|  | 243 | // sequence id -> callbacks map | 
|  | 244 | std::map<int, CallbackHolder> mSequenceCallbackMap; | 
|  | 245 |  | 
|  | 246 | static const int64_t NO_FRAMES_CAPTURED = -1; | 
|  | 247 | class FrameNumberTracker { | 
|  | 248 | public: | 
|  | 249 | // TODO: Called in onResultReceived and onCaptureErrorLocked | 
|  | 250 | void updateTracker(int64_t frameNumber, bool isError); | 
|  | 251 | inline int64_t getCompletedFrameNumber() { return mCompletedFrameNumber; } | 
|  | 252 | private: | 
|  | 253 | void update(); | 
|  | 254 | void updateCompletedFrameNumber(int64_t frameNumber); | 
|  | 255 |  | 
|  | 256 | int64_t mCompletedFrameNumber = NO_FRAMES_CAPTURED; | 
|  | 257 | List<int64_t> mSkippedFrameNumbers; | 
|  | 258 | std::set<int64_t> mFutureErrorSet; | 
|  | 259 | }; | 
|  | 260 | FrameNumberTracker mFrameNumberTracker; | 
|  | 261 |  | 
|  | 262 | void checkRepeatingSequenceCompleteLocked(const int sequenceId, const int64_t lastFrameNumber); | 
|  | 263 | void checkAndFireSequenceCompleteLocked(); | 
|  | 264 |  | 
|  | 265 | // Misc variables | 
|  | 266 | int32_t mShadingMapSize[2];   // const after constructor | 
|  | 267 | int32_t mPartialResultCount;  // const after constructor | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 268 |  | 
|  | 269 | }; | 
|  | 270 |  | 
|  | 271 | } // namespace android; | 
|  | 272 |  | 
|  | 273 | /** | 
|  | 274 | * ACameraDevice opaque struct definition | 
|  | 275 | * Leave outside of android namespace because it's NDK struct | 
|  | 276 | */ | 
|  | 277 | struct ACameraDevice { | 
|  | 278 | ACameraDevice(const char* id, ACameraDevice_StateCallbacks* cb, | 
|  | 279 | std::unique_ptr<ACameraMetadata> chars) : | 
|  | 280 | mDevice(new CameraDevice(id, cb, std::move(chars), this)) {} | 
|  | 281 |  | 
|  | 282 | ~ACameraDevice() {}; | 
|  | 283 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 284 | /******************* | 
|  | 285 | * NDK public APIs * | 
|  | 286 | *******************/ | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 287 | inline const char* getId() const { return mDevice->getId(); } | 
|  | 288 |  | 
|  | 289 | camera_status_t createCaptureRequest( | 
|  | 290 | ACameraDevice_request_template templateId, | 
|  | 291 | ACaptureRequest** request) const { | 
|  | 292 | return mDevice->createCaptureRequest(templateId, request); | 
|  | 293 | } | 
|  | 294 |  | 
| Yin-Chia Yeh | ead9146 | 2016-01-06 16:45:08 -0800 | [diff] [blame] | 295 | camera_status_t createCaptureSession( | 
|  | 296 | const ACaptureSessionOutputContainer*       outputs, | 
|  | 297 | const ACameraCaptureSession_stateCallbacks* callbacks, | 
|  | 298 | /*out*/ACameraCaptureSession** session) { | 
|  | 299 | return mDevice->createCaptureSession(outputs, callbacks, session); | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | /*********************** | 
|  | 303 | * Device interal APIs * | 
|  | 304 | ***********************/ | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 305 | inline android::sp<android::hardware::camera2::ICameraDeviceCallbacks> getServiceCallback() { | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 306 | return mDevice->getServiceCallback(); | 
|  | 307 | }; | 
|  | 308 |  | 
|  | 309 | // Camera device is only functional after remote being set | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 310 | inline void setRemoteDevice(android::sp<android::hardware::camera2::ICameraDeviceUser> remote) { | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 311 | mDevice->setRemoteDevice(remote); | 
|  | 312 | } | 
|  | 313 |  | 
|  | 314 | private: | 
| Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 315 | android::sp<android::CameraDevice> mDevice; | 
| Yin-Chia Yeh | 0dea57f | 2015-12-09 16:46:07 -0800 | [diff] [blame] | 316 | }; | 
|  | 317 |  | 
|  | 318 | #endif // _ACAMERA_DEVICE_H |