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