|
1 /* |
|
2 * Copyright (c) 2003 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: smilpresentation declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef SMILPRESENTATION_H |
|
21 #define SMILPRESENTATION_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <coedef.h> |
|
26 #include <w32std.h> |
|
27 |
|
28 #include <smiltextbuf.h> |
|
29 |
|
30 #include <smiltime.h> |
|
31 #include <smilevent.h> |
|
32 #include <smillinkedlist.h> |
|
33 #include <smilregioninterface.h> |
|
34 #include <smilplayerinterface.h> |
|
35 |
|
36 #include <smilmediafactoryinterface.h> |
|
37 |
|
38 #define JEEVES_MEDIUM_VOLUME 50 |
|
39 #define JEEVES_MAX_VOLUME 100 |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CSmilRootRegion; |
|
43 class CSmilSequence; |
|
44 class CSmilTimeContainer; |
|
45 class CSmilTransition; |
|
46 class CSmilAnchor; |
|
47 class MSmilTransitionFactory; |
|
48 class MSmilActive; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * A SMIL presentation |
|
54 */ |
|
55 class CSmilPresentation : public CActive |
|
56 { |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 */ |
|
62 IMPORT_C static CSmilPresentation* NewL(MSmilPlayer* aPlayer); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CSmilPresentation(); |
|
68 |
|
69 |
|
70 public: // New functions |
|
71 |
|
72 /** |
|
73 * Returns the MSmilPlayer object associated with this presentation |
|
74 */ |
|
75 inline MSmilPlayer* GetPlayer(); |
|
76 |
|
77 /** |
|
78 * Called from outside of the engine to update the given |
|
79 * region within the presentation area, using the given |
|
80 * graphics context The engine draws the region |
|
81 * backgrounds and the media objects that are not |
|
82 * responsible for performing their own drawing. |
|
83 * |
|
84 * This method should ultimately be called by the Draw |
|
85 * method of the CCoeControl that contains the SMIL |
|
86 * presentation. It should also be called as a result |
|
87 * of MSmilPlayer::Redraw() call. |
|
88 */ |
|
89 |
|
90 IMPORT_C void Draw(CGraphicsContext& aGc, const TRect& aRect); |
|
91 |
|
92 /** |
|
93 * Starts the presentation playback. |
|
94 */ |
|
95 IMPORT_C void PlayL(); |
|
96 |
|
97 |
|
98 /** |
|
99 * Stops the presentation playback, resetting the |
|
100 * timeline to the beginning and possibly freeing some |
|
101 * allocated resouces. |
|
102 */ |
|
103 IMPORT_C void StopL(); |
|
104 |
|
105 |
|
106 /** |
|
107 * Pauses the presentation playback. |
|
108 */ |
|
109 IMPORT_C void Pause(); |
|
110 |
|
111 |
|
112 /** |
|
113 * Resumes the presentation playback. |
|
114 */ |
|
115 IMPORT_C void Resume(); |
|
116 |
|
117 |
|
118 /** |
|
119 * Tries to seek the presentation to the given position |
|
120 * in the timeline. If this fails, the presentation is |
|
121 * stopped. |
|
122 * |
|
123 * Returns TRUE if succesful. |
|
124 */ |
|
125 IMPORT_C TBool SeekL(TSmilTime aTo); |
|
126 |
|
127 |
|
128 /** |
|
129 * Returns the base URL of the presentation |
|
130 */ |
|
131 IMPORT_C TPtrC BaseUrl() const; |
|
132 |
|
133 |
|
134 /** |
|
135 * Sets the base URL of the presentation |
|
136 */ |
|
137 IMPORT_C void SetBaseUrlL(const TDesC& aUrl); |
|
138 |
|
139 |
|
140 /** |
|
141 * Current position on presentation timeline |
|
142 */ |
|
143 IMPORT_C TSmilTime CurrentTime(); |
|
144 |
|
145 |
|
146 enum TPresentationState |
|
147 { |
|
148 EPlaying, |
|
149 EStopped, |
|
150 EPaused |
|
151 }; |
|
152 |
|
153 /** |
|
154 * State of the presentation: |
|
155 * |
|
156 * EStopped |
|
157 * EPlaying |
|
158 * EPaused |
|
159 */ |
|
160 IMPORT_C TPresentationState State(); |
|
161 |
|
162 |
|
163 IMPORT_C TSmilTime Duration() const; |
|
164 |
|
165 /** |
|
166 * Submits an event to the Engine. Events are |
|
167 * characterised by event name and event source. |
|
168 * |
|
169 * Event source is a name of a source element. If |
|
170 * the source is within the timegraph the name can |
|
171 * be obtained using TSmilObject::GetName() method. |
|
172 * |
|
173 * Event name is a name of an event class, for example |
|
174 * "activateEvent". |
|
175 */ |
|
176 IMPORT_C void SubmitEventL(const TDesC& aName, const TDesC& aSource); |
|
177 |
|
178 IMPORT_C void SubmitEventL(const TDesC& aName, CSmilObject* aSource); |
|
179 |
|
180 /** |
|
181 * Convenience method for generating UI events |
|
182 */ |
|
183 IMPORT_C void MouseClickedL(const TPoint& aPoint); |
|
184 |
|
185 /** |
|
186 * Move media focus maintained by the SMIL engine to given direction. |
|
187 * HandleKeyEvent replaces this method in most cases. |
|
188 */ |
|
189 IMPORT_C void MoveFocusL(TInt aX, TInt aY); |
|
190 |
|
191 /** |
|
192 * Remove focus if exists |
|
193 */ |
|
194 IMPORT_C void CancelFocusL(); |
|
195 |
|
196 /** |
|
197 * Return currently focused object, or null |
|
198 */ |
|
199 IMPORT_C CSmilObject* FocusedObject() const; |
|
200 |
|
201 /** |
|
202 * Generate activate event for currently focused media (if there is one) |
|
203 */ |
|
204 IMPORT_C void ActivateFocusedL(); |
|
205 |
|
206 /** |
|
207 * Set to true to enable slide mode used for playing back Conformance |
|
208 * Document MMS messages. Use NextSlide(), CurrentSlide(), SlideCount() to navigate. |
|
209 * |
|
210 */ |
|
211 inline void SetSlideModeEnabled(TBool aEnable); |
|
212 |
|
213 inline TBool SlideModeEnabled() const; |
|
214 |
|
215 /** |
|
216 * Handle Symbian OS key event. This may generate SMIL events, may move key focus |
|
217 * and may cause media to scroll |
|
218 */ |
|
219 IMPORT_C TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
220 |
|
221 /** |
|
222 * Handle Symbian OS mouse event. This may generate SMIL events, may move key focus |
|
223 * and may cause media to scroll |
|
224 */ |
|
225 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
226 /** |
|
227 * Return the sequence number (starting from 1) of current slide (top level <body> child element) |
|
228 */ |
|
229 IMPORT_C TInt CurrentSlide() const; |
|
230 |
|
231 /** |
|
232 * Return total number of slides in the presentation (top level <body> child elements) |
|
233 */ |
|
234 IMPORT_C TInt SlideCount() const; |
|
235 |
|
236 /** |
|
237 * Go to next slide in the presentation: |
|
238 */ |
|
239 IMPORT_C TBool NextSlideL(); |
|
240 |
|
241 /** |
|
242 * Go to previous slide in the presentation: |
|
243 */ |
|
244 IMPORT_C TBool PreviousSlideL(); |
|
245 |
|
246 /** |
|
247 * Returns true if presentation background is transparent |
|
248 */ |
|
249 IMPORT_C TBool IsTransparent() const; |
|
250 |
|
251 /** |
|
252 * If true, using two-way (up-down) navigation mode, four-way otherwise |
|
253 */ |
|
254 inline TBool TwoWayNavigation() const; |
|
255 |
|
256 /** |
|
257 * If set to true (default), use two-way (up-down) navigation mode, four-way otherwise |
|
258 */ |
|
259 inline void SetTwoWayNavigation(TBool aEnable); |
|
260 |
|
261 /** |
|
262 * If set to true (default), scale down oversized SMIL layouts |
|
263 */ |
|
264 inline TBool ScaleLayout() const; |
|
265 |
|
266 /** |
|
267 * If set to true (default), scale down oversized SMIL layouts |
|
268 */ |
|
269 inline void SetScaleLayout(TBool aScale); |
|
270 |
|
271 /** |
|
272 * Volume getter function. SetVolume notifies renderes about changes. |
|
273 * Range: [0..100] |
|
274 */ |
|
275 inline TInt Volume(); |
|
276 |
|
277 /** |
|
278 * Volume setter function. SetVolume notifies renderes about changes. |
|
279 * Range: [0..100] |
|
280 */ |
|
281 IMPORT_C void SetVolume(const TInt aVolume); |
|
282 |
|
283 |
|
284 enum TEndAction { EStopAtEnd, EPauseAtEnd, ERepeatAtEnd }; |
|
285 |
|
286 /** |
|
287 * What to do at the end of the presentation. |
|
288 * Values: EStopAtEnd, EPauseAtEnd, ERepeatAtEnd |
|
289 */ |
|
290 inline void SetEndAction(TEndAction aEndAction); |
|
291 |
|
292 /** |
|
293 * What to do at the end of the presentation. |
|
294 * Values: EStopAtEnd, EPauseAtEnd, ERepeatAtEnd |
|
295 */ |
|
296 inline TEndAction GetEndAction() const; |
|
297 |
|
298 |
|
299 enum TStartAction { EDoNothing, EShowFirstFrame }; |
|
300 |
|
301 /** |
|
302 * What to do when then the presentation is in the beginning |
|
303 * (stopped) and not playing. |
|
304 * Values: EDoNothing, EShowFirstFrame |
|
305 */ |
|
306 inline void SetStartAction(TStartAction aStartAction); |
|
307 |
|
308 /** |
|
309 * What to do when then the presentation is in the beginning |
|
310 * (stopped) and not playing. |
|
311 * Values: EDoNothing, EShowFirstFrame |
|
312 */ |
|
313 inline TStartAction GetStartAction() const; |
|
314 |
|
315 |
|
316 /** |
|
317 * Sets the keyboards focus navigation order |
|
318 * EFalse: from left to right |
|
319 * ETrue: from right to left |
|
320 */ |
|
321 inline void SetRTLNavigation(TBool aRTL); |
|
322 |
|
323 |
|
324 /** |
|
325 * Gets the keyboards focus navigation order |
|
326 * EFalse: from left to right |
|
327 * ETrue: from right to left |
|
328 */ |
|
329 inline TBool RTLNavigation() const; |
|
330 |
|
331 inline void SetMaxDownUpScaling( TReal aDown, TReal aUp ); |
|
332 |
|
333 TReal32 GetMaxDownScaling(); |
|
334 |
|
335 TReal32 GetMaxUpScaling(); |
|
336 |
|
337 /** |
|
338 * Returns true if the presentation contains interactive elements |
|
339 * (besides scrollable media) |
|
340 */ |
|
341 IMPORT_C TBool IsInteractive() const; |
|
342 |
|
343 IMPORT_C TReal32 GetScalingFactor(); |
|
344 |
|
345 /** |
|
346 * Returns root region rectangle. |
|
347 */ |
|
348 IMPORT_C TRect RootRegionRect() const; |
|
349 |
|
350 public: |
|
351 |
|
352 inline CSmilRootRegion* GetLayout(); |
|
353 void SetLayout(CSmilRootRegion* aRoot); |
|
354 |
|
355 inline CSmilTimeContainer* GetTimegraph(); |
|
356 void SetTimegraph(CSmilTimeContainer* aBody); |
|
357 |
|
358 |
|
359 MSmilMediaFactory* GetMediaFactory(); |
|
360 MSmilTransitionFactory* GetTransitionFactory(); |
|
361 |
|
362 void SetFocusedObjectL(CSmilObject* aFocus); |
|
363 |
|
364 void AddTransitionL(CSmilTransition* aTransition); |
|
365 void ClearTransitions(); |
|
366 CSmilTransition* FindTransition(const TDesC& aName); |
|
367 |
|
368 void ProcessScheduledL(); |
|
369 void ProcessScheduledRecL(); |
|
370 void ScheduleNext(); |
|
371 void ClearSchedule(); |
|
372 void ScheduleUpdateL(const TSmilTime& aTime, MSmilActive* aActive = 0); |
|
373 |
|
374 void PrintDebug(); |
|
375 |
|
376 TSmilTime RealTime(); |
|
377 |
|
378 TBool SeekL(CSmilObject* aTo); |
|
379 |
|
380 void SubmitEventL(const TSmilEvent& aEvent, TSmilTime aNow = TSmilTime::KUnresolved); |
|
381 |
|
382 void ReadyL(); |
|
383 |
|
384 void ActivateAnchorL(const CSmilAnchor* anchor); |
|
385 |
|
386 void AfterL(MSmilActive* aActive, const TSmilTime& aDelay, TBool aLazy); |
|
387 void CancelActive(MSmilActive* aActive); |
|
388 |
|
389 inline TBool MediaSelected() const; |
|
390 |
|
391 void UpdateFocusListL(); |
|
392 |
|
393 protected: |
|
394 |
|
395 |
|
396 friend class CSmilParser; |
|
397 |
|
398 /** constructor */ |
|
399 CSmilPresentation(); |
|
400 void ConstructL(MSmilPlayer* aPlayer); |
|
401 |
|
402 virtual void RunL(); |
|
403 virtual void DoCancel(); |
|
404 |
|
405 void PauseInternal(); |
|
406 |
|
407 TBool iSlideModeEnabled; |
|
408 |
|
409 void AutoFocusL(); |
|
410 TBool SelectionKeyPressedL(); |
|
411 TBool MoveDirectionL(TInt aX, TInt aY); |
|
412 |
|
413 |
|
414 private: |
|
415 |
|
416 CSmilRootRegion* iLayout; |
|
417 CSmilTimeContainer* iTimegraph; |
|
418 |
|
419 RSmilTextBuf iBaseUrl; |
|
420 |
|
421 MSmilPlayer* iPlayer; |
|
422 |
|
423 TSmilTime iClock; |
|
424 |
|
425 TPresentationState iState; |
|
426 |
|
427 RTimer iTimer; |
|
428 |
|
429 |
|
430 TTime iStartTime; |
|
431 TSmilTime iAccumulatedTime; |
|
432 |
|
433 struct ScheduleItem |
|
434 { |
|
435 ScheduleItem* iNext; |
|
436 TSmilTime iTime; |
|
437 MSmilActive* iActive; |
|
438 }; |
|
439 |
|
440 ScheduleItem* iSchedule; |
|
441 |
|
442 CSmilTransition* iTransitions; |
|
443 CSmilObject* iFocusedObject; |
|
444 CSmilMedia* iInBounds; |
|
445 |
|
446 TInt iVolume; |
|
447 |
|
448 TBool iMediaSelected; |
|
449 |
|
450 TBool iEventsEnabled; |
|
451 TBool iSchedulingEnabled; |
|
452 TBool iProcessing; |
|
453 |
|
454 TEndAction iEndAction; |
|
455 TStartAction iStartAction; |
|
456 |
|
457 TTime iLastEventTime; |
|
458 |
|
459 TBool iTwoWayNavigation; |
|
460 |
|
461 CLinkedList<CSmilObject*> iFocusOrder; |
|
462 |
|
463 const CSmilAnchor* iDelayedAnchor; |
|
464 |
|
465 TBool iFirstFramePaused; |
|
466 |
|
467 TBool iRTL; |
|
468 |
|
469 TReal iDown; |
|
470 TReal iUp; |
|
471 }; |
|
472 |
|
473 #include <smilpresentation.inl> |
|
474 |
|
475 #endif // ?INCLUDE_H |
|
476 |
|
477 // End of File |