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