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