blob: 55c7579df08e8cc4e50d9116c4d5989e5ae3c490 [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 Chowdhary22441f32021-12-26 18:35:41 -080037#include "device3/hidl/HidlCamera3Device.h"
Jayant Chowdhary12361932018-08-27 14:46:13 -070038#include "utils/CameraThreadState.h"
Shuzhen Wang316781a2020-08-18 18:11:01 -070039#include "utils/CameraServiceProxyWrapper.h"
Igor Murashkin44cfcf02013-03-01 16:22:28 -080040
41namespace android {
42using namespace camera2;
43
Igor Murashkin44cfcf02013-03-01 16:22:28 -080044// Interface used by CameraService
45
46template <typename TClientBase>
47Camera2ClientBase<TClientBase>::Camera2ClientBase(
48 const sp<CameraService>& cameraService,
49 const sp<TCamCallbacks>& remoteCallback,
50 const String16& clientPackageName,
Jooyung Han3f9a3b42020-01-23 12:27:18 +090051 const std::optional<String16>& clientFeatureId,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080052 const String8& cameraId,
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080053 int api1CameraId,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080054 int cameraFacing,
Emilian Peev8b64f282021-03-25 16:49:57 -070055 int sensorOrientation,
Igor Murashkin44cfcf02013-03-01 16:22:28 -080056 int clientPid,
57 uid_t clientUid,
Shuzhen Wangd4abdf72021-05-28 11:22:50 -070058 int servicePid,
Emilian Peev5104fe92021-10-21 14:27:09 -070059 bool overrideForPerfClass,
60 bool legacyClient):
Philip P. Moltmann9e648f62019-11-04 12:52:45 -080061 TClientBase(cameraService, remoteCallback, clientPackageName, clientFeatureId,
Emilian Peev8b64f282021-03-25 16:49:57 -070062 cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid, clientUid,
63 servicePid),
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -070064 mSharedCameraCallbacks(remoteCallback),
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080065 mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -080066 mDeviceActive(false), mApi1CameraId(api1CameraId)
Igor Murashkin44cfcf02013-03-01 16:22:28 -080067{
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080068 ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070069 String8(clientPackageName).string(), clientPid, clientUid);
Igor Murashkin98e24722013-06-19 19:51:04 -070070
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -070071 mInitialClientPid = clientPid;
Jayant Chowdhary22441f32021-12-26 18:35:41 -080072 mOverrideForPerfClass = overrideForPerfClass;
73 mLegacyClient = legacyClient;
Igor Murashkin44cfcf02013-03-01 16:22:28 -080074}
75
76template <typename TClientBase>
77status_t Camera2ClientBase<TClientBase>::checkPid(const char* checkLocation)
78 const {
79
Jayant Chowdhary12361932018-08-27 14:46:13 -070080 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -080081 if (callingPid == TClientBase::mClientPid) return NO_ERROR;
82
83 ALOGE("%s: attempt to use a locked camera from a different process"
84 " (old pid %d, new pid %d)", checkLocation, TClientBase::mClientPid, callingPid);
85 return PERMISSION_DENIED;
86}
87
88template <typename TClientBase>
Emilian Peevbd8c5032018-02-14 23:05:40 +000089status_t Camera2ClientBase<TClientBase>::initialize(sp<CameraProviderManager> manager,
90 const String8& monitorTags) {
91 return initializeImpl(manager, monitorTags);
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080092}
93
94template <typename TClientBase>
95template <typename TProviderPtr>
Emilian Peevbd8c5032018-02-14 23:05:40 +000096status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr,
97 const String8& monitorTags) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -080098 ATRACE_CALL();
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -080099 ALOGV("%s: Initializing client for camera %s", __FUNCTION__,
100 TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800101 status_t res;
102
Igor Murashkine6800ce2013-03-04 17:25:57 -0800103 // Verify ops permissions
104 res = TClientBase::startCameraOps();
105 if (res != OK) {
106 return 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 =
117 new HidlCamera3Device(TClientBase::mCameraIdStr, mOverrideForPerfClass,
118 mLegacyClient);
119 break;
120 case IPCTransport::AIDL:
121 ALOGE("%s: AIDL camera3Devices not available yet", __FUNCTION__);
122 return NO_INIT;
123 default:
124 ALOGE("%s Invalid transport for camera id %s", __FUNCTION__,
125 TClientBase::mCameraIdStr.string());
126 return NO_INIT;
127 }
Igor Murashkine6800ce2013-03-04 17:25:57 -0800128 if (mDevice == NULL) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800129 ALOGE("%s: Camera %s: No device connected",
130 __FUNCTION__, TClientBase::mCameraIdStr.string());
Igor Murashkine6800ce2013-03-04 17:25:57 -0800131 return NO_INIT;
132 }
133
Emilian Peevbd8c5032018-02-14 23:05:40 +0000134 res = mDevice->initialize(providerPtr, monitorTags);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800135 if (res != OK) {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800136 ALOGE("%s: Camera %s: unable to initialize device: %s (%d)",
137 __FUNCTION__, TClientBase::mCameraIdStr.string(), strerror(-res), res);
Zhijun He66281c32013-09-13 17:59:59 -0700138 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800139 }
140
Yin-Chia Yeh5fd603e2019-11-20 11:22:27 -0800141 wp<NotificationListener> weakThis(this);
Yin-Chia Yehe1c80632016-08-08 14:48:05 -0700142 res = mDevice->setNotifyCallback(weakThis);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800143
144 return OK;
145}
146
147template <typename TClientBase>
148Camera2ClientBase<TClientBase>::~Camera2ClientBase() {
149 ATRACE_CALL();
150
151 TClientBase::mDestructionStarted = true;
152
153 disconnect();
154
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800155 ALOGI("Closed Camera %s. Client was: %s (PID %d, UID %u)",
156 TClientBase::mCameraIdStr.string(),
Svetoslav Ganov280405a2015-05-12 02:19:27 +0000157 String8(TClientBase::mClientPackageName).string(),
Eino-Ville Talvalab9d2f332014-09-18 17:24:22 -0700158 mInitialClientPid, TClientBase::mClientUid);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800159}
160
161template <typename TClientBase>
Eino-Ville Talvalac4003962016-01-13 10:07:04 -0800162status_t Camera2ClientBase<TClientBase>::dumpClient(int fd,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800163 const Vector<String16>& args) {
164 String8 result;
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800165 result.appendFormat("Camera2ClientBase[%s] (%p) PID: %d, dump:\n",
166 TClientBase::mCameraIdStr.string(),
Eino-Ville Talvalae992e752014-11-07 16:17:48 -0800167 (TClientBase::getRemoteCallback() != NULL ?
Marco Nelissen06b46062014-11-14 07:58:25 -0800168 IInterface::asBinder(TClientBase::getRemoteCallback()).get() : NULL),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800169 TClientBase::mClientPid);
170 result.append(" State: ");
171
172 write(fd, result.string(), result.size());
173 // TODO: print dynamic/request section from most recent requests
174
175 return dumpDevice(fd, args);
176}
177
178template <typename TClientBase>
Avichal Rakesh7e53cad2021-10-05 13:46:30 -0700179status_t Camera2ClientBase<TClientBase>::startWatchingTags(const String8 &tags, int out) {
180 sp<CameraDeviceBase> device = mDevice;
181 if (!device) {
182 dprintf(out, " Device is detached");
183 return OK;
184 }
185
186 return device->startWatchingTags(tags);
187}
188
189template <typename TClientBase>
190status_t Camera2ClientBase<TClientBase>::stopWatchingTags(int out) {
191 sp<CameraDeviceBase> device = mDevice;
192 if (!device) {
193 dprintf(out, " Device is detached");
194 return OK;
195 }
196
197 return device->stopWatchingTags();
198}
199
200template <typename TClientBase>
201status_t Camera2ClientBase<TClientBase>::dumpWatchedEventsToVector(std::vector<std::string> &out) {
202 sp<CameraDeviceBase> device = mDevice;
203 if (!device) {
204 // Nothing to dump if the device is detached
205 return OK;
206 }
207 return device->dumpWatchedEventsToVector(out);
208}
209
210template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800211status_t Camera2ClientBase<TClientBase>::dumpDevice(
212 int fd,
213 const Vector<String16>& args) {
214 String8 result;
215
216 result = " Device dump:\n";
217 write(fd, result.string(), result.size());
218
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800219 sp<CameraDeviceBase> device = mDevice;
220 if (!device.get()) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800221 result = " *** Device is detached\n";
222 write(fd, result.string(), result.size());
223 return NO_ERROR;
224 }
225
Yin-Chia Yehe5138f12017-11-10 14:10:05 -0800226 status_t res = device->dump(fd, args);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800227 if (res != OK) {
228 result = String8::format(" Error dumping device: %s (%d)",
229 strerror(-res), res);
230 write(fd, result.string(), result.size());
231 }
232
233 return NO_ERROR;
234}
235
236// ICameraClient2BaseUser interface
237
238
239template <typename TClientBase>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800240binder::Status Camera2ClientBase<TClientBase>::disconnect() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800241 ATRACE_CALL();
242 Mutex::Autolock icl(mBinderSerializationLock);
243
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800244 binder::Status res = binder::Status::ok();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800245 // Allow both client and the media server to disconnect at all times
Jayant Chowdhary12361932018-08-27 14:46:13 -0700246 int callingPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800247 if (callingPid != TClientBase::mClientPid &&
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800248 callingPid != TClientBase::mServicePid) return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800249
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800250 ALOGV("Camera %s: Shutting down", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800251
Rucha Katakwardf223072021-06-15 10:21:00 -0700252 // Before detaching the device, cache the info from current open session.
253 // The disconnected check avoids duplication of info and also prevents
254 // deadlock while acquiring service lock in cacheDump.
255 if (!TClientBase::mDisconnected) {
256 Camera2ClientBase::getCameraService()->cacheDump();
257 }
258
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800259 detachDevice();
260
Igor Murashkine6800ce2013-03-04 17:25:57 -0800261 CameraService::BasicClient::disconnect();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800262
Shuzhen Wang316781a2020-08-18 18:11:01 -0700263 ALOGV("Camera %s: Shut down complete", TClientBase::mCameraIdStr.string());
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800264
265 return res;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800266}
267
268template <typename TClientBase>
269void Camera2ClientBase<TClientBase>::detachDevice() {
270 if (mDevice == 0) return;
271 mDevice->disconnect();
272
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800273 ALOGV("Camera %s: Detach complete", TClientBase::mCameraIdStr.string());
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800274}
275
276template <typename TClientBase>
277status_t Camera2ClientBase<TClientBase>::connect(
278 const sp<TCamCallbacks>& client) {
279 ATRACE_CALL();
280 ALOGV("%s: E", __FUNCTION__);
281 Mutex::Autolock icl(mBinderSerializationLock);
282
283 if (TClientBase::mClientPid != 0 &&
Jayant Chowdhary12361932018-08-27 14:46:13 -0700284 CameraThreadState::getCallingPid() != TClientBase::mClientPid) {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800285
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800286 ALOGE("%s: Camera %s: Connection attempt from pid %d; "
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800287 "current locked to pid %d",
288 __FUNCTION__,
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800289 TClientBase::mCameraIdStr.string(),
Jayant Chowdhary12361932018-08-27 14:46:13 -0700290 CameraThreadState::getCallingPid(),
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800291 TClientBase::mClientPid);
292 return BAD_VALUE;
293 }
294
Jayant Chowdhary12361932018-08-27 14:46:13 -0700295 TClientBase::mClientPid = CameraThreadState::getCallingPid();
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800296
297 TClientBase::mRemoteCallback = client;
298 mSharedCameraCallbacks = client;
299
300 return OK;
301}
302
303/** Device-related methods */
304
305template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700306void Camera2ClientBase<TClientBase>::notifyError(
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800307 int32_t errorCode,
Jianing Weicb0652e2014-03-12 18:29:36 -0700308 const CaptureResultExtras& resultExtras) {
309 ALOGE("Error condition %d reported by HAL, requestId %" PRId32, errorCode,
310 resultExtras.requestId);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800311}
312
313template <typename TClientBase>
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700314status_t Camera2ClientBase<TClientBase>::notifyActive() {
315 if (!mDeviceActive) {
316 status_t res = TClientBase::startCameraStreamingOps();
317 if (res != OK) {
318 ALOGE("%s: Camera %s: Error starting camera streaming ops: %d", __FUNCTION__,
319 TClientBase::mCameraIdStr.string(), res);
320 return res;
321 }
322 CameraServiceProxyWrapper::logActive(TClientBase::mCameraIdStr);
323 }
324 mDeviceActive = true;
325
326 ALOGV("Camera device is now active");
327 return OK;
328}
329
330template <typename TClientBase>
Shuzhen Wang316781a2020-08-18 18:11:01 -0700331void Camera2ClientBase<TClientBase>::notifyIdle(
332 int64_t requestCount, int64_t resultErrorCount, bool deviceError,
333 const std::vector<hardware::CameraStreamStats>& streamStats) {
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700334 if (mDeviceActive) {
Eino-Ville Talvala178e8232021-04-16 18:41:39 -0700335 status_t res = TClientBase::finishCameraStreamingOps();
336 if (res != OK) {
337 ALOGE("%s: Camera %s: Error finishing streaming ops: %d", __FUNCTION__,
338 TClientBase::mCameraIdStr.string(), res);
339 }
Shuzhen Wang316781a2020-08-18 18:11:01 -0700340 CameraServiceProxyWrapper::logIdle(TClientBase::mCameraIdStr,
341 requestCount, resultErrorCount, deviceError, streamStats);
Eino-Ville Talvala412fe562015-08-20 17:08:32 -0700342 }
343 mDeviceActive = false;
344
Eino-Ville Talvalaf1e98d82013-09-06 09:32:43 -0700345 ALOGV("Camera device is now idle");
346}
347
348template <typename TClientBase>
Jianing Weicb0652e2014-03-12 18:29:36 -0700349void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& resultExtras,
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800350 nsecs_t timestamp) {
Jianing Weicb0652e2014-03-12 18:29:36 -0700351 (void)resultExtras;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800352 (void)timestamp;
353
Jianing Weicb0652e2014-03-12 18:29:36 -0700354 ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64,
355 __FUNCTION__, resultExtras.requestId, timestamp);
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800356}
357
358template <typename TClientBase>
359void Camera2ClientBase<TClientBase>::notifyAutoFocus(uint8_t newState,
360 int triggerId) {
361 (void)newState;
362 (void)triggerId;
363
364 ALOGV("%s: Autofocus state now %d, last trigger %d",
365 __FUNCTION__, newState, triggerId);
366
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800367}
368
369template <typename TClientBase>
370void Camera2ClientBase<TClientBase>::notifyAutoExposure(uint8_t newState,
371 int triggerId) {
372 (void)newState;
373 (void)triggerId;
374
375 ALOGV("%s: Autoexposure state now %d, last trigger %d",
376 __FUNCTION__, newState, triggerId);
377}
378
379template <typename TClientBase>
380void Camera2ClientBase<TClientBase>::notifyAutoWhitebalance(uint8_t newState,
381 int triggerId) {
382 (void)newState;
383 (void)triggerId;
384
385 ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
386 __FUNCTION__, newState, triggerId);
387}
388
389template <typename TClientBase>
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700390void Camera2ClientBase<TClientBase>::notifyPrepared(int streamId) {
391 (void)streamId;
392
393 ALOGV("%s: Stream %d now prepared",
394 __FUNCTION__, streamId);
395}
396
397template <typename TClientBase>
Shuzhen Wang9d066012016-09-30 11:30:20 -0700398void Camera2ClientBase<TClientBase>::notifyRequestQueueEmpty() {
399
400 ALOGV("%s: Request queue now empty", __FUNCTION__);
401}
402
403template <typename TClientBase>
Chien-Yu Chene8c535e2016-04-14 12:18:26 -0700404void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameNumber) {
405 (void)lastFrameNumber;
406
407 ALOGV("%s: Repeating request was stopped. Last frame number is %ld",
408 __FUNCTION__, lastFrameNumber);
409}
410
411template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800412int Camera2ClientBase<TClientBase>::getCameraId() const {
Yin-Chia Yehc3e9d6f2018-02-06 10:56:32 -0800413 return mApi1CameraId;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800414}
415
416template <typename TClientBase>
Yin-Chia Yehcd8fce82014-06-18 10:51:34 -0700417int Camera2ClientBase<TClientBase>::getCameraDeviceVersion() const {
418 return mDeviceVersion;
419}
420
421template <typename TClientBase>
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800422const sp<CameraDeviceBase>& Camera2ClientBase<TClientBase>::getCameraDevice() {
423 return mDevice;
424}
425
426template <typename TClientBase>
427const sp<CameraService>& Camera2ClientBase<TClientBase>::getCameraService() {
Eino-Ville Talvala2f09bac2016-12-13 11:29:54 -0800428 return TClientBase::sCameraService;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800429}
430
431template <typename TClientBase>
432Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::Lock(
433 SharedCameraCallbacks &client) :
434
435 mRemoteCallback(client.mRemoteCallback),
436 mSharedClient(client) {
437
438 mSharedClient.mRemoteCallbackLock.lock();
439}
440
441template <typename TClientBase>
442Camera2ClientBase<TClientBase>::SharedCameraCallbacks::Lock::~Lock() {
443 mSharedClient.mRemoteCallbackLock.unlock();
444}
445
446template <typename TClientBase>
447Camera2ClientBase<TClientBase>::SharedCameraCallbacks::SharedCameraCallbacks(
448 const sp<TCamCallbacks>&client) :
449
450 mRemoteCallback(client) {
451}
452
453template <typename TClientBase>
454typename Camera2ClientBase<TClientBase>::SharedCameraCallbacks&
455Camera2ClientBase<TClientBase>::SharedCameraCallbacks::operator=(
456 const sp<TCamCallbacks>&client) {
457
458 Mutex::Autolock l(mRemoteCallbackLock);
459 mRemoteCallback = client;
460 return *this;
461}
462
463template <typename TClientBase>
464void Camera2ClientBase<TClientBase>::SharedCameraCallbacks::clear() {
465 Mutex::Autolock l(mRemoteCallbackLock);
466 mRemoteCallback.clear();
467}
468
Cliff Wud3a05312021-04-26 23:07:31 +0800469template <typename TClientBase>
470status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
471 sp<CameraProviderManager> manager) {
472 return mDevice->injectCamera(injectedCamId, manager);
473}
474
475template <typename TClientBase>
476status_t Camera2ClientBase<TClientBase>::stopInjection() {
477 return mDevice->stopInjection();
478}
479
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800480template class Camera2ClientBase<CameraService::Client>;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700481template class Camera2ClientBase<CameraDeviceClientBase>;
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800482
483} // namespace android