blob: f926b88fd0bbcc122c68818165accd29a3c25b88 [file] [log] [blame]
Igor Murashkin44cfcf02013-03-01 16:22:28 -08001/*
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 Crosse5729fa2014-03-21 15:04:25 -070021#include <inttypes.h>
22
Igor Murashkin44cfcf02013-03-01 16:22:28 -080023#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 Murashkin44cfcf02013-03-01 16:22:28 -080029
Shuzhen Wang316781a2020-08-18 18:11:01 -070030#include <camera/CameraSessionStats.h>
31
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070032#include "common/Camera2ClientBase.h"
Igor Murashkine7ee7632013-06-11 18:10:18 -070033
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070034#include "api2/CameraDeviceClient.h"
35
Eino-Ville Talvalad309fb92015-11-25 12:12:45 -080036#include "device3/Camera3Device.h"
Jayant Chowdhary35642f22022-01-08 00:39:39 +000037#include "device3/aidl/AidlCamera3Device.h"
Jayant Chowdhary22441f32021-12-26 18:35:41 -080038#include "device3/hidl/HidlCamera3Device.h"
Jayant Chowdhary12361932018-08-27 14:46:13 -070039#include "utils/CameraThreadState.h"
Igor Murashkin44cfcf02013-03-01 16:22:28 -080040
41namespace android {
Jayant Chowdhary620763f2022-05-27 05:37:14 +000042
43const static size_t kDisconnectTimeoutMs = 2500;
44
Igor Murashkin44cfcf02013-03-01 16:22:28 -080045using namespace camera2;
46
Igor Murashkin44cfcf02013-03-01 16:22:28 -080047// Interface used by CameraService
48
49template <typename TClientBase>
50Camera2ClientBase<TClientBase>::Camera2ClientBase(
51 const sp<CameraService>& cameraService,
52 const sp<TCamCallbacks>& remoteCallback,
Austin Borger74fca042022-05-23 12:41:21 -070053 std::shared_ptr<CameraServiceProxyWrapper> cameraServiceProxyWrapper,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080054 const String16& clientPackageName,
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080055 bool systemNativeClient,
Jooyung Han3f9a3b42020-01-23 12:27:18 +090056 const std::optional<String16>& clientFeatureId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080057 const String8& cameraId,
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080058 int api1CameraId,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080059 int cameraFacing,
Emilian Peev8b64f282021-03-25 16:49:57 -070060 int sensorOrientation,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080061 int clientPid,
62 uid_t clientUid,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070063 int servicePid,
Emilian Peev5104fe92021-10-21 14:27:09 -070064 bool overrideForPerfClass,
65 bool legacyClient):
Jayant Chowdharyeb0169f2022-01-31 00:00:02 -080066 TClientBase(cameraService, remoteCallback, clientPackageName, systemNativeClient,
67 clientFeatureId, cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid,
68 clientUid, servicePid),
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -070069 mSharedCameraCallbacks(remoteCallback),
Austin Borger74fca042022-05-23 12:41:21 -070070 mCameraServiceProxyWrapper(cameraServiceProxyWrapper),
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080071 mDeviceActive(false), mApi1CameraId(api1CameraId)
Igor Murashkin44cfcf02013-03-01 16:22:28 -080072{
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080073 ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070074 String8(clientPackageName).string(), clientPid, clientUid);
Igor Murashkin98e24722013-06-19 19:51:04 -070075
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070076 mInitialClientPid = clientPid;
Jayant Chowdhary22441f32021-12-26 18:35:41 -080077 mOverrideForPerfClass = overrideForPerfClass;
78 mLegacyClient = legacyClient;
Igor Murashkin44cfcf02013-03-01 16:22:28 -080079}
80
81template <typename TClientBase>
82status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation)
83 const {
84
Jayant Chowdhary12361932018-08-27 14:46:13 -070085 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -080086 if (callingPid == TClientBase::mClientPid) return NO_ERROR;
87
88 ALOGE("%s: attempt to use a locked camera from a different process"
89 " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid);
90 return PERMISSION_DENIED;
91}
92
93template <typename TClientBase>
Emilian Peevbd8c5032018-02-14 23:05:40 +000094status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager,
95 const String8& monitorTags) {
96 return initializeImpl(manager, monitorTags);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080097}
98
99template <typename TClientBase>
100template <typename TProviderPtr>
Emilian Peevbd8c5032018-02-14 23:05:40 +0000101status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr,
102 const String8& monitorTags) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800103 ATRACE_CALL();
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800104 ALOGV("%s: Initializing client for camera %s", __FUNCTION__,
105 TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800106 status_t res;
107
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800108 IPCTransport providerTransport = IPCTransport::INVALID;
109 res = providerPtr->getCameraIdIPCTransport(TClientBase::mCameraIdStr.string(),
110 &providerTransport);
111 if (res != OK) {
112 return res;
113 }
114 switch (providerTransport) {
115 case IPCTransport::HIDL:
116 mDevice =
Austin Borger74fca042022-05-23 12:41:21 -0700117 new HidlCamera3Device(mCameraServiceProxyWrapper,
118 TClientBase::mCameraIdStr, mOverrideForPerfClass, mLegacyClient);
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800119 break;
120 case IPCTransport::AIDL:
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000121 mDevice =
Austin Borger74fca042022-05-23 12:41:21 -0700122 new AidlCamera3Device(mCameraServiceProxyWrapper,
123 TClientBase::mCameraIdStr, mOverrideForPerfClass, mLegacyClient);
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000124 break;
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800125 default:
126 ALOGE("%s Invalid transport for camera id %s", __FUNCTION__,
127 TClientBase::mCameraIdStr.string());
128 return NO_INIT;
129 }
Igor Murashkine6800ce2013-03-04 17:25:57 -0800130 if (mDevice == NULL) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800131 ALOGE("%s: Camera %s: No device connected",
132 __FUNCTION__, TClientBase::mCameraIdStr.string());
Igor Murashkine6800ce2013-03-04 17:25:57 -0800133 return NO_INIT;
134 }
135
Emilian Peevbd8c5032018-02-14 23:05:40 +0000136 res = mDevice->initialize(providerPtr, monitorTags);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800137 if (res != OK) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800138 ALOGE("%s: Camera %s: unable to initialize device: %s (%d)",
139 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
Zhijun He66281c32013-09-13 17:59:59 -0700140 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800141 }
142
Emilian Peevfa17f092022-07-29 13:28:55 -0700143 // Verify ops permissions
144 res = TClientBase::startCameraOps();
145 if (res != OK) {
146 TClientBase::finishCameraOps();
147 mDevice.clear();
148 return res;
149 }
150
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800151 wp<NotificationListener> weakThis(this);
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700152 res = mDevice->setNotifyCallback(weakThis);
Austin Borger7b129542022-06-09 13:23:06 -0700153 if (res != OK) {
154 ALOGE("%s: Camera %s: Unable to set notify callback: %s (%d)",
155 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
156 return res;
157 }
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800158
Jayant Chowdhary620763f2022-05-27 05:37:14 +0000159 /** Start watchdog thread */
160 mCameraServiceWatchdog = new CameraServiceWatchdog();
Austin Borger7b129542022-06-09 13:23:06 -0700161 res = mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog");
162 if (res != OK) {
163 ALOGE("%s: Unable to start camera service watchdog thread: %s (%d)",
164 __FUNCTION__, strerror(-res), res);
165 return res;
166 }
Jayant Chowdhary620763f2022-05-27 05:37:14 +0000167
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800168 return OK;
169}
170
171template <typename TClientBase>
172Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
173 ATRACE_CALL();
174
175 TClientBase::mDestructionStarted = true;
176
177 disconnect();
178
Ravneetc83d7c42022-06-03 20:51:58 +0000179 if (mCameraServiceWatchdog != NULL) {
180 mCameraServiceWatchdog->requestExit();
181 mCameraServiceWatchdog.clear();
182 }
183
Jayant Chowdhary3ab499d2022-06-15 15:43:33 -0700184 ALOGI("%s: Client object's dtor for Camera Id %s completed. Client was: %s (PID %d, UID %u)",
185 __FUNCTION__, TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000186 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700187 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800188}
189
190template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800191status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800192 const Vector<String16>& args) {
193 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800194 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
195 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800196 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800197 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800198 TClientBase::mClientPid);
199 result.append(" State: ");
200
201 write(fd, result.string(), result.size());
202 // TODO: print dynamic/request section from most recent requests
203
204 return dumpDevice(fd, args);
205}
206
207template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700208status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
209 sp<CameraDeviceBase> device = mDevice;
210 if (!device) {
211 dprintf(out, " Device is detached");
212 return OK;
213 }
214
215 return device->startWatchingTags(tags);
216}
217
218template <typename TClientBase>
219status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
220 sp<CameraDeviceBase> device = mDevice;
221 if (!device) {
222 dprintf(out, " Device is detached");
223 return OK;
224 }
225
226 return device->stopWatchingTags();
227}
228
229template <typename TClientBase>
230status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
231 sp<CameraDeviceBase> device = mDevice;
232 if (!device) {
233 // Nothing to dump if the device is detached
234 return OK;
235 }
236 return device->dumpWatchedEventsToVector(out);
237}
238
239template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800240status_t Camera2ClientBase<TClientBase>::dumpDevice(
241 int fd,
242 const Vector<String16>& args) {
243 String8 result;
244
245 result = " Device dump:\n";
246 write(fd, result.string(), result.size());
247
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800248 sp<CameraDeviceBase> device = mDevice;
249 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800250 result = " *** Device is detached\n";
251 write(fd, result.string(), result.size());
252 return NO_ERROR;
253 }
254
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800255 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800256 if (res != OK) {
257 result = String8::format(" Error dumping device: %s (%d)",
258 strerror(-res), res);
259 write(fd, result.string(), result.size());
260 }
261
262 return NO_ERROR;
263}
264
265// ICameraClient2BaseUser interface
266
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800267template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800268binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Jayant Chowdhary3f20d192022-05-31 17:24:39 +0000269 if (mCameraServiceWatchdog != nullptr) {
270 // Initialization from hal succeeded, time disconnect.
271 return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(),
272 kDisconnectTimeoutMs / kCycleLengthMs, kCycleLengthMs);
273 }
274 return disconnectImpl();
Jayant Chowdhary620763f2022-05-27 05:37:14 +0000275}
276
277template <typename TClientBase>
278binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800279 ATRACE_CALL();
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700280 ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800281 Mutex::Autolock icl(mBinderSerializationLock);
282
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700283 ALOGD("Camera %s: serializationLock acquired", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800284 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800285 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700286 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800287 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800288 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800289
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700290 ALOGD("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800291
Rucha Katakwardf223072021-06-15 10:21:00 -0700292 // Before detaching the device, cache the info from current open session.
293 // The disconnected check avoids duplication of info and also prevents
294 // deadlock while acquiring service lock in cacheDump.
295 if (!TClientBase::mDisconnected) {
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700296 ALOGD("Camera %s: start to cacheDump", TClientBase::mCameraIdStr.string());
Rucha Katakwardf223072021-06-15 10:21:00 -0700297 Camera2ClientBase::getCameraService()->cacheDump();
298 }
299
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800300 detachDevice();
301
Igor Murashkine6800ce2013-03-04 17:25:57 -0800302 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800303
Shuzhen Wang316781a2020-08-18 18:11:01 -0700304 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800305
306 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800307}
308
309template <typename TClientBase>
310void Camera2ClientBase<TClientBase>::detachDevice() {
311 if (mDevice == 0) return;
312 mDevice->disconnect();
313
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800314 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800315}
316
317template <typename TClientBase>
318status_t Camera2ClientBase<TClientBase>::connect(
319 const sp<TCamCallbacks>& client) {
320 ATRACE_CALL();
321 ALOGV("%s: E", __FUNCTION__);
322 Mutex::Autolock icl(mBinderSerializationLock);
323
324 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700325 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800326
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800327 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800328 "current locked to pid %d",
329 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800330 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700331 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800332 TClientBase::mClientPid);
333 return BAD_VALUE;
334 }
335
Jayant Chowdhary12361932018-08-27 14:46:13 -0700336 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800337
338 TClientBase::mRemoteCallback = client;
339 mSharedCameraCallbacks = client;
340
341 return OK;
342}
343
344/** Device-related methods */
345
346template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700347void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800348 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700349 const CaptureResultExtras& resultExtras) {
350 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
351 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800352}
353
354template <typename TClientBase>
Austin Borger4a870a32022-02-25 01:48:41 +0000355status_t Camera2ClientBase<TClientBase>::notifyActive(float maxPreviewFps) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700356 if (!mDeviceActive) {
357 status_t res = TClientBase::startCameraStreamingOps();
358 if (res != OK) {
359 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
360 TClientBase::mCameraIdStr.string(), res);
361 return res;
362 }
Austin Borger74fca042022-05-23 12:41:21 -0700363 mCameraServiceProxyWrapper->logActive(TClientBase::mCameraIdStr, maxPreviewFps);
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700364 }
365 mDeviceActive = true;
366
367 ALOGV("Camera device is now active");
368 return OK;
369}
370
371template <typename TClientBase>
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800372void Camera2ClientBase<TClientBase>::notifyIdleWithUserTag(
Shuzhen Wang316781a2020-08-18 18:11:01 -0700373 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800374 const std::vector<hardware::CameraStreamStats>& streamStats,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700375 const std::string& userTag, int videoStabilizationMode) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700376 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700377 status_t res = TClientBase::finishCameraStreamingOps();
378 if (res != OK) {
379 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
380 TClientBase::mCameraIdStr.string(), res);
381 }
Austin Borger74fca042022-05-23 12:41:21 -0700382 mCameraServiceProxyWrapper->logIdle(TClientBase::mCameraIdStr,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700383 requestCount, resultErrorCount, deviceError, userTag, videoStabilizationMode,
384 streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700385 }
386 mDeviceActive = false;
387
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700388 ALOGV("Camera device is now idle");
389}
390
391template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700392void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800393 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700394 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800395 (void)timestamp;
396
Jianing Weicb0652e2014-03-12 18:29:36 -0700397 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
398 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800399}
400
401template <typename TClientBase>
402void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
403 int triggerId) {
404 (void)newState;
405 (void)triggerId;
406
407 ALOGV("%s: Autofocus state now %d, last trigger %d",
408 __FUNCTION__, newState, triggerId);
409
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800410}
411
412template <typename TClientBase>
413void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
414 int triggerId) {
415 (void)newState;
416 (void)triggerId;
417
418 ALOGV("%s: Autoexposure state now %d, last trigger %d",
419 __FUNCTION__, newState, triggerId);
420}
421
422template <typename TClientBase>
423void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
424 int triggerId) {
425 (void)newState;
426 (void)triggerId;
427
428 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
429 __FUNCTION__, newState, triggerId);
430}
431
432template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700433void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
434 (void)streamId;
435
436 ALOGV("%s: Stream %d now prepared",
437 __FUNCTION__, streamId);
438}
439
440template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700441void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
442
443 ALOGV("%s: Request queue now empty", __FUNCTION__);
444}
445
446template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700447void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
448 (void)lastFrameNumber;
449
450 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
451 __FUNCTION__, lastFrameNumber);
452}
453
454template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800455int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800456 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800457}
458
459template <typename TClientBase>
460const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
461 return mDevice;
462}
463
464template <typename TClientBase>
465const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800466 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800467}
468
469template <typename TClientBase>
470Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
471 SharedCameraCallbacks &client) :
472
473 mRemoteCallback(client.mRemoteCallback),
474 mSharedClient(client) {
475
476 mSharedClient.mRemoteCallbackLock.lock();
477}
478
479template <typename TClientBase>
480Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
481 mSharedClient.mRemoteCallbackLock.unlock();
482}
483
484template <typename TClientBase>
485Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
486 const sp<TCamCallbacks>&client) :
487
488 mRemoteCallback(client) {
489}
490
491template <typename TClientBase>
492typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
493Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
494 const sp<TCamCallbacks>&client) {
495
496 Mutex::Autolock l(mRemoteCallbackLock);
497 mRemoteCallback = client;
498 return *this;
499}
500
501template <typename TClientBase>
502void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
503 Mutex::Autolock l(mRemoteCallbackLock);
504 mRemoteCallback.clear();
505}
506
Cliff Wud3a05312021-04-26 23:07:31 +0800507template <typename TClientBase>
508status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
509 sp<CameraProviderManager> manager) {
510 return mDevice->injectCamera(injectedCamId, manager);
511}
512
513template <typename TClientBase>
514status_t Camera2ClientBase<TClientBase>::stopInjection() {
515 return mDevice->stopInjection();
516}
517
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800518template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700519template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800520
521} // namespace android