blob: da535f8b55c1dec8b6929aa46c2cd0d44279c2a9 [file] [log] [blame]
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -08001/*
2 * Copyright (C) 2018 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#include "ACameraCaptureSession.h"
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080018#ifdef __ANDROID_VNDK__
Avichal Rakeshf099b232022-10-27 15:44:50 -070019#include <ndk_vendor/impl/ACameraDeviceVendor.inc>
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080020#else
21#include "ACameraDevice.inc"
22#endif
23
24using namespace android;
25
26template <class T>
27camera_status_t
28ACameraCaptureSession::setRepeatingRequest(
29 /*optional*/T* cbs,
30 int numRequests, ACaptureRequest** requests,
31 /*optional*/int* captureSequenceId) {
Avichal Rakeshf099b232022-10-27 15:44:50 -070032#ifdef __ANDROID_VNDK__
33 std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
34#else
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080035 sp<acam::CameraDevice> dev = getDeviceSp();
Avichal Rakeshf099b232022-10-27 15:44:50 -070036#endif
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080037 if (dev == nullptr) {
38 ALOGE("Error: Device associated with session %p has been closed!", this);
39 return ACAMERA_ERROR_SESSION_CLOSED;
40 }
41
42 camera_status_t ret;
43 dev->lockDeviceForSessionOps();
44 {
45 Mutex::Autolock _l(mSessionLock);
46 ret = dev->setRepeatingRequestsLocked(
47 this, cbs, numRequests, requests, captureSequenceId);
48 }
49 dev->unlockDevice();
50 return ret;
51}
52
53template <class T>
54camera_status_t ACameraCaptureSession::capture(
55 /*optional*/T* cbs,
56 int numRequests, ACaptureRequest** requests,
57 /*optional*/int* captureSequenceId) {
Avichal Rakeshf099b232022-10-27 15:44:50 -070058#ifdef __ANDROID_VNDK__
59 std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
60#else
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080061 sp<acam::CameraDevice> dev = getDeviceSp();
Avichal Rakeshf099b232022-10-27 15:44:50 -070062#endif
Shuzhen Wang0ff9ae32018-12-05 18:06:12 -080063 if (dev == nullptr) {
64 ALOGE("Error: Device associated with session %p has been closed!", this);
65 return ACAMERA_ERROR_SESSION_CLOSED;
66 }
67 camera_status_t ret;
68 dev->lockDeviceForSessionOps();
69 {
70 Mutex::Autolock _l(mSessionLock);
71 ret = dev->captureLocked(this, cbs, numRequests, requests, captureSequenceId);
72 }
73 dev->unlockDevice();
74 return ret;
75}