sl@0: /*
sl@0: * Copyright (c) 2008 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: 
sl@0: 
sl@0: #ifndef __NGAPOSTPROCSURFACEHANDLER_H__
sl@0: #define __NGAPOSTPROCSURFACEHANDLER_H__
sl@0: 
sl@0: #include <e32std.h>
sl@0: #include <graphics/surface.h>
sl@0: 
sl@0: class RSurfaceManager;
sl@0: 
sl@0: class CNGAPostProcSurfaceHandler: public CBase
sl@0: {
sl@0: 
sl@0: public: 
sl@0:     //  === Constructors and destructor ===
sl@0:     /**
sl@0:     * Two-phased constructor.   
sl@0:     * @return pointer to an instance of CMMFVideoPostProcHwDevice
sl@0:     */
sl@0:     static CNGAPostProcSurfaceHandler* NewL();
sl@0: 
sl@0:     /**
sl@0:     * Destructor.
sl@0:     */
sl@0:     ~CNGAPostProcSurfaceHandler();
sl@0: 
sl@0: public: 
sl@0:     
sl@0:     /**
sl@0:     Sets the device input format to an uncompressed video format.
sl@0: 
sl@0:     @param  "aFormat"   "The input format to use."
sl@0:     @leave  "The method will leave if an error occurs. Typical error codes used:
sl@0:             * KErrNotSupported - The input format is not supported."    
sl@0:     @pre    "This method can only be called before the hwdevice has been initialized with Initialize()."
sl@0:     */
sl@0:     TInt CreateSurface(const RSurfaceManager::TSurfaceCreationAttributes & aAttributes, TSurfaceId& aSurfaceId, const RChunk& aChunk);
sl@0:     TInt CreateSurface(const RSurfaceManager::TSurfaceCreationAttributesBuf & aAttributes, TSurfaceId& aSurfaceId);
sl@0: 
sl@0:     /**
sl@0:     Sets the decoder device that will write data to this post-processor. Decoded pictures will be 
sl@0:     written with WritePictureL() or through a custom interface. After pictures have been processed, 
sl@0:     they must be returned to the decoder using ReturnPicture().
sl@0: 
sl@0:     @param  "aDevice"   "The decoder source plug-in to use."
sl@0:     @pre    "This method can only be called before the hwdevice has been initialized with Initialize()."
sl@0:     */
sl@0:     TInt OpenSurface(const TSurfaceId& aSurfaceId);
sl@0: 
sl@0:     /**
sl@0:     Writes an uncompressed video picture to the post-processor. The picture must be returned to the 
sl@0:     client or source plug-in after it has been used.
sl@0: 
sl@0:     @param  "aPicture"  "The picture to write."
sl@0:     @leave  "This method may leave with one of the system-wide error codes."
sl@0:     @pre    "This method can only be called after the hwdevice has been initialized with Initialize()."
sl@0:     */
sl@0:     TInt MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle);    
sl@0: 
sl@0:     /**
sl@0:     Retrieves post-processing information about this hardware device. 
sl@0:     The device creates a CPostProcessorInfo structure, fills it with correct data, pushes it 
sl@0:     to the cleanup stack and returns it. The client will delete the object when it is no 
sl@0:     longer needed.
sl@0: 
sl@0:     @return "Post-processor information as a CPostProcessorInfo object. 
sl@0:             The object is pushed to the cleanup stack, and must be deallocated by the caller."
sl@0:     @leave  "This method may leave with one of the system-wide error codes.
sl@0:     */
sl@0:     TInt SurfaceInfo(const TSurfaceId& aSurfaceId, RSurfaceManager::TInfoBuf& aInfo);
sl@0: 
sl@0:     /**
sl@0:     Retrieves the list of the output formats that the device supports. The list is ordered in 
sl@0:     plug-in preference order, with the preferred formats at the beginning of the list. The list 
sl@0:     can depend on the device source format, and therefore SetSourceFormatL() must be called before 
sl@0:     calling this method.
sl@0: 
sl@0:     @param "aFormats" "An array for the result format list. The array must be created and destroyed by the caller."
sl@0:     @leave  "This method may leave with one of the system-wide error codes.
sl@0:     @pre    "This method may only be called before the hwdevice has been initialized using Initialize()."
sl@0:     */
sl@0:     TInt DestroySurface(const TSurfaceId& aSurfaceId);
sl@0:     
sl@0:     /**
sl@0: 	Get the offset of the specified buffer from the base address of the underlying
sl@0: 	chunk.
sl@0: 	
sl@0: 	To obtain the address of the buffer, the offset returned must be added onto the
sl@0: 	base address of the RChunk returned in a call to MapSurface(). Note that
sl@0: 	buffer offsets are immutable during the lifetime of the surface.
sl@0: 	@param aParam The input parameters including the surface ID and buffer index.
sl@0: 	@pre The surface is open in the calling process.
sl@0: 	@return KErrNone if successful, KErrArgument if aSurfaceId or aBuffer are invalid,
sl@0: 	KErrAccessDenied if the surface is not open in the current process, KErrNotSupported if
sl@0: 	the surface is not mappable, otherwise a system wide error code.
sl@0: 	*/
sl@0:     TInt GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset);
sl@0:     
sl@0:      /**
sl@0:     Adds a Surface hint to the video surface. 
sl@0:     
sl@0:     */
sl@0:     TInt AddSurfaceHint(const TSurfaceId& aSurfaceId,const RSurfaceManager::THintPair& aHint);
sl@0:     
sl@0:     /**
sl@0:     Updates an existing Surface hint. 
sl@0:     
sl@0:     */
sl@0:     TInt SetSurfaceHint(const TSurfaceId& aSurfaceId,const RSurfaceManager::THintPair& aHint);
sl@0:     
sl@0: protected:
sl@0: 	CNGAPostProcSurfaceHandler();
sl@0:     /**
sl@0:      *  Symbian 2nd phase constructor .
sl@0:      */
sl@0:     void ConstructL();
sl@0: 
sl@0: private: 
sl@0: 
sl@0:     RSurfaceManager*      iSurfaceManager;
sl@0: 
sl@0:     RSurfaceManager::TSurfaceCreationAttributesBuf iSurfaceAttributesBuf;
sl@0:     // A surface attribute.
sl@0:     RSurfaceManager::TSurfaceCreationAttributes& iSurfaceAttributes;
sl@0: };    
sl@0: 
sl@0: #endif //__NGAPOSTPROCSURFACEHANDLER_H__