os/mm/mmswadaptation/videorenderer/inc/videorenderer.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmswadaptation/videorenderer/inc/videorenderer.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,124 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef VIDEORENDERER_H
    1.20 +#define VIDEORENDERER_H
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <e32cmn.h>
    1.24 +#include <graphics/surface.h>
    1.25 +#include <graphics/surfacemanager.h>
    1.26 +#include <mmf/devvideo/devvideobase.h>
    1.27 +
    1.28 +// class declaration
    1.29 +class TVideoFrameBuffer;
    1.30 +class MVideoRendererRelay;
    1.31 +class CRendererBufferManager;
    1.32 +class CThreadUndertaker;
    1.33 +
    1.34 +/** The interface implemented by clients using CVideoRenderer
    1.35 +
    1.36 +An object of a class which implements this interface should be passed to CVideoRenderer::NewL().
    1.37 +
    1.38 +@publishedPartner
    1.39 +@released
    1.40 +@see CVideoRenderer 
    1.41 +*/
    1.42 +class MVideoRendererObserver
    1.43 +	{
    1.44 +public:
    1.45 +	/**
    1.46 +	Called when the renderer has a new video buffer available. The renderer 
    1.47 +	will call this once for each surface buffer when a surface is created, and 
    1.48 +	subsequently for each buffer that becomes available after it has been 
    1.49 +	updated to the display or released.
    1.50 +	*/
    1.51 +	virtual void MvroVideoBufferAvailable() = 0;
    1.52 +
    1.53 +	/**
    1.54 +	Called when a buffer has been displayed. The client can use these 
    1.55 +	callbacks to maintain rendering delay statistics.
    1.56 +	@param 	aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId
    1.57 +	@param aTime The system clock time when the buffer was displayed
    1.58 +	*/
    1.59 +	virtual void MvroBufferDisplayed(TInt aBufferId, const TTime& aTime) = 0;
    1.60 +
    1.61 +	/**
    1.62 +	Called when a buffer was skipped in the rendering process. Buffers can be 
    1.63 +	skipped if rendering gets delayed too far and a more recent buffer is 
    1.64 +	already available for rendering. The client can use these callbacks to 
    1.65 +	maintain video rendering statistics.
    1.66 +	@param 	aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId
    1.67 +	*/
    1.68 +	virtual void MvroBufferSkipped(TInt aBufferId) = 0;
    1.69 +	};
    1.70 +
    1.71 +/** 
    1.72 +CVideoRenderer is a utility class intended to be used to perform video 
    1.73 +rendering to graphics surfaces on the behalf of a client. CVideoRenderer has 
    1.74 +two modes: timed and non-timed.
    1.75 +
    1.76 +In timed mode the CVideoRenderer will attempt to schedule buffer updates as 
    1.77 +close to the specified presentation time as possible. This is done by running 
    1.78 +a high priority thread which is in responsible for rendering the buffers. 
    1.79 +
    1.80 +In non-timed mode the CVideoRenderer will not schedule buffer updates and will 
    1.81 +instead simply render the buffer as soon as the preceding buffer has been 
    1.82 +displayed one or more times. Non-timed mode requires the presence of a CActive
    1.83 +Scheduler in the calling thread.
    1.84 +
    1.85 +@publishedPartner
    1.86 +@prototype
    1.87 +*/
    1.88 +NONSHARABLE_CLASS(CVideoRenderer) : public CBase
    1.89 +	{
    1.90 +public:
    1.91 +
    1.92 +	IMPORT_C static CVideoRenderer* NewL(MVideoRendererObserver& aObserver, TBool aTimed);
    1.93 +	IMPORT_C ~CVideoRenderer();
    1.94 +
    1.95 +	IMPORT_C void GetSupportedFormatsL(RArray<TUncompressedVideoFormat>& aArray);
    1.96 +	IMPORT_C void CreateSurfaceL(const TSize& aSize, TInt aNumBuffers, const TUncompressedVideoFormat& aFormat, TSurfaceId& aSurface);
    1.97 +	IMPORT_C void DestroySurface(const TSurfaceId& aSurface);
    1.98 +	IMPORT_C TVideoFrameBuffer* NextBuffer();
    1.99 +	IMPORT_C void UpdateBuffer(TVideoFrameBuffer* aBuffer, const TTime& aPresentationTime);
   1.100 +	IMPORT_C void ReleaseBuffer(TVideoFrameBuffer* aBuffer);
   1.101 +
   1.102 +	void Release();
   1.103 +
   1.104 +private:
   1.105 +	CVideoRenderer(MVideoRendererObserver& aObserver, TBool aTimed);
   1.106 +	void ConstructL();
   1.107 +	void RegisterSurfaceL();
   1.108 +	void UnregisterSurface();
   1.109 +	
   1.110 +	static TInt ThreadCreateFunction(TAny* aPtr);
   1.111 +	static void ThreadTrapFunctionL(TAny* aPtr);
   1.112 +
   1.113 +private:
   1.114 +	MVideoRendererObserver& iObserver;
   1.115 +	TBool iTimed;
   1.116 +	RSurfaceManager iSurfaceManager;
   1.117 +	MVideoRendererRelay* iRendererRelay;
   1.118 +	RArray<TUncompressedVideoFormat> iSupportedFormat;
   1.119 +	TSurfaceId iSurfaceId;
   1.120 +	CRendererBufferManager* iBufferManager;
   1.121 +	RThread iRendererThread;
   1.122 +	TBool iThreadCreated;
   1.123 +	CThreadUndertaker* iRendererThreadUndertaker;
   1.124 +	RWsSession iWsSession;
   1.125 +	};
   1.126 +
   1.127 +#endif  // VIDEORENDERER_H