1784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber/* 2784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * Copyright (C) 2009 The Android Open Source Project 3784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * 4784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * you may not use this file except in compliance with the License. 6784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * You may obtain a copy of the License at 7784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * 8784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * 10784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * Unless required by applicable law or agreed to in writing, software 11784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * See the License for the specific language governing permissions and 14784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber * limitations under the License. 15784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber */ 16784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 17784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#ifndef OMX_NODE_INSTANCE_H_ 18784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 19784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#define OMX_NODE_INSTANCE_H_ 20784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 21784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#include "OMX.h" 22784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 23784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#include <utils/RefBase.h> 24784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#include <utils/threads.h> 25784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 26784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Hubernamespace android { 27784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 28784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huberclass IOMXObserver; 29fef6435a0692f3c9b6055903dfb7699e90e19d46Andreas Huberstruct OMXMaster; 30784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 31784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huberstruct OMXNodeInstance { 32784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMXNodeInstance( 33784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX *owner, const sp<IOMXObserver> &observer); 34784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 35784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber void setHandle(OMX::node_id node_id, OMX_HANDLETYPE handle); 36784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 37784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX *owner(); 38784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber sp<IOMXObserver> observer(); 39784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX::node_id nodeID(); 40784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 41fef6435a0692f3c9b6055903dfb7699e90e19d46Andreas Huber status_t freeNode(OMXMaster *master); 42784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 43784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param); 44784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t getParameter(OMX_INDEXTYPE index, void *params, size_t size); 45784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 46784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t setParameter( 47784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_INDEXTYPE index, const void *params, size_t size); 48784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 49784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t getConfig(OMX_INDEXTYPE index, void *params, size_t size); 50784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t setConfig(OMX_INDEXTYPE index, const void *params, size_t size); 51784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 526607b39baa05ee85a0857c3f95ff9224517b2abcJamie Gennis status_t getState(OMX_STATETYPE* state); 536607b39baa05ee85a0857c3f95ff9224517b2abcJamie Gennis 5433a78149e00806d055ff214d300279963965a677Jamie Gennis status_t enableGraphicBuffers(OMX_U32 portIndex, OMX_BOOL enable); 55e6befb88bd2ade12c50b0a0e95b209e1f4be94b4Jamie Gennis 56e6befb88bd2ade12c50b0a0e95b209e1f4be94b4Jamie Gennis status_t getGraphicBufferUsage(OMX_U32 portIndex, OMX_U32* usage); 57e6befb88bd2ade12c50b0a0e95b209e1f4be94b4Jamie Gennis 58387e38dd87ae9c04ef79ebe06ea798762916ff5cJames Dong status_t storeMetaDataInBuffers(OMX_U32 portIndex, OMX_BOOL enable); 5933a78149e00806d055ff214d300279963965a677Jamie Gennis 60784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t useBuffer( 61784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_U32 portIndex, const sp<IMemory> ¶ms, 62784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX::buffer_id *buffer); 63784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 6433a78149e00806d055ff214d300279963965a677Jamie Gennis status_t useGraphicBuffer( 6533a78149e00806d055ff214d300279963965a677Jamie Gennis OMX_U32 portIndex, const sp<GraphicBuffer> &graphicBuffer, 6633a78149e00806d055ff214d300279963965a677Jamie Gennis OMX::buffer_id *buffer); 6733a78149e00806d055ff214d300279963965a677Jamie Gennis 68784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t allocateBuffer( 69c712b9fe2859435ce142b90ddcb46c5bed33eea8Andreas Huber OMX_U32 portIndex, size_t size, OMX::buffer_id *buffer, 70c712b9fe2859435ce142b90ddcb46c5bed33eea8Andreas Huber void **buffer_data); 71784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 72784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t allocateBufferWithBackup( 73784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_U32 portIndex, const sp<IMemory> ¶ms, 74784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX::buffer_id *buffer); 75784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 76784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t freeBuffer(OMX_U32 portIndex, OMX::buffer_id buffer); 77784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 78784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t fillBuffer(OMX::buffer_id buffer); 79784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 80784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t emptyBuffer( 81784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX::buffer_id buffer, 82784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_U32 rangeOffset, OMX_U32 rangeLength, 83784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_U32 flags, OMX_TICKS timestamp); 84784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 85784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber status_t getExtensionIndex( 86784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber const char *parameterName, OMX_INDEXTYPE *index); 87784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 88784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber void onMessage(const omx_message &msg); 89fef6435a0692f3c9b6055903dfb7699e90e19d46Andreas Huber void onObserverDied(OMXMaster *master); 90784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber void onGetHandleFailed(); 91784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 92784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber static OMX_CALLBACKTYPE kCallbacks; 93784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 94784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huberprivate: 95784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber Mutex mLock; 96784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 97784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX *mOwner; 98784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX::node_id mNodeID; 99784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_HANDLETYPE mHandle; 100784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber sp<IOMXObserver> mObserver; 1012ea14e231945afb6581fa8f54015b33bc74a19e5Andreas Huber bool mDying; 102784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 1033085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber struct ActiveBuffer { 1043085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber OMX_U32 mPortIndex; 1053085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber OMX::buffer_id mID; 1063085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber }; 1073085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber Vector<ActiveBuffer> mActiveBuffers; 1083085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber 109784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber ~OMXNodeInstance(); 110784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 1113085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber void addActiveBuffer(OMX_U32 portIndex, OMX::buffer_id id); 1123085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber void removeActiveBuffer(OMX_U32 portIndex, OMX::buffer_id id); 1133085c83e0015f019c960bc76f9689dfbfc9f5bb8Andreas Huber void freeActiveBuffers(); 1143db9f38174b84404d31048dcdc6f84638a41ef37Anu Sundararajan status_t useGraphicBuffer2_l( 1153db9f38174b84404d31048dcdc6f84638a41ef37Anu Sundararajan OMX_U32 portIndex, const sp<GraphicBuffer> &graphicBuffer, 1163db9f38174b84404d31048dcdc6f84638a41ef37Anu Sundararajan OMX::buffer_id *buffer); 117784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber static OMX_ERRORTYPE OnEvent( 118784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_HANDLETYPE hComponent, 119784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_PTR pAppData, 120784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_EVENTTYPE eEvent, 121784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_U32 nData1, 122784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_U32 nData2, 123784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_PTR pEventData); 124784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 125784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber static OMX_ERRORTYPE OnEmptyBufferDone( 126784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_HANDLETYPE hComponent, 127784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_PTR pAppData, 128784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 129784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 130784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber static OMX_ERRORTYPE OnFillBufferDone( 131784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_HANDLETYPE hComponent, 132784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_PTR pAppData, 133784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 134784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 135784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMXNodeInstance(const OMXNodeInstance &); 136784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber OMXNodeInstance &operator=(const OMXNodeInstance &); 137784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber}; 138784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 139784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber} // namespace android 140784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber 141784202ea115603004b067aacf6a57bf5d2a7d53bAndreas Huber#endif // OMX_NODE_INSTANCE_H_ 142