Home | History | Annotate | Download | only in videocodec
      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_ERRORTYPE ProcessorInit(void);  /* Loaded to Idle */
     61     virtual OMX_ERRORTYPE ProcessorDeinit(void);/* Idle to Loaded */
     62     virtual OMX_ERRORTYPE ProcessorStart(void); /* Idle to Executing/Pause */
     63     virtual OMX_ERRORTYPE ProcessorStop(void);  /* Executing/Pause to Idle */
     64     virtual OMX_ERRORTYPE ProcessorPause(void); /* Executing to Pause */
     65     virtual OMX_ERRORTYPE ProcessorResume(void);/* Pause to Executing */
     66 
     67     // Derived class must implement  ProcessorFlush and ProcessorProcess
     68 
     69     enum {
     70         INPORT_INDEX = 0,
     71         OUTPORT_INDEX = 1,
     72         NUMBER_PORTS = 2,
     73     };
     74 
     75     typedef OMX_ERRORTYPE (*OMXHANDLER)(void *inst, OMX_PTR p);
     76     virtual OMX_ERRORTYPE AddHandler(OMX_INDEXTYPE type, OMXHANDLER getter, OMXHANDLER setter);
     77     virtual OMX_ERRORTYPE BuildHandlerList(void);
     78 
     79 private:
     80     // return getter or setter
     81     OMXHANDLER FindHandler(OMX_INDEXTYPE type, bool get);
     82 
     83 protected:
     84     pthread_mutex_t mSerializationLock;
     85 
     86 private:
     87     struct HandlerEntry {
     88         OMX_INDEXTYPE type;
     89         OMXHANDLER getter;
     90         OMXHANDLER setter;
     91         HandlerEntry *next;
     92     };
     93 
     94     HandlerEntry *mHandlerList;
     95 };
     96 
     97 #endif /* OMX_COMPONENT_CODEC_BASE_H_ */
     98