sl@0: // Copyright (c) 2007-2009 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: #ifndef VIDEORENDERER_H sl@0: #define VIDEORENDERER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // class declaration sl@0: class TVideoFrameBuffer; sl@0: class MVideoRendererRelay; sl@0: class CRendererBufferManager; sl@0: class CThreadUndertaker; sl@0: sl@0: /** The interface implemented by clients using CVideoRenderer sl@0: sl@0: An object of a class which implements this interface should be passed to CVideoRenderer::NewL(). sl@0: sl@0: @publishedPartner sl@0: @released sl@0: @see CVideoRenderer sl@0: */ sl@0: class MVideoRendererObserver sl@0: { sl@0: public: sl@0: /** sl@0: Called when the renderer has a new video buffer available. The renderer sl@0: will call this once for each surface buffer when a surface is created, and sl@0: subsequently for each buffer that becomes available after it has been sl@0: updated to the display or released. sl@0: */ sl@0: virtual void MvroVideoBufferAvailable() = 0; sl@0: sl@0: /** sl@0: Called when a buffer has been displayed. The client can use these sl@0: callbacks to maintain rendering delay statistics. sl@0: @param aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId sl@0: @param aTime The system clock time when the buffer was displayed sl@0: */ sl@0: virtual void MvroBufferDisplayed(TInt aBufferId, const TTime& aTime) = 0; sl@0: sl@0: /** sl@0: Called when a buffer was skipped in the rendering process. Buffers can be sl@0: skipped if rendering gets delayed too far and a more recent buffer is sl@0: already available for rendering. The client can use these callbacks to sl@0: maintain video rendering statistics. sl@0: @param aBufferId Identifies the buffer, equal to TVideoFrameBuffer.iBufferId sl@0: */ sl@0: virtual void MvroBufferSkipped(TInt aBufferId) = 0; sl@0: }; sl@0: sl@0: /** sl@0: CVideoRenderer is a utility class intended to be used to perform video sl@0: rendering to graphics surfaces on the behalf of a client. CVideoRenderer has sl@0: two modes: timed and non-timed. sl@0: sl@0: In timed mode the CVideoRenderer will attempt to schedule buffer updates as sl@0: close to the specified presentation time as possible. This is done by running sl@0: a high priority thread which is in responsible for rendering the buffers. sl@0: sl@0: In non-timed mode the CVideoRenderer will not schedule buffer updates and will sl@0: instead simply render the buffer as soon as the preceding buffer has been sl@0: displayed one or more times. Non-timed mode requires the presence of a CActive sl@0: Scheduler in the calling thread. sl@0: sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: NONSHARABLE_CLASS(CVideoRenderer) : public CBase sl@0: { sl@0: public: sl@0: sl@0: IMPORT_C static CVideoRenderer* NewL(MVideoRendererObserver& aObserver, TBool aTimed); sl@0: IMPORT_C ~CVideoRenderer(); sl@0: sl@0: IMPORT_C void GetSupportedFormatsL(RArray& aArray); sl@0: IMPORT_C void CreateSurfaceL(const TSize& aSize, TInt aNumBuffers, const TUncompressedVideoFormat& aFormat, TSurfaceId& aSurface); sl@0: IMPORT_C void DestroySurface(const TSurfaceId& aSurface); sl@0: IMPORT_C TVideoFrameBuffer* NextBuffer(); sl@0: IMPORT_C void UpdateBuffer(TVideoFrameBuffer* aBuffer, const TTime& aPresentationTime); sl@0: IMPORT_C void ReleaseBuffer(TVideoFrameBuffer* aBuffer); sl@0: sl@0: void Release(); sl@0: sl@0: private: sl@0: CVideoRenderer(MVideoRendererObserver& aObserver, TBool aTimed); sl@0: void ConstructL(); sl@0: void RegisterSurfaceL(); sl@0: void UnregisterSurface(); sl@0: sl@0: static TInt ThreadCreateFunction(TAny* aPtr); sl@0: static void ThreadTrapFunctionL(TAny* aPtr); sl@0: sl@0: private: sl@0: MVideoRendererObserver& iObserver; sl@0: TBool iTimed; sl@0: RSurfaceManager iSurfaceManager; sl@0: MVideoRendererRelay* iRendererRelay; sl@0: RArray iSupportedFormat; sl@0: TSurfaceId iSurfaceId; sl@0: CRendererBufferManager* iBufferManager; sl@0: RThread iRendererThread; sl@0: TBool iThreadCreated; sl@0: CThreadUndertaker* iRendererThreadUndertaker; sl@0: RWsSession iWsSession; sl@0: }; sl@0: sl@0: #endif // VIDEORENDERER_H