1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __VEITITLECLIPGENERATOR_H__ |
|
22 #define __VEITITLECLIPGENERATOR_H__ |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 #include <VedVideoClipGenerator.h> |
|
27 |
|
28 /* |
|
29 * UID of this generator. The Uids are only used to identify generators |
|
30 * in UI, the Engine does not use Uids for any purpose. |
|
31 */ |
|
32 #define KUidTitleClipGenerator TUid::Uid(0x00000002) |
|
33 |
|
34 |
|
35 // Forward declarations |
|
36 |
|
37 class CVeiTitleClipGenerator; |
|
38 //class CVeiTitleClipMainTitleFrameOperation; |
|
39 //class CVeiTitleClipScrollerFrameOperation; |
|
40 class CVeiTitleClipImageDecodeOperation; |
|
41 class CFbsBitmap; |
|
42 class CBitmapScaler; |
|
43 class CImageDecoder; |
|
44 class CFont; |
|
45 |
|
46 // Enumerations |
|
47 |
|
48 /** |
|
49 * Title clip style. |
|
50 */ |
|
51 enum TVeiTitleClipVerticalAlignment |
|
52 { |
|
53 EVeiTitleClipVerticalAlignmentTop, |
|
54 EVeiTitleClipVerticalAlignmentBottom, |
|
55 EVeiTitleClipVerticalAlignmentCenter |
|
56 }; |
|
57 |
|
58 /** |
|
59 * Title clip justification. |
|
60 */ |
|
61 enum TVeiTitleClipHorizontalAlignment |
|
62 { |
|
63 EVeiTitleClipHorizontalAlignmentLeft, |
|
64 EVeiTitleClipHorizontalAlignmentRight, |
|
65 EVeiTitleClipHorizontalAlignmentCenter |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Title clip transition. |
|
70 */ |
|
71 enum TVeiTitleClipTransition |
|
72 { |
|
73 EVeiTitleClipTransitionNone = 0, |
|
74 EVeiTitleClipTransitionScrollLeftToRight, |
|
75 EVeiTitleClipTransitionScrollRightToLeft, |
|
76 EVeiTitleClipTransitionScrollTopToBottom, |
|
77 EVeiTitleClipTransitionScrollBottomToTop, |
|
78 EVeiTitleClipTransitionFade |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 /** |
|
84 * Observer for title clip generator. |
|
85 */ |
|
86 class MVeiTitleClipGeneratorObserver |
|
87 { |
|
88 public: |
|
89 /** |
|
90 * Notifies that the title clip generator has finished loading and |
|
91 * preparing the background image. |
|
92 * |
|
93 * @param aGenerator generator that caused the event |
|
94 * @param aError error code |
|
95 */ |
|
96 virtual void NotifyTitleClipBackgroundImageLoadComplete(CVeiTitleClipGenerator& aGenerator, TInt aError) = 0; |
|
97 }; |
|
98 |
|
99 /** |
|
100 * Title clip generator. |
|
101 */ |
|
102 class CVeiTitleClipGenerator : public CVedVideoClipGenerator |
|
103 { |
|
104 public: |
|
105 |
|
106 /* Constructors / destructors. */ |
|
107 |
|
108 IMPORT_C static CVeiTitleClipGenerator* NewL(const TSize& aMaxResolution, |
|
109 TVeiTitleClipTransition aTransition, |
|
110 TVeiTitleClipHorizontalAlignment aHorizontalAlignment, |
|
111 TVeiTitleClipVerticalAlignment aVerticalAlignment); |
|
112 |
|
113 IMPORT_C static CVeiTitleClipGenerator* NewLC(const TSize& aMaxResolution, |
|
114 TVeiTitleClipTransition aTransition, |
|
115 TVeiTitleClipHorizontalAlignment aHorizontalAlignment, |
|
116 TVeiTitleClipVerticalAlignment aVerticalAlignment); |
|
117 |
|
118 IMPORT_C virtual ~CVeiTitleClipGenerator(); |
|
119 |
|
120 /* Property methods. */ |
|
121 |
|
122 IMPORT_C virtual TPtrC DescriptiveName() const; |
|
123 |
|
124 IMPORT_C virtual TUid Uid() const; |
|
125 |
|
126 IMPORT_C virtual TTimeIntervalMicroSeconds Duration() const; |
|
127 |
|
128 |
|
129 /* Video frame property methods. */ |
|
130 |
|
131 IMPORT_C virtual TInt VideoFrameCount() const; |
|
132 |
|
133 IMPORT_C virtual TTimeIntervalMicroSeconds VideoFrameStartTime(TInt aIndex) const; |
|
134 |
|
135 IMPORT_C virtual TTimeIntervalMicroSeconds VideoFrameEndTime(TInt aIndex) const; |
|
136 |
|
137 IMPORT_C virtual TTimeIntervalMicroSeconds VideoFrameDuration(TInt aIndex) const; |
|
138 |
|
139 IMPORT_C virtual TInt GetVideoFrameIndex(TTimeIntervalMicroSeconds aTime) const; |
|
140 |
|
141 IMPORT_C virtual TInt VideoFirstFrameComplexityFactor() const; |
|
142 |
|
143 IMPORT_C virtual TInt VideoFrameDifferenceFactor(TInt aIndex) const; |
|
144 |
|
145 |
|
146 /* Frame methods. */ |
|
147 |
|
148 IMPORT_C virtual void GetFrameL(MVedVideoClipGeneratorFrameObserver& aObserver, |
|
149 TInt aIndex, |
|
150 TSize* const aResolution, |
|
151 TDisplayMode aDisplayMode, |
|
152 TBool aEnhance, |
|
153 TInt aPriority); |
|
154 |
|
155 IMPORT_C virtual void CancelFrame(); |
|
156 |
|
157 |
|
158 |
|
159 /* New methods. */ |
|
160 |
|
161 /** |
|
162 * Sets the text for the generator. |
|
163 * |
|
164 * @param aText text for the generator |
|
165 */ |
|
166 IMPORT_C void SetTextL(const TDesC& aText); |
|
167 |
|
168 /** |
|
169 * Returns the text for this generator. |
|
170 * |
|
171 * @return text for the generator |
|
172 */ |
|
173 IMPORT_C TPtrC Text() const; |
|
174 |
|
175 /** |
|
176 * Returns the transition of this title screen clip. |
|
177 * |
|
178 * @return transition |
|
179 */ |
|
180 IMPORT_C TVeiTitleClipTransition Transition() const; |
|
181 |
|
182 /** |
|
183 * Returns the horizontal alignment. |
|
184 * |
|
185 * @return horizontal alignment |
|
186 */ |
|
187 IMPORT_C TVeiTitleClipHorizontalAlignment HorizontalAlignment() const; |
|
188 |
|
189 /** |
|
190 * Returns the vertical alignment. |
|
191 * |
|
192 * @return vertical alignment |
|
193 */ |
|
194 IMPORT_C TVeiTitleClipVerticalAlignment VerticalAlignment() const; |
|
195 |
|
196 /** |
|
197 * Sets the transiton and alignments. They are all tied together |
|
198 * to allow them to be set at once to avoid generating several |
|
199 * thumbnails when setting many options at the same time. |
|
200 * |
|
201 * @param aTransition transition for the generator. |
|
202 * @param aHorizontalAlignment horizontal alignment |
|
203 * @param aVerticalAlignment vertical alignment |
|
204 */ |
|
205 IMPORT_C void SetTransitionAndAlignmentsL(TVeiTitleClipTransition aTransition, |
|
206 TVeiTitleClipHorizontalAlignment aHorizontalAlignment, |
|
207 TVeiTitleClipVerticalAlignment aVerticalAlignment); |
|
208 |
|
209 /** |
|
210 * Returns the background color. |
|
211 * |
|
212 * @return background color. |
|
213 */ |
|
214 IMPORT_C TRgb BackgroundColor() const; |
|
215 |
|
216 /** |
|
217 * Sets the background color. This is used only if no background image |
|
218 * is set. |
|
219 * |
|
220 * @param aBacgroundColor background color |
|
221 */ |
|
222 IMPORT_C void SetBackgroundColorL(const TRgb& aBackgroundColor); |
|
223 |
|
224 /** |
|
225 * Returns the text color. |
|
226 * |
|
227 * @return text color. |
|
228 */ |
|
229 IMPORT_C TRgb TextColor() const; |
|
230 |
|
231 /** |
|
232 * Sets the text color. |
|
233 * |
|
234 * @param aBacgroundColor text color |
|
235 */ |
|
236 IMPORT_C void SetTextColorL(const TRgb& aTextColor); |
|
237 |
|
238 /** |
|
239 * Sets the background image. Transfers the ownership of the bitmap |
|
240 * to the generator. |
|
241 * |
|
242 * @param aBackgroundImage background image |
|
243 */ |
|
244 IMPORT_C void SetBackgroundImageL(const CFbsBitmap* aBackgroundImage); |
|
245 |
|
246 /** |
|
247 * Sets the background image from the specified file. |
|
248 * |
|
249 * @param aFilename filename for the image to load |
|
250 * @param aObserver observer to notify when loading is complete |
|
251 */ |
|
252 IMPORT_C void SetBackgroundImageL(const TDesC& aFilename, MVeiTitleClipGeneratorObserver& aObserver); |
|
253 |
|
254 /** |
|
255 * Returns the background image. |
|
256 * |
|
257 * @return background image |
|
258 */ |
|
259 IMPORT_C CFbsBitmap* BackgroundImage() const; |
|
260 |
|
261 /** |
|
262 * Sets the duration. |
|
263 * |
|
264 * @param aDuration duration |
|
265 */ |
|
266 IMPORT_C void SetDuration(const TTimeIntervalMicroSeconds& aDuration); |
|
267 |
|
268 /** |
|
269 * Sets the descriptive name. |
|
270 * |
|
271 * @param aDescriptiveName descriptive name |
|
272 */ |
|
273 IMPORT_C void SetDescriptiveNameL(const TDesC& aDescriptiveName); |
|
274 |
|
275 private: |
|
276 // from MVedVideoClipGeneratorFrameObserver |
|
277 void NotifyVideoClipGeneratorFrameCompleted(CVedVideoClipGenerator& aGenerator, TInt aError, CFbsBitmap* aBitmap); |
|
278 |
|
279 private: // constructors |
|
280 |
|
281 /** |
|
282 * First-phase constructor. |
|
283 * |
|
284 * @param aMaxResolution maximum resolution |
|
285 * @param aTransition transition |
|
286 * @param aHorizontalAlignment horizontal alignment |
|
287 * @param aVerticalAlignment vertical alignment |
|
288 */ |
|
289 CVeiTitleClipGenerator(const TSize& aMaxResolution, |
|
290 TVeiTitleClipTransition aTransition, |
|
291 TVeiTitleClipHorizontalAlignment aHorizontalAlignment, |
|
292 TVeiTitleClipVerticalAlignment aVerticalAlignment); |
|
293 |
|
294 /** |
|
295 * Second-phase constructor. |
|
296 */ |
|
297 void ConstructL(); |
|
298 |
|
299 private: // new methods |
|
300 |
|
301 /** |
|
302 * Wrap the input text into lines. |
|
303 */ |
|
304 void WrapTextToArrayL(const TDesC& aText); |
|
305 |
|
306 /** |
|
307 * Updates the first frame complexity factor value. |
|
308 */ |
|
309 void UpdateFirstFrameComplexityFactorL(); |
|
310 |
|
311 /** |
|
312 * Calculates the fading transition start and end indices. |
|
313 * |
|
314 * @param aInEndFrame for returning the end frame of in-transition |
|
315 * @param aOutStartFrame for returning the start frame of out-transition |
|
316 * @param aNumberOfFrames for returning number of frames |
|
317 */ |
|
318 void CalculateTransitionFrameIndices(TInt& aInEndFrame, TInt& aOutStartFrame) const; |
|
319 |
|
320 /** |
|
321 * Gets the text font suitable for the current frame resolution. |
|
322 */ |
|
323 void GetTextFont(TInt aFontDivisor = 0); |
|
324 |
|
325 /** |
|
326 * Draws wrapped texts on the specified bitmap. |
|
327 * |
|
328 * @param aBitmap bitmap to draw on |
|
329 * @param aTextPoint text starting point |
|
330 * @param aTextColor text color |
|
331 * @param aBgColor background color |
|
332 * @param aShadowColor shadow color |
|
333 */ |
|
334 void DrawWrappedTextL(CFbsBitmap& aBitmap, const TPoint& aTextPoint, const TRgb& aTextColor, |
|
335 const TRgb& aBgColor, const TRgb& aShadowColor, TBool aDrawBackground); |
|
336 |
|
337 /** |
|
338 * Finishes the GetFrameL() call. |
|
339 */ |
|
340 CFbsBitmap* FinishGetFrameL(TInt aError = KErrNone); |
|
341 |
|
342 /** |
|
343 * Synchronous method for getting the first frame for complexity |
|
344 * calculation. |
|
345 * |
|
346 * @return first frame |
|
347 */ |
|
348 CFbsBitmap* GetFirstFrameL(); |
|
349 |
|
350 /** |
|
351 * Draws the main title frame on a specified bitmap. |
|
352 * |
|
353 * @param aBitmap bitmap to draw on |
|
354 * @param aIndex index of the frame to draw |
|
355 */ |
|
356 void DrawMainTitleFrameL(CFbsBitmap& aBitmap, TInt aIndex); |
|
357 |
|
358 /** |
|
359 * Draws the scroll title frame on a specified bitmap. |
|
360 * |
|
361 * @param aBitmap bitmap to draw on |
|
362 * @param aIndex index of the frame to draw |
|
363 */ |
|
364 void DrawScrollTitleFrameL(CFbsBitmap& aBitmap, TInt aIndex); |
|
365 |
|
366 /** |
|
367 * Get the maximum frame rate, which is either the movie's |
|
368 * frame rate, of the hard-coded maximum value. |
|
369 * |
|
370 * @return max frames per second |
|
371 */ |
|
372 TInt MaximumFramerate() const; |
|
373 |
|
374 private: |
|
375 // Member variables |
|
376 |
|
377 /** First frame complexity factor. */ |
|
378 TInt iFirstFrameComplexityFactor; |
|
379 |
|
380 /** Text. */ |
|
381 HBufC* iText; |
|
382 |
|
383 /** Font for the text */ |
|
384 const CFont* iTextFont; |
|
385 |
|
386 /** Resolution used to calculate font size. */ |
|
387 TSize iGetFontResolution; |
|
388 |
|
389 /** Desciptive name. */ |
|
390 HBufC* iDescriptiveName; |
|
391 |
|
392 /** Wrapped text pointer array. */ |
|
393 CArrayFix<TPtrC>* iWrappedArray; |
|
394 |
|
395 /** Height of the wrapped text box. */ |
|
396 TInt iWrappedTextBoxHeight; |
|
397 |
|
398 /** Resolution. */ |
|
399 TSize iMaxResolution; |
|
400 |
|
401 /** Duration. */ |
|
402 TTimeIntervalMicroSeconds iDuration; |
|
403 |
|
404 /** Transition. */ |
|
405 TVeiTitleClipTransition iTransition; |
|
406 |
|
407 /** Horizontal alignment. */ |
|
408 TVeiTitleClipHorizontalAlignment iHorizontalAlignment; |
|
409 |
|
410 /** Vertical alignment. */ |
|
411 TVeiTitleClipVerticalAlignment iVerticalAlignment; |
|
412 |
|
413 /** Background image decode operation. */ |
|
414 CVeiTitleClipImageDecodeOperation* iDecodeOperation; |
|
415 |
|
416 /** Background color. */ |
|
417 TRgb iBackgroundColor; |
|
418 |
|
419 /** Text color. */ |
|
420 TRgb iTextColor; |
|
421 |
|
422 /** Flag for notifying setting change. */ |
|
423 TBool iSettingsChanged; |
|
424 |
|
425 /** Background image. */ |
|
426 CFbsBitmap* iBackgroundImage; |
|
427 |
|
428 /** Scaled background image. */ |
|
429 CFbsBitmap* iScaledBackgroundImage; |
|
430 |
|
431 /** Flag indicating that we should use the scaled bitmap. */ |
|
432 TBool iUseScaledImage; |
|
433 |
|
434 |
|
435 /* |
|
436 * Following member variables are temporary storage for the two-phase |
|
437 * GetFrameL. |
|
438 */ |
|
439 |
|
440 /** Observer. */ |
|
441 MVedVideoClipGeneratorFrameObserver* iGetFrameObserver; |
|
442 /** Index. */ |
|
443 TInt iGetFrameIndex; |
|
444 /** Resolution. */ |
|
445 TSize iGetFrameResolution; |
|
446 /** DisplayMode. */ |
|
447 TDisplayMode iGetFrameDisplayMode; |
|
448 /** Enhance flag. */ |
|
449 TBool iGetFrameEnhance; |
|
450 /** Priority. */ |
|
451 TInt iGetFramePriority; |
|
452 |
|
453 /* Operation classes need to be our friends. */ |
|
454 friend class CVeiTitleClipImageDecodeOperation; |
|
455 }; |
|
456 |
|
457 /** |
|
458 * Image decode operation. Helper class for decoding the image and |
|
459 * performing first-stage resizing. |
|
460 */ |
|
461 class CVeiTitleClipImageDecodeOperation : public CActive |
|
462 { |
|
463 public: |
|
464 /** |
|
465 * Factory constructor method. Constructs a decode operation. |
|
466 * |
|
467 * @param aGenerator generator that owns this operation |
|
468 * @param aObserver observer that will be notified when the |
|
469 * operation is complete |
|
470 * @param aFilename filename of the image to be decoded |
|
471 * @param aPriority priority of the active object |
|
472 * |
|
473 * @return constructed instance of decode operation |
|
474 */ |
|
475 static CVeiTitleClipImageDecodeOperation* NewL(CVeiTitleClipGenerator& aGenerator, |
|
476 MVeiTitleClipGeneratorObserver& aObserver, |
|
477 const TDesC& aFilename, |
|
478 TInt aPriority = CActive::EPriorityStandard); |
|
479 |
|
480 |
|
481 /** |
|
482 * Factory constructor method. Constructs a decode operation. |
|
483 * |
|
484 * @param aGenerator generator that owns this operation |
|
485 * @param aSourceBitmap source bitmap |
|
486 * @param aPriority priority of the active object |
|
487 * |
|
488 * @return constructed instance of decode operation |
|
489 */ |
|
490 static CVeiTitleClipImageDecodeOperation* NewL(CVeiTitleClipGenerator& aGenerator, |
|
491 CFbsBitmap* aSourceBitmap, |
|
492 TInt aPriority = CActive::EPriorityStandard); |
|
493 |
|
494 /** |
|
495 * Destructor. |
|
496 */ |
|
497 virtual ~CVeiTitleClipImageDecodeOperation(); |
|
498 |
|
499 virtual void RunL(); |
|
500 virtual void DoCancel(); |
|
501 virtual TInt RunError(TInt aError); |
|
502 |
|
503 /** |
|
504 * Starts the loading operation. |
|
505 * |
|
506 * @param aMaxResolution maximum resolution that will be used |
|
507 */ |
|
508 void StartLoadOperationL(const TSize& aMaxResolution); |
|
509 |
|
510 /** |
|
511 * Starts the scaling operation. |
|
512 * |
|
513 * @param aResolution resolution for the image |
|
514 */ |
|
515 void StartScalingOperationL(const TSize& aResolution); |
|
516 |
|
517 private: // methods |
|
518 /** |
|
519 * EPOC first-phase constructor. |
|
520 * |
|
521 * @param aGenerator generator that owns this decode operation |
|
522 * @param aObserver observer to notify when the operation is |
|
523 * complete |
|
524 * @param aPriority priority for the active object |
|
525 */ |
|
526 CVeiTitleClipImageDecodeOperation(CVeiTitleClipGenerator& aGenerator, |
|
527 MVeiTitleClipGeneratorObserver& aObserver, |
|
528 TInt aPriority = CActive::EPriorityStandard); |
|
529 |
|
530 /** |
|
531 * EPOC first-phase constructor. |
|
532 * |
|
533 * @param aGenerator generator that owns this decode operation |
|
534 * @param aSourceBitmap source bitmap |
|
535 * @param aPriority priority for the active object |
|
536 */ |
|
537 CVeiTitleClipImageDecodeOperation(CVeiTitleClipGenerator& aGenerator, |
|
538 CFbsBitmap* aSourceBitmap, |
|
539 TInt aPriority = CActive::EPriorityStandard); |
|
540 /** |
|
541 * EPOC second-phase constructor. |
|
542 * |
|
543 * @param aFilename filename to decode. |
|
544 */ |
|
545 void ConstructL(const TDesC& aFilename); |
|
546 |
|
547 private: // members |
|
548 |
|
549 /** |
|
550 * Enumeration for the decode phase. |
|
551 */ |
|
552 enum TDecodePhase |
|
553 { |
|
554 EPhaseNotStarted = 0, |
|
555 EPhaseLoading, |
|
556 EPhaseScaling, |
|
557 EPhaseComplete |
|
558 }; |
|
559 |
|
560 /** Decode phase. */ |
|
561 TDecodePhase iDecodePhase; |
|
562 |
|
563 /** Generator that owns this decoder operation. */ |
|
564 CVeiTitleClipGenerator& iGenerator; |
|
565 |
|
566 /** Observer.*/ |
|
567 MVeiTitleClipGeneratorObserver* iObserver; |
|
568 |
|
569 /** Decoder. */ |
|
570 CImageDecoder* iDecoder; |
|
571 |
|
572 /** Bitmap. */ |
|
573 CFbsBitmap* iBitmap; |
|
574 |
|
575 /** Scaler. */ |
|
576 CBitmapScaler* iScaler; |
|
577 |
|
578 /** Flag indicating whether to notify observer. */ |
|
579 TBool iNotifyObserver; |
|
580 }; |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 #endif // __VEITITLECLIPGENERATOR_H__ |
|
586 |
|