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