blob: 7fd551fc2be4da85ccde8122ad32601b9b4d6f9a [file] [log] [blame]
Pawin Vongmasac80bf212018-09-06 05:22:36 -07001/*
2 * Copyright (C) 2018 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.media.c2@1.0;
18
Pawin Vongmasa7570e3c2018-11-11 19:30:19 -080019import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer;
Pawin Vongmasac80bf212018-09-06 05:22:36 -070020import android.hardware.media.omx@1.0::IGraphicBufferSource;
21
22import IConfigurable;
23import IComponentInterface;
24import IComponentListener;
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080025import IInputSurface;
26import IInputSurfaceConnection;
Pawin Vongmasac80bf212018-09-06 05:22:36 -070027
28/**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080029 * Interface for a Codec2 component corresponding to API level 1.0 or below.
30 * Components have two states: stopped and running. The running state has three
31 * sub-states: executing, tripped and error.
32 *
33 * All methods in `IComponent` must not block. If a method call cannot be
34 * completed in a timely manner, it must return `TIMED_OUT` in the return
35 * status.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070036 */
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080037interface IComponent {
Pawin Vongmasac80bf212018-09-06 05:22:36 -070038
39 // METHODS AVAILABLE WHEN RUNNING
40 // =========================================================================
41
42 /**
43 * Queues up work for the component.
44 *
45 * This method must be supported in running (including tripped) states.
46 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080047 * It is acceptable for this method to return `OK` and return an error value
48 * using the IComponentListener::onWorkDone() callback.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070049 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080050 * @param workBundle `WorkBundle` object containing a list of `Work` objects
51 * to queue to the component.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070052 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080053 * - `OK` - Works in @p workBundle were successfully queued.
54 * - `BAD_INDEX` - Some component id in some `Worklet` is not valid.
55 * - `CANNOT_DO` - The components are not tunneled but some `Work` object
56 * contains tunneling information.
57 * - `NO_MEMORY` - Not enough memory to queue @p workBundle.
58 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
59 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070060 */
61 queue(WorkBundle workBundle) generates (Status status);
62
63 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080064 * Discards and abandons any pending `Work` items for the component.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070065 *
66 * This method must be supported in running (including tripped) states.
67 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080068 * `Work` that could be immediately abandoned/discarded must be returned in
69 * @p flushedWorkBundle. The order in which queued `Work` items are
70 * discarded can be arbitrary.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070071 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080072 * `Work` that could not be abandoned or discarded immediately must be
73 * marked to be discarded at the earliest opportunity, and must be returned
74 * via IComponentListener::onWorkDone(). This must be completed within
75 * 500ms.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070076 *
77 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080078 * - `OK` - The component has been successfully flushed.
79 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
80 * - `CORRUPTED` - Some unknown error occurred.
81 * @return flushedWorkBundle `WorkBundle` object containing flushed `Work`
82 * items.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070083 */
84 flush(
85 ) generates (
86 Status status,
87 WorkBundle flushedWorkBundle
88 );
89
90 /**
91 * Drains the component, and optionally downstream components. This is a
92 * signalling method; as such it does not wait for any work completion.
93 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080094 * The last `Work` item is marked as "drain-till-here", so the component is
95 * notified not to wait for further `Work` before it processes what is
96 * already queued. This method can also be used to set the end-of-stream
97 * flag after `Work` has been queued. Client can continue to queue further
98 * `Work` immediately after this method returns.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070099 *
100 * This method must be supported in running (including tripped) states.
101 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800102 * `Work` that is completed must be returned via
103 * IComponentListener::onWorkDone().
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700104 *
105 * @param withEos Whether to drain the component with marking end-of-stream.
106 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800107 * - `OK` - The drain request has been successfully recorded.
108 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
109 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700110 */
111 drain(bool withEos) generates (Status status);
112
113 /**
114 * Starts using a surface for output.
115 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800116 * This method must not block.
117 *
118 * @param blockPoolId Id of the `C2BlockPool` to be associated with the
119 * output surface.
120 * @param surface Output surface.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700121 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800122 * - `OK` - The operation completed successfully.
123 * - `CANNOT_DO` - The component does not support an output surface.
124 * - `REFUSED` - The output surface cannot be accessed.
125 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
126 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700127 */
128 setOutputSurface(
129 uint64_t blockPoolId,
130 IGraphicBufferProducer surface
131 ) generates (
132 Status status
133 );
134
135 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800136 * Starts using an input surface.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700137 *
138 * The component must be in running state.
139 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800140 * @param inputSurface Input surface to connect to.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700141 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800142 * - `OK` - The operation completed successfully.
143 * - `CANNOT_DO` - The component does not support an input surface.
144 * - `BAD_STATE` - The component is not in running state.
145 * - `DUPLICATE` - The component is already connected to an input surface.
146 * - `REFUSED` - The input surface is already in use.
147 * - `NO_MEMORY` - Not enough memory to start the component.
148 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
149 * - `CORRUPTED` - Some unknown error occurred.
150 * @return connection `IInputSurfaceConnection` object, which can be used to
151 * query and configure properties of the connection. This cannot be
152 * null.
153 */
154 connectToInputSurface(
155 IInputSurface inputSurface
156 ) generates (
157 Status status,
158 IInputSurfaceConnection connection
159 );
160
161 /**
162 * Starts using an OMX input surface.
163 *
164 * The component must be in running state.
165 *
166 * This method is similar to connectToInputSurface(), but it takes an OMX
167 * input surface (as a pair of `IGraphicBufferProducer` and
168 * `IGraphicBufferSource`) instead of Codec2's own `IInputSurface`.
169 *
170 * @param producer Producer component of an OMX input surface.
171 * @param source Source component of an OMX input surface.
172 * @return status Status of the call, which may be
173 * - `OK` - The operation completed successfully.
174 * - `CANNOT_DO` - The component does not support an OMX input surface.
175 * - `BAD_STATE` - The component is not in running state.
176 * - `DUPLICATE` - The component is already connected to an input surface.
177 * - `REFUSED` - The input surface is already in use.
178 * - `NO_MEMORY` - Not enough memory to start the component.
179 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
180 * - `CORRUPTED` - Some unknown error occurred.
181 * @return connection `IInputSurfaceConnection` object, which can be used to
182 * query and configure properties of the connection. This cannot be
183 * null.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700184 */
185 connectToOmxInputSurface(
186 IGraphicBufferProducer producer,
187 IGraphicBufferSource source
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800188 ) generates (
189 Status status,
190 IInputSurfaceConnection connection
191 );
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700192
193 /**
194 * Stops using an input surface.
195 *
196 * The component must be in running state.
197 *
198 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800199 * - `OK` - The operation completed successfully.
200 * - `CANNOT_DO` - The component does not support an input surface.
201 * - `BAD_STATE` - The component is not in running state.
202 * - `NOT_FOUND` - The component is not connected to an input surface.
203 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
204 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700205 */
206 disconnectFromInputSurface() generates (Status Status);
207
208 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800209 * Creates a local `C2BlockPool` backed by the given allocator and returns
210 * its id.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700211 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800212 * The returned @p blockPoolId is the only way the client can refer to a
213 * `C2BlockPool` object in the component. The id can be passed to
214 * setOutputSurface() or used in some C2Param objects later.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700215 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800216 * The created `C2BlockPool` object can be destroyed by calling
217 * destroyBlockPool(), reset() or release(). reset() and release() must
218 * destroy all `C2BlockPool` objects that have been created.
219 *
220 * @param allocatorId Id of a `C2Allocator`.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700221 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800222 * - `OK` - The operation completed successfully.
223 * - `NO_MEMORY` - Not enough memory to create the pool.
224 * - `BAD_VALUE` - @p allocatorId is not recognized.
225 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
226 * - `CORRUPTED` - Some unknown error occurred.
227 * @return blockPoolId Id of the created C2BlockPool object. This may be
228 * used in setOutputSurface() if the allocator
229 * @return configurable Configuration interface for the created pool. This
230 * must not be null.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700231 */
232 createBlockPool(uint32_t allocatorId) generates (
233 Status status,
234 uint64_t blockPoolId,
235 IConfigurable configurable
236 );
237
238 /**
239 * Destroys a local block pool previously created by createBlockPool().
240 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800241 * @param blockPoolId Id of a `C2BlockPool` that was previously returned by
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700242 * createBlockPool().
243 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800244 * - `OK` - The operation completed successfully.
245 * - `NOT_FOUND` - The supplied blockPoolId is not valid.
246 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
247 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700248 */
249 destroyBlockPool(uint64_t blockPoolId) generates (Status status);
250
251 // STATE CHANGE METHODS
252 // =========================================================================
253
254 /**
255 * Starts the component.
256 *
257 * This method must be supported in stopped state as well as tripped state.
258 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800259 * If the return value is `OK`, the component must be in the running state.
260 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
261 * expected as a response to this call. Otherwise, the component must be in
262 * the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700263 *
264 * If a component is in the tripped state and start() is called while the
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800265 * component configuration still results in a trip, start() must succeed and
266 * a new onTripped() callback must be used to communicate the configuration
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700267 * conflict that results in the new trip.
268 *
269 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800270 * - `OK` - The component has started successfully.
271 * - `BAD_STATE` - Component is not in stopped or tripped state.
272 * - `DUPLICATE` - When called during another start call from another
273 * thread.
274 * - `NO_MEMORY` - Not enough memory to start the component.
275 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
276 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700277 */
278 start() generates (Status status);
279
280 /**
281 * Stops the component.
282 *
283 * This method must be supported in running (including tripped) state.
284 *
285 * This method must return withing 500ms.
286 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800287 * Upon this call, all pending `Work` must be abandoned.
288 *
289 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
290 * expected as a response to this call. For all other return values, the
291 * component must be in the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700292 *
293 * This does not alter any settings and tunings that may have resulted in a
294 * tripped state.
295 *
296 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800297 * - `OK` - The component has stopped successfully.
298 * - `BAD_STATE` - Component is not in running state.
299 * - `DUPLICATE` - When called during another stop call from another
300 * thread.
301 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
302 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700303 */
304 stop() generates (Status status);
305
306 /**
307 * Resets the component.
308 *
309 * This method must be supported in all (including tripped) states other
310 * than released.
311 *
312 * This method must be supported during any other blocking call.
313 *
314 * This method must return withing 500ms.
315 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800316 * When this call returns, if @p status is `OK`, all `Work` items must
317 * have been abandoned, and all resources (including `C2BlockPool` objects
318 * previously created by createBlockPool()) must have been released.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700319 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800320 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
321 * expected as a response to this call. For all other return values, the
322 * component must be in the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700323 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800324 * This brings settings back to their default, "guaranteeing" no tripped
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700325 * state.
326 *
327 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800328 * - `OK` - The component has been reset.
329 * - `BAD_STATE` - Component is in released state.
330 * - `DUPLICATE` - When called during another reset call from another
331 * thread.
332 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
333 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700334 */
335 reset() generates (Status status);
336
337 /**
338 * Releases the component.
339 *
340 * This method must be supported in stopped state.
341 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800342 * This method destroys the component. Upon return, if @p status is `OK` or
343 * `DUPLICATE`, all resources must have been released.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700344 *
345 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800346 * - `OK` - The component has been released.
347 * - `BAD_STATE` - The component is running.
348 * - `DUPLICATE` - The component is already released.
349 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
350 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700351 */
352 release() generates (Status status);
353
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800354 /**
355 * Returns the @ref IComponentInterface instance associated to this
356 * component.
357 *
358 * An @p IConfigurable instance for the component can be obtained by calling
359 * IComponentInterface::getConfigurable() on the returned @p intf.
360 *
361 * @return intf `IComponentInterface` instance. This must not be null.
362 */
363 getInterface() generates (IComponentInterface intf);
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700364};
365