os/mm/mmswadaptation/videorenderer/inc/videorenderer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-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 VIDEORENDERER_H
    17 #define VIDEORENDERER_H
    18 
    19 #include <e32base.h>
    20 #include <e32cmn.h>
    21 #include <graphics/surface.h>
    22 #include <graphics/surfacemanager.h>
    23 #include <mmf/devvideo/devvideobase.h>
    24 
    25 // class declaration
    26 class TVideoFrameBuffer;
    27 class MVideoRendererRelay;
    28 class CRendererBufferManager;
    29 class CThreadUndertaker;
    30 
    31 /** The interface implemented by clients using CVideoRenderer
    32 
    33 An object of a class which implements this interface should be passed to CVideoRenderer::NewL().
    34 
    35 @publishedPartner
    36 @released
    37 @see CVideoRenderer 
    38 */
    39 class MVideoRendererObserver
    40 	{
    41 public:
    42 	/**
    43 	Called when the renderer has a new video buffer available. The renderer 
    44 	will call this once for each surface buffer when a surface is created, and 
    45 	subsequently for each buffer that becomes available after it has been 
    46 	updated to the display or released.
    47 	*/
    48 	virtual void MvroVideoBufferAvailable() = 0;
    49 
    50 	/**
    51 	Called when a buffer has been displayed. The client can use these 
    52 	callbacks to maintain rendering delay statistics.
    53 	@param 	aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId
    54 	@param aTime The system clock time when the buffer was displayed
    55 	*/
    56 	virtual void MvroBufferDisplayed(TInt aBufferId, const TTime& aTime) = 0;
    57 
    58 	/**
    59 	Called when a buffer was skipped in the rendering process. Buffers can be 
    60 	skipped if rendering gets delayed too far and a more recent buffer is 
    61 	already available for rendering. The client can use these callbacks to 
    62 	maintain video rendering statistics.
    63 	@param 	aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId
    64 	*/
    65 	virtual void MvroBufferSkipped(TInt aBufferId) = 0;
    66 	};
    67 
    68 /** 
    69 CVideoRenderer is a utility class intended to be used to perform video 
    70 rendering to graphics surfaces on the behalf of a client. CVideoRenderer has 
    71 two modes: timed and non-timed.
    72 
    73 In timed mode the CVideoRenderer will attempt to schedule buffer updates as 
    74 close to the specified presentation time as possible. This is done by running 
    75 a high priority thread which is in responsible for rendering the buffers. 
    76 
    77 In non-timed mode the CVideoRenderer will not schedule buffer updates and will 
    78 instead simply render the buffer as soon as the preceding buffer has been 
    79 displayed one or more times. Non-timed mode requires the presence of a CActive
    80 Scheduler in the calling thread.
    81 
    82 @publishedPartner
    83 @prototype
    84 */
    85 NONSHARABLE_CLASS(CVideoRenderer) : public CBase
    86 	{
    87 public:
    88 
    89 	IMPORT_C static CVideoRenderer* NewL(MVideoRendererObserver& aObserver, TBool aTimed);
    90 	IMPORT_C ~CVideoRenderer();
    91 
    92 	IMPORT_C void GetSupportedFormatsL(RArray<TUncompressedVideoFormat>& aArray);
    93 	IMPORT_C void CreateSurfaceL(const TSize& aSize, TInt aNumBuffers, const TUncompressedVideoFormat& aFormat, TSurfaceId& aSurface);
    94 	IMPORT_C void DestroySurface(const TSurfaceId& aSurface);
    95 	IMPORT_C TVideoFrameBuffer* NextBuffer();
    96 	IMPORT_C void UpdateBuffer(TVideoFrameBuffer* aBuffer, const TTime& aPresentationTime);
    97 	IMPORT_C void ReleaseBuffer(TVideoFrameBuffer* aBuffer);
    98 
    99 	void Release();
   100 
   101 private:
   102 	CVideoRenderer(MVideoRendererObserver& aObserver, TBool aTimed);
   103 	void ConstructL();
   104 	void RegisterSurfaceL();
   105 	void UnregisterSurface();
   106 	
   107 	static TInt ThreadCreateFunction(TAny* aPtr);
   108 	static void ThreadTrapFunctionL(TAny* aPtr);
   109 
   110 private:
   111 	MVideoRendererObserver& iObserver;
   112 	TBool iTimed;
   113 	RSurfaceManager iSurfaceManager;
   114 	MVideoRendererRelay* iRendererRelay;
   115 	RArray<TUncompressedVideoFormat> iSupportedFormat;
   116 	TSurfaceId iSurfaceId;
   117 	CRendererBufferManager* iBufferManager;
   118 	RThread iRendererThread;
   119 	TBool iThreadCreated;
   120 	CThreadUndertaker* iRendererThreadUndertaker;
   121 	RWsSession iWsSession;
   122 	};
   123 
   124 #endif  // VIDEORENDERER_H