Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      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
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 #ifndef PVMF_OMX_ENC_CALLBACKS_H_INCLUDED
     19 #define PVMF_OMX_ENC_CALLBACKS_H_INCLUDED
     20 
     21 
     22 #ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
     23 #include "threadsafe_callback_ao.h"
     24 #endif
     25 
     26 #ifndef THREADSAFE_MEMPOOL_H_INCLUDED
     27 #include "threadsafe_mempool.h"
     28 #endif
     29 
     30 
     31 #ifndef OMX_Types_h
     32 #include "OMX_Types.h"
     33 #endif
     34 
     35 #ifndef OMX_Core_h
     36 #include "OMX_Core.h"
     37 #endif
     38 
     39 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
     40 #include "oscl_mem_mempool.h"
     41 #endif
     42 // structure that contains EventHandler callback type parameters:
     43 typedef struct EventHandlerSpecificData
     44 {
     45     OMX_HANDLETYPE hComponent;
     46     OMX_PTR pAppData;
     47     OMX_EVENTTYPE eEvent;
     48     OMX_U32 nData1;
     49     OMX_U32 nData2;
     50     OMX_PTR pEventData;
     51 } EventHandlerSpecificData;
     52 
     53 
     54 // structure that contains EmptyBufferDone callback type parameters:
     55 typedef struct EmptyBufferDoneSpecificData
     56 {
     57     OMX_HANDLETYPE hComponent;
     58     OMX_PTR pAppData;
     59     OMX_BUFFERHEADERTYPE* pBuffer;
     60 } EmptyBufferDoneSpecificData;
     61 
     62 
     63 // structure that contains FillBufferDone callback type parameters:
     64 typedef struct FillBufferDoneSpecificData
     65 {
     66     OMX_HANDLETYPE hComponent;
     67     OMX_PTR pAppData;
     68     OMX_BUFFERHEADERTYPE* pBuffer;
     69 } FillBufferDoneSpecificData;
     70 
     71 
     72 // This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
     73 // The callback events arriving from the remote thread are queued and processed later in PV thread context.
     74 // The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
     75 // OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
     76 
     77 
     78 // Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
     79 const char EventHandlerAOName[] = "EventHandlerCallbackAO";
     80 const char EmptyBufferDoneAOName[] = "EventHandlerCallbackAO";
     81 const char FillBufferDoneAOName[] = "EventHandlerCallbackAO";
     82 
     83 
     84 /**************** CLASS FOR EVENT HANDLER *************/
     85 class EventHandlerThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
     86 {
     87     public:
     88         // Constructor
     89         EventHandlerThreadSafeCallbackAOEnc(
     90             void* aObserver = NULL,
     91             uint32 aDepth = DEFAULT_QUEUE_DEPTH,
     92             const char* aAOname = EventHandlerAOName,
     93             int32 aPriority = OsclActiveObject::EPriorityNominal);
     94 
     95 
     96         // OVERLOADED ProcessEvent
     97         OsclReturnCode ProcessEvent(OsclAny* EventData);
     98 
     99         // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
    100         virtual void Run();
    101         virtual OsclAny* DeQueue(OsclReturnCode &stat);
    102 
    103         virtual ~EventHandlerThreadSafeCallbackAOEnc();
    104         ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
    105 
    106 };
    107 
    108 
    109 /**************** CLASS FOR EVENT HANDLER *************/
    110 class EmptyBufferDoneThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
    111 {
    112     public:
    113         // Constructor
    114         EmptyBufferDoneThreadSafeCallbackAOEnc(
    115             void* aObserver = NULL,
    116             uint32 aDepth = DEFAULT_QUEUE_DEPTH,
    117             const char* aAOname = EmptyBufferDoneAOName,
    118             int32 aPriority = OsclActiveObject::EPriorityNominal);
    119 
    120         // OVERLOADED ProcessEvent
    121         OsclReturnCode ProcessEvent(OsclAny* EventData);
    122 
    123         // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
    124         virtual void Run();
    125         virtual OsclAny* DeQueue(OsclReturnCode &stat);
    126 
    127         virtual ~EmptyBufferDoneThreadSafeCallbackAOEnc();
    128         ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
    129 };
    130 
    131 
    132 
    133 
    134 /**************** CLASS FOR EVENT HANDLER *************/
    135 class FillBufferDoneThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
    136 {
    137     public:
    138         // Constructor
    139         FillBufferDoneThreadSafeCallbackAOEnc(void* aObserver = NULL,
    140                                               uint32 aDepth = DEFAULT_QUEUE_DEPTH,
    141                                               const char* aAOname = FillBufferDoneAOName,
    142                                               int32 aPriority = OsclActiveObject::EPriorityNominal);
    143 
    144         // OVERLOADED ProcessEvent
    145         OsclReturnCode ProcessEvent(OsclAny* EventData);
    146         // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
    147         virtual void Run();
    148         virtual OsclAny* DeQueue(OsclReturnCode &stat);
    149 
    150         virtual ~FillBufferDoneThreadSafeCallbackAOEnc();
    151         ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
    152 };
    153 
    154 #endif  //#ifndef PVMF_OMX_ENC_CALLBACKS_H_INLCUDED
    155