blob: abd14482bdff5e405d7224bcdc90cdb009a1fb53 [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 Vongmasab58b3112019-02-25 23:08:14 -080025import IInputSink;
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080026import IInputSurface;
27import IInputSurfaceConnection;
Pawin Vongmasac80bf212018-09-06 05:22:36 -070028
29/**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080030 * Interface for a Codec2 component corresponding to API level 1.0 or below.
31 * Components have two states: stopped and running. The running state has three
32 * sub-states: executing, tripped and error.
33 *
34 * All methods in `IComponent` must not block. If a method call cannot be
35 * completed in a timely manner, it must return `TIMED_OUT` in the return
36 * status.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070037 */
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080038interface IComponent {
Pawin Vongmasac80bf212018-09-06 05:22:36 -070039
40 // METHODS AVAILABLE WHEN RUNNING
41 // =========================================================================
42
43 /**
44 * Queues up work for the component.
45 *
46 * This method must be supported in running (including tripped) states.
47 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080048 * It is acceptable for this method to return `OK` and return an error value
49 * using the IComponentListener::onWorkDone() callback.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070050 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080051 * @param workBundle `WorkBundle` object containing a list of `Work` objects
52 * to queue to the component.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070053 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080054 * - `OK` - Works in @p workBundle were successfully queued.
55 * - `BAD_INDEX` - Some component id in some `Worklet` is not valid.
56 * - `CANNOT_DO` - The components are not tunneled but some `Work` object
57 * contains tunneling information.
58 * - `NO_MEMORY` - Not enough memory to queue @p workBundle.
59 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
60 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070061 */
62 queue(WorkBundle workBundle) generates (Status status);
63
64 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080065 * Discards and abandons any pending `Work` items for the component.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070066 *
67 * This method must be supported in running (including tripped) states.
68 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080069 * `Work` that could be immediately abandoned/discarded must be returned in
70 * @p flushedWorkBundle. The order in which queued `Work` items are
71 * discarded can be arbitrary.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070072 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080073 * `Work` that could not be abandoned or discarded immediately must be
74 * marked to be discarded at the earliest opportunity, and must be returned
75 * via IComponentListener::onWorkDone(). This must be completed within
76 * 500ms.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070077 *
78 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080079 * - `OK` - The component has been successfully flushed.
80 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
81 * - `CORRUPTED` - Some unknown error occurred.
82 * @return flushedWorkBundle `WorkBundle` object containing flushed `Work`
83 * items.
Pawin Vongmasac80bf212018-09-06 05:22:36 -070084 */
85 flush(
86 ) generates (
87 Status status,
88 WorkBundle flushedWorkBundle
89 );
90
91 /**
92 * Drains the component, and optionally downstream components. This is a
93 * signalling method; as such it does not wait for any work completion.
94 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -080095 * The last `Work` item is marked as "drain-till-here", so the component is
96 * notified not to wait for further `Work` before it processes what is
97 * already queued. This method can also be used to set the end-of-stream
98 * flag after `Work` has been queued. Client can continue to queue further
99 * `Work` immediately after this method returns.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700100 *
101 * This method must be supported in running (including tripped) states.
102 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800103 * `Work` that is completed must be returned via
104 * IComponentListener::onWorkDone().
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700105 *
106 * @param withEos Whether to drain the component with marking end-of-stream.
107 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800108 * - `OK` - The drain request has been successfully recorded.
109 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
110 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700111 */
112 drain(bool withEos) generates (Status status);
113
114 /**
115 * Starts using a surface for output.
116 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800117 * This method must not block.
118 *
119 * @param blockPoolId Id of the `C2BlockPool` to be associated with the
120 * output surface.
121 * @param surface Output surface.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700122 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800123 * - `OK` - The operation completed successfully.
124 * - `CANNOT_DO` - The component does not support an output surface.
125 * - `REFUSED` - The output surface cannot be accessed.
126 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
127 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700128 */
129 setOutputSurface(
130 uint64_t blockPoolId,
131 IGraphicBufferProducer surface
132 ) generates (
133 Status status
134 );
135
136 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800137 * Starts using an input surface.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700138 *
139 * The component must be in running state.
140 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800141 * @param inputSurface Input surface to connect to.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700142 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800143 * - `OK` - The operation completed successfully.
144 * - `CANNOT_DO` - The component does not support an input surface.
145 * - `BAD_STATE` - The component is not in running state.
146 * - `DUPLICATE` - The component is already connected to an input surface.
147 * - `REFUSED` - The input surface is already in use.
148 * - `NO_MEMORY` - Not enough memory to start the component.
149 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
150 * - `CORRUPTED` - Some unknown error occurred.
151 * @return connection `IInputSurfaceConnection` object, which can be used to
152 * query and configure properties of the connection. This cannot be
153 * null.
154 */
155 connectToInputSurface(
156 IInputSurface inputSurface
157 ) generates (
158 Status status,
159 IInputSurfaceConnection connection
160 );
161
162 /**
163 * Starts using an OMX input surface.
164 *
165 * The component must be in running state.
166 *
167 * This method is similar to connectToInputSurface(), but it takes an OMX
168 * input surface (as a pair of `IGraphicBufferProducer` and
169 * `IGraphicBufferSource`) instead of Codec2's own `IInputSurface`.
170 *
171 * @param producer Producer component of an OMX input surface.
172 * @param source Source component of an OMX input surface.
173 * @return status Status of the call, which may be
174 * - `OK` - The operation completed successfully.
175 * - `CANNOT_DO` - The component does not support an OMX input surface.
176 * - `BAD_STATE` - The component is not in running state.
177 * - `DUPLICATE` - The component is already connected to an input surface.
178 * - `REFUSED` - The input surface is already in use.
179 * - `NO_MEMORY` - Not enough memory to start the component.
180 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
181 * - `CORRUPTED` - Some unknown error occurred.
182 * @return connection `IInputSurfaceConnection` object, which can be used to
183 * query and configure properties of the connection. This cannot be
184 * null.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700185 */
186 connectToOmxInputSurface(
187 IGraphicBufferProducer producer,
188 IGraphicBufferSource source
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800189 ) generates (
190 Status status,
191 IInputSurfaceConnection connection
192 );
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700193
194 /**
195 * Stops using an input surface.
196 *
197 * The component must be in running state.
198 *
199 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800200 * - `OK` - The operation completed successfully.
201 * - `CANNOT_DO` - The component does not support an input surface.
202 * - `BAD_STATE` - The component is not in running state.
203 * - `NOT_FOUND` - The component is not connected to an input surface.
204 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
205 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700206 */
207 disconnectFromInputSurface() generates (Status Status);
208
209 /**
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800210 * Creates a local `C2BlockPool` backed by the given allocator and returns
211 * its id.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700212 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800213 * The returned @p blockPoolId is the only way the client can refer to a
214 * `C2BlockPool` object in the component. The id can be passed to
215 * setOutputSurface() or used in some C2Param objects later.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700216 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800217 * The created `C2BlockPool` object can be destroyed by calling
218 * destroyBlockPool(), reset() or release(). reset() and release() must
219 * destroy all `C2BlockPool` objects that have been created.
220 *
221 * @param allocatorId Id of a `C2Allocator`.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700222 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800223 * - `OK` - The operation completed successfully.
224 * - `NO_MEMORY` - Not enough memory to create the pool.
225 * - `BAD_VALUE` - @p allocatorId is not recognized.
226 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
227 * - `CORRUPTED` - Some unknown error occurred.
228 * @return blockPoolId Id of the created C2BlockPool object. This may be
229 * used in setOutputSurface() if the allocator
230 * @return configurable Configuration interface for the created pool. This
231 * must not be null.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700232 */
233 createBlockPool(uint32_t allocatorId) generates (
234 Status status,
235 uint64_t blockPoolId,
236 IConfigurable configurable
237 );
238
239 /**
240 * Destroys a local block pool previously created by createBlockPool().
241 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800242 * @param blockPoolId Id of a `C2BlockPool` that was previously returned by
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700243 * createBlockPool().
244 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800245 * - `OK` - The operation completed successfully.
246 * - `NOT_FOUND` - The supplied blockPoolId is not valid.
247 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
248 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700249 */
250 destroyBlockPool(uint64_t blockPoolId) generates (Status status);
251
252 // STATE CHANGE METHODS
253 // =========================================================================
254
255 /**
256 * Starts the component.
257 *
258 * This method must be supported in stopped state as well as tripped state.
259 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800260 * If the return value is `OK`, the component must be in the running state.
261 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
262 * expected as a response to this call. Otherwise, the component must be in
263 * the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700264 *
265 * If a component is in the tripped state and start() is called while the
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800266 * component configuration still results in a trip, start() must succeed and
267 * a new onTripped() callback must be used to communicate the configuration
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700268 * conflict that results in the new trip.
269 *
270 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800271 * - `OK` - The component has started successfully.
272 * - `BAD_STATE` - Component is not in stopped or tripped state.
273 * - `DUPLICATE` - When called during another start call from another
274 * thread.
275 * - `NO_MEMORY` - Not enough memory to start the component.
276 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
277 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700278 */
279 start() generates (Status status);
280
281 /**
282 * Stops the component.
283 *
284 * This method must be supported in running (including tripped) state.
285 *
286 * This method must return withing 500ms.
287 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800288 * Upon this call, all pending `Work` must be abandoned.
289 *
290 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
291 * expected as a response to this call. For all other return values, the
292 * component must be in the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700293 *
294 * This does not alter any settings and tunings that may have resulted in a
295 * tripped state.
296 *
297 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800298 * - `OK` - The component has stopped successfully.
299 * - `BAD_STATE` - Component is not in running state.
300 * - `DUPLICATE` - When called during another stop call from another
301 * thread.
302 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
303 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700304 */
305 stop() generates (Status status);
306
307 /**
308 * Resets the component.
309 *
310 * This method must be supported in all (including tripped) states other
311 * than released.
312 *
313 * This method must be supported during any other blocking call.
314 *
315 * This method must return withing 500ms.
316 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800317 * When this call returns, if @p status is `OK`, all `Work` items must
318 * have been abandoned, and all resources (including `C2BlockPool` objects
319 * previously created by createBlockPool()) must have been released.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700320 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800321 * If the return value is `BAD_STATE` or `DUPLICATE`, no state change is
322 * expected as a response to this call. For all other return values, the
323 * component must be in the stopped state.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700324 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800325 * This brings settings back to their default, "guaranteeing" no tripped
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700326 * state.
327 *
328 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800329 * - `OK` - The component has been reset.
330 * - `BAD_STATE` - Component is in released state.
331 * - `DUPLICATE` - When called during another reset call from another
332 * thread.
333 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
334 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700335 */
336 reset() generates (Status status);
337
338 /**
339 * Releases the component.
340 *
341 * This method must be supported in stopped state.
342 *
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800343 * This method destroys the component. Upon return, if @p status is `OK` or
344 * `DUPLICATE`, all resources must have been released.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700345 *
346 * @return status Status of the call, which may be
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800347 * - `OK` - The component has been released.
348 * - `BAD_STATE` - The component is running.
349 * - `DUPLICATE` - The component is already released.
350 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
351 * - `CORRUPTED` - Some unknown error occurred.
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700352 */
353 release() generates (Status status);
354
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800355 /**
356 * Returns the @ref IComponentInterface instance associated to this
357 * component.
358 *
Pawin Vongmasab58b3112019-02-25 23:08:14 -0800359 * An @ref IConfigurable instance for the component can be obtained by calling
Pawin Vongmasa6c9e7842018-11-14 17:16:10 -0800360 * IComponentInterface::getConfigurable() on the returned @p intf.
361 *
362 * @return intf `IComponentInterface` instance. This must not be null.
363 */
364 getInterface() generates (IComponentInterface intf);
Pawin Vongmasab58b3112019-02-25 23:08:14 -0800365
366 /**
367 * Returns an @ref IInputSink instance that has the component as the
368 * underlying implementation.
369 *
370 * @return sink `IInputSink` instance.
371 */
372 asInputSink() generates (IInputSink sink);
Pawin Vongmasac80bf212018-09-06 05:22:36 -0700373};
374