tsrc/xmltestharness/xmlclient/src/baseprofilehandler.h
changeset 0 0e4a32b9112d
equal deleted inserted replaced
-1:000000000000 0:0e4a32b9112d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BASEPROFILEHANDLER_H_
       
    20 #define BASEPROFILEHANDLER_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include <openmax/il/khronos/v1_x/OMX_Core.h>
       
    25 #include <openmax/il/khronos/v1_x/OMX_Component.h>
       
    26 
       
    27 #include "asbreakeventhandler.h"
       
    28 #include "omxscripttest.h"
       
    29 
       
    30 
       
    31 NONSHARABLE_CLASS(CBaseProfileHandler) : public CBase
       
    32     {
       
    33 public:
       
    34     CBaseProfileHandler(ROmxScriptTest& aTestOwner, RASBreakEventHandler& aParentEventHandler);
       
    35     ~CBaseProfileHandler();
       
    36     
       
    37     OMX_COMPONENTTYPE* LoadComponentL(const TDesC8& aTestSpecificName, const TDesC8& aOmxName);
       
    38     
       
    39     void AddPortSupportL(TInt aPortIndex);
       
    40     void SetBufferSupplier(TInt aPortIndex, TBool aComponentBufferSupplier);
       
    41     void SetAutoMode(TInt aPortIndex, TBool aAutoMode);
       
    42     void SetupBuffersL(TInt aPortIndex, TInt aNumberBuffers);
       
    43 	void FreeAllocatedBuffersL();
       
    44     void FillThisBuffer(TInt aPortIndex, TInt aBufferIndexInPort);
       
    45     void EmptyThisBuffer(TInt aPortIndex, TInt aBufferIndexInPort);
       
    46     void WaitForBufferCompletion(TInt aPortIndex, TInt aBufferIndexInPort);
       
    47     
       
    48     //OpenMAX IL callbacks
       
    49     static OMX_ERRORTYPE EventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData);
       
    50     static OMX_ERRORTYPE FillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
       
    51     static OMX_ERRORTYPE EmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
       
    52     
       
    53     void HandleEventReceived(OMX_EVENTTYPE aeEvent, OMX_U32 anData1, OMX_U32 anData2, OMX_PTR apEventData);
       
    54     void HandleFillBufferDone(OMX_IN OMX_BUFFERHEADERTYPE* aFilledBuffer);
       
    55     void HandleEmptyBufferDone(OMX_IN OMX_BUFFERHEADERTYPE* aEmptiedBuffer);
       
    56     
       
    57 protected:
       
    58     
       
    59     NONSHARABLE_CLASS(CBufferHeaderInfo) : public CBase
       
    60         {
       
    61     public:
       
    62         CBufferHeaderInfo(CBaseProfileHandler& aParent);
       
    63         ~CBufferHeaderInfo();
       
    64         
       
    65     public:
       
    66         OMX_BUFFERHEADERTYPE* iBufferHeader;    
       
    67         TBool iBufferAvailable;     //EFalse if buffer currently with IL Component
       
    68         TInt iPortIndex;    //Port the buffer is assigned to
       
    69         CBaseProfileHandler& iParent;
       
    70         };
       
    71     
       
    72     struct TPortInfo
       
    73         {
       
    74         TInt iPortIndex;
       
    75         TBool iWeAreBufferSupplier;
       
    76         TBool iAutoMode;
       
    77         };
       
    78     
       
    79     virtual void DoEventReceived(OMX_EVENTTYPE aeEvent, OMX_U32 anData1, OMX_U32 anData2, OMX_PTR apEventData);
       
    80     virtual void DoFillBufferDone(OMX_IN OMX_BUFFERHEADERTYPE* aFilledBuffer);
       
    81     virtual void DoEmptyBufferDone(OMX_IN OMX_BUFFERHEADERTYPE* aEmptiedBuffer); 
       
    82 
       
    83     static TBool PortIndexMatchComparison(const TInt* aPortIndex, const TPortInfo& aPortInfo);
       
    84     static TBool BufferHeaderMatchComparison(const OMX_BUFFERHEADERTYPE* aBufferHeader, const CBufferHeaderInfo& aBufferHeaderInfo);
       
    85 
       
    86     //aBufferIndexInPort starts at 0 for the first buffer
       
    87     TInt LocateBufferForPort(TInt aPortIndex, TInt aBufferIndexInPort);
       
    88     
       
    89 protected:
       
    90     OMX_CALLBACKTYPE iOmxCallbacks;
       
    91     OMX_COMPONENTTYPE* iOmxComponent;   //Not owned    
       
    92 
       
    93     RPointerArray<CBufferHeaderInfo> iBufferHeaders;
       
    94 
       
    95     RArray<TPortInfo> iPortsUsingBaseProfile;
       
    96      
       
    97     HBufC* iXmlName;
       
    98     
       
    99     ROmxScriptTest& iErrorCallbacks;
       
   100     RASBreakEventHandler& iEventHandlerCallbacks;
       
   101  
       
   102     OMX_BUFFERHEADERTYPE* iWaitingOnBuffer; //Not owned, only ever one wait request pending at any one time so this suffices
       
   103     
       
   104     RMutex iMutex;  //Used to ensure serialised execution of buffer completions and calls to wait on buffer completions
       
   105     };
       
   106 
       
   107 #endif /* BASEPROFILEHANDLER_H_ */