os/mm/mmdevicefw/mdf/src/video/hwdevicevideoutils/mdfvideodecoderbuffermanager.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 MDFVIDEODECODERBUFFERMANAGER_H
    17 #define MDFVIDEODECODERBUFFERMANAGER_H
    18 
    19 #include <e32base.h>
    20 #include <mmf/devvideo/videoplayhwdevice.h>
    21 #include <mmf/devvideo/devvideoplay.h>
    22 #include <mmf/server/mmfdatabuffer.h>
    23 
    24 /**
    25 
    26 */
    27 class CVideoDataBuffer : public CBase
    28 	{
    29 public:
    30 	static CVideoDataBuffer* NewL(TUint aSize);
    31 	static CVideoDataBuffer* NewL(CMMFBuffer* aBuffer);
    32 
    33 	operator CMMFBuffer*();
    34 	operator TVideoInputBuffer&();
    35 
    36 	TBool operator ==(const CMMFBuffer* aBuffer) const;
    37 	TBool operator ==(const TVideoInputBuffer& aVideoInputBuffer) const;
    38 	
    39 	TUint Length();
    40 
    41 	~CVideoDataBuffer();
    42 private:
    43 	CVideoDataBuffer();
    44 	
    45 	void ConstructL(TUint aSize);
    46 	void ConstructL(CMMFBuffer* aBuffer);
    47 
    48 private:
    49 	TUint iSize;
    50 	CMMFBuffer* iMmfBuffer;
    51 	TVideoInputBuffer iVideoInputBuffer;	
    52 	};
    53 	
    54 /**
    55 
    56 */	
    57 class CVideoFrameBuffer : public CBase
    58 	{
    59 public:
    60 	enum TFrameBufferState
    61 		{
    62 		EEmptied,
    63 		EFilled
    64 		};
    65 public:
    66 	static CVideoFrameBuffer* NewL(TSize aFrameSize, TUncompressedVideoFormat aVideoFormat, TDisplayMode aDisplayMode);
    67 
    68 	operator CMMFBuffer&();
    69 	operator CMMFBuffer*();
    70 	operator TVideoPicture&();
    71 	operator TVideoPicture*();
    72 
    73 	TBool operator ==(const CMMFBuffer* aBuffer) const;
    74 	TBool operator ==(const TVideoPicture& aVideoPicture) const;
    75 	
    76 	void LockFrameBufferHeap();
    77 	void UnlockFrameBufferHeap();
    78 	void SetLastBuffer(TBool aLastBuffer);
    79 	TBool LastBuffer();
    80 
    81 	~CVideoFrameBuffer();
    82 private:
    83 	CVideoFrameBuffer(TSize aFrameSize, TUncompressedVideoFormat aVideoFormat, TDisplayMode aDisplayMode);
    84 	
    85 	void ConstructL();
    86 
    87 	CMMFBuffer* iMmfBuffer;
    88 	TVideoPicture iVideoPicture;
    89 	CFbsBitmap* iBitmap;
    90 	
    91 	HBufC8* iRawBuffer;
    92 	TPtr8 iRawPtr;
    93 	
    94 	TInt iFrameBufferSize; // still need to fill this in
    95 	TSize iFrameSize;
    96 	TUncompressedVideoFormat iVideoFormat;
    97 	TDisplayMode iDisplayMode;
    98 	TBool iHeapLocked;	
    99 	TBool iLastBuffer;
   100 	};
   101 	
   102 /**
   103 Buffer manager for video decoder hardware device.
   104 @internalComponent
   105 */
   106 class CMdfVideoDecoderBufferManager : public CBase 
   107 	{
   108 
   109 public:
   110 	static CMdfVideoDecoderBufferManager* NewL();
   111 	~CMdfVideoDecoderBufferManager();
   112 
   113 	void Init(const TUncompressedVideoFormat& aFormat);
   114 	
   115 	// data buffers (input)
   116 	CVideoDataBuffer& CreateDataBufferL(TUint aSize);
   117 	TInt DataBuffersAvailable() const;
   118 	CVideoDataBuffer& GetDataBufferL();
   119 
   120 	// for convenience, allow the return of the data buffer in all permutations
   121 	void ReturnDataBufferL(TVideoInputBuffer& aBuffer);
   122 
   123 	// frame buffer management
   124 	CVideoFrameBuffer& CreateFrameBufferL(TDisplayMode aDisplayMode);
   125 	
   126 	CVideoFrameBuffer& GetEmptyFrameBufferL(TBool aLockHeap);
   127 	CVideoFrameBuffer& GetFilledFrameBufferL(TBool aLockHeap);
   128 
   129 	void ReturnFrameBufferL(TVideoPicture& aPicture, CVideoFrameBuffer::TFrameBufferState aState);
   130 	void ReturnFrameBufferL(CMMFBuffer* aBuffer, 
   131 							CVideoFrameBuffer::TFrameBufferState aState,
   132 							TBool aLastBuffer);
   133 	
   134 	TInt EmptyFrameBuffersAvailable() const;
   135 	TInt FilledFrameBuffersAvailable() const;
   136 	
   137 	const TPictureData& LastPictureL() const;
   138 	
   139 	// getters/setters for frame attributes
   140 	void SetFrameSize(const TSize& aSize);
   141 	void SetFrameBufferSize(TInt aSize);	
   142 	const TSize& FrameSize() const;
   143 	TInt FrameBufferSize() const;
   144 	TInt MaxFrameBuffers() const;
   145 
   146 private:
   147 	CMdfVideoDecoderBufferManager();
   148 	
   149 	TInt FindFrameBuffer(const CMMFBuffer* aBuffer) const;
   150 	TInt FindFrameBuffer(const TVideoPicture& aVideoPicture) const;
   151 	TInt FindFrameBuffer(const CVideoFrameBuffer& aFrameBuffer) const;
   152 	
   153 	void ConstructL();
   154 private:
   155 	// the format of the incoming video
   156 	TUncompressedVideoFormat iFormat;
   157 	
   158 	// input data buffers
   159 	CVideoDataBuffer* iInputBuffer;
   160 	TBool iInputBufferInUse;
   161 	
   162 	// output frame buffers
   163 	RPointerArray<CVideoFrameBuffer> iEmptyFrameBuffers;
   164 	RPointerArray<CVideoFrameBuffer> iFilledFrameBuffers;
   165 
   166 	RPointerArray<CVideoFrameBuffer> iFrameBuffersInUse;
   167 
   168 	TSize iFrameSize;
   169 	TInt iFrameBufferSize;
   170 	TInt iMaxFrameBuffers;
   171 	
   172 	// last displayed frame
   173 	TPictureData iLastDisplayedFrame;
   174 	
   175 	};
   176 
   177 #endif // MDFVIDEODECODERBUFFERMANAGER_H