1 /* 2 * Copyright (c) 2009-2011 Intel Corporation. All rights reserved. 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 OMX_COMPONENT_CODEC_BASE_H_ 18 #define OMX_COMPONENT_CODEC_BASE_H_ 19 20 #include <unistd.h> 21 22 #include <OMX_Core.h> 23 #include <OMX_Component.h> 24 #include <OMX_IndexExt.h> 25 #include <OMX_IntelErrorTypes.h> 26 27 #include <portbase.h> 28 #include <portvideo.h> 29 30 #include <componentbase.h> 31 #include "OMXComponentDefines.h" 32 #include <HardwareAPI.h> 33 34 class OMXComponentCodecBase : public ComponentBase { 35 public: 36 OMXComponentCodecBase(); 37 virtual ~OMXComponentCodecBase(); 38 39 protected: 40 virtual OMX_ERRORTYPE ComponentAllocatePorts(void); 41 virtual OMX_ERRORTYPE InitInputPort(void) = 0; 42 virtual OMX_ERRORTYPE InitOutputPort(void) = 0; 43 44 virtual OMX_ERRORTYPE ComponentGetParameter( 45 OMX_INDEXTYPE nIndex, 46 OMX_PTR pComponentParameterStructure); 47 48 virtual OMX_ERRORTYPE ComponentSetParameter( 49 OMX_INDEXTYPE nIndex, 50 OMX_PTR pComponentParameterStructure); 51 52 virtual OMX_ERRORTYPE ComponentGetConfig( 53 OMX_INDEXTYPE nIndex, 54 OMX_PTR pComponentConfigStructure); 55 56 virtual OMX_ERRORTYPE ComponentSetConfig( 57 OMX_INDEXTYPE nIndex, 58 OMX_PTR pComponentConfigStructure); 59 60 virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width); 61 62 virtual OMX_ERRORTYPE ProcessorInit(void); /* Loaded to Idle */ 63 virtual OMX_ERRORTYPE ProcessorDeinit(void);/* Idle to Loaded */ 64 virtual OMX_ERRORTYPE ProcessorStart(void); /* Idle to Executing/Pause */ 65 virtual OMX_ERRORTYPE ProcessorStop(void); /* Executing/Pause to Idle */ 66 virtual OMX_ERRORTYPE ProcessorPause(void); /* Executing to Pause */ 67 virtual OMX_ERRORTYPE ProcessorResume(void);/* Pause to Executing */ 68 69 // Derived class must implement ProcessorFlush and ProcessorProcess 70 71 enum { 72 INPORT_INDEX = 0, 73 OUTPORT_INDEX = 1, 74 NUMBER_PORTS = 2, 75 }; 76 77 typedef OMX_ERRORTYPE (*OMXHANDLER)(void *inst, OMX_PTR p); 78 virtual OMX_ERRORTYPE AddHandler(OMX_INDEXTYPE type, OMXHANDLER getter, OMXHANDLER setter); 79 virtual OMX_ERRORTYPE BuildHandlerList(void); 80 81 private: 82 // return getter or setter 83 OMXHANDLER FindHandler(OMX_INDEXTYPE type, bool get); 84 85 protected: 86 pthread_mutex_t mSerializationLock; 87 88 private: 89 struct HandlerEntry { 90 OMX_INDEXTYPE type; 91 OMXHANDLER getter; 92 OMXHANDLER setter; 93 HandlerEntry *next; 94 }; 95 96 HandlerEntry *mHandlerList; 97 }; 98 99 #endif /* OMX_COMPONENT_CODEC_BASE_H_ */ 100