Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware.media.c2@1.0; |
| 18 | |
Pawin Vongmasa | 7570e3c | 2018-11-11 19:30:19 -0800 | [diff] [blame] | 19 | import android.hardware.media.bufferpool@1.0::IClientManager; |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 20 | import IComponentInterface; |
| 21 | import IComponentListener; |
| 22 | import IComponent; |
| 23 | import IConfigurable; |
| 24 | import IInputSurface; |
| 25 | |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 26 | interface IComponentStore extends IConfigurable { |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Creates a component by name. |
| 30 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 31 | * This method must return within 100ms. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 32 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 33 | * @param name Name of the component to create. This should match one of the |
| 34 | * names returned by listComponents(). |
| 35 | * @param listener The component listener to use for the component. |
| 36 | * @param pool The buffer pool client manager of the component listener. |
| 37 | * This must be null if the listener process does not own a buffer pool. |
| 38 | * @return status Status of the call, which may be |
| 39 | * - OK - The component was created successfully. |
| 40 | * - NOT_FOUND - There is no component with the given name. |
| 41 | * - NO_MEMORY - Not enough memory to create the component. |
| 42 | * - TIMED_OUT - The component could not be created within the time limit. |
| 43 | * (unexpected) |
| 44 | * - CORRUPTED - Some unknown error prevented the creation of the |
| 45 | * component. (unexpected) |
| 46 | * @return comp The created component if `Status = OK`. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 47 | */ |
| 48 | createComponent( |
| 49 | string name, |
| 50 | IComponentListener listener, |
| 51 | IClientManager pool |
| 52 | ) generates ( |
| 53 | Status status, |
| 54 | IComponent comp |
| 55 | ); |
| 56 | |
| 57 | /** |
| 58 | * Creates a component interface by name. |
| 59 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 60 | * This method must return within 100ms. |
| 61 | * |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 62 | * @param name Name of the component interface to create. This should match |
| 63 | * one of the names returned by listComponents(). |
| 64 | * @return status Status of the call, which may be |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 65 | * - OK - The component interface was created successfully. |
| 66 | * - NOT_FOUND - There is no component interface with the given name. |
| 67 | * - NO_MEMORY - Not enough memory to create the component interface. |
| 68 | * - TIMED_OUT - The component interface could not be created within the |
| 69 | * time limit. (unexpected) |
| 70 | * - CORRUPTED - Some unknown error prevented the creation of the |
| 71 | * component interface. (unexpected) |
| 72 | * @return compIntf The created component interface if `Status = OK`. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 73 | */ |
| 74 | createInterface( |
| 75 | string name |
| 76 | ) generates ( |
| 77 | Status status, |
| 78 | IComponentInterface compIntf |
| 79 | ); |
| 80 | |
| 81 | /** |
| 82 | * Component traits. |
| 83 | */ |
| 84 | struct ComponentTraits { |
| 85 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 86 | * Name of the component. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 87 | */ |
| 88 | string name; |
| 89 | |
| 90 | enum Domain : uint32_t { |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 91 | AUDIO, |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 92 | VIDEO, |
| 93 | OTHER = 0xffffffff, |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 94 | }; |
| 95 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 96 | * Component domain. The framework may not recognize `OTHER`. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 97 | */ |
| 98 | Domain domain; |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 99 | /** |
| 100 | * If #domain is `OTHER`, #domainOther can be used to provide additional |
| 101 | * information. Otherwise, #domainOther is ignored. The framework may |
| 102 | * not inspect this value. |
| 103 | */ |
| 104 | uint32_t domainOther; |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 105 | |
| 106 | enum Kind : uint32_t { |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 107 | DECODER, |
| 108 | ENCODER, |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 109 | OTHER = 0xffffffff, |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 110 | }; |
| 111 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 112 | * Component kind. The framework may not recognize `OTHER`. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 113 | */ |
| 114 | Kind kind; |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 115 | /** |
| 116 | * If #kind is `OTHER`, #kindOther can be used to provide additional |
| 117 | * information. Otherwise, #kindOther is ignored. The framework may not |
| 118 | * inspect this value. |
| 119 | */ |
| 120 | uint32_t kindOther; |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 123 | * Rank used by MediaCodecList to determine component ordering. Lower |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 124 | * value means higher priority. |
| 125 | */ |
| 126 | uint32_t rank; |
| 127 | |
| 128 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 129 | * Media type. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 130 | */ |
| 131 | string mediaType; |
| 132 | |
| 133 | /** |
| 134 | * Aliases for component name for backward compatibility. |
| 135 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 136 | * \note Multiple components can have the same alias (but not the same |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 137 | * component name) as long as their media types differ. |
| 138 | */ |
| 139 | vec<string> aliases; |
| 140 | }; |
| 141 | |
| 142 | /** |
| 143 | * Returns the list of components supported by this component store. |
| 144 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 145 | * This method must return within 500ms. |
| 146 | * |
| 147 | * @return traits List of component traits for all components supported by this store in no |
| 148 | * particular order. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 149 | */ |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 150 | listComponents() generates (vec<ComponentTraits> traits); |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * Creates a persistent input surface that can be used as an input surface |
| 154 | * for any IComponent instance |
| 155 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 156 | * This method must return within 100ms. |
| 157 | * |
| 158 | * @return surface A persistent input surface |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 159 | */ |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 160 | createInputSurface() generates (IInputSurface surface); |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 161 | |
| 162 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 163 | * Returns a list of StructDescriptor object for a set of requested |
| 164 | * structures that this store is aware of. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 165 | * |
| 166 | * This operation must be performed at best effort, e.g. the component |
| 167 | * store must simply ignore all struct indices that it is not aware of. |
| 168 | * |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 169 | * @param indices struct indices to return des |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 170 | * @return status Status of the call, which may be |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 171 | * - OK - The operation completed successfully. |
| 172 | * - NOT_FOUND - Some indices were not known. |
| 173 | * - NO_MEMORY - Not enough memory to complete this method. |
| 174 | * @return structs List of StructDescriptor objects. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 175 | */ |
| 176 | getStructDescriptors( |
| 177 | vec<ParamIndex> indices |
| 178 | ) generates ( |
| 179 | Status status, |
| 180 | vec<StructDescriptor> structs |
| 181 | ); |
| 182 | |
| 183 | /** |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 184 | * Returns information required for using BufferPool API in buffer passing. |
| 185 | * If the returned pool is not null, the client can call registerSender() to |
| 186 | * register its IAccessor instance, hence allowing the client to send |
| 187 | * buffers to components hosted by this process. |
| 188 | * |
| 189 | * @return pool If the component store supports receiving buffers via |
| 190 | * BufferPool API, \p pool must be a valid `IClientManager` instance. |
| 191 | * Otherwise, \p pool must be null. |
| 192 | */ |
| 193 | getPoolClientManager( |
| 194 | ) generates ( |
| 195 | IClientManager pool |
| 196 | ); |
| 197 | |
| 198 | /** |
| 199 | * The store must copy the contents of \p src into \p dst without changing |
| 200 | * the format of \p dst. |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 201 | * |
| 202 | * @param src Source buffer. |
| 203 | * @param dst Destination buffer. |
| 204 | * @return status Status of the call, which may be |
Pawin Vongmasa | 9d1cf2a | 2018-11-14 13:40:40 -0800 | [diff] [blame] | 205 | * - OK - The copy is successful. |
| 206 | * - CANNOT_DO - \p src and \p dst are not compatible. |
| 207 | * - REFUSED - No permission to copy. |
| 208 | * - CORRUPTED - The copy cannot be done. (unexpected) |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 209 | */ |
| 210 | copyBuffer(Buffer src, Buffer dst) generates (Status status); |
| 211 | |
Pawin Vongmasa | c80bf21 | 2018-09-06 05:22:36 -0700 | [diff] [blame] | 212 | }; |
| 213 | |