blob: a3da52eab800ea11a7442377a54a52e27e1b39d5 [file] [log] [blame]
Iliyan Malchev66ea3572011-05-01 14:05:30 -07001/*
2 * Copyright (C) 2011 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <sys/types.h>
23#include <cutils/native_handle.h>
24#include <hardware/hardware.h>
25#include <hardware/gralloc.h>
26
27__BEGIN_DECLS
28
29/**
30 * A set of bit masks for specifying how the received preview frames are
31 * handled before the previewCallback() call.
32 *
33 * The least significant 3 bits of an "int" value are used for this purpose:
34 *
35 * ..... 0 0 0
36 * ^ ^ ^
37 * | | |---------> determine whether the callback is enabled or not
38 * | |-----------> determine whether the callback is one-shot or not
39 * |-------------> determine whether the frame is copied out or not
40 *
41 * WARNING: When a frame is sent directly without copying, it is the frame
42 * receiver's responsiblity to make sure that the frame data won't get
43 * corrupted by subsequent preview frames filled by the camera. This flag is
44 * recommended only when copying out data brings significant performance price
45 * and the handling/processing of the received frame data is always faster than
46 * the preview frame rate so that data corruption won't occur.
47 *
48 * For instance,
49 * 1. 0x00 disables the callback. In this case, copy out and one shot bits
50 * are ignored.
51 * 2. 0x01 enables a callback without copying out the received frames. A
52 * typical use case is the Camcorder application to avoid making costly
53 * frame copies.
54 * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical
55 * use case is the Camera application.
56 * 4. 0x07 is enabling a callback with frame copied out only once. A typical
57 * use case is the Barcode scanner application.
58 */
59
60enum {
61 CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01,
62 CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02,
63 CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04,
64 /** Typical use cases */
65 CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00,
66 CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01,
67 CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05,
68 CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07
69};
70
71/** msgType in notifyCallback and dataCallback functions */
72enum {
73 CAMERA_MSG_ERROR = 0x0001,
74 CAMERA_MSG_SHUTTER = 0x0002,
75 CAMERA_MSG_FOCUS = 0x0004,
76 CAMERA_MSG_ZOOM = 0x0008,
77 CAMERA_MSG_PREVIEW_FRAME = 0x0010,
78 CAMERA_MSG_VIDEO_FRAME = 0x0020,
79 CAMERA_MSG_POSTVIEW_FRAME = 0x0040,
80 CAMERA_MSG_RAW_IMAGE = 0x0080,
81 CAMERA_MSG_COMPRESSED_IMAGE = 0x0100,
82 CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200,
Wu-cheng Lide19ea22011-07-20 20:06:45 -070083 CAMERA_MSG_FACE = 0x0400,
Iliyan Malchev66ea3572011-05-01 14:05:30 -070084 CAMERA_MSG_ALL_MSGS = 0xFFFF
85};
86
87/** cmdType in sendCommand functions */
88enum {
89 CAMERA_CMD_START_SMOOTH_ZOOM = 1,
90 CAMERA_CMD_STOP_SMOOTH_ZOOM = 2,
Wu-cheng Lide19ea22011-07-20 20:06:45 -070091
92 /**
93 * Set the clockwise rotation of preview display (setPreviewDisplay) in
Iliyan Malchev66ea3572011-05-01 14:05:30 -070094 * degrees. This affects the preview frames and the picture displayed after
95 * snapshot. This method is useful for portrait mode applications. Note
96 * that preview display of front-facing cameras is flipped horizontally
97 * before the rotation, that is, the image is reflected along the central
98 * vertical axis of the camera sensor. So the users can see themselves as
99 * looking into a mirror.
100 *
101 * This does not affect the order of byte array of
102 * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME,
103 * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or
104 * CAMERA_MSG_COMPRESSED_IMAGE. This is not allowed to be set during
105 * preview
106 */
107 CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3,
108
Wu-cheng Lide19ea22011-07-20 20:06:45 -0700109 /**
110 * cmdType to disable/enable shutter sound. In sendCommand passing arg1 =
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700111 * 0 will disable, while passing arg1 = 1 will enable the shutter sound.
112 */
113 CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4,
114
115 /* cmdType to play recording sound */
116 CAMERA_CMD_PLAY_RECORDING_SOUND = 5,
Wu-cheng Lide19ea22011-07-20 20:06:45 -0700117
118 /**
119 * Start the face detection. This should be called after preview is started.
120 * The camera will notify the listener of CAMERA_MSG_FACE and the detected
121 * faces in the preview frame. The detected faces may be the same as the
122 * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop
123 * the face detection. This method is supported if CameraParameters
124 * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is
125 * bigger than 0. Hardware and software face detection should not be running
126 * at the same time. If the face detection has started, apps should not send
127 * this again.
128 *
129 * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE,
130 * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect.
131 *
132 * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or
133 * CAMERA_FACE_DETECTION_SW.
134 */
135 CAMERA_CMD_START_FACE_DETECTION = 6,
136
137 /**
138 * Stop the face detection.
139 */
140 CAMERA_CMD_STOP_FACE_DETECTION = 7,
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700141};
142
143/** camera fatal errors */
144enum {
145 CAMERA_ERROR_UNKNOWN = 1,
146 CAMERA_ERROR_SERVER_DIED = 100
147};
148
149enum {
Wu-cheng Lide19ea22011-07-20 20:06:45 -0700150 /** The facing of the camera is opposite to that of the screen. */
151 CAMERA_FACING_BACK = 0,
152 /** The facing of the camera is the same as that of the screen. */
153 CAMERA_FACING_FRONT = 1
154};
155
156enum {
157 /** Hardware face detection. It does not use much CPU. */
158 CAMERA_FACE_DETECTION_HW = 0,
159 /**
160 * Software face detection. It uses some CPU. Applications must use
161 * Camera.setPreviewTexture for preview in this mode.
162 */
163 CAMERA_FACE_DETECTION_SW = 1
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700164};
165
166__END_DECLS
167
168#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */