sl@0: // Copyright (c) 2006-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 MDFVIDEODECODERBUFFERMANAGER_H sl@0: #define MDFVIDEODECODERBUFFERMANAGER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: sl@0: */ sl@0: class CVideoDataBuffer : public CBase sl@0: { sl@0: public: sl@0: static CVideoDataBuffer* NewL(TUint aSize); sl@0: static CVideoDataBuffer* NewL(CMMFBuffer* aBuffer); sl@0: sl@0: operator CMMFBuffer*(); sl@0: operator TVideoInputBuffer&(); sl@0: sl@0: TBool operator ==(const CMMFBuffer* aBuffer) const; sl@0: TBool operator ==(const TVideoInputBuffer& aVideoInputBuffer) const; sl@0: sl@0: TUint Length(); sl@0: sl@0: ~CVideoDataBuffer(); sl@0: private: sl@0: CVideoDataBuffer(); sl@0: sl@0: void ConstructL(TUint aSize); sl@0: void ConstructL(CMMFBuffer* aBuffer); sl@0: sl@0: private: sl@0: TUint iSize; sl@0: CMMFBuffer* iMmfBuffer; sl@0: TVideoInputBuffer iVideoInputBuffer; sl@0: }; sl@0: sl@0: /** sl@0: sl@0: */ sl@0: class CVideoFrameBuffer : public CBase sl@0: { sl@0: public: sl@0: enum TFrameBufferState sl@0: { sl@0: EEmptied, sl@0: EFilled sl@0: }; sl@0: public: sl@0: static CVideoFrameBuffer* NewL(TSize aFrameSize, TUncompressedVideoFormat aVideoFormat, TDisplayMode aDisplayMode); sl@0: sl@0: operator CMMFBuffer&(); sl@0: operator CMMFBuffer*(); sl@0: operator TVideoPicture&(); sl@0: operator TVideoPicture*(); sl@0: sl@0: TBool operator ==(const CMMFBuffer* aBuffer) const; sl@0: TBool operator ==(const TVideoPicture& aVideoPicture) const; sl@0: sl@0: void LockFrameBufferHeap(); sl@0: void UnlockFrameBufferHeap(); sl@0: void SetLastBuffer(TBool aLastBuffer); sl@0: TBool LastBuffer(); sl@0: sl@0: ~CVideoFrameBuffer(); sl@0: private: sl@0: CVideoFrameBuffer(TSize aFrameSize, TUncompressedVideoFormat aVideoFormat, TDisplayMode aDisplayMode); sl@0: sl@0: void ConstructL(); sl@0: sl@0: CMMFBuffer* iMmfBuffer; sl@0: TVideoPicture iVideoPicture; sl@0: CFbsBitmap* iBitmap; sl@0: sl@0: HBufC8* iRawBuffer; sl@0: TPtr8 iRawPtr; sl@0: sl@0: TInt iFrameBufferSize; // still need to fill this in sl@0: TSize iFrameSize; sl@0: TUncompressedVideoFormat iVideoFormat; sl@0: TDisplayMode iDisplayMode; sl@0: TBool iHeapLocked; sl@0: TBool iLastBuffer; sl@0: }; sl@0: sl@0: /** sl@0: Buffer manager for video decoder hardware device. sl@0: @internalComponent sl@0: */ sl@0: class CMdfVideoDecoderBufferManager : public CBase sl@0: { sl@0: sl@0: public: sl@0: static CMdfVideoDecoderBufferManager* NewL(); sl@0: ~CMdfVideoDecoderBufferManager(); sl@0: sl@0: void Init(const TUncompressedVideoFormat& aFormat); sl@0: sl@0: // data buffers (input) sl@0: CVideoDataBuffer& CreateDataBufferL(TUint aSize); sl@0: TInt DataBuffersAvailable() const; sl@0: CVideoDataBuffer& GetDataBufferL(); sl@0: sl@0: // for convenience, allow the return of the data buffer in all permutations sl@0: void ReturnDataBufferL(TVideoInputBuffer& aBuffer); sl@0: sl@0: // frame buffer management sl@0: CVideoFrameBuffer& CreateFrameBufferL(TDisplayMode aDisplayMode); sl@0: sl@0: CVideoFrameBuffer& GetEmptyFrameBufferL(TBool aLockHeap); sl@0: CVideoFrameBuffer& GetFilledFrameBufferL(TBool aLockHeap); sl@0: sl@0: void ReturnFrameBufferL(TVideoPicture& aPicture, CVideoFrameBuffer::TFrameBufferState aState); sl@0: void ReturnFrameBufferL(CMMFBuffer* aBuffer, sl@0: CVideoFrameBuffer::TFrameBufferState aState, sl@0: TBool aLastBuffer); sl@0: sl@0: TInt EmptyFrameBuffersAvailable() const; sl@0: TInt FilledFrameBuffersAvailable() const; sl@0: sl@0: const TPictureData& LastPictureL() const; sl@0: sl@0: // getters/setters for frame attributes sl@0: void SetFrameSize(const TSize& aSize); sl@0: void SetFrameBufferSize(TInt aSize); sl@0: const TSize& FrameSize() const; sl@0: TInt FrameBufferSize() const; sl@0: TInt MaxFrameBuffers() const; sl@0: sl@0: private: sl@0: CMdfVideoDecoderBufferManager(); sl@0: sl@0: TInt FindFrameBuffer(const CMMFBuffer* aBuffer) const; sl@0: TInt FindFrameBuffer(const TVideoPicture& aVideoPicture) const; sl@0: TInt FindFrameBuffer(const CVideoFrameBuffer& aFrameBuffer) const; sl@0: sl@0: void ConstructL(); sl@0: private: sl@0: // the format of the incoming video sl@0: TUncompressedVideoFormat iFormat; sl@0: sl@0: // input data buffers sl@0: CVideoDataBuffer* iInputBuffer; sl@0: TBool iInputBufferInUse; sl@0: sl@0: // output frame buffers sl@0: RPointerArray iEmptyFrameBuffers; sl@0: RPointerArray iFilledFrameBuffers; sl@0: sl@0: RPointerArray iFrameBuffersInUse; sl@0: sl@0: TSize iFrameSize; sl@0: TInt iFrameBufferSize; sl@0: TInt iMaxFrameBuffers; sl@0: sl@0: // last displayed frame sl@0: TPictureData iLastDisplayedFrame; sl@0: sl@0: }; sl@0: sl@0: #endif // MDFVIDEODECODERBUFFERMANAGER_H