1/* 2 * Copyright (C) 2022 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 "impl/ACameraCaptureSession.h" 18 19#include <camera/NdkCameraCaptureSession.h> 20 21using namespace android; 22 23template <class CallbackType> 24camera_status_t captureTemplate( 25 ACameraCaptureSession* session, 26 /*optional*/CallbackType* cbs, 27 int numRequests, ACaptureRequest** requests, 28 /*optional*/int* captureSequenceId) { 29 ATRACE_CALL(); 30 if (session == nullptr || requests == nullptr || numRequests < 1) { 31 ALOGE("%s: Error: invalid input: session %p, numRequest %d, requests %p", 32 __FUNCTION__, session, numRequests, requests); 33 return ACAMERA_ERROR_INVALID_PARAMETER; 34 } 35 36 if (session->isClosed()) { 37 ALOGE("%s: session %p is already closed", __FUNCTION__, session); 38 if (captureSequenceId) { 39 *captureSequenceId = CAPTURE_SEQUENCE_ID_NONE; 40 } 41 return ACAMERA_ERROR_SESSION_CLOSED; 42 } 43 44 return session->capture( 45 cbs, numRequests, requests, captureSequenceId); 46} 47 48template <class CallbackType> 49camera_status_t setRepeatingRequestTemplate( 50 ACameraCaptureSession* session, 51 /*optional*/CallbackType* cbs, 52 int numRequests, ACaptureRequest** requests, 53 /*optional*/int* captureSequenceId) { 54 ATRACE_CALL(); 55 if (session == nullptr || requests == nullptr || numRequests < 1) { 56 ALOGE("%s: Error: invalid input: session %p, numRequest %d, requests %p", 57 __FUNCTION__, session, numRequests, requests); 58 return ACAMERA_ERROR_INVALID_PARAMETER; 59 } 60 61 if (session->isClosed()) { 62 ALOGE("%s: session %p is already closed", __FUNCTION__, session); 63 if (captureSequenceId) { 64 *captureSequenceId = CAPTURE_SEQUENCE_ID_NONE; 65 } 66 return ACAMERA_ERROR_SESSION_CLOSED; 67 } 68 69 return session->setRepeatingRequest(cbs, numRequests, requests, captureSequenceId); 70} 71