blob: 4d8eb5370205c00224d414b27bf2393923887a3b [file] [log] [blame]
Igor Murashkine7ee7632013-06-11 18:10:18 -07001/*
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
17#ifndef ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H
18#define ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H
19
20#include <binder/IInterface.h>
21#include <binder/Parcel.h>
Jianing Weicb0652e2014-03-12 18:29:36 -070022#include <utils/List.h>
Igor Murashkine7ee7632013-06-11 18:10:18 -070023
24struct camera_metadata;
25
26namespace android {
27
28class ICameraDeviceUserClient;
29class IGraphicBufferProducer;
Igor Murashkine7ee7632013-06-11 18:10:18 -070030class CaptureRequest;
31class CameraMetadata;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070032class OutputConfiguration;
Igor Murashkine7ee7632013-06-11 18:10:18 -070033
Jianing Wei2d6bb3f2014-04-11 10:00:31 -070034enum {
35 NO_IN_FLIGHT_REPEATING_FRAMES = -1,
36};
37
Igor Murashkine7ee7632013-06-11 18:10:18 -070038class ICameraDeviceUser : public IInterface
39{
40 /**
41 * Keep up-to-date with ICameraDeviceUser.aidl in frameworks/base
42 */
43public:
44 DECLARE_META_INTERFACE(CameraDeviceUser);
45
46 virtual void disconnect() = 0;
47
48 /**
49 * Request Handling
50 **/
51
Jianing Weicb0652e2014-03-12 18:29:36 -070052 /**
53 * For streaming requests, output lastFrameNumber is the last frame number
54 * of the previous repeating request.
55 * For non-streaming requests, output lastFrameNumber is the expected last
56 * frame number of the current request.
57 */
Igor Murashkine7ee7632013-06-11 18:10:18 -070058 virtual int submitRequest(sp<CaptureRequest> request,
Jianing Weicb0652e2014-03-12 18:29:36 -070059 bool streaming = false,
60 /*out*/
61 int64_t* lastFrameNumber = NULL) = 0;
62
63 /**
64 * For streaming requests, output lastFrameNumber is the last frame number
65 * of the previous repeating request.
66 * For non-streaming requests, output lastFrameNumber is the expected last
67 * frame number of the current request.
68 */
69 virtual int submitRequestList(List<sp<CaptureRequest> > requestList,
70 bool streaming = false,
71 /*out*/
72 int64_t* lastFrameNumber = NULL) = 0;
73
74 /**
75 * Output lastFrameNumber is the last frame number of the previous repeating request.
76 */
77 virtual status_t cancelRequest(int requestId,
78 /*out*/
79 int64_t* lastFrameNumber = NULL) = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -070080
Ruben Brunkb2119af2014-05-09 19:57:56 -070081 /**
82 * Begin the device configuration.
83 *
84 * <p>
85 * beginConfigure must be called before any call to deleteStream, createStream,
86 * or endConfigure. It is not valid to call this when the device is not idle.
87 * <p>
88 */
89 virtual status_t beginConfigure() = 0;
90
91 /**
92 * End the device configuration.
93 *
94 * <p>
95 * endConfigure must be called after stream configuration is complete (i.e. after
96 * a call to beginConfigure and subsequent createStream/deleteStream calls). This
97 * must be called before any requests can be submitted.
98 * <p>
99 */
Zhijun He1fa89992015-06-01 15:44:31 -0700100 virtual status_t endConfigure(bool isConstrainedHighSpeed = false) = 0;
Ruben Brunkb2119af2014-05-09 19:57:56 -0700101
Igor Murashkine7ee7632013-06-11 18:10:18 -0700102 virtual status_t deleteStream(int streamId) = 0;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700103
104 virtual status_t createStream(const OutputConfiguration& outputConfiguration) = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700105
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -0700106 /**
107 * Create an input stream of width, height, and format (one of
108 * HAL_PIXEL_FORMAT_*)
109 *
110 * Return stream ID if it's a non-negative value. status_t if it's a
111 * negative value.
112 */
113 virtual status_t createInputStream(int width, int height, int format) = 0;
114
115 // get the buffer producer of the input stream
116 virtual status_t getInputBufferProducer(
117 sp<IGraphicBufferProducer> *producer) = 0;
118
Igor Murashkine7ee7632013-06-11 18:10:18 -0700119 // Create a request object from a template.
120 virtual status_t createDefaultRequest(int templateId,
121 /*out*/
122 CameraMetadata* request) = 0;
123 // Get static camera metadata
Igor Murashkin099b4572013-07-12 17:52:16 -0700124 virtual status_t getCameraInfo(/*out*/
125 CameraMetadata* info) = 0;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700126
Zhijun He2ab500c2013-07-23 08:02:53 -0700127 // Wait until all the submitted requests have finished processing
128 virtual status_t waitUntilIdle() = 0;
Eino-Ville Talvalaabaa51d2013-08-14 11:37:00 -0700129
Jianing Weicb0652e2014-03-12 18:29:36 -0700130 /**
131 * Flush all pending and in-progress work as quickly as possible.
132 * Output lastFrameNumber is the last frame number of the previous repeating request.
133 */
134 virtual status_t flush(/*out*/
135 int64_t* lastFrameNumber = NULL) = 0;
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700136
137 /**
138 * Preallocate buffers for a given output stream asynchronously.
139 */
140 virtual status_t prepare(int streamId) = 0;
Eino-Ville Talvalab25e3c82015-07-15 16:04:27 -0700141
142 /**
Ruben Brunkc78ac262015-08-13 17:58:46 -0700143 * Preallocate up to maxCount buffers for a given output stream asynchronously.
144 */
145 virtual status_t prepare2(int maxCount, int streamId) = 0;
146
147 /**
Eino-Ville Talvalab25e3c82015-07-15 16:04:27 -0700148 * Free all unused buffers for a given output stream.
149 */
150 virtual status_t tearDown(int streamId) = 0;
151
Igor Murashkine7ee7632013-06-11 18:10:18 -0700152};
153
154// ----------------------------------------------------------------------------
155
156class BnCameraDeviceUser: public BnInterface<ICameraDeviceUser>
157{
158public:
159 virtual status_t onTransact( uint32_t code,
160 const Parcel& data,
161 Parcel* reply,
162 uint32_t flags = 0);
163};
164
165}; // namespace android
166
167#endif