1/*
2 * Copyright (C) 2013 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
17package android.hardware.camera2;
18
19import android.hardware.camera2.CaptureRequest;
20import android.hardware.camera2.impl.CameraMetadataNative;
21import android.hardware.camera2.params.OutputConfiguration;
22import android.hardware.camera2.utils.SubmitInfo;
23import android.view.Surface;
24
25/** @hide */
26interface ICameraDeviceUser
27{
28    void disconnect();
29
30    const int NO_IN_FLIGHT_REPEATING_FRAMES = -1;
31
32    SubmitInfo submitRequest(in CaptureRequest request, boolean streaming);
33    SubmitInfo submitRequestList(in CaptureRequest[] requestList, boolean streaming);
34
35    /**
36     * Cancel the repeating request specified by requestId
37     * Returns the frame number of the last frame that will be produced from this
38     * repeating request, or NO_IN_FLIGHT_REPEATING_FRAMES if no frames were produced
39     * by this repeating request.
40     *
41     * Repeating request may be stopped by camera device due to an error. Canceling a stopped
42     * repeating request will trigger ERROR_ILLEGAL_ARGUMENT.
43     */
44    long cancelRequest(int requestId);
45
46    /**
47     * Begin the device configuration.
48     *
49     * <p>
50     * beginConfigure must be called before any call to deleteStream, createStream,
51     * or endConfigure.  It is not valid to call this when the device is not idle.
52     * <p>
53     */
54    void beginConfigure();
55
56    /**
57     * The standard operating mode for a camera device; all API guarantees are in force
58     */
59    const int NORMAL_MODE = 0;
60
61    /**
62     * High-speed recording mode; only two outputs targeting preview and video recording may be
63     * used, and requests must be batched.
64     */
65    const int CONSTRAINED_HIGH_SPEED_MODE = 1;
66
67    /**
68     * Start of custom vendor modes
69     */
70    const int VENDOR_MODE_START = 0x8000;
71
72    /**
73     * End the device configuration.
74     *
75     * <p>
76     * endConfigure must be called after stream configuration is complete (i.e. after
77     * a call to beginConfigure and subsequent createStream/deleteStream calls).  This
78     * must be called before any requests can be submitted.
79     * <p>
80     * @param operatingMode The kind of session to create; either NORMAL_MODE or
81     *     CONSTRAINED_HIGH_SPEED_MODE. Must be a non-negative value.
82     * @param sessionParams Session wide camera parameters
83     */
84    void endConfigure(int operatingMode, in CameraMetadataNative sessionParams);
85
86    void deleteStream(int streamId);
87
88    /**
89     * Create an output stream
90     *
91     * <p>Create an output stream based on the given output configuration</p>
92     *
93     * @param outputConfiguration size, format, and other parameters for the stream
94     * @return new stream ID
95     */
96    int createStream(in OutputConfiguration outputConfiguration);
97
98    /**
99     * Create an input stream
100     *
101     * <p>Create an input stream of width, height, and format</p>
102     *
103     * @param width Width of the input buffers
104     * @param height Height of the input buffers
105     * @param format Format of the input buffers. One of HAL_PIXEL_FORMAT_*.
106     *
107     * @return new stream ID
108     */
109    int createInputStream(int width, int height, int format);
110
111    /**
112     * Get the surface of the input stream.
113     *
114     * <p>It's valid to call this method only after a stream configuration is completed
115     * successfully and the stream configuration includes a input stream.</p>
116     *
117     * @param surface An output argument for the surface of the input stream buffer queue.
118     */
119    Surface getInputSurface();
120
121    // Keep in sync with public API in
122    // frameworks/base/core/java/android/hardware/camera2/CameraDevice.java
123    const int TEMPLATE_PREVIEW = 1;
124    const int TEMPLATE_STILL_CAPTURE = 2;
125    const int TEMPLATE_RECORD = 3;
126    const int TEMPLATE_VIDEO_SNAPSHOT = 4;
127    const int TEMPLATE_ZERO_SHUTTER_LAG = 5;
128    const int TEMPLATE_MANUAL = 6;
129
130    CameraMetadataNative createDefaultRequest(int templateId);
131
132    CameraMetadataNative getCameraInfo();
133
134    void waitUntilIdle();
135
136    long flush();
137
138    void prepare(int streamId);
139
140    void tearDown(int streamId);
141
142    void prepare2(int maxCount, int streamId);
143
144    void updateOutputConfiguration(int streamId, in OutputConfiguration outputConfiguration);
145
146    void finalizeOutputConfigurations(int streamId, in OutputConfiguration outputConfiguration);
147}
148