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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef VIDEORENDERER_H
17 #define VIDEORENDERER_H
21 #include <graphics/surface.h>
22 #include <graphics/surfacemanager.h>
23 #include <mmf/devvideo/devvideobase.h>
26 class TVideoFrameBuffer;
27 class MVideoRendererRelay;
28 class CRendererBufferManager;
29 class CThreadUndertaker;
31 /** The interface implemented by clients using CVideoRenderer
33 An object of a class which implements this interface should be passed to CVideoRenderer::NewL().
39 class MVideoRendererObserver
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.
48 virtual void MvroVideoBufferAvailable() = 0;
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
56 virtual void MvroBufferDisplayed(TInt aBufferId, const TTime& aTime) = 0;
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
65 virtual void MvroBufferSkipped(TInt aBufferId) = 0;
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.
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.
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.
85 NONSHARABLE_CLASS(CVideoRenderer) : public CBase
89 IMPORT_C static CVideoRenderer* NewL(MVideoRendererObserver& aObserver, TBool aTimed);
90 IMPORT_C ~CVideoRenderer();
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);
102 CVideoRenderer(MVideoRendererObserver& aObserver, TBool aTimed);
104 void RegisterSurfaceL();
105 void UnregisterSurface();
107 static TInt ThreadCreateFunction(TAny* aPtr);
108 static void ThreadTrapFunctionL(TAny* aPtr);
111 MVideoRendererObserver& iObserver;
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;
124 #endif // VIDEORENDERER_H