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