1e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu/* 2e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* Copyright (c) 2009-2011 Intel Corporation. All rights reserved. 3e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* 4e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* Licensed under the Apache License, Version 2.0 (the "License"); 5e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* you may not use this file except in compliance with the License. 6e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* You may obtain a copy of the License at 7e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* 8e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* http://www.apache.org/licenses/LICENSE-2.0 9e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* 10e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* Unless required by applicable law or agreed to in writing, software 11e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* distributed under the License is distributed on an "AS IS" BASIS, 12e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* See the License for the specific language governing permissions and 14e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu* limitations under the License. 15e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu*/ 16e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 17e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#ifndef OMX_COMPONENT_CODEC_BASE_H_ 18e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#define OMX_COMPONENT_CODEC_BASE_H_ 19e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 20e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <unistd.h> 21e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 22e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <OMX_Core.h> 23e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <OMX_Component.h> 24e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <OMX_IndexExt.h> 25e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <OMX_IntelErrorTypes.h> 26e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 27e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <portbase.h> 28e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <portvideo.h> 29e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 30e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include <componentbase.h> 31e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#include "OMXComponentDefines.h" 321be8a72c09dada58bec33d32c5da17dd27774bfaXiaolin Zhang#include <HardwareAPI.h> 33e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 34e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiuclass OMXComponentCodecBase : public ComponentBase { 35e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiupublic: 36e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMXComponentCodecBase(); 37e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual ~OMXComponentCodecBase(); 38e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 39e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiuprotected: 40e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ComponentAllocatePorts(void); 41e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE InitInputPort(void) = 0; 42e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE InitOutputPort(void) = 0; 43e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 44e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ComponentGetParameter( 45e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_INDEXTYPE nIndex, 46e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_PTR pComponentParameterStructure); 47e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 48e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ComponentSetParameter( 49e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_INDEXTYPE nIndex, 50e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_PTR pComponentParameterStructure); 51e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 52e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ComponentGetConfig( 53e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_INDEXTYPE nIndex, 54e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_PTR pComponentConfigStructure); 55e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 56e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ComponentSetConfig( 57e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_INDEXTYPE nIndex, 58e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_PTR pComponentConfigStructure); 59e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 60938672ff659640d56a4ea6e089378ed3d2de8201Austin Hu virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width); 61938672ff659640d56a4ea6e089378ed3d2de8201Austin Hu 62e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorInit(void); /* Loaded to Idle */ 63e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorDeinit(void);/* Idle to Loaded */ 64e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorStart(void); /* Idle to Executing/Pause */ 65e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorStop(void); /* Executing/Pause to Idle */ 66e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorPause(void); /* Executing to Pause */ 67e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE ProcessorResume(void);/* Pause to Executing */ 68e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 69e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu // Derived class must implement ProcessorFlush and ProcessorProcess 70e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 71e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu enum { 72e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu INPORT_INDEX = 0, 73e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OUTPORT_INDEX = 1, 74e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu NUMBER_PORTS = 2, 75e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu }; 76e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 77e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu typedef OMX_ERRORTYPE (*OMXHANDLER)(void *inst, OMX_PTR p); 78e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE AddHandler(OMX_INDEXTYPE type, OMXHANDLER getter, OMXHANDLER setter); 79e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu virtual OMX_ERRORTYPE BuildHandlerList(void); 80e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 81e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiuprivate: 82e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu // return getter or setter 83e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMXHANDLER FindHandler(OMX_INDEXTYPE type, bool get); 84e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 85e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiuprotected: 86e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu pthread_mutex_t mSerializationLock; 87e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 88e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiuprivate: 89e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu struct HandlerEntry { 90e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMX_INDEXTYPE type; 91e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMXHANDLER getter; 92e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu OMXHANDLER setter; 93e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu HandlerEntry *next; 94e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu }; 95e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 96e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu HandlerEntry *mHandlerList; 97e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu}; 98e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu 99e7ace334fb7c64f7b32aa3746e5a11bcefa60bfbAndy Qiu#endif /* OMX_COMPONENT_CODEC_BASE_H_ */ 100