• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
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#ifdef __ANDROID_VNDK__
19#include <ndk_vendor/impl/ACameraDeviceVendor.inc>
20#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) {
32#ifdef __ANDROID_VNDK__
33    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
34#else
35    sp<acam::CameraDevice> dev = getDeviceSp();
36#endif
37    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) {
58#ifdef __ANDROID_VNDK__
59    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
60#else
61    sp<acam::CameraDevice> dev = getDeviceSp();
62#endif
63    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}
76