os/mm/mmdevicefw/mdf/src/openmax/omxcomponentimpl.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef OMX_COMPONENTIMPL_H
    17 #define OMX_COMPONENTIMPL_H
    18 
    19 #include <e32msgqueue.h>
    20 
    21 class CMMFBuffer;
    22 
    23 class COmxBufferManager : public CBase
    24 	{
    25 public:
    26 
    27 	class COmxBuffer : public CBase
    28 		{
    29 	public:
    30 		static COmxBuffer* NewL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer);
    31 		~COmxBuffer();
    32 		
    33 		CMMFBuffer* MmfBuffer() const;
    34 		OMX_BUFFERHEADERTYPE* BufferHeader() const;
    35 		
    36 		void SetInputPortCallbacks(MOmxInputPortCallbacks* aCallbacks);
    37 		void SetOutputPortCallbacks(MOmxOutputPortCallbacks* aCallbacks);
    38 		
    39 		MOmxInputPortCallbacks* InputPortCallbacks() const;
    40 		MOmxOutputPortCallbacks* OutputPortCallbacks() const;
    41 		
    42 	private:
    43 		COmxBuffer();
    44 		void ConstructL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer);
    45 		
    46 		OMX_BUFFERHEADERTYPE* iBufferHeader;
    47 		CMMFBuffer* iMmfBuffer;
    48 		
    49 		TBool iOwnsMmfBuffer;
    50 		MOmxInputPortCallbacks* iInputPortCallbacks;
    51 		MOmxOutputPortCallbacks* iOutputPortCallbacks;
    52 		};
    53 		
    54 public:
    55 	COmxBufferManager(OMX_COMPONENTTYPE* aHandle);
    56 	~COmxBufferManager();
    57 	
    58 	// Buffer lookup
    59 	COmxBuffer* FindBuffer(const CMMFBuffer* aBuffer) const;
    60 	COmxBuffer* FindBuffer(OMX_BUFFERHEADERTYPE* aBuffer) const;
    61 	
    62 	// OMX Calls
    63 	TInt UseBuffer(CMMFBuffer& aBuffer, TUint nPortIndex);
    64 	CMMFBuffer* AllocateBufferL(TUint nPortIndex, TUint nSizeBytes);
    65 	TInt FreeBuffer(CMMFBuffer* aBuffer);
    66 	
    67 	TInt EmptyThisBuffer(const CMMFBuffer* aBuffer, MOmxInputPortCallbacks* aObserver);
    68 	TInt FillThisBuffer(CMMFBuffer* aBuffer, MOmxOutputPortCallbacks* aObserver);
    69 	
    70 	// Store OMX buffer pointer
    71 	void StoreBufferL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer);
    72 	
    73 	
    74 private:	
    75 	RPointerArray<COmxBuffer> iBuffers;
    76 	OMX_COMPONENTTYPE* iHandle;
    77 	};
    78 
    79 class COmxCallbacks : public CActive
    80 	{
    81 public:
    82 	enum TMessageType 
    83 		{
    84 		EFillBufferCallback,
    85 		EEmptyBufferCallback,
    86 		EEventCallback
    87 		};	
    88 
    89 	class TEventParams
    90 		{
    91 	public:		
    92 	 	OMX_EVENTTYPE iEvent; 
    93 		TUint iData1;
    94 		TUint iData2;
    95 		TAny* iExtra;
    96 		};
    97 
    98 	class TOmxMessage
    99 		{
   100 	public:
   101 		TMessageType iType;
   102 		OMX_HANDLETYPE iComponent;
   103 		union 
   104 			{
   105 			COmxBufferManager::COmxBuffer* iBuffer;
   106 			TEventParams iEventParams;
   107 			};	
   108 		};
   109 public:
   110 	static COmxCallbacks* NewL(MOmxPuCallbacks& aPuCallbacks);
   111 	operator OMX_CALLBACKTYPE*();
   112 	void RunL();
   113 	void DoCancel();
   114 	TInt FillBufferDone(OMX_HANDLETYPE aComponent, COmxBufferManager::COmxBuffer* aBuffer);
   115 	TInt EmptyBufferDone(OMX_HANDLETYPE aComponent, COmxBufferManager::COmxBuffer* aBuffer);
   116 	TInt EventHandler(OMX_HANDLETYPE aComponent, TEventParams aParams);
   117 	virtual ~COmxCallbacks();
   118 private:
   119 	void ConstructL();
   120 	COmxCallbacks(MOmxPuCallbacks& aPuCallbacks);
   121 	int iState;
   122 	MOmxPuCallbacks* iPuCallbacks;
   123 	RMsgQueue<TOmxMessage> iMsgQueue;
   124 	OMX_CALLBACKTYPE iHandle;
   125 	};
   126 
   127 #endif // OMX_COMPONENTIMPL_H