66
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: This class is used for playing animated images.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMMAANIMATIONPLAYER_H
|
|
20 |
#define CMMAANIMATIONPLAYER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <w32std.h>
|
|
24 |
#include "cmmaplayer.h"
|
|
25 |
#include "mmmaguiplayer.h"
|
|
26 |
#include "mmmasnapshot.h"
|
|
27 |
#include "rmmatempfile.h"
|
|
28 |
#include "MIHLViewerObserver.h"
|
|
29 |
#include "MIHLImageViewer.h"
|
|
30 |
|
|
31 |
// FORWARD DECLARATIONS
|
|
32 |
class CMMAEventSource;
|
|
33 |
class CMMAAnimationWindow;
|
|
34 |
class MIHLFileImage;
|
|
35 |
class MIHLBitmap;
|
|
36 |
class CFbsBitmap;
|
|
37 |
|
|
38 |
// CONSTANTS
|
|
39 |
_LIT(KMMAVideoPlayer, "VideoPlayer");
|
|
40 |
|
|
41 |
NONSHARABLE_CLASS(MMMAAnimationObserver)
|
|
42 |
{
|
|
43 |
public: // new methods
|
|
44 |
/**
|
|
45 |
* Listener for animation advancing
|
|
46 |
* @param aFrame current frame
|
|
47 |
* @param aMediaTime current media time
|
|
48 |
*/
|
|
49 |
virtual void AnimationAdvancedL(TInt aFrame, TInt64 aMediaTime) = 0;
|
|
50 |
};
|
|
51 |
|
|
52 |
// CLASS DECLARATION
|
|
53 |
/**
|
|
54 |
* This class is used for playing animated images.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
NONSHARABLE_CLASS(CMMAAnimationPlayer): public CMMAPlayer,
|
|
58 |
public MMMAGuiPlayer,
|
|
59 |
public MMMASnapshot,
|
|
60 |
public MIHLViewerObserver
|
|
61 |
{
|
|
62 |
public: // Construction
|
|
63 |
static CMMAAnimationPlayer* NewLC();
|
|
64 |
static CMMAAnimationPlayer* NewLC(const TDesC& aFileName);
|
|
65 |
|
|
66 |
// Destructor
|
|
67 |
~CMMAAnimationPlayer();
|
|
68 |
|
|
69 |
protected:
|
|
70 |
// C++ constructor
|
|
71 |
CMMAAnimationPlayer();
|
|
72 |
void ConstructL();
|
|
73 |
|
|
74 |
public: // from CMMAPlayer
|
|
75 |
void SetPlayerListenerObjectL(jobject aListenerObject,
|
|
76 |
JNIEnv* aJni,
|
|
77 |
MMMAEventPoster* aEventPoster);
|
|
78 |
void RealizeL();
|
|
79 |
void PrefetchL();
|
|
80 |
void StartL(TBool aPostEvent);
|
|
81 |
void StopL(TBool aPostEvent);
|
|
82 |
void DeallocateL();
|
|
83 |
void GetDuration(TInt64* aDuration);
|
|
84 |
const TDesC& Type();
|
|
85 |
void SetMediaTimeL(TInt64* aTime);
|
|
86 |
void GetMediaTime(TInt64* aMediaTime);
|
|
87 |
|
|
88 |
public: // from CMMAPlayer/MMMASourceStreamListener
|
|
89 |
void ReadCompletedL(TInt aStatus, const TDesC8& aData);
|
|
90 |
|
|
91 |
public: // new methods
|
|
92 |
void PrefetchFileL();
|
|
93 |
void PrefetchDataL(const TDesC8& aData);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Check whether this player is playing from a file locator
|
|
97 |
* @return ETrue if is a file player, EFalse otherwise
|
|
98 |
*/
|
|
99 |
TBool IsFilePlayer();
|
|
100 |
|
|
101 |
// Finds current frame for given media time
|
|
102 |
TInt FindFrame(TInt64 aTime);
|
|
103 |
|
|
104 |
// Calculates media time for specified frame
|
|
105 |
TInt64 MediaTimeForFrame(TInt aFrameIndex);
|
|
106 |
|
|
107 |
// Frame duration of specified frame
|
|
108 |
TTimeIntervalMicroSeconds32 FrameDuration(TInt aFrameIndex);
|
|
109 |
|
|
110 |
MIHLImageViewer* Viewer();
|
|
111 |
|
|
112 |
// Setter for frame listener, used for stop time control
|
|
113 |
void SetAnimationObserver(MMMAAnimationObserver* aAnimationObserver);
|
|
114 |
|
|
115 |
/**
|
|
116 |
* @param aRate Rate to set in "milli-percentage"..
|
|
117 |
* @return Actual rate set.
|
|
118 |
*/
|
|
119 |
TInt SetRateL(TInt aRate);
|
|
120 |
|
|
121 |
/**
|
|
122 |
* @return The current playback rate in "milli-percentage".
|
|
123 |
*/
|
|
124 |
TInt RateL();
|
|
125 |
|
|
126 |
private: // new methods
|
|
127 |
void PrepareViewerL();
|
|
128 |
void ProcessCurrentFrameL();
|
|
129 |
|
|
130 |
public: // From MMMAGuiPlayer
|
|
131 |
void SetDisplayL(MMMADisplay* aDisplay);
|
|
132 |
TSize SourceSize();
|
|
133 |
void NotifyWithStringEvent(CMMAPlayerEvent::TEventType aEventType,
|
|
134 |
const TDesC& aStringEventData);
|
|
135 |
|
|
136 |
MMMASnapshot* SnapshoterL();
|
|
137 |
|
|
138 |
public: // From MMMASnapshot
|
|
139 |
MMMASnapshot::TEncoding TakeSnapshotL(TRequestStatus* aStatus,
|
|
140 |
const TSize& aSize,
|
|
141 |
const CMMAImageSettings& aSettings);
|
|
142 |
CFbsBitmap* SnapshotBitmap();
|
|
143 |
HBufC8* SnapshotEncoded();
|
|
144 |
|
|
145 |
public: // From MIHLViewerObserver
|
|
146 |
virtual void ViewerBitmapChangedL();
|
|
147 |
virtual void ViewerError(TInt aError);
|
|
148 |
|
|
149 |
private: // Data
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Display to draw animation.
|
|
153 |
*/
|
|
154 |
MMMADisplay* iDisplay;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Window to draw animation.
|
|
158 |
*/
|
|
159 |
CMMAAnimationWindow* iWindow;
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Dimensions of animation.
|
|
163 |
*/
|
|
164 |
TSize iSourceSize;
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Animated image to play. Owned.
|
|
168 |
*/
|
|
169 |
MIHLFileImage* iImage;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Destination bitmap for animation. Owned.
|
|
173 |
*/
|
|
174 |
MIHLBitmap* iBitmap;
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Animation viewer. Owned.
|
|
178 |
*/
|
|
179 |
MIHLImageViewer* iViewer;
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Bitmap for snapshot. Ownership is transferred for
|
|
183 |
* snapshot requester, but owned if not null.
|
|
184 |
*/
|
|
185 |
CFbsBitmap* iSnapshotBitmap;
|
|
186 |
|
|
187 |
/**
|
|
188 |
* File system session for IHL interfacing
|
|
189 |
*/
|
|
190 |
RFs iFSession;
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Animation frame count. Held locally for optimization.
|
|
194 |
*/
|
|
195 |
TInt iFrameCount;
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Possible file name, owned
|
|
199 |
*/
|
|
200 |
HBufC* iFileName;
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Current Media Time
|
|
204 |
*/
|
|
205 |
TInt64 iMediaTime;
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Animation listener
|
|
209 |
*/
|
|
210 |
MMMAAnimationObserver* iAnimationObserver;
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Current rate
|
|
214 |
*/
|
|
215 |
TInt iCurrentRate;
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Hold the information whether playback should be started
|
|
219 |
* from beginning on next start or from current position
|
|
220 |
*/
|
|
221 |
TBool iEndReached;
|
|
222 |
|
|
223 |
/**
|
|
224 |
* EndOfMedia will be delivered when next frame arrives if
|
|
225 |
* iSendEndOfMediaOnNextFrame is true
|
|
226 |
*/
|
|
227 |
TBool iSendEndOfMediaOnNextFrame;
|
|
228 |
};
|
|
229 |
|
|
230 |
#endif // CMMAANIMATIONPLAYER_H
|