ARX  1.0
The next-generation open source augmented reality toolkit.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
camera_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 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#ifndef __CAMERA_CAMERA_UTILS_H__
18#define __CAMERA_CAMERA_UTILS_H__
19
20#include "videoAndroid.h"
21
22#include <camera/NdkCameraError.h>
23#include <camera/NdkCameraManager.h>
24
25#define ASSERT(cond, fmt, ...) \
26 if (!(cond)) { \
27 ARLOGe(#cond, fmt, ##__VA_ARGS__); \
28 }
29
30/*
31 * A set of macros to call into Camera APIs. The API is grouped with a few
32 * objects, with object name as the prefix of function names.
33 */
34#define CALL_CAMERA(func) \
35 { \
36 camera_status_t status = func; \
37 ASSERT(status == ACAMERA_OK, "%s call failed with code: %#x, %s", \
38 __FUNCTION__, status, GetErrorStr(status)); \
39 }
40#define CALL_MGR(func) CALL_CAMERA(ACameraManager_##func)
41#define CALL_DEV(func) CALL_CAMERA(ACameraDevice_##func)
42#define CALL_METADATA(func) CALL_CAMERA(ACameraMetadata_##func)
43#define CALL_CONTAINER(func) CALL_CAMERA(ACaptureSessionOutputContainer_##func)
44#define CALL_OUTPUT(func) CALL_CAMERA(ACaptureSessionOutput_##func)
45#define CALL_TARGET(func) CALL_CAMERA(ACameraOutputTarget_##func)
46#define CALL_REQUEST(func) CALL_CAMERA(ACaptureRequest_##func)
47#define CALL_SESSION(func) CALL_CAMERA(ACameraCaptureSession_##func)
48
49/*
50 * A few debugging functions for error code strings etc
51 */
52const char* GetErrorStr(camera_status_t err);
53const char* GetTagStr(acamera_metadata_tag_t tag);
54void PrintMetadataTags(int32_t entries, const uint32_t* pTags);
55void PrintLensFacing(ACameraMetadata_const_entry& lensData);
56void PrintCameras(ACameraManager* cameraMgr);
57void PrintCameraDeviceError(int err);
58
59void PrintRequestMetadata(ACaptureRequest* req);
60#endif // __CAMERA_CAMERA_UTILS_H__
void PrintCameraDeviceError(int err)
Definition: camera_utils.cpp:455
void PrintLensFacing(ACameraMetadata_const_entry &lensData)
Definition: camera_utils.cpp:296
const char * GetTagStr(acamera_metadata_tag_t tag)
Definition: camera_utils.cpp:268
void PrintMetadataTags(int32_t entries, const uint32_t *pTags)
Definition: camera_utils.cpp:286
void PrintCameras(ACameraManager *cameraMgr)
Definition: camera_utils.cpp:361
void PrintRequestMetadata(ACaptureRequest *req)
Definition: camera_utils.cpp:402
const char * GetErrorStr(camera_status_t err)
Definition: camera_utils.cpp:62