Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
| 17 | #define LOG_TAG "Camera2ClientBase" |
| 18 | #define ATRACE_TAG ATRACE_TAG_CAMERA |
| 19 | //#define LOG_NDEBUG 0 |
| 20 | |
Colin Cross | e5729fa | 2014-03-21 15:04:25 -0700 | [diff] [blame] | 21 | #include <inttypes.h> |
| 22 | |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 23 | #include <utils/Log.h> |
| 24 | #include <utils/Trace.h> |
| 25 | |
| 26 | #include <cutils/properties.h> |
| 27 | #include <gui/Surface.h> |
| 28 | #include <gui/Surface.h> |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 29 | |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 30 | #include "common/Camera2ClientBase.h" |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 31 | |
Eino-Ville Talvala | 7b82efe | 2013-07-25 17:12:35 -0700 | [diff] [blame] | 32 | #include "api2/CameraDeviceClient.h" |
| 33 | |
Eino-Ville Talvala | d309fb9 | 2015-11-25 12:12:45 -0800 | [diff] [blame] | 34 | #include "device3/Camera3Device.h" |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 35 | |
| 36 | namespace android { |
| 37 | using namespace camera2; |
| 38 | |
| 39 | static int getCallingPid() { |
| 40 | return IPCThreadState::self()->getCallingPid(); |
| 41 | } |
| 42 | |
| 43 | // Interface used by CameraService |
| 44 | |
| 45 | template <typename TClientBase> |
| 46 | Camera2ClientBase<TClientBase>::Camera2ClientBase( |
| 47 | const sp<CameraService>& cameraService, |
| 48 | const sp<TCamCallbacks>& remoteCallback, |
| 49 | const String16& clientPackageName, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 50 | const String8& cameraId, |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 51 | int cameraFacing, |
| 52 | int clientPid, |
| 53 | uid_t clientUid, |
| 54 | int servicePid): |
| 55 | TClientBase(cameraService, remoteCallback, clientPackageName, |
| 56 | cameraId, cameraFacing, clientPid, clientUid, servicePid), |
Yin-Chia Yeh | cd8fce8 | 2014-06-18 10:51:34 -0700 | [diff] [blame] | 57 | mSharedCameraCallbacks(remoteCallback), |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 58 | mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)), |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 59 | mDeviceActive(false) |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 60 | { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 61 | ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(), |
Eino-Ville Talvala | b9d2f33 | 2014-09-18 17:24:22 -0700 | [diff] [blame] | 62 | String8(clientPackageName).string(), clientPid, clientUid); |
Igor Murashkin | 98e2472 | 2013-06-19 19:51:04 -0700 | [diff] [blame] | 63 | |
Eino-Ville Talvala | b9d2f33 | 2014-09-18 17:24:22 -0700 | [diff] [blame] | 64 | mInitialClientPid = clientPid; |
Eino-Ville Talvala | d309fb9 | 2015-11-25 12:12:45 -0800 | [diff] [blame] | 65 | mDevice = new Camera3Device(cameraId); |
Igor Murashkin | 98e2472 | 2013-06-19 19:51:04 -0700 | [diff] [blame] | 66 | LOG_ALWAYS_FATAL_IF(mDevice == 0, "Device should never be NULL here."); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | template <typename TClientBase> |
| 70 | status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation) |
| 71 | const { |
| 72 | |
| 73 | int callingPid = getCallingPid(); |
| 74 | if (callingPid == TClientBase::mClientPid) return NO_ERROR; |
| 75 | |
| 76 | ALOGE("%s: attempt to use a locked camera from a different process" |
| 77 | " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid); |
| 78 | return PERMISSION_DENIED; |
| 79 | } |
| 80 | |
| 81 | template <typename TClientBase> |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 82 | status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager) { |
| 83 | return initializeImpl(manager); |
| 84 | } |
| 85 | |
| 86 | template <typename TClientBase> |
| 87 | template <typename TProviderPtr> |
| 88 | status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr) { |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 89 | ATRACE_CALL(); |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 90 | ALOGV("%s: Initializing client for camera %s", __FUNCTION__, |
| 91 | TClientBase::mCameraIdStr.string()); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 92 | status_t res; |
| 93 | |
Igor Murashkin | e6800ce | 2013-03-04 17:25:57 -0800 | [diff] [blame] | 94 | // Verify ops permissions |
| 95 | res = TClientBase::startCameraOps(); |
| 96 | if (res != OK) { |
| 97 | return res; |
| 98 | } |
| 99 | |
| 100 | if (mDevice == NULL) { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 101 | ALOGE("%s: Camera %s: No device connected", |
| 102 | __FUNCTION__, TClientBase::mCameraIdStr.string()); |
Igor Murashkin | e6800ce | 2013-03-04 17:25:57 -0800 | [diff] [blame] | 103 | return NO_INIT; |
| 104 | } |
| 105 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 106 | res = mDevice->initialize(providerPtr); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 107 | if (res != OK) { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 108 | ALOGE("%s: Camera %s: unable to initialize device: %s (%d)", |
| 109 | __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res); |
Zhijun He | 66281c3 | 2013-09-13 17:59:59 -0700 | [diff] [blame] | 110 | return res; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Yin-Chia Yeh | e1c8063 | 2016-08-08 14:48:05 -0700 | [diff] [blame] | 113 | wp<CameraDeviceBase::NotificationListener> weakThis(this); |
| 114 | res = mDevice->setNotifyCallback(weakThis); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 115 | |
| 116 | return OK; |
| 117 | } |
| 118 | |
| 119 | template <typename TClientBase> |
| 120 | Camera2ClientBase<TClientBase>::~Camera2ClientBase() { |
| 121 | ATRACE_CALL(); |
| 122 | |
| 123 | TClientBase::mDestructionStarted = true; |
| 124 | |
| 125 | disconnect(); |
| 126 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 127 | ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)", |
| 128 | TClientBase::mCameraIdStr.string(), |
Svetoslav Ganov | 280405a | 2015-05-12 02:19:27 +0000 | [diff] [blame] | 129 | String8(TClientBase::mClientPackageName).string(), |
Eino-Ville Talvala | b9d2f33 | 2014-09-18 17:24:22 -0700 | [diff] [blame] | 130 | mInitialClientPid, TClientBase::mClientUid); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | template <typename TClientBase> |
Eino-Ville Talvala | c400396 | 2016-01-13 10:07:04 -0800 | [diff] [blame] | 134 | status_t Camera2ClientBase<TClientBase>::dumpClient(int fd, |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 135 | const Vector<String16>& args) { |
| 136 | String8 result; |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 137 | result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n", |
| 138 | TClientBase::mCameraIdStr.string(), |
Eino-Ville Talvala | e992e75 | 2014-11-07 16:17:48 -0800 | [diff] [blame] | 139 | (TClientBase::getRemoteCallback() != NULL ? |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 140 | IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL), |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 141 | TClientBase::mClientPid); |
| 142 | result.append(" State: "); |
| 143 | |
| 144 | write(fd, result.string(), result.size()); |
| 145 | // TODO: print dynamic/request section from most recent requests |
| 146 | |
| 147 | return dumpDevice(fd, args); |
| 148 | } |
| 149 | |
| 150 | template <typename TClientBase> |
| 151 | status_t Camera2ClientBase<TClientBase>::dumpDevice( |
| 152 | int fd, |
| 153 | const Vector<String16>& args) { |
| 154 | String8 result; |
| 155 | |
| 156 | result = " Device dump:\n"; |
| 157 | write(fd, result.string(), result.size()); |
| 158 | |
| 159 | if (!mDevice.get()) { |
| 160 | result = " *** Device is detached\n"; |
| 161 | write(fd, result.string(), result.size()); |
| 162 | return NO_ERROR; |
| 163 | } |
| 164 | |
| 165 | status_t res = mDevice->dump(fd, args); |
| 166 | if (res != OK) { |
| 167 | result = String8::format(" Error dumping device: %s (%d)", |
| 168 | strerror(-res), res); |
| 169 | write(fd, result.string(), result.size()); |
| 170 | } |
| 171 | |
| 172 | return NO_ERROR; |
| 173 | } |
| 174 | |
| 175 | // ICameraClient2BaseUser interface |
| 176 | |
| 177 | |
| 178 | template <typename TClientBase> |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 179 | binder::Status Camera2ClientBase<TClientBase>::disconnect() { |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 180 | ATRACE_CALL(); |
| 181 | Mutex::Autolock icl(mBinderSerializationLock); |
| 182 | |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 183 | binder::Status res = binder::Status::ok(); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 184 | // Allow both client and the media server to disconnect at all times |
| 185 | int callingPid = getCallingPid(); |
| 186 | if (callingPid != TClientBase::mClientPid && |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 187 | callingPid != TClientBase::mServicePid) return res; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 188 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 189 | ALOGV("Camera %s: Shutting down", TClientBase::mCameraIdStr.string()); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 190 | |
| 191 | detachDevice(); |
| 192 | |
Igor Murashkin | e6800ce | 2013-03-04 17:25:57 -0800 | [diff] [blame] | 193 | CameraService::BasicClient::disconnect(); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 194 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 195 | ALOGV("Camera %s: Shut down complete complete", TClientBase::mCameraIdStr.string()); |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 196 | |
| 197 | return res; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | template <typename TClientBase> |
| 201 | void Camera2ClientBase<TClientBase>::detachDevice() { |
| 202 | if (mDevice == 0) return; |
| 203 | mDevice->disconnect(); |
| 204 | |
| 205 | mDevice.clear(); |
| 206 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 207 | ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string()); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | template <typename TClientBase> |
| 211 | status_t Camera2ClientBase<TClientBase>::connect( |
| 212 | const sp<TCamCallbacks>& client) { |
| 213 | ATRACE_CALL(); |
| 214 | ALOGV("%s: E", __FUNCTION__); |
| 215 | Mutex::Autolock icl(mBinderSerializationLock); |
| 216 | |
| 217 | if (TClientBase::mClientPid != 0 && |
| 218 | getCallingPid() != TClientBase::mClientPid) { |
| 219 | |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 220 | ALOGE("%s: Camera %s: Connection attempt from pid %d; " |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 221 | "current locked to pid %d", |
| 222 | __FUNCTION__, |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 223 | TClientBase::mCameraIdStr.string(), |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 224 | getCallingPid(), |
| 225 | TClientBase::mClientPid); |
| 226 | return BAD_VALUE; |
| 227 | } |
| 228 | |
| 229 | TClientBase::mClientPid = getCallingPid(); |
| 230 | |
| 231 | TClientBase::mRemoteCallback = client; |
| 232 | mSharedCameraCallbacks = client; |
| 233 | |
| 234 | return OK; |
| 235 | } |
| 236 | |
| 237 | /** Device-related methods */ |
| 238 | |
| 239 | template <typename TClientBase> |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 240 | void Camera2ClientBase<TClientBase>::notifyError( |
Eino-Ville Talvala | d56db1d | 2015-12-17 16:50:35 -0800 | [diff] [blame] | 241 | int32_t errorCode, |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 242 | const CaptureResultExtras& resultExtras) { |
| 243 | ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode, |
| 244 | resultExtras.requestId); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | template <typename TClientBase> |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 248 | void Camera2ClientBase<TClientBase>::notifyIdle() { |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 249 | if (mDeviceActive) { |
| 250 | getCameraService()->updateProxyDeviceState( |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 251 | ICameraServiceProxy::CAMERA_STATE_IDLE, TClientBase::mCameraIdStr); |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 252 | } |
| 253 | mDeviceActive = false; |
| 254 | |
Eino-Ville Talvala | f1e98d8 | 2013-09-06 09:32:43 -0700 | [diff] [blame] | 255 | ALOGV("Camera device is now idle"); |
| 256 | } |
| 257 | |
| 258 | template <typename TClientBase> |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 259 | void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras, |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 260 | nsecs_t timestamp) { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 261 | (void)resultExtras; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 262 | (void)timestamp; |
| 263 | |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 264 | if (!mDeviceActive) { |
| 265 | getCameraService()->updateProxyDeviceState( |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 266 | ICameraServiceProxy::CAMERA_STATE_ACTIVE, TClientBase::mCameraIdStr); |
Eino-Ville Talvala | 412fe56 | 2015-08-20 17:08:32 -0700 | [diff] [blame] | 267 | } |
| 268 | mDeviceActive = true; |
| 269 | |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 270 | ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, |
| 271 | __FUNCTION__, resultExtras.requestId, timestamp); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | template <typename TClientBase> |
| 275 | void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState, |
| 276 | int triggerId) { |
| 277 | (void)newState; |
| 278 | (void)triggerId; |
| 279 | |
| 280 | ALOGV("%s: Autofocus state now %d, last trigger %d", |
| 281 | __FUNCTION__, newState, triggerId); |
| 282 | |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | template <typename TClientBase> |
| 286 | void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState, |
| 287 | int triggerId) { |
| 288 | (void)newState; |
| 289 | (void)triggerId; |
| 290 | |
| 291 | ALOGV("%s: Autoexposure state now %d, last trigger %d", |
| 292 | __FUNCTION__, newState, triggerId); |
| 293 | } |
| 294 | |
| 295 | template <typename TClientBase> |
| 296 | void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState, |
| 297 | int triggerId) { |
| 298 | (void)newState; |
| 299 | (void)triggerId; |
| 300 | |
| 301 | ALOGV("%s: Auto-whitebalance state now %d, last trigger %d", |
| 302 | __FUNCTION__, newState, triggerId); |
| 303 | } |
| 304 | |
| 305 | template <typename TClientBase> |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 306 | void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) { |
| 307 | (void)streamId; |
| 308 | |
| 309 | ALOGV("%s: Stream %d now prepared", |
| 310 | __FUNCTION__, streamId); |
| 311 | } |
| 312 | |
| 313 | template <typename TClientBase> |
Shuzhen Wang | 9d06601 | 2016-09-30 11:30:20 -0700 | [diff] [blame] | 314 | void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() { |
| 315 | |
| 316 | ALOGV("%s: Request queue now empty", __FUNCTION__); |
| 317 | } |
| 318 | |
| 319 | template <typename TClientBase> |
Chien-Yu Chen | e8c535e | 2016-04-14 12:18:26 -0700 | [diff] [blame] | 320 | void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) { |
| 321 | (void)lastFrameNumber; |
| 322 | |
| 323 | ALOGV("%s: Repeating request was stopped. Last frame number is %ld", |
| 324 | __FUNCTION__, lastFrameNumber); |
| 325 | } |
| 326 | |
| 327 | template <typename TClientBase> |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 328 | int Camera2ClientBase<TClientBase>::getCameraId() const { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 329 | return std::stoi(TClientBase::mCameraIdStr.string()); |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | template <typename TClientBase> |
Yin-Chia Yeh | cd8fce8 | 2014-06-18 10:51:34 -0700 | [diff] [blame] | 333 | int Camera2ClientBase<TClientBase>::getCameraDeviceVersion() const { |
| 334 | return mDeviceVersion; |
| 335 | } |
| 336 | |
| 337 | template <typename TClientBase> |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 338 | const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() { |
| 339 | return mDevice; |
| 340 | } |
| 341 | |
| 342 | template <typename TClientBase> |
| 343 | const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() { |
Eino-Ville Talvala | 2f09bac | 2016-12-13 11:29:54 -0800 | [diff] [blame] | 344 | return TClientBase::sCameraService; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | template <typename TClientBase> |
| 348 | Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock( |
| 349 | SharedCameraCallbacks &client) : |
| 350 | |
| 351 | mRemoteCallback(client.mRemoteCallback), |
| 352 | mSharedClient(client) { |
| 353 | |
| 354 | mSharedClient.mRemoteCallbackLock.lock(); |
| 355 | } |
| 356 | |
| 357 | template <typename TClientBase> |
| 358 | Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() { |
| 359 | mSharedClient.mRemoteCallbackLock.unlock(); |
| 360 | } |
| 361 | |
| 362 | template <typename TClientBase> |
| 363 | Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks( |
| 364 | const sp<TCamCallbacks>&client) : |
| 365 | |
| 366 | mRemoteCallback(client) { |
| 367 | } |
| 368 | |
| 369 | template <typename TClientBase> |
| 370 | typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks& |
| 371 | Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=( |
| 372 | const sp<TCamCallbacks>&client) { |
| 373 | |
| 374 | Mutex::Autolock l(mRemoteCallbackLock); |
| 375 | mRemoteCallback = client; |
| 376 | return *this; |
| 377 | } |
| 378 | |
| 379 | template <typename TClientBase> |
| 380 | void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() { |
| 381 | Mutex::Autolock l(mRemoteCallbackLock); |
| 382 | mRemoteCallback.clear(); |
| 383 | } |
| 384 | |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 385 | template class Camera2ClientBase<CameraService::Client>; |
Igor Murashkin | e7ee763 | 2013-06-11 18:10:18 -0700 | [diff] [blame] | 386 | template class Camera2ClientBase<CameraDeviceClientBase>; |
Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame] | 387 | |
| 388 | } // namespace android |