sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef OMX_COMPONENTIMPL_H sl@0: #define OMX_COMPONENTIMPL_H sl@0: sl@0: #include sl@0: sl@0: class CMMFBuffer; sl@0: sl@0: class COmxBufferManager : public CBase sl@0: { sl@0: public: sl@0: sl@0: class COmxBuffer : public CBase sl@0: { sl@0: public: sl@0: static COmxBuffer* NewL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer); sl@0: ~COmxBuffer(); sl@0: sl@0: CMMFBuffer* MmfBuffer() const; sl@0: OMX_BUFFERHEADERTYPE* BufferHeader() const; sl@0: sl@0: void SetInputPortCallbacks(MOmxInputPortCallbacks* aCallbacks); sl@0: void SetOutputPortCallbacks(MOmxOutputPortCallbacks* aCallbacks); sl@0: sl@0: MOmxInputPortCallbacks* InputPortCallbacks() const; sl@0: MOmxOutputPortCallbacks* OutputPortCallbacks() const; sl@0: sl@0: private: sl@0: COmxBuffer(); sl@0: void ConstructL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer); sl@0: sl@0: OMX_BUFFERHEADERTYPE* iBufferHeader; sl@0: CMMFBuffer* iMmfBuffer; sl@0: sl@0: TBool iOwnsMmfBuffer; sl@0: MOmxInputPortCallbacks* iInputPortCallbacks; sl@0: MOmxOutputPortCallbacks* iOutputPortCallbacks; sl@0: }; sl@0: sl@0: public: sl@0: COmxBufferManager(OMX_COMPONENTTYPE* aHandle); sl@0: ~COmxBufferManager(); sl@0: sl@0: // Buffer lookup sl@0: COmxBuffer* FindBuffer(const CMMFBuffer* aBuffer) const; sl@0: COmxBuffer* FindBuffer(OMX_BUFFERHEADERTYPE* aBuffer) const; sl@0: sl@0: // OMX Calls sl@0: TInt UseBuffer(CMMFBuffer& aBuffer, TUint nPortIndex); sl@0: CMMFBuffer* AllocateBufferL(TUint nPortIndex, TUint nSizeBytes); sl@0: TInt FreeBuffer(CMMFBuffer* aBuffer); sl@0: sl@0: TInt EmptyThisBuffer(const CMMFBuffer* aBuffer, MOmxInputPortCallbacks* aObserver); sl@0: TInt FillThisBuffer(CMMFBuffer* aBuffer, MOmxOutputPortCallbacks* aObserver); sl@0: sl@0: // Store OMX buffer pointer sl@0: void StoreBufferL(OMX_BUFFERHEADERTYPE* aBufferHeader, CMMFBuffer* aBuffer); sl@0: sl@0: sl@0: private: sl@0: RPointerArray iBuffers; sl@0: OMX_COMPONENTTYPE* iHandle; sl@0: }; sl@0: sl@0: class COmxCallbacks : public CActive sl@0: { sl@0: public: sl@0: enum TMessageType sl@0: { sl@0: EFillBufferCallback, sl@0: EEmptyBufferCallback, sl@0: EEventCallback sl@0: }; sl@0: sl@0: class TEventParams sl@0: { sl@0: public: sl@0: OMX_EVENTTYPE iEvent; sl@0: TUint iData1; sl@0: TUint iData2; sl@0: TAny* iExtra; sl@0: }; sl@0: sl@0: class TOmxMessage sl@0: { sl@0: public: sl@0: TMessageType iType; sl@0: OMX_HANDLETYPE iComponent; sl@0: union sl@0: { sl@0: COmxBufferManager::COmxBuffer* iBuffer; sl@0: TEventParams iEventParams; sl@0: }; sl@0: }; sl@0: public: sl@0: static COmxCallbacks* NewL(MOmxPuCallbacks& aPuCallbacks); sl@0: operator OMX_CALLBACKTYPE*(); sl@0: void RunL(); sl@0: void DoCancel(); sl@0: TInt FillBufferDone(OMX_HANDLETYPE aComponent, COmxBufferManager::COmxBuffer* aBuffer); sl@0: TInt EmptyBufferDone(OMX_HANDLETYPE aComponent, COmxBufferManager::COmxBuffer* aBuffer); sl@0: TInt EventHandler(OMX_HANDLETYPE aComponent, TEventParams aParams); sl@0: virtual ~COmxCallbacks(); sl@0: private: sl@0: void ConstructL(); sl@0: COmxCallbacks(MOmxPuCallbacks& aPuCallbacks); sl@0: int iState; sl@0: MOmxPuCallbacks* iPuCallbacks; sl@0: RMsgQueue iMsgQueue; sl@0: OMX_CALLBACKTYPE iHandle; sl@0: }; sl@0: sl@0: #endif // OMX_COMPONENTIMPL_H