blob: 86bf8a5d255e8ce1e39bde94900f88828a3264c3 [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"
18
19#ifdef __ANDROID_VNDK__
20#include "ndk_vendor/impl/ACameraDeviceVendor.inc"
21#else
22#include "ACameraDevice.inc"
23#endif
24
25using namespace android;
26
27template <class T>
28camera_status_t
29ACameraCaptureSession::setRepeatingRequest(
30 /*optional*/T* cbs,
31 int numRequests, ACaptureRequest** requests,
32 /*optional*/int* captureSequenceId) {
33 sp<acam::CameraDevice> dev = getDeviceSp();
34 if (dev == nullptr) {
35 ALOGE("Error: Device associated with session %p has been closed!", this);
36 return ACAMERA_ERROR_SESSION_CLOSED;
37 }
38
39 camera_status_t ret;
40 dev->lockDeviceForSessionOps();
41 {
42 Mutex::Autolock _l(mSessionLock);
43 ret = dev->setRepeatingRequestsLocked(
44 this, cbs, numRequests, requests, captureSequenceId);
45 }
46 dev->unlockDevice();
47 return ret;
48}
49
50template <class T>
51camera_status_t ACameraCaptureSession::capture(
52 /*optional*/T* cbs,
53 int numRequests, ACaptureRequest** requests,
54 /*optional*/int* captureSequenceId) {
55 sp<acam::CameraDevice> dev = getDeviceSp();
56 if (dev == nullptr) {
57 ALOGE("Error: Device associated with session %p has been closed!", this);
58 return ACAMERA_ERROR_SESSION_CLOSED;
59 }
60 camera_status_t ret;
61 dev->lockDeviceForSessionOps();
62 {
63 Mutex::Autolock _l(mSessionLock);
64 ret = dev->captureLocked(this, cbs, numRequests, requests, captureSequenceId);
65 }
66 dev->unlockDevice();
67 return ret;
68}