Andreas Huber | 4b3913a | 2011-05-11 14:13:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 SOFT_OMX_COMPONENT_H_ |
| 18 | |
| 19 | #define SOFT_OMX_COMPONENT_H_ |
| 20 | |
| 21 | #include <media/stagefright/foundation/ABase.h> |
| 22 | #include <media/stagefright/foundation/AString.h> |
| 23 | #include <utils/RefBase.h> |
| 24 | |
| 25 | #include <OMX_Component.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | struct SoftOMXComponent : public RefBase { |
| 30 | SoftOMXComponent( |
| 31 | const char *name, |
| 32 | const OMX_CALLBACKTYPE *callbacks, |
| 33 | OMX_PTR appData, |
| 34 | OMX_COMPONENTTYPE **component); |
| 35 | |
| 36 | virtual OMX_ERRORTYPE initCheck() const; |
| 37 | |
| 38 | void setLibHandle(void *libHandle); |
| 39 | void *libHandle() const; |
| 40 | |
| 41 | protected: |
| 42 | virtual ~SoftOMXComponent(); |
| 43 | |
| 44 | const char *name() const; |
| 45 | |
| 46 | void notify( |
| 47 | OMX_EVENTTYPE event, |
| 48 | OMX_U32 data1, OMX_U32 data2, OMX_PTR data); |
| 49 | |
| 50 | void notifyEmptyBufferDone(OMX_BUFFERHEADERTYPE *header); |
| 51 | void notifyFillBufferDone(OMX_BUFFERHEADERTYPE *header); |
| 52 | |
| 53 | virtual OMX_ERRORTYPE sendCommand( |
| 54 | OMX_COMMANDTYPE cmd, OMX_U32 param, OMX_PTR data); |
| 55 | |
| 56 | virtual OMX_ERRORTYPE getParameter( |
| 57 | OMX_INDEXTYPE index, OMX_PTR params); |
| 58 | |
| 59 | virtual OMX_ERRORTYPE setParameter( |
| 60 | OMX_INDEXTYPE index, const OMX_PTR params); |
| 61 | |
| 62 | virtual OMX_ERRORTYPE getConfig( |
| 63 | OMX_INDEXTYPE index, OMX_PTR params); |
| 64 | |
| 65 | virtual OMX_ERRORTYPE setConfig( |
| 66 | OMX_INDEXTYPE index, const OMX_PTR params); |
| 67 | |
| 68 | virtual OMX_ERRORTYPE getExtensionIndex( |
| 69 | const char *name, OMX_INDEXTYPE *index); |
| 70 | |
| 71 | virtual OMX_ERRORTYPE useBuffer( |
| 72 | OMX_BUFFERHEADERTYPE **buffer, |
| 73 | OMX_U32 portIndex, |
| 74 | OMX_PTR appPrivate, |
| 75 | OMX_U32 size, |
| 76 | OMX_U8 *ptr); |
| 77 | |
| 78 | virtual OMX_ERRORTYPE allocateBuffer( |
| 79 | OMX_BUFFERHEADERTYPE **buffer, |
| 80 | OMX_U32 portIndex, |
| 81 | OMX_PTR appPrivate, |
| 82 | OMX_U32 size); |
| 83 | |
| 84 | virtual OMX_ERRORTYPE freeBuffer( |
| 85 | OMX_U32 portIndex, |
| 86 | OMX_BUFFERHEADERTYPE *buffer); |
| 87 | |
| 88 | virtual OMX_ERRORTYPE emptyThisBuffer( |
| 89 | OMX_BUFFERHEADERTYPE *buffer); |
| 90 | |
| 91 | virtual OMX_ERRORTYPE fillThisBuffer( |
| 92 | OMX_BUFFERHEADERTYPE *buffer); |
| 93 | |
| 94 | virtual OMX_ERRORTYPE getState(OMX_STATETYPE *state); |
| 95 | |
| 96 | private: |
| 97 | AString mName; |
| 98 | const OMX_CALLBACKTYPE *mCallbacks; |
| 99 | OMX_COMPONENTTYPE *mComponent; |
| 100 | |
| 101 | void *mLibHandle; |
| 102 | |
| 103 | static OMX_ERRORTYPE SendCommandWrapper( |
| 104 | OMX_HANDLETYPE component, |
| 105 | OMX_COMMANDTYPE cmd, |
| 106 | OMX_U32 param, |
| 107 | OMX_PTR data); |
| 108 | |
| 109 | static OMX_ERRORTYPE GetParameterWrapper( |
| 110 | OMX_HANDLETYPE component, |
| 111 | OMX_INDEXTYPE index, |
| 112 | OMX_PTR params); |
| 113 | |
| 114 | static OMX_ERRORTYPE SetParameterWrapper( |
| 115 | OMX_HANDLETYPE component, |
| 116 | OMX_INDEXTYPE index, |
| 117 | OMX_PTR params); |
| 118 | |
| 119 | static OMX_ERRORTYPE GetConfigWrapper( |
| 120 | OMX_HANDLETYPE component, |
| 121 | OMX_INDEXTYPE index, |
| 122 | OMX_PTR params); |
| 123 | |
| 124 | static OMX_ERRORTYPE SetConfigWrapper( |
| 125 | OMX_HANDLETYPE component, |
| 126 | OMX_INDEXTYPE index, |
| 127 | OMX_PTR params); |
| 128 | |
| 129 | static OMX_ERRORTYPE GetExtensionIndexWrapper( |
| 130 | OMX_HANDLETYPE component, |
| 131 | OMX_STRING name, |
| 132 | OMX_INDEXTYPE *index); |
| 133 | |
| 134 | static OMX_ERRORTYPE UseBufferWrapper( |
| 135 | OMX_HANDLETYPE component, |
| 136 | OMX_BUFFERHEADERTYPE **buffer, |
| 137 | OMX_U32 portIndex, |
| 138 | OMX_PTR appPrivate, |
| 139 | OMX_U32 size, |
| 140 | OMX_U8 *ptr); |
| 141 | |
| 142 | static OMX_ERRORTYPE AllocateBufferWrapper( |
| 143 | OMX_HANDLETYPE component, |
| 144 | OMX_BUFFERHEADERTYPE **buffer, |
| 145 | OMX_U32 portIndex, |
| 146 | OMX_PTR appPrivate, |
| 147 | OMX_U32 size); |
| 148 | |
| 149 | static OMX_ERRORTYPE FreeBufferWrapper( |
| 150 | OMX_HANDLETYPE component, |
| 151 | OMX_U32 portIndex, |
| 152 | OMX_BUFFERHEADERTYPE *buffer); |
| 153 | |
| 154 | static OMX_ERRORTYPE EmptyThisBufferWrapper( |
| 155 | OMX_HANDLETYPE component, |
| 156 | OMX_BUFFERHEADERTYPE *buffer); |
| 157 | |
| 158 | static OMX_ERRORTYPE FillThisBufferWrapper( |
| 159 | OMX_HANDLETYPE component, |
| 160 | OMX_BUFFERHEADERTYPE *buffer); |
| 161 | |
| 162 | static OMX_ERRORTYPE GetStateWrapper( |
| 163 | OMX_HANDLETYPE component, |
| 164 | OMX_STATETYPE *state); |
| 165 | |
| 166 | DISALLOW_EVIL_CONSTRUCTORS(SoftOMXComponent); |
| 167 | }; |
| 168 | |
| 169 | } // namespace android |
| 170 | |
| 171 | #endif // SOFT_OMX_COMPONENT_H_ |