Path: blob/21.2-virgl/include/android_stub/system/camera.h
4547 views
/*1* Copyright (C) 2011 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H17#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H1819#include <stdint.h>20#include <sys/cdefs.h>21#include <sys/types.h>22#include <cutils/native_handle.h>23#include <hardware/hardware.h>24#include <hardware/gralloc.h>2526__BEGIN_DECLS2728/**29* A set of bit masks for specifying how the received preview frames are30* handled before the previewCallback() call.31*32* The least significant 3 bits of an "int" value are used for this purpose:33*34* ..... 0 0 035* ^ ^ ^36* | | |---------> determine whether the callback is enabled or not37* | |-----------> determine whether the callback is one-shot or not38* |-------------> determine whether the frame is copied out or not39*40* WARNING: When a frame is sent directly without copying, it is the frame41* receiver's responsiblity to make sure that the frame data won't get42* corrupted by subsequent preview frames filled by the camera. This flag is43* recommended only when copying out data brings significant performance price44* and the handling/processing of the received frame data is always faster than45* the preview frame rate so that data corruption won't occur.46*47* For instance,48* 1. 0x00 disables the callback. In this case, copy out and one shot bits49* are ignored.50* 2. 0x01 enables a callback without copying out the received frames. A51* typical use case is the Camcorder application to avoid making costly52* frame copies.53* 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical54* use case is the Camera application.55* 4. 0x07 is enabling a callback with frame copied out only once. A typical56* use case is the Barcode scanner application.57*/5859enum {60CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01,61CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02,62CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04,63/** Typical use cases */64CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00,65CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01,66CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05,67CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x0768};6970/** msgType in notifyCallback and dataCallback functions */71enum {72CAMERA_MSG_ERROR = 0x0001, // notifyCallback73CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback74CAMERA_MSG_FOCUS = 0x0004, // notifyCallback75CAMERA_MSG_ZOOM = 0x0008, // notifyCallback76CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback77CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback78CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback79CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback80CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback81CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback82// Preview frame metadata. This can be combined with83// CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can84// request FRAME and METADATA. Or the apps can request only FRAME or only85// METADATA.86CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback87// Notify on autofocus start and stop. This is useful in continuous88// autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE.89CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback90CAMERA_MSG_ALL_MSGS = 0xFFFF91};9293/** cmdType in sendCommand functions */94enum {95CAMERA_CMD_START_SMOOTH_ZOOM = 1,96CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,9798/**99* Set the clockwise rotation of preview display (setPreviewDisplay) in100* degrees. This affects the preview frames and the picture displayed after101* snapshot. This method is useful for portrait mode applications. Note102* that preview display of front-facing cameras is flipped horizontally103* before the rotation, that is, the image is reflected along the central104* vertical axis of the camera sensor. So the users can see themselves as105* looking into a mirror.106*107* This does not affect the order of byte array of108* CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME,109* CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or110* CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview111* since API level 14.112*/113CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,114115/**116* cmdType to disable/enable shutter sound. In sendCommand passing arg1 =117* 0 will disable, while passing arg1 = 1 will enable the shutter sound.118*/119CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4,120121/* cmdType to play recording sound */122CAMERA_CMD_PLAY_RECORDING_SOUND = 5,123124/**125* Start the face detection. This should be called after preview is started.126* The camera will notify the listener of CAMERA_MSG_FACE and the detected127* faces in the preview frame. The detected faces may be the same as the128* previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop129* the face detection. This method is supported if CameraParameters130* KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is131* bigger than 0. Hardware and software face detection should not be running132* at the same time. If the face detection has started, apps should not send133* this again.134*135* In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,136* KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.137*138* arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or139* CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not140* supported, the HAL must return BAD_VALUE.141*/142CAMERA_CMD_START_FACE_DETECTION = 6,143144/**145* Stop the face detection.146*/147CAMERA_CMD_STOP_FACE_DETECTION = 7,148149/**150* Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing151* arg1 = 0 will disable, while passing arg1 = 1 will enable the callback.152*/153CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8,154155/**156* Ping camera service to see if camera hardware is released.157*158* When any camera method returns error, the client can use ping command159* to see if the camera has been taken away by other clients. If the result160* is OK, it means the camera hardware is not released. If the result161* is not OK, the camera has been released and the existing client162* can silently finish itself or show a dialog.163*/164CAMERA_CMD_PING = 9,165166/**167* Configure the number of video buffers used for recording. The intended168* video buffer count for recording is passed as arg1, which must be169* greater than 0. This command must be sent before recording is started.170* This command returns INVALID_OPERATION error if it is sent after video171* recording is started, or the command is not supported at all. This172* command also returns a BAD_VALUE error if the intended video buffer173* count is non-positive or too big to be realized.174*/175CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10,176177/**178* Configure an explicit format to use for video recording metadata mode.179* This can be used to switch the format from the180* default IMPLEMENTATION_DEFINED gralloc format to some other181* device-supported format, and the default dataspace from the BT_709 color182* space to some other device-supported dataspace. arg1 is the HAL pixel183* format, and arg2 is the HAL dataSpace. This command returns184* INVALID_OPERATION error if it is sent after video recording is started,185* or the command is not supported at all.186*187* If the gralloc format is set to a format other than188* IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags189* of SW_READ_OFTEN.190*/191CAMERA_CMD_SET_VIDEO_FORMAT = 11192};193194/** camera fatal errors */195enum {196CAMERA_ERROR_UNKNOWN = 1,197/**198* Camera was released because another client has connected to the camera.199* The original client should call Camera::disconnect immediately after200* getting this notification. Otherwise, the camera will be released by201* camera service in a short time. The client should not call any method202* (except disconnect and sending CAMERA_CMD_PING) after getting this.203*/204CAMERA_ERROR_RELEASED = 2,205206/**207* Camera was released because device policy change or the client application208* is going to background. The client should call Camera::disconnect209* immediately after getting this notification. Otherwise, the camera will be210* released by camera service in a short time. The client should not call any211* method (except disconnect and sending CAMERA_CMD_PING) after getting this.212*/213CAMERA_ERROR_DISABLED = 3,214CAMERA_ERROR_SERVER_DIED = 100215};216217enum {218/** The facing of the camera is opposite to that of the screen. */219CAMERA_FACING_BACK = 0,220/** The facing of the camera is the same as that of the screen. */221CAMERA_FACING_FRONT = 1,222/**223* The facing of the camera is not fixed relative to the screen.224* The cameras with this facing are external cameras, e.g. USB cameras.225*/226CAMERA_FACING_EXTERNAL = 2227};228229enum {230/** Hardware face detection. It does not use much CPU. */231CAMERA_FACE_DETECTION_HW = 0,232/**233* Software face detection. It uses some CPU. Applications must use234* Camera.setPreviewTexture for preview in this mode.235*/236CAMERA_FACE_DETECTION_SW = 1237};238239/**240* The information of a face from camera face detection.241*/242typedef struct camera_face {243/**244* Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents245* the top-left of the camera field of view, and (1000, 1000) represents the246* bottom-right of the field of view. The width and height cannot be 0 or247* negative. This is supported by both hardware and software face detection.248*249* The direction is relative to the sensor orientation, that is, what the250* sensor sees. The direction is not affected by the rotation or mirroring251* of CAMERA_CMD_SET_DISPLAY_ORIENTATION.252*/253int32_t rect[4];254255/**256* The confidence level of the face. The range is 1 to 100. 100 is the257* highest confidence. This is supported by both hardware and software258* face detection.259*/260int32_t score;261262/**263* An unique id per face while the face is visible to the tracker. If264* the face leaves the field-of-view and comes back, it will get a new265* id. If the value is 0, id is not supported.266*/267int32_t id;268269/**270* The coordinates of the center of the left eye. The range is -1000 to271* 1000. -2000, -2000 if this is not supported.272*/273int32_t left_eye[2];274275/**276* The coordinates of the center of the right eye. The range is -1000 to277* 1000. -2000, -2000 if this is not supported.278*/279int32_t right_eye[2];280281/**282* The coordinates of the center of the mouth. The range is -1000 to 1000.283* -2000, -2000 if this is not supported.284*/285int32_t mouth[2];286287} camera_face_t;288289/**290* The metadata of the frame data.291*/292typedef struct camera_frame_metadata {293/**294* The number of detected faces in the frame.295*/296int32_t number_of_faces;297298/**299* An array of the detected faces. The length is number_of_faces.300*/301camera_face_t *faces;302} camera_frame_metadata_t;303304__END_DECLS305306#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */307308309