blob: f2a7d52419518cdedfcc095d2eca933670adafd7 [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"
Shuzhen Wang316781a2020-08-18 18:11:01 -070040#include "utils/CameraServiceProxyWrapper.h"
Igor Murashkin44cfcf02013-03-01 16:22:28 -080041
42namespace android {
Jayant Chowdhary48162a72022-05-27 05:37:14 +000043
44const static size_t kDisconnectTimeoutMs = 2500;
45
Igor Murashkin44cfcf02013-03-01 16:22:28 -080046using namespace camera2;
47
Igor Murashkin44cfcf02013-03-01 16:22:28 -080048// Interface used by CameraService
49
50template <typename TClientBase>
51Camera2ClientBase<TClientBase>::Camera2ClientBase(
52 const sp<CameraService>& cameraService,
53 const sp<TCamCallbacks>& remoteCallback,
54 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),
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080070 mDeviceActive(false), mApi1CameraId(api1CameraId)
Igor Murashkin44cfcf02013-03-01 16:22:28 -080071{
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080072 ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070073 String8(clientPackageName).string(), clientPid, clientUid);
Igor Murashkin98e24722013-06-19 19:51:04 -070074
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070075 mInitialClientPid = clientPid;
Jayant Chowdhary22441f32021-12-26 18:35:41 -080076 mOverrideForPerfClass = overrideForPerfClass;
77 mLegacyClient = legacyClient;
Igor Murashkin44cfcf02013-03-01 16:22:28 -080078}
79
80template <typename TClientBase>
81status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation)
82 const {
83
Jayant Chowdhary12361932018-08-27 14:46:13 -070084 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -080085 if (callingPid == TClientBase::mClientPid) return NO_ERROR;
86
87 ALOGE("%s: attempt to use a locked camera from a different process"
88 " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid);
89 return PERMISSION_DENIED;
90}
91
92template <typename TClientBase>
Emilian Peevbd8c5032018-02-14 23:05:40 +000093status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager,
94 const String8& monitorTags) {
95 return initializeImpl(manager, monitorTags);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080096}
97
98template <typename TClientBase>
99template <typename TProviderPtr>
Emilian Peevbd8c5032018-02-14 23:05:40 +0000100status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr,
101 const String8& monitorTags) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800102 ATRACE_CALL();
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800103 ALOGV("%s: Initializing client for camera %s", __FUNCTION__,
104 TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800105 status_t res;
106
Igor Murashkine6800ce2013-03-04 17:25:57 -0800107 // Verify ops permissions
108 res = TClientBase::startCameraOps();
109 if (res != OK) {
110 return res;
111 }
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800112 IPCTransport providerTransport = IPCTransport::INVALID;
113 res = providerPtr->getCameraIdIPCTransport(TClientBase::mCameraIdStr.string(),
114 &providerTransport);
115 if (res != OK) {
116 return res;
117 }
118 switch (providerTransport) {
119 case IPCTransport::HIDL:
120 mDevice =
121 new HidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
122 mLegacyClient);
123 break;
124 case IPCTransport::AIDL:
Jayant Chowdhary35642f22022-01-08 00:39:39 +0000125 mDevice =
126 new AidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
127 mLegacyClient);
128 break;
Jayant Chowdhary22441f32021-12-26 18:35:41 -0800129 default:
130 ALOGE("%s Invalid transport for camera id %s", __FUNCTION__,
131 TClientBase::mCameraIdStr.string());
132 return NO_INIT;
133 }
Igor Murashkine6800ce2013-03-04 17:25:57 -0800134 if (mDevice == NULL) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800135 ALOGE("%s: Camera %s: No device connected",
136 __FUNCTION__, TClientBase::mCameraIdStr.string());
Igor Murashkine6800ce2013-03-04 17:25:57 -0800137 return NO_INIT;
138 }
139
Emilian Peevbd8c5032018-02-14 23:05:40 +0000140 res = mDevice->initialize(providerPtr, monitorTags);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800141 if (res != OK) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800142 ALOGE("%s: Camera %s: unable to initialize device: %s (%d)",
143 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
Zhijun He66281c32013-09-13 17:59:59 -0700144 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800145 }
146
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800147 wp<NotificationListener> weakThis(this);
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700148 res = mDevice->setNotifyCallback(weakThis);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800149
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000150 /** Start watchdog thread */
151 mCameraServiceWatchdog = new CameraServiceWatchdog();
152 mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog");
153
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800154 return OK;
155}
156
157template <typename TClientBase>
158Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
159 ATRACE_CALL();
160
161 TClientBase::mDestructionStarted = true;
162
163 disconnect();
164
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800165 ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)",
166 TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000167 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700168 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800169}
170
171template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800172status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800173 const Vector<String16>& args) {
174 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800175 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
176 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800177 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800178 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800179 TClientBase::mClientPid);
180 result.append(" State: ");
181
182 write(fd, result.string(), result.size());
183 // TODO: print dynamic/request section from most recent requests
184
185 return dumpDevice(fd, args);
186}
187
188template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700189status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
190 sp<CameraDeviceBase> device = mDevice;
191 if (!device) {
192 dprintf(out, " Device is detached");
193 return OK;
194 }
195
196 return device->startWatchingTags(tags);
197}
198
199template <typename TClientBase>
200status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
201 sp<CameraDeviceBase> device = mDevice;
202 if (!device) {
203 dprintf(out, " Device is detached");
204 return OK;
205 }
206
207 return device->stopWatchingTags();
208}
209
210template <typename TClientBase>
211status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
212 sp<CameraDeviceBase> device = mDevice;
213 if (!device) {
214 // Nothing to dump if the device is detached
215 return OK;
216 }
217 return device->dumpWatchedEventsToVector(out);
218}
219
220template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800221status_t Camera2ClientBase<TClientBase>::dumpDevice(
222 int fd,
223 const Vector<String16>& args) {
224 String8 result;
225
226 result = " Device dump:\n";
227 write(fd, result.string(), result.size());
228
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800229 sp<CameraDeviceBase> device = mDevice;
230 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800231 result = " *** Device is detached\n";
232 write(fd, result.string(), result.size());
233 return NO_ERROR;
234 }
235
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800236 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800237 if (res != OK) {
238 result = String8::format(" Error dumping device: %s (%d)",
239 strerror(-res), res);
240 write(fd, result.string(), result.size());
241 }
242
243 return NO_ERROR;
244}
245
246// ICameraClient2BaseUser interface
247
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800248template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800249binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Jayant Chowdhary48162a72022-05-27 05:37:14 +0000250 return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(),
251 kDisconnectTimeoutMs / kCycleLengthMs, kCycleLengthMs);
252}
253
254template <typename TClientBase>
255binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800256 ATRACE_CALL();
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700257 ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800258 Mutex::Autolock icl(mBinderSerializationLock);
259
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700260 ALOGD("Camera %s: serializationLock acquired", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800261 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800262 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700263 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800264 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800265 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800266
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700267 ALOGD("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800268
Rucha Katakwardf223072021-06-15 10:21:00 -0700269 // Before detaching the device, cache the info from current open session.
270 // The disconnected check avoids duplication of info and also prevents
271 // deadlock while acquiring service lock in cacheDump.
272 if (!TClientBase::mDisconnected) {
Shuzhen Wang046f4a82022-05-05 17:15:24 -0700273 ALOGD("Camera %s: start to cacheDump", TClientBase::mCameraIdStr.string());
Rucha Katakwardf223072021-06-15 10:21:00 -0700274 Camera2ClientBase::getCameraService()->cacheDump();
275 }
276
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800277 detachDevice();
278
Igor Murashkine6800ce2013-03-04 17:25:57 -0800279 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800280
Shuzhen Wang316781a2020-08-18 18:11:01 -0700281 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800282
283 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800284}
285
286template <typename TClientBase>
287void Camera2ClientBase<TClientBase>::detachDevice() {
288 if (mDevice == 0) return;
289 mDevice->disconnect();
290
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800291 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800292}
293
294template <typename TClientBase>
295status_t Camera2ClientBase<TClientBase>::connect(
296 const sp<TCamCallbacks>& client) {
297 ATRACE_CALL();
298 ALOGV("%s: E", __FUNCTION__);
299 Mutex::Autolock icl(mBinderSerializationLock);
300
301 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700302 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800303
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800304 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800305 "current locked to pid %d",
306 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800307 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700308 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800309 TClientBase::mClientPid);
310 return BAD_VALUE;
311 }
312
Jayant Chowdhary12361932018-08-27 14:46:13 -0700313 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800314
315 TClientBase::mRemoteCallback = client;
316 mSharedCameraCallbacks = client;
317
318 return OK;
319}
320
321/** Device-related methods */
322
323template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700324void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800325 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700326 const CaptureResultExtras& resultExtras) {
327 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
328 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800329}
330
331template <typename TClientBase>
Austin Borger4a870a32022-02-25 01:48:41 +0000332status_t Camera2ClientBase<TClientBase>::notifyActive(float maxPreviewFps) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700333 if (!mDeviceActive) {
334 status_t res = TClientBase::startCameraStreamingOps();
335 if (res != OK) {
336 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
337 TClientBase::mCameraIdStr.string(), res);
338 return res;
339 }
Austin Borger4a870a32022-02-25 01:48:41 +0000340 CameraServiceProxyWrapper::logActive(TClientBase::mCameraIdStr, maxPreviewFps);
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700341 }
342 mDeviceActive = true;
343
344 ALOGV("Camera device is now active");
345 return OK;
346}
347
348template <typename TClientBase>
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800349void Camera2ClientBase<TClientBase>::notifyIdleWithUserTag(
Shuzhen Wang316781a2020-08-18 18:11:01 -0700350 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
Shuzhen Wangd26b1862022-03-07 12:05:05 -0800351 const std::vector<hardware::CameraStreamStats>& streamStats,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700352 const std::string& userTag, int videoStabilizationMode) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700353 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700354 status_t res = TClientBase::finishCameraStreamingOps();
355 if (res != OK) {
356 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
357 TClientBase::mCameraIdStr.string(), res);
358 }
Shuzhen Wang316781a2020-08-18 18:11:01 -0700359 CameraServiceProxyWrapper::logIdle(TClientBase::mCameraIdStr,
Shuzhen Wang9372b0b2022-05-11 18:55:19 -0700360 requestCount, resultErrorCount, deviceError, userTag, videoStabilizationMode,
361 streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700362 }
363 mDeviceActive = false;
364
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700365 ALOGV("Camera device is now idle");
366}
367
368template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700369void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800370 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700371 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800372 (void)timestamp;
373
Jianing Weicb0652e2014-03-12 18:29:36 -0700374 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
375 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800376}
377
378template <typename TClientBase>
379void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
380 int triggerId) {
381 (void)newState;
382 (void)triggerId;
383
384 ALOGV("%s: Autofocus state now %d, last trigger %d",
385 __FUNCTION__, newState, triggerId);
386
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800387}
388
389template <typename TClientBase>
390void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
391 int triggerId) {
392 (void)newState;
393 (void)triggerId;
394
395 ALOGV("%s: Autoexposure state now %d, last trigger %d",
396 __FUNCTION__, newState, triggerId);
397}
398
399template <typename TClientBase>
400void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
401 int triggerId) {
402 (void)newState;
403 (void)triggerId;
404
405 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
406 __FUNCTION__, newState, triggerId);
407}
408
409template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700410void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
411 (void)streamId;
412
413 ALOGV("%s: Stream %d now prepared",
414 __FUNCTION__, streamId);
415}
416
417template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700418void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
419
420 ALOGV("%s: Request queue now empty", __FUNCTION__);
421}
422
423template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700424void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
425 (void)lastFrameNumber;
426
427 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
428 __FUNCTION__, lastFrameNumber);
429}
430
431template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800432int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800433 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800434}
435
436template <typename TClientBase>
437const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
438 return mDevice;
439}
440
441template <typename TClientBase>
442const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800443 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800444}
445
446template <typename TClientBase>
447Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
448 SharedCameraCallbacks &client) :
449
450 mRemoteCallback(client.mRemoteCallback),
451 mSharedClient(client) {
452
453 mSharedClient.mRemoteCallbackLock.lock();
454}
455
456template <typename TClientBase>
457Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
458 mSharedClient.mRemoteCallbackLock.unlock();
459}
460
461template <typename TClientBase>
462Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
463 const sp<TCamCallbacks>&client) :
464
465 mRemoteCallback(client) {
466}
467
468template <typename TClientBase>
469typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
470Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
471 const sp<TCamCallbacks>&client) {
472
473 Mutex::Autolock l(mRemoteCallbackLock);
474 mRemoteCallback = client;
475 return *this;
476}
477
478template <typename TClientBase>
479void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
480 Mutex::Autolock l(mRemoteCallbackLock);
481 mRemoteCallback.clear();
482}
483
Cliff Wud3a05312021-04-26 23:07:31 +0800484template <typename TClientBase>
485status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
486 sp<CameraProviderManager> manager) {
487 return mDevice->injectCamera(injectedCamId, manager);
488}
489
490template <typename TClientBase>
491status_t Camera2ClientBase<TClientBase>::stopInjection() {
492 return mDevice->stopInjection();
493}
494
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800495template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700496template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800497
498} // namespace android