10dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/* 20dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Copyright (C) 2015 The Android Open Source Project 30dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 40dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Licensed under the Apache License, Version 2.0 (the "License"); 50dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * you may not use this file except in compliance with the License. 60dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * You may obtain a copy of the License at 70dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 80dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * http://www.apache.org/licenses/LICENSE-2.0 90dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * 100dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Unless required by applicable law or agreed to in writing, software 110dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * distributed under the License is distributed on an "AS IS" BASIS, 120dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * See the License for the specific language governing permissions and 140dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * limitations under the License. 150dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 160dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 173e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 183e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @addtogroup Camera 193e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @{ 203e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 213e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh 223e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 233e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @file NdkCameraManager.h 243e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 253e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh 260dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/* 270dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * This file defines an NDK API. 280dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not remove methods. 290dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not change method signatures. 300dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not change the value of constants. 310dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not change the size of any of the classes defined in here. 320dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not reference types that are not part of the NDK. 330dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh * Do not #include files that aren't part of the NDK. 340dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 350dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 360dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#ifndef _NDK_CAMERA_MANAGER_H 370dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#define _NDK_CAMERA_MANAGER_H 380dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 39d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert#include <sys/cdefs.h> 40d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert 410dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include "NdkCameraError.h" 420dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include "NdkCameraMetadata.h" 430dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh#include "NdkCameraDevice.h" 440dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 45d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert__BEGIN_DECLS 46d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert 47d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert#if __ANDROID_API__ >= 24 480dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 493e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 503e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * ACameraManager is opaque type that provides access to camera service. 513e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 523e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * A pointer can be obtained using {@link ACameraManager_create} method. 533e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 540dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehtypedef struct ACameraManager ACameraManager; 550dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 560dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 573e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Create ACameraManager instance. 583e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 593e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>The ACameraManager is responsible for 603e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * detecting, characterizing, and connecting to {@link ACameraDevice}s.</p> 613e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 623e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>The caller must call {@link ACameraManager_delete} to free the resources once it is done 633e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * using the ACameraManager instance.</p> 643e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 653e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return a {@link ACameraManager} instance. 663e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 670dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 680dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia YehACameraManager* ACameraManager_create(); 690dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 700dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 713e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Delete the {@link ACameraManager} instance and free its resources. </p> 723e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 733e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} instance to be deleted. 740dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 753e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yehvoid ACameraManager_delete(ACameraManager* manager); 760dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 773e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/// Struct to hold list of camera devices 780dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehtypedef struct ACameraIdList { 793e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh int numCameras; ///< Number of connected camera devices 803e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh const char** cameraIds; ///< list of identifier of connected camera devices 810dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh} ACameraIdList; 820dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 830dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 843e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Create a list of currently connected camera devices, including 853e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * cameras that may be in use by other camera API clients. 863e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 873e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Non-removable cameras use integers starting at 0 for their 883e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * identifiers, while removable cameras have a unique identifier for each 893e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * individual device, even if they are the same model.</p> 903e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 913e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>ACameraManager_getCameraIdList will allocate and return an {@link ACameraIdList}. 923e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * The caller must call {@link ACameraManager_deleteCameraIdList} to free the memory</p> 933e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 943e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} of interest 953e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param cameraIdList the output {@link ACameraIdList} will be filled in here if the method call 963e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * succeeds. 973e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 983e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return <ul> 993e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_OK} if the method call succeeds.</li> 1003e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if manager or cameraIdList is NULL.</li> 1013e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_CAMERA_DISCONNECTED} if connection to camera service fails.</li> 1023e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_NOT_ENOUGH_MEMORY} if allocating memory fails.</li></ul> 1030dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 1043e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yehcamera_status_t ACameraManager_getCameraIdList(ACameraManager* manager, 1050dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh /*out*/ACameraIdList** cameraIdList); 1060dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 1073e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 1083e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Delete a list of camera devices allocated via {@link ACameraManager_getCameraIdList}. 1093e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1103e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param cameraIdList the {@link ACameraIdList} to be deleted. 1113e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 1123e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yehvoid ACameraManager_deleteCameraIdList(ACameraIdList* cameraIdList); 1130dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 1143e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 1153e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Definition of camera availability callbacks. 1163e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1173e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param context The optional application context provided by user in 1183e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraManager_AvailabilityCallbacks}. 1193e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param cameraId The ID of the camera device whose availability is changing. The memory of this 1203e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * argument is owned by camera framework and will become invalid immediately after 1213e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * this callback returns. 1223e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 1230dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehtypedef void (*ACameraManager_AvailabilityCallback)(void* context, const char* cameraId); 1240dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 1253e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 1263e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * A listener for camera devices becoming available or unavailable to open. 1273e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1283e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Cameras become available when they are no longer in use, or when a new 1293e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * removable camera is connected. They become unavailable when some 1303e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * application or service starts using a camera, or when a removable camera 1313e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * is disconnected.</p> 1323e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1333e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @see ACameraManager_registerAvailabilityCallback 1343e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 1350dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehtypedef struct ACameraManager_AvailabilityListener { 1363e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh /// Optional application context. 1373e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh void* context; 1383e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh /// Called when a camera becomes available 1390dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ACameraManager_AvailabilityCallback onCameraAvailable; 1403e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh /// Called when a camera becomes unavailable 1410dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ACameraManager_AvailabilityCallback onCameraUnavailable; 1420dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh} ACameraManager_AvailabilityCallbacks; 1430dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 1440dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 1453e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Register camera availability callbacks. 1463e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1473e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>onCameraUnavailable will be called whenever a camera device is opened by any camera API client. 1483e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Other camera API clients may still be able to open such a camera device, evicting the existing 1493e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * client if they have higher priority than the existing client of a camera device. 1503e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * See {@link ACameraManager_openCamera} for more details.</p> 1513e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1523e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>The callbacks will be called on a dedicated thread shared among all ACameraManager 1533e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * instances.</p> 1543e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1553e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Since this callback will be registered with the camera service, remember to unregister it 1563e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * once it is no longer needed; otherwise the callback will continue to receive events 1573e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * indefinitely and it may prevent other resources from being released. Specifically, the 1583e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * callbacks will be invoked independently of the general activity lifecycle and independently 1593e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * of the state of individual ACameraManager instances.</p> 1603e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1613e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} of interest. 1623e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param callback the {@link ACameraManager_AvailabilityCallbacks} to be registered. 1633e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1643e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return <ul> 1653e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_OK} if the method call succeeds.</li> 1663e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if manager or callback is NULL, or 1673e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {ACameraManager_AvailabilityCallbacks#onCameraAvailable} or 1683e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {ACameraManager_AvailabilityCallbacks#onCameraUnavailable} is NULL.</li></ul> 1690dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 1700dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehcamera_status_t ACameraManager_registerAvailabilityCallback( 1713e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh ACameraManager* manager, const ACameraManager_AvailabilityCallbacks* callback); 1723e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh 1733e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** 1743e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Unregister camera availability callbacks. 1753e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1763e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Removing a callback that isn't registered has no effect.</p> 1773e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1783e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} of interest. 1793e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param callback the {@link ACameraManager_AvailabilityCallbacks} to be unregistered. 1803e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1813e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return <ul> 1823e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_OK} if the method call succeeds.</li> 1833e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if callback, 1843e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {ACameraManager_AvailabilityCallbacks#onCameraAvailable} or 1853e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {ACameraManager_AvailabilityCallbacks#onCameraUnavailable} is NULL.</li></ul> 1863e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh */ 1870dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehcamera_status_t ACameraManager_unregisterAvailabilityCallback( 1883e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh ACameraManager* manager, const ACameraManager_AvailabilityCallbacks* callback); 1890dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 1900dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 1913e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Query the capabilities of a camera device. These capabilities are 1923e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * immutable for a given camera. 1933e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1943e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>See {@link ACameraMetadata} document and {@link NdkCameraMetadataTags.h} for more details.</p> 1953e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1963e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>The caller must call {@link ACameraMetadata_free} to free the memory of the output 1973e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * characteristics.</p> 1983e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 1993e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} of interest. 2003e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param cameraId the ID string of the camera device of interest. 2013e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param characteristics the output {@link ACameraMetadata} will be filled here if the method call 2023e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * succeeeds. 2033e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2043e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return <ul> 2053e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_OK} if the method call succeeds.</li> 2063e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if manager, cameraId, or characteristics 2073e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * is NULL, or cameraId does not match any camera devices connected.</li> 2083e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_CAMERA_DISCONNECTED} if connection to camera service fails.</li> 2093e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_NOT_ENOUGH_MEMORY} if allocating memory fails.</li> 2103e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_UNKNOWN} if the method fails for some other reasons.</li></ul> 2110dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 2120dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehcamera_status_t ACameraManager_getCameraCharacteristics( 2133e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh ACameraManager* manager, const char* cameraId, 2143e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh /*out*/ACameraMetadata** characteristics); 2150dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 2160dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh/** 2173e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * Open a connection to a camera with the given ID. The opened camera device will be 2183e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * returned in the `device` parameter. 2193e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2203e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Use {@link ACameraManager_getCameraIdList} to get the list of available camera 2213e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * devices. Note that even if an id is listed, open may fail if the device 2223e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * is disconnected between the calls to {@link ACameraManager_getCameraIdList} and 2233e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraManager_openCamera}, or if a higher-priority camera API client begins using the 2243e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * camera device.</p> 2253e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2263e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Devices for which the 2273e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraManager_AvailabilityCallbacks#onCameraUnavailable} callback has been called due to 2283e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * the device being in use by a lower-priority, background camera API client can still potentially 2293e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * be opened by calling this method when the calling camera API client has a higher priority 2303e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * than the current camera API client using this device. In general, if the top, foreground 2313e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * activity is running within your application process, your process will be given the highest 2323e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * priority when accessing the camera, and this method will succeed even if the camera device is 2333e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * in use by another camera API client. Any lower-priority application that loses control of the 2343e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * camera in this way will receive an 2353e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraDevice_stateCallbacks#onDisconnected} callback.</p> 2363e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2373e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>Once the camera is successfully opened,the ACameraDevice can then be set up 2383e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * for operation by calling {@link ACameraDevice_createCaptureSession} and 2393e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraDevice_createCaptureRequest}.</p> 2403e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2413e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>If the camera becomes disconnected after this function call returns, 2423e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraDevice_stateCallbacks#onDisconnected} with a 2433e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * ACameraDevice in the disconnected state will be called.</p> 2443e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2453e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <p>If the camera runs into error after this function call returns, 2463e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * {@link ACameraDevice_stateCallbacks#onError} with a 2473e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * ACameraDevice in the error state will be called.</p> 2483e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2493e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param manager the {@link ACameraManager} of interest. 2503e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param cameraId the ID string of the camera device to be opened. 2513e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param callback the {@link ACameraDevice_StateCallbacks} associated with the opened camera device. 2523e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @param device the opened {@link ACameraDevice} will be filled here if the method call succeeds. 2533e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * 2543e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * @return <ul> 2553e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_OK} if the method call succeeds.</li> 2563e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_INVALID_PARAMETER} if manager, cameraId, callback, or device 2573e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * is NULL, or cameraId does not match any camera devices connected.</li> 2583e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_CAMERA_DISCONNECTED} if connection to camera service fails.</li> 2593e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_NOT_ENOUGH_MEMORY} if allocating memory fails.</li> 2603e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_CAMERA_IN_USE} if camera device is being used by a higher 2613e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * priority camera API client.</li> 2623e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_MAX_CAMERA_IN_USE} if the system-wide limit for number of open 2633e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * cameras or camera resources has been reached, and more camera devices cannot be 2643e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * opened until previous instances are closed.</li> 2653e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_CAMERA_DISABLED} if the camera is disabled due to a device 2663e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * policy, and cannot be opened.</li> 2673e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_PERMISSION_DENIED} if the application does not have permission 2683e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * to open camera.</li> 2693e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh * <li>{@link ACAMERA_ERROR_UNKNOWN} if the method fails for some other reasons.</li></ul> 2700dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh */ 2710dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yehcamera_status_t ACameraManager_openCamera( 2723e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh ACameraManager* manager, const char* cameraId, 2730dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh ACameraDevice_StateCallbacks* callback, 2740dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh /*out*/ACameraDevice** device); 2750dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 276d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert#endif /* __ANDROID_API__ >= 24 */ 277d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert 278d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert__END_DECLS 2790dea57fd9fc4b2ccaab97d9477359fbd5a626f5cYin-Chia Yeh 280d7973ba37cea1a9638ded23041c69774ae8cebbcDan Albert#endif /* _NDK_CAMERA_MANAGER_H */ 2813e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh 2823e49be17d8c8c53f50bb0d39affbbc36f6a12488Yin-Chia Yeh/** @} */ 283