Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | #ifndef ANDROID_IOMX_H_ |
| 18 | |
| 19 | #define ANDROID_IOMX_H_ |
| 20 | |
| 21 | #include <binder/IInterface.h> |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 22 | #include <gui/IGraphicBufferProducer.h> |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 23 | #include <gui/IGraphicBufferConsumer.h> |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 24 | #include <ui/GraphicBuffer.h> |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 25 | #include <utils/List.h> |
| 26 | #include <utils/String8.h> |
| 27 | |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 28 | #include <list> |
| 29 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 30 | #include <media/hardware/MetadataBufferType.h> |
| 31 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 32 | #include <OMX_Core.h> |
Andreas Huber | 8b938cd | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 33 | #include <OMX_Video.h> |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 34 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 35 | namespace android { |
| 36 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame] | 37 | class IGraphicBufferSource; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 38 | class IMemory; |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 39 | class IOMXNode; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 40 | class IOMXObserver; |
Lajos Molnar | 1b40f28 | 2016-05-09 22:24:52 -0700 | [diff] [blame] | 41 | class NativeHandle; |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 42 | struct omx_message; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 43 | |
| 44 | class IOMX : public IInterface { |
| 45 | public: |
| 46 | DECLARE_META_INTERFACE(OMX); |
| 47 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 48 | typedef uint32_t buffer_id; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 49 | |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 50 | enum { |
| 51 | kFenceTimeoutMs = 1000 |
| 52 | }; |
| 53 | |
| 54 | // Returns true iff the implementation of the OMX interface |
| 55 | // lives in the same process. |
| 56 | virtual bool livesLocally() = 0; |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 57 | |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 58 | struct ComponentInfo { |
| 59 | String8 mName; |
| 60 | List<String8> mRoles; |
| 61 | }; |
| 62 | virtual status_t listNodes(List<ComponentInfo> *list) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 63 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 64 | virtual status_t allocateNode( |
| 65 | const char *name, const sp<IOMXObserver> &observer, |
Chong Zhang | 1d2e9cf | 2016-10-05 21:08:36 -0700 | [diff] [blame^] | 66 | sp<IOMXNode> *omxNode) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 67 | |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 68 | virtual status_t createPersistentInputSurface( |
| 69 | sp<IGraphicBufferProducer> *bufferProducer, |
| 70 | sp<IGraphicBufferConsumer> *bufferConsumer) = 0; |
| 71 | }; |
| 72 | |
| 73 | class IOMXNode : public IInterface { |
| 74 | public: |
| 75 | DECLARE_META_INTERFACE(OMXNode); |
| 76 | |
| 77 | typedef IOMX::buffer_id buffer_id; |
| 78 | |
| 79 | virtual status_t freeNode() = 0; |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 80 | |
| 81 | virtual status_t sendCommand( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 82 | OMX_COMMANDTYPE cmd, OMX_S32 param) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 83 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 84 | virtual status_t getParameter( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 85 | OMX_INDEXTYPE index, void *params, size_t size) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 86 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 87 | virtual status_t setParameter( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 88 | OMX_INDEXTYPE index, const void *params, size_t size) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 89 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 90 | virtual status_t getConfig( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 91 | OMX_INDEXTYPE index, void *params, size_t size) = 0; |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 92 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 93 | virtual status_t setConfig( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 94 | OMX_INDEXTYPE index, const void *params, size_t size) = 0; |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 95 | |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 96 | virtual status_t getState(OMX_STATETYPE* state) = 0; |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 97 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 98 | // This will set *type to previous metadata buffer type on OMX error (not on binder error), and |
| 99 | // new metadata buffer type on success. |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 100 | virtual status_t storeMetaDataInBuffers( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 101 | OMX_U32 port_index, OMX_BOOL enable, MetadataBufferType *type = NULL) = 0; |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 102 | |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 103 | virtual status_t prepareForAdaptivePlayback( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 104 | OMX_U32 portIndex, OMX_BOOL enable, |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 105 | OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) = 0; |
| 106 | |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 107 | virtual status_t configureVideoTunnelMode( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 108 | OMX_U32 portIndex, OMX_BOOL tunneled, |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 109 | OMX_U32 audioHwSync, native_handle_t **sidebandHandle) = 0; |
| 110 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 111 | virtual status_t enableNativeBuffers( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 112 | OMX_U32 port_index, OMX_BOOL graphic, OMX_BOOL enable) = 0; |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 113 | |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 114 | virtual status_t getGraphicBufferUsage( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 115 | OMX_U32 port_index, OMX_U32* usage) = 0; |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 116 | |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 117 | // Use |params| as an OMX buffer, but limit the size of the OMX buffer to |allottedSize|. |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 118 | virtual status_t useBuffer( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 119 | OMX_U32 port_index, const sp<IMemory> ¶ms, |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 120 | buffer_id *buffer, OMX_U32 allottedSize) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 121 | |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 122 | virtual status_t useGraphicBuffer( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 123 | OMX_U32 port_index, |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 124 | const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0; |
| 125 | |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 126 | virtual status_t updateGraphicBufferInMeta( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 127 | OMX_U32 port_index, |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 128 | const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) = 0; |
| 129 | |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 130 | virtual status_t updateNativeHandleInMeta( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 131 | OMX_U32 port_index, |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 132 | const sp<NativeHandle> &nativeHandle, buffer_id buffer) = 0; |
| 133 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 134 | // This will set *type to resulting metadata buffer type on OMX error (not on binder error) as |
| 135 | // well as on success. |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 136 | virtual status_t createInputSurface( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 137 | OMX_U32 port_index, android_dataspace dataSpace, |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 138 | sp<IGraphicBufferProducer> *bufferProducer, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame] | 139 | sp<IGraphicBufferSource> *bufferSource, |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 140 | MetadataBufferType *type = NULL) = 0; |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 141 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 142 | // This will set *type to resulting metadata buffer type on OMX error (not on binder error) as |
| 143 | // well as on success. |
Chong Zhang | 8f469e1 | 2015-05-13 10:21:33 -0700 | [diff] [blame] | 144 | virtual status_t setInputSurface( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 145 | OMX_U32 port_index, |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 146 | const sp<IGraphicBufferConsumer> &bufferConsumer, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame] | 147 | sp<IGraphicBufferSource> *bufferSource, |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 148 | MetadataBufferType *type) = 0; |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 149 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 150 | // Allocate an opaque buffer as a native handle. If component supports returning native |
| 151 | // handles, those are returned in *native_handle. Otherwise, the allocated buffer is |
| 152 | // returned in *buffer_data. This clearly only makes sense if the caller lives in the |
| 153 | // same process as the callee, i.e. is the media_server, as the returned "buffer_data" |
| 154 | // pointer is just that, a pointer into local address space. |
| 155 | virtual status_t allocateSecureBuffer( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 156 | OMX_U32 port_index, size_t size, buffer_id *buffer, |
| 157 | void **buffer_data, sp<NativeHandle> *native_handle) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 158 | |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 159 | // Allocate an OMX buffer of size |allotedSize|. Use |params| as the backup buffer, which |
| 160 | // may be larger. |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 161 | virtual status_t allocateBufferWithBackup( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 162 | OMX_U32 port_index, const sp<IMemory> ¶ms, |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 163 | buffer_id *buffer, OMX_U32 allottedSize) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 164 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 165 | virtual status_t freeBuffer( |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 166 | OMX_U32 port_index, buffer_id buffer) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 167 | |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 168 | // Calls OMX_FillBuffer on buffer, and passes |fenceFd| to component if it supports |
| 169 | // fences. Otherwise, it waits on |fenceFd| before calling OMX_FillBuffer. |
| 170 | // Takes ownership of |fenceFd| even if this call fails. |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 171 | virtual status_t fillBuffer(buffer_id buffer, int fenceFd = -1) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 172 | |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 173 | // Calls OMX_EmptyBuffer on buffer (after updating buffer header with |range_offset|, |
| 174 | // |range_length|, |flags| and |timestamp|). Passes |fenceFd| to component if it |
| 175 | // supports fences. Otherwise, it waits on |fenceFd| before calling OMX_EmptyBuffer. |
| 176 | // Takes ownership of |fenceFd| even if this call fails. |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 177 | virtual status_t emptyBuffer( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 178 | buffer_id buffer, |
| 179 | OMX_U32 range_offset, OMX_U32 range_length, |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 180 | OMX_U32 flags, OMX_TICKS timestamp, int fenceFd = -1) = 0; |
Andreas Huber | 8b938cd | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 181 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame] | 182 | // Calls OMX_EmptyBuffer on buffer (after updating buffer header with metadata of |
| 183 | // |graphicBuffer|, |flags| and |timestamp|). Passes |fenceFd| to component if it |
| 184 | // supports fences. Otherwise, it waits on |fenceFd| before calling OMX_EmptyBuffer. |
| 185 | // Takes ownership of |fenceFd| even if this call fails. If |origTimestamp| >= 0, |
| 186 | // timestamp on the filled buffer corresponding to this frame will be modified to |
| 187 | // |origTimestamp| after it's filled. |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 188 | virtual status_t emptyGraphicBuffer( |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 189 | buffer_id buffer, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame] | 190 | const sp<GraphicBuffer> &graphicBuffer, OMX_U32 flags, |
| 191 | OMX_TICKS timestamp, OMX_TICKS origTimestamp, int fenceFd) = 0; |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 192 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 193 | virtual status_t getExtensionIndex( |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 194 | const char *parameter_name, |
| 195 | OMX_INDEXTYPE *index) = 0; |
Andreas Huber | e40cda7 | 2013-07-17 13:55:26 -0700 | [diff] [blame] | 196 | |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 197 | virtual status_t dispatchMessage(const omx_message &msg) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | struct omx_message { |
| 201 | enum { |
| 202 | EVENT, |
| 203 | EMPTY_BUFFER_DONE, |
| 204 | FILL_BUFFER_DONE, |
Lajos Molnar | 90fcf68 | 2015-06-04 10:29:19 -0700 | [diff] [blame] | 205 | FRAME_RENDERED, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 206 | } type; |
| 207 | |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 208 | int fenceFd; // used for EMPTY_BUFFER_DONE and FILL_BUFFER_DONE; client must close this |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 209 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 210 | union { |
| 211 | // if type == EVENT |
| 212 | struct { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 213 | OMX_EVENTTYPE event; |
| 214 | OMX_U32 data1; |
| 215 | OMX_U32 data2; |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 216 | OMX_U32 data3; |
| 217 | OMX_U32 data4; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 218 | } event_data; |
| 219 | |
Andreas Huber | e0f0b08 | 2009-08-27 14:50:58 -0700 | [diff] [blame] | 220 | // if type == EMPTY_BUFFER_DONE |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 221 | struct { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 222 | IOMX::buffer_id buffer; |
| 223 | } buffer_data; |
| 224 | |
Andreas Huber | e0f0b08 | 2009-08-27 14:50:58 -0700 | [diff] [blame] | 225 | // if type == FILL_BUFFER_DONE |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 226 | struct { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 227 | IOMX::buffer_id buffer; |
| 228 | OMX_U32 range_offset; |
| 229 | OMX_U32 range_length; |
| 230 | OMX_U32 flags; |
| 231 | OMX_TICKS timestamp; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 232 | } extended_buffer_data; |
| 233 | |
Lajos Molnar | 90fcf68 | 2015-06-04 10:29:19 -0700 | [diff] [blame] | 234 | // if type == FRAME_RENDERED |
| 235 | struct { |
| 236 | OMX_TICKS timestamp; |
| 237 | OMX_S64 nanoTime; |
| 238 | } render_data; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 239 | } u; |
| 240 | }; |
| 241 | |
| 242 | class IOMXObserver : public IInterface { |
| 243 | public: |
| 244 | DECLARE_META_INTERFACE(OMXObserver); |
| 245 | |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 246 | // Handle (list of) messages. |
| 247 | virtual void onMessages(const std::list<omx_message> &messages) = 0; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | //////////////////////////////////////////////////////////////////////////////// |
| 251 | |
| 252 | class BnOMX : public BnInterface<IOMX> { |
| 253 | public: |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 254 | virtual bool livesLocally() { |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | virtual status_t onTransact( |
| 259 | uint32_t code, const Parcel &data, Parcel *reply, |
| 260 | uint32_t flags = 0); |
| 261 | }; |
| 262 | |
| 263 | class BnOMXNode : public BnInterface<IOMXNode> { |
| 264 | public: |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 265 | virtual status_t onTransact( |
| 266 | uint32_t code, const Parcel &data, Parcel *reply, |
| 267 | uint32_t flags = 0); |
Wei Jia | 8dde726 | 2015-09-28 11:32:23 -0700 | [diff] [blame] | 268 | |
| 269 | protected: |
| 270 | // check if the codec is secure. |
Chong Zhang | d59b972 | 2016-09-20 16:31:18 -0700 | [diff] [blame] | 271 | virtual bool isSecure() const { |
Wei Jia | 8dde726 | 2015-09-28 11:32:23 -0700 | [diff] [blame] | 272 | return false; |
| 273 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | class BnOMXObserver : public BnInterface<IOMXObserver> { |
| 277 | public: |
| 278 | virtual status_t onTransact( |
| 279 | uint32_t code, const Parcel &data, Parcel *reply, |
| 280 | uint32_t flags = 0); |
| 281 | }; |
| 282 | |
James Dong | 457116d | 2011-07-11 12:29:10 -0700 | [diff] [blame] | 283 | struct CodecProfileLevel { |
| 284 | OMX_U32 mProfile; |
| 285 | OMX_U32 mLevel; |
| 286 | }; |
| 287 | |
Lajos Molnar | 3e32878 | 2016-05-09 10:56:46 -0700 | [diff] [blame] | 288 | inline static const char *asString(MetadataBufferType i, const char *def = "??") { |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 289 | using namespace android; |
| 290 | switch (i) { |
| 291 | case kMetadataBufferTypeCameraSource: return "CameraSource"; |
| 292 | case kMetadataBufferTypeGrallocSource: return "GrallocSource"; |
| 293 | case kMetadataBufferTypeANWBuffer: return "ANWBuffer"; |
Lajos Molnar | 3e32878 | 2016-05-09 10:56:46 -0700 | [diff] [blame] | 294 | case kMetadataBufferTypeNativeHandleSource: return "NativeHandleSource"; |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 295 | case kMetadataBufferTypeInvalid: return "Invalid"; |
| 296 | default: return def; |
| 297 | } |
| 298 | } |
| 299 | |
Lajos Molnar | 3e32878 | 2016-05-09 10:56:46 -0700 | [diff] [blame] | 300 | } // namespace android |
| 301 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 302 | #endif // ANDROID_IOMX_H_ |