OMX.h revision e3ec3cec3a2e27033249ff82964d2cbd441d9873
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 status_t listNodes(List<String8> *list); 35 36 virtual status_t allocateNode( 37 const char *name, const sp<IOMXObserver> &observer, node_id *node); 38 39 virtual status_t freeNode(node_id node); 40 41 virtual status_t sendCommand( 42 node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param); 43 44 virtual status_t getParameter( 45 node_id node, OMX_INDEXTYPE index, 46 void *params, size_t size); 47 48 virtual status_t setParameter( 49 node_id node, OMX_INDEXTYPE index, 50 const void *params, size_t size); 51 52 virtual status_t getConfig( 53 node_id node, OMX_INDEXTYPE index, 54 void *params, size_t size); 55 56 virtual status_t setConfig( 57 node_id node, OMX_INDEXTYPE index, 58 const void *params, size_t size); 59 60 virtual status_t useBuffer( 61 node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, 62 buffer_id *buffer); 63 64 virtual status_t allocateBuffer( 65 node_id node, OMX_U32 port_index, size_t size, 66 buffer_id *buffer); 67 68 virtual status_t allocateBufferWithBackup( 69 node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, 70 buffer_id *buffer); 71 72 virtual status_t freeBuffer( 73 node_id node, OMX_U32 port_index, buffer_id buffer); 74 75 virtual status_t fillBuffer(node_id node, buffer_id buffer); 76 77 virtual status_t emptyBuffer( 78 node_id node, 79 buffer_id buffer, 80 OMX_U32 range_offset, OMX_U32 range_length, 81 OMX_U32 flags, OMX_TICKS timestamp); 82 83 virtual status_t getExtensionIndex( 84 node_id node, 85 const char *parameter_name, 86 OMX_INDEXTYPE *index); 87 88 virtual sp<IOMXRenderer> createRenderer( 89 const sp<ISurface> &surface, 90 const char *componentName, 91 OMX_COLOR_FORMATTYPE colorFormat, 92 size_t encodedWidth, size_t encodedHeight, 93 size_t displayWidth, size_t displayHeight); 94 95 virtual void binderDied(const wp<IBinder> &the_late_who); 96 97 OMX_ERRORTYPE OnEvent( 98 node_id node, 99 OMX_IN OMX_EVENTTYPE eEvent, 100 OMX_IN OMX_U32 nData1, 101 OMX_IN OMX_U32 nData2, 102 OMX_IN OMX_PTR pEventData); 103 104 OMX_ERRORTYPE OnEmptyBufferDone( 105 node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 106 107 OMX_ERRORTYPE OnFillBufferDone( 108 node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); 109 110 void invalidateNodeID(node_id node); 111 112protected: 113 virtual ~OMX(); 114 115private: 116 Mutex mLock; 117 118 OMXMaster *mMaster; 119 120 struct CallbackDispatcher; 121 sp<CallbackDispatcher> mDispatcher; 122 123 int32_t mNodeCounter; 124 125 KeyedVector<wp<IBinder>, OMXNodeInstance *> mLiveNodes; 126 KeyedVector<node_id, OMXNodeInstance *> mNodeIDToInstance; 127 128 node_id makeNodeID(OMXNodeInstance *instance); 129 OMXNodeInstance *findInstance(node_id node); 130 131 void invalidateNodeID_l(node_id node); 132 133 OMX(const OMX &); 134 OMX &operator=(const OMX &); 135}; 136 137} // namespace android 138 139#endif // ANDROID_OMX_H_ 140