Pawin Vongmasa | 6ec37b9 | 2016-10-06 19:01:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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.omx@1.0; |
| 18 | |
| 19 | import IOmxBufferSource; |
| 20 | |
| 21 | import android.hardware.media@1.0::types; |
| 22 | |
| 23 | /** |
| 24 | * Ref: frameworks/av/include/media/IOMX.h: IOMXNode |
| 25 | * Ref: https://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pdf |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * IOmxNode is an interface for communicating with an OMX component (called |
| 30 | * "node" here) that has been previously obtained by calling |
| 31 | * IOmx::allocateNode(). |
| 32 | */ |
| 33 | interface IOmxNode { |
| 34 | |
| 35 | /** |
| 36 | * Free the node. |
| 37 | * |
| 38 | * @param[out] status will be the status of the call. |
| 39 | */ |
| 40 | freeNode( |
| 41 | ) generates ( |
| 42 | Status status |
| 43 | ); |
| 44 | |
| 45 | /** |
| 46 | * Invoke a command on the node. |
| 47 | * |
| 48 | * @param[in] cmd indicates the type of the command. |
| 49 | * @param[in] info holds information about the command. |
| 50 | * @param[out] status will be the status of the call. |
| 51 | * |
| 52 | * @see OMX_SendCommand() in the OpenMax IL standard. |
| 53 | */ |
| 54 | sendCommand( |
| 55 | uint32_t cmd, |
| 56 | Bytes info // TODO: describe structure better or point at standard |
| 57 | ) generates ( |
| 58 | Status status |
| 59 | ); |
| 60 | |
| 61 | /** |
| 62 | * Retrieve a parameter setting from the node. |
| 63 | * |
| 64 | * @param[in] index indicates the type of the parameter to retrieve. |
| 65 | * @param[in] inParams holds some information about the retrieval. |
| 66 | * @param[out] status will be the status of the call. |
| 67 | * @param[out] outParams will be the current parameter setting. |
| 68 | * |
| 69 | * @see OMX_GetParameter() in the OpenMax IL standard. |
| 70 | */ |
| 71 | getParameter( |
| 72 | uint32_t index, |
| 73 | Bytes inParams // TODO: describe structure better or point at standard |
| 74 | ) generates ( |
| 75 | Status status, |
| 76 | Bytes outParams // TODO: describe structure better or point at standard |
| 77 | ); |
| 78 | |
| 79 | /** |
| 80 | * Change a parameter setting of the node. |
| 81 | * |
| 82 | * @param[in] index indicates the type of the parameter to change. |
| 83 | * @param[in] params holds the new parameter setting. |
| 84 | * @param[out] status will be the status of the call. |
| 85 | * |
| 86 | * @see OMX_SetParameter() in the OpenMax IL standard. |
| 87 | */ |
| 88 | setParameter( |
| 89 | uint32_t index, |
| 90 | Bytes params // TODO: describe structure better or point at standard |
| 91 | ) generates ( |
| 92 | Status status |
| 93 | ); |
| 94 | |
| 95 | /** |
| 96 | * Retrieve a configuration from the node. |
| 97 | * |
| 98 | * @param[in] index indicates the type of the configuration to retrieve. |
| 99 | * @param[in] inConfig holds some information about the retrieval. |
| 100 | * @param[out] status will be the status of the call. |
| 101 | * @param[out] outConfig will be the current configuration. |
| 102 | * |
| 103 | * @see OMX_GetConfig() in the OpenMax IL standard. |
| 104 | */ |
| 105 | getConfig( |
| 106 | uint32_t index, |
| 107 | Bytes inConfig // TODO: describe structure better or point at standard |
| 108 | ) generates ( |
| 109 | Status status, |
| 110 | Bytes outConfig // TODO: describe structure better or point at standard |
| 111 | ); |
| 112 | |
| 113 | /** |
| 114 | * Change a configuration of the node. |
| 115 | * |
| 116 | * @param[in] index indicates the type of the configuration to change. |
| 117 | * @param[in] config holds the new configuration. |
| 118 | * @param[out] status will be the status of the call. |
| 119 | * |
| 120 | * @see OMX_SetConfig() in the OpenMax IL standard. |
| 121 | */ |
| 122 | setConfig( |
| 123 | uint32_t index, |
| 124 | Bytes config // TODO: describe structure better or point at standard |
| 125 | ) generates ( |
| 126 | Status status |
| 127 | ); |
| 128 | |
| 129 | /** |
| 130 | * Set the mode of a port on the node. |
| 131 | * |
| 132 | * @param[in] portIndex is the index of the port. |
| 133 | * @param[in] mode is the target mode on the specified port. |
| 134 | */ |
| 135 | setPortMode( |
| 136 | uint32_t portIndex, |
| 137 | PortMode mode |
| 138 | ) generates ( |
| 139 | Status status |
| 140 | ); |
| 141 | |
| 142 | /** |
| 143 | * Prepare a port for adaptive playback. This is based on the extension |
| 144 | * "OMX.google.android.index.prepareForAdaptivePlayback". |
| 145 | * |
| 146 | * @param[in] portIndex is the index of the port. |
| 147 | * @param[in] enable indicates whether adaptive playback is enabled or not. |
| 148 | * @param[in] maxFrameWidth specifies the maximum frame width. |
| 149 | * @param[in] maxFrameHeight specifies the maximum frame height. |
| 150 | * @param[out] status status will be the status of the call. |
| 151 | */ |
| 152 | prepareForAdaptivePlayback( |
| 153 | uint32_t portIndex, |
| 154 | bool enable, |
| 155 | uint32_t maxFrameWidth, |
| 156 | uint32_t maxFrameHeight |
| 157 | ) generates ( |
| 158 | Status status |
| 159 | ); |
| 160 | |
| 161 | /** |
| 162 | * Configure a port for a tunneled playback mode. This is based on the |
| 163 | * extension "OMX.google.android.index.configureVideoTunnelMode". |
| 164 | * |
| 165 | * @param[in] portIndex is the index of the port. |
| 166 | * @param[in] tunneled indicates whether the tunneled mode is used or not. |
| 167 | * @param[in] audioHwSync is the HW SYNC ID of the audio HAL output stream |
| 168 | * to sync the video with. |
| 169 | * @param[out] status will be the status of the call. |
| 170 | * @param[out] sidebandHandle will contain the codec-allocated sideband |
| 171 | * window handle. |
| 172 | */ |
| 173 | configureVideoTunnelMode( |
| 174 | uint32_t portIndex, |
| 175 | bool tunneled, |
| 176 | uint32_t audioHwSync |
| 177 | ) generates ( |
| 178 | Status status, |
| 179 | handle sidebandHandle |
| 180 | ); |
| 181 | |
| 182 | /** |
| 183 | * Retrieve the buffer usage on a port. This is based on the extension |
| 184 | * "OMX.google.android.index.getAndroidNativeBufferUsage". |
| 185 | * |
| 186 | * @param[in] portIndex is the index of the port. |
| 187 | * @param[out] status will be the status of the call. |
| 188 | * @param[out] usage will be the usage. |
| 189 | */ |
| 190 | getGraphicBufferUsage( |
| 191 | uint32_t portIndex |
| 192 | ) generates ( |
| 193 | Status status, |
| 194 | uint32_t usage // TODO: Ask graphics team to define an enum. |
| 195 | ); |
| 196 | |
| 197 | /** |
| 198 | * Set up a listener to events related to the input surface. |
| 199 | * |
| 200 | * @param[in] bufferSource is the listener object that implements |
| 201 | * IOmxBufferSource. |
| 202 | * @param[out] status will be the status of the call. |
| 203 | * |
| 204 | * @see IOmxBufferSource. |
| 205 | */ |
| 206 | setInputSurface( |
| 207 | IOmxBufferSource bufferSource |
| 208 | ) generates ( |
| 209 | Status status |
| 210 | ); |
| 211 | |
| 212 | /** |
| 213 | * Allocate an opaque buffer on a port as a native handle. |
| 214 | * |
| 215 | * @param[in] portIndex is the index of the port. |
| 216 | * @param[in] size is the desired size of the buffer. |
| 217 | * @param[out] status will be the status of the call. |
| 218 | * @param[out] buffer will be the id of the allocated buffer, which will be |
| 219 | * needed in some other buffer-related function calls. |
| 220 | * @param[out] nativeHandle will be the native handle of the allocated |
| 221 | * buffer. |
| 222 | * |
| 223 | * @see OMX_AllocateBuffer() in the OpenMax IL standard. |
| 224 | */ |
| 225 | allocateSecureBuffer( |
| 226 | uint32_t portIndex, |
| 227 | uint64_t size |
| 228 | ) generates ( |
| 229 | Status status, |
| 230 | BufferId buffer, |
| 231 | handle nativeHandle |
| 232 | ); |
| 233 | |
| 234 | /** |
| 235 | * Assign a buffer to a port. |
| 236 | * |
| 237 | * @param[in] portIndex is the index of the port. |
| 238 | * @param[in] omxBuffer is the buffer to be assigned to the port. |
| 239 | * @param[out] status will be the status of the call. |
| 240 | * @param[out] buffer will be the id of the assigned buffer, which will be |
| 241 | * needed in some other buffer-related function calls. |
| 242 | * |
| 243 | * @see OMX_UseBuffer() in the OpenMax IL standard. |
| 244 | */ |
| 245 | useBuffer( |
| 246 | uint32_t portIndex, |
| 247 | CodecBuffer omxBuffer |
| 248 | ) generates ( |
| 249 | Status status, |
| 250 | BufferId buffer |
| 251 | ); |
| 252 | |
| 253 | /** |
| 254 | * Free a buffer previously assigned to a port by allocateSecureBuffer() or |
| 255 | * useBuffer(). |
| 256 | * |
| 257 | * @param[in] portIndex is the index of the port. |
| 258 | * @param[in] buffer is the id of the buffer to be freed. |
| 259 | * @param[out] status will be the status of the call. |
| 260 | * |
| 261 | * @see OMX_FreeBuffer() in the OpenMax IL standard. |
| 262 | */ |
| 263 | freeBuffer( |
| 264 | uint32_t portIndex, |
| 265 | BufferId buffer |
| 266 | ) generates ( |
| 267 | Status status |
| 268 | ); |
| 269 | |
| 270 | /** |
| 271 | * Pass \p fence to the node if it supports fences. Otherwise, it waits on |
| 272 | * \p fence before calling OMX_FillThisBuffer(). The node will take |
| 273 | * ownership of the fence even if this call fails. |
| 274 | * |
| 275 | * If the port is in metadata mode, the buffer will be updated to point to |
| 276 | * the new buffer passed in via \p omxBuffer before OMX_FillThisBuffer() is |
| 277 | * called. Otherwise, \p omxBuffer is not used. |
| 278 | * |
| 279 | * @param[in] buffer is the id of the buffer to fill. |
| 280 | * @param[in] omxBuffer points to the new buffer in metadata mode. |
| 281 | * @param[in] fence is the fence to wait for (if not null). |
| 282 | * @param[out] status is the status of the call. |
| 283 | * |
| 284 | * @see OMX_FillThisBuffer() in the OpenMax IL standard. |
| 285 | */ |
| 286 | fillBuffer( |
| 287 | BufferId buffer, |
| 288 | CodecBuffer omxBuffer, |
| 289 | Fence fence |
| 290 | ) generates ( |
| 291 | Status status |
| 292 | ); |
| 293 | |
| 294 | /** |
| 295 | * Pass \p fence to the node if it supports fences. Otherwise, wait on |
| 296 | * \p fence before calling OMX_EmptyThisBuffer(). The node will take |
| 297 | * ownership of the fence even if this call fails. |
| 298 | * |
| 299 | * If the port is in metadata mode, the buffer will be updated to point to |
| 300 | * the new buffer passed in via \p omxBuffer before OMX_EmptyThisBuffer() is |
| 301 | * called. Otherwise, \p omxBuffer is not used. |
| 302 | * |
| 303 | * @param[in] buffer is the id of the buffer to fill. |
| 304 | * @param[in] omxBuffer points to the new buffer in metadata mode. |
| 305 | * @param[in] flags is put into the header information that is passed to |
| 306 | * OMX_EmptyBuffer(). |
| 307 | * @param[in] timestampUs is put into the header information that is passed |
| 308 | * to OMX_EmptyBuffer(). |
| 309 | * @param[in] fence is the fence to wait for (if not null). |
| 310 | * @param[out] status is the status of the call. |
| 311 | * |
| 312 | * @see OMX_EmptyThisBuffer() in the OpenMax IL standard. |
| 313 | */ |
| 314 | emptyBuffer( |
| 315 | BufferId buffer, |
| 316 | CodecBuffer omxBuffer, |
| 317 | uint32_t flags, // TODO: describe structure better or point at standard |
| 318 | uint64_t timestampUs, |
| 319 | Fence fence |
| 320 | ) generates ( |
| 321 | Status status |
| 322 | ); |
| 323 | |
| 324 | /** |
| 325 | * Request the node to translate an extension string to an index. |
| 326 | * |
| 327 | * @param[in] parameterName is the requested extension string. |
| 328 | * @param[out] status is the status of the call. |
| 329 | * @param[out] index is the translated index. |
| 330 | * |
| 331 | * @see OMX_GetExtensionIndex() in the OpenMax IL standard. |
| 332 | */ |
| 333 | getExtensionIndex( |
| 334 | string parameterName |
| 335 | ) generates ( |
| 336 | Status status, |
| 337 | uint32_t index |
| 338 | ); |
| 339 | |
| 340 | /** |
| 341 | * Add an OMX message on the node's message queue. The instance of |
| 342 | * IOmxObserver that was obtained during the creation of the node will |
| 343 | * receive the message in batches by the callback |
| 344 | * IOmxObserver::onMessages(). |
| 345 | * |
| 346 | * @param[in] msg is the message to send. |
| 347 | * @param[out] status is the status of the call. |
| 348 | * |
| 349 | * @see IOmxObserver::onMessages(). |
| 350 | */ |
| 351 | dispatchMessage( |
| 352 | Message msg |
| 353 | ) generates ( |
| 354 | Status status |
| 355 | ); |
| 356 | |
| 357 | }; |
| 358 | |