blob: a027afe465aaca8a32e72d782c13e884ced8634a [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.media.bufferpool@1.0::IClientManager;
Pawin Vongmasac80bf212018-09-06 05:22:36 -070020import IComponentInterface;
21import IComponentListener;
22import IComponent;
23import IConfigurable;
24import IInputSurface;
25
26/**
27 * Entry point for Codec2 HAL.
28 *
29 * All methods in `IComponentStore` must not block. If a method call cannot be
30 * completed in a timely manner, it must return `TIMED_OUT` in the return
31 * status. The only exceptions are getPoolClientManager() and getConfigurable(),
32 * which must always return immediately.
33 */
34interface IComponentStore {
35
36 /**
37 * Creates a component by name.
38 *
39 * @param name Name of the component to create. This must match one of the
40 * names returned by listComponents().
41 * @param listener Callback receiver.
42 * @param pool `IClientManager` object of the BufferPool in the client
43 * process. This may be null if the client does not own a BufferPool.
44 * @return status Status of the call, which may be
45 * - `OK` - The component was created successfully.
46 * - `NOT_FOUND` - There is no component with the given name.
47 * - `NO_MEMORY` - Not enough memory to create the component.
48 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
49 * - `CORRUPTED` - Some unknown error occurred.
50 * @return comp The created component if @p status is `OK`.
51 *
52 * @sa IComponentListener.
53 */
54 createComponent(
55 string name,
56 IComponentListener listener,
57 IClientManager pool
58 ) generates (
59 Status status,
60 IComponent comp
61 );
62
63 /**
64 * Creates a component interface by name.
65 *
66 * @param name Name of the component interface to create. This should match
67 * one of the names returned by listComponents().
68 * @return status Status of the call, which may be
69 * - `OK - The component interface was created successfully.
70 * - `NOT_FOUND` - There is no component interface with the given name.
71 * - `NO_MEMORY` - Not enough memory to create the component interface.
72 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
73 * - `CORRUPTED` - Some unknown error occurred.
74 * @return compIntf The created component interface if @p status is `OK`.
75 */
76 createInterface(
77 string name
78 ) generates (
79 Status status,
80 IComponentInterface compIntf
81 );
82
83 /**
84 * Component traits.
85 */
86 struct ComponentTraits {
87 /**
88 * Name of the component. This must be unique for each component.
89 *
90 * This name is use to identify the component to create in
91 * createComponent() and createComponentInterface().
92 */
93 string name;
94
95 enum Domain : uint32_t {
96 OTHER = 0,
97 VIDEO,
98 AUDIO,
99 IMAGE,
100 };
101 /**
102 * Component domain.
103 */
104 Domain domain;
105
106 enum Kind : uint32_t {
107 OTHER = 0,
108 DECODER,
109 ENCODER,
110 };
111 /**
112 * Component kind.
113 */
114 Kind kind;
115
116 /**
117 * Rank used by `MediaCodecList` to determine component ordering. Lower
118 * value means higher priority.
119 */
120 uint32_t rank;
121
122 /**
123 * MIME type.
124 */
125 string mediaType;
126
127 /**
128 * Aliases for component name for backward compatibility.
129 *
130 * Multiple components can have the same alias (but not the same
131 * component name) as long as their media types differ.
132 */
133 vec<string> aliases;
134 };
135
136 /**
137 * Returns the list of components supported by this component store.
138 *
139 * @return status Status of the call, which may be
140 * - `OK - The operation was successful.
141 * - `NO_MEMORY` - Not enough memory to complete this method.
142 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
143 * - `CORRUPTED` - Some unknown error occurred.
144 * @return traits List of component traits for all components supported by
145 * this store (in no particular order).
146 */
147 listComponents() generates (
148 Status status,
149 vec<ComponentTraits> traits
150 );
151
152 /**
153 * Creates a persistent input surface that can be used as an input surface
154 * for any IComponent instance
155 *
156 * @return status Status of the call, which may be
157 * - `OK - The operation was successful.
158 * - `NO_MEMORY` - Not enough memory to complete this method.
159 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
160 * - `CORRUPTED` - Some unknown error occurred.
161 * @return surface A persistent input surface. This may be null to indicate
162 * an error.
163 */
164 createInputSurface() generates (
165 Status status,
166 IInputSurface surface
167 );
168
169 /**
170 * Returns a list of `StructDescriptor` objects for a set of requested
171 * C2Param structure indices that this store is aware of.
172 *
173 * This operation must be performed at best effort, e.g. the component
174 * store must simply ignore all struct indices that it is not aware of.
175 *
176 * @param indices Indices of C2Param structures to describe.
177 * @return status Status of the call, which may be
178 * - `OK` - The operation completed successfully.
179 * - `NOT_FOUND` - Some indices were not known.
180 * - `NO_MEMORY` - Not enough memory to complete this method.
181 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
182 * - `CORRUPTED` - Some unknown error occurred.
183 * @return structs List of `StructDescriptor` objects.
184 */
185 getStructDescriptors(
186 vec<ParamIndex> indices
187 ) generates (
188 Status status,
189 vec<StructDescriptor> structs
190 );
191
192 /**
193 * Copies the contents of @p src into @p dst without changing the format of
194 * @p dst.
195 *
196 * @param src Source buffer.
197 * @param dst Destination buffer.
198 * @return status Status of the call, which may be
199 * - `OK` - The copy is successful.
200 * - `CANNOT_DO` - @p src and @p dst are not compatible.
201 * - `REFUSED` - No permission to copy.
202 * - `TIMED_OUT` - The operation cannot be finished in a timely manner.
203 * - `CORRUPTED` - Some unknown error occurred.
204 */
205 copyBuffer(Buffer src, Buffer dst) generates (Status status);
206
207 /**
208 * Returns the `IClientManager` object for the component's BufferPool.
209 *
210 * @return pool If the component store supports receiving buffers via
211 * BufferPool API, @p pool must be a valid `IClientManager` instance.
212 * Otherwise, @p pool must be null.
213 */
214 getPoolClientManager() generates (IClientManager pool);
215
216 /**
217 * Returns the @ref IConfigurable instance associated to this component
218 * store.
219 *
220 * @return configurable `IConfigurable` instance. This must not be null.
221 */
222 getConfigurable() generates (IConfigurable configurable);
223};
224