OMX.h revision e870772a78ffe08b1c14a791e368f1499f1be0f3
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_OMX_H_ 18#define ANDROID_OMX_H_ 19 20#include <media/IOMX.h> 21#include <utils/threads.h> 22#include <utils/KeyedVector.h> 23 24namespace android { 25 26struct OMXMaster; 27class OMXNodeInstance; 28 29class OMX : public BnOMX, 30 public IBinder::DeathRecipient { 31public: 32 OMX(); 33 34 virtual bool livesLocally(pid_t pid); 35 36 virtual status_t listNodes(List<ComponentInfo> *list); 37 38 virtual status_t allocateNode( 39 const char *name, const sp<IOMXObserver> &observer, node_id *node); 40 41 virtual status_t freeNode(node_id node); 42 43 virtual status_t sendCommand( 44 node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param); 45 46 virtual status_t getParameter( 47 node_id node, OMX_INDEXTYPE index, 48 void *params, size_t size); 49 50 virtual status_t setParameter( 51 node_id node, OMX_INDEXTYPE index, 52 const void *params, size_t size); 53 54 virtual status_t getConfig( 55 node_id node, OMX_INDEXTYPE index, 56 void *params, size_t size); 57 58 virtual status_t setConfig( 59 node_id node, OMX_INDEXTYPE index, 60 const void *params, size_t size); 61 62 virtual status_t enableGraphicBuffers( 63 node_id node, OMX_U32 port_index, OMX_BOOL enable); 64 65 virtual status_t storeMetaDataInBuffers( 66 node_id node, OMX_U32 port_index, OMX_BOOL enable); 67 68 virtual status_t useBuffer( 69 node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, 70 buffer_id *buffer); 71 72 virtual status_t useGraphicBuffer( 73 node_id node, OMX_U32 port_index, 74 const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer); 75 76 virtual status_t allocateBuffer( 77 node_id node, OMX_U32 port_index, size_t size, 78 buffer_id *buffer, void **buffer_data); 79 80 virtual status_t allocateBufferWithBackup( 81 node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, 82 buffer_id *buffer); 83 84 virtual status_t freeBuffer( 85 node_id node, OMX_U32 port_index, buffer_id buffer); 86 87 virtual status_t fillBuffer(node_id node, buffer_id buffer); 88 89 virtual status_t emptyBuffer( 90 node_id node, 91 buffer_id buffer, 92 OMX_U32 range_offset, OMX_U32 range_length, 93 OMX_U32 flags, OMX_TICKS timestamp); 94 95 virtual status_t getExtensionIndex( 96 node_id node, 97 const char *parameter_name, 98 OMX_INDEXTYPE *index); 99 100 virtual sp<IOMXRenderer> createRenderer( 101 const sp<ISurface> &surface, 102 const char *componentName, 103 OMX_COLOR_FORMATTYPE colorFormat, 104 size_t encodedWidth, size_t encodedHeight, 105 size_t displayWidth, size_t displayHeight); 106 107 virtual void binderDied(const wp<IBinder> &the_late_who); 108 109 OMX_ERRORTYPE OnEvent( 110 node_id node, 111 OMX_IN OMX_EVENTTYPE eEvent, 112 OMX_IN OMX_U32 nData1, 113 OMX_IN OMX_U32 nData2, 114 OMX_IN OMX_PTR pEventData); 115 116 OMX_ERRORTYPE OnEmptyBufferDone( 117 node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 118 119 OMX_ERRORTYPE OnFillBufferDone( 120 node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 121 122 void invalidateNodeID(node_id node); 123 124protected: 125 virtual ~OMX(); 126 127private: 128 struct CallbackDispatcher; 129 130 Mutex mLock; 131 OMXMaster *mMaster; 132 int32_t mNodeCounter; 133 134 KeyedVector<wp<IBinder>, OMXNodeInstance *> mLiveNodes; 135 KeyedVector<node_id, OMXNodeInstance *> mNodeIDToInstance; 136 KeyedVector<node_id, sp<CallbackDispatcher> > mDispatchers; 137 138 node_id makeNodeID(OMXNodeInstance *instance); 139 OMXNodeInstance *findInstance(node_id node); 140 sp<CallbackDispatcher> findDispatcher(node_id node); 141 142 void invalidateNodeID_l(node_id node); 143 144 OMX(const OMX &); 145 OMX &operator=(const OMX &); 146}; 147 148} // namespace android 149 150#endif // ANDROID_OMX_H_ 151