portbase.h revision 65f90f13a4ae2f113daf17558f01ffda1a0d05af
1/* 2 * Copyright (C) 2009 Wind River Systems. 3 */ 4 5#ifndef __PORTBASE_H 6#define __PORTBASE_H 7 8#include <pthread.h> 9 10#include <OMX_Core.h> 11#include <OMX_Component.h> 12 13#include <list.h> 14 15class PortBase 16{ 17public: 18 /* 19 * constructor & destructor 20 */ 21 PortBase(); 22 PortBase(const OMX_PARAM_PORTDEFINITIONTYPE *param); 23 virtual ~PortBase(); 24 25 /* end of constructor & destructor */ 26 27 /* 28 * accessor 29 */ 30 /* owner */ 31 void SetOwner(OMX_COMPONENTTYPE *handle); 32 OMX_COMPONENTTYPE *GetOwner(void); 33 34 /* 35 * component methods & helpers 36 */ 37 /* Get/SetParameter */ 38 void SetPortParam( 39 const OMX_PARAM_PORTDEFINITIONTYPE *pComponentParameterStructure); 40 const OMX_PARAM_PORTDEFINITIONTYPE *GetPortParam(void); 41 /* audio parameter */ 42 void SetAudioPortParam( 43 const OMX_AUDIO_PARAM_PORTFORMATTYPE *pComponentParameterStructure); 44 const OMX_AUDIO_PARAM_PORTFORMATTYPE *GetAudioPortParam(void); 45 46 /* Use/Allocate/FreeBuffer */ 47 OMX_ERRORTYPE UseBuffer(OMX_BUFFERHEADERTYPE **ppBufferHdr, 48 OMX_U32 nPortIndex, 49 OMX_PTR pAppPrivate, 50 OMX_U32 nSizeBytes, 51 OMX_U8 *pBuffer); 52 OMX_ERRORTYPE AllocateBuffer(OMX_BUFFERHEADERTYPE **ppBuffer, 53 OMX_U32 nPortIndex, 54 OMX_PTR pAppPrivate, 55 OMX_U32 nSizeBytes); 56 OMX_ERRORTYPE FreeBuffer(OMX_U32 nPortIndex, 57 OMX_BUFFERHEADERTYPE *pBuffer); 58 59 /* 60 * called in ComponentBase::TransStateToLoaded(OMX_StateIdle) or 61 * in ComponentBase::TransStateToIdle(OMX_StateLoaded) 62 * wokeup by Use/Allocate/FreeBuffer 63 */ 64 void WaitPortBufferCompletion(void); 65 66 /* end of component methods & helpers */ 67 68private: 69 /* common routines for constructor */ 70 void __PortBase(void); 71 72 /* 73 * component methods & helpers 74 */ 75 OMX_STATETYPE GetOwnerState(void); 76 77 /* end of component methods & helpers */ 78 79 /* buffer headers */ 80 struct list *buffer_hdrs; 81 OMX_U32 nr_buffer_hdrs; 82 bool buffer_hdrs_completion; /* Use/Allocate/FreeBuffer completion flag */ 83 pthread_mutex_t hdrs_lock; 84 pthread_cond_t hdrs_wait; 85 86 /* parameter */ 87 OMX_PARAM_PORTDEFINITIONTYPE portparam; 88 OMX_AUDIO_PARAM_PORTFORMATTYPE audioparam; 89 90 /* owner handle */ 91 OMX_COMPONENTTYPE *owner; 92}; 93 94#endif /* __PORTBASE_H */ 95