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