|
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 |
|
22 // INCLUDE FILES |
|
23 // System includes |
|
24 #include <AknIconUtils.h> // AknIconUtils |
|
25 #include <eikenv.h> // iEikonEnv |
|
26 #include <trimformms.rsg> // Video Editor resources |
|
27 #include <StringLoader.h> // StringLoader |
|
28 |
|
29 #include <aknbiditextutils.h> |
|
30 #include <gulfont.h> |
|
31 |
|
32 #include <aknsdrawutils.h> |
|
33 #include <aknsdatacontext.h> |
|
34 #include <aknsbasicbackgroundcontrolcontext.h> |
|
35 |
|
36 #include <AknProgressDialog.h> |
|
37 #include <eikprogi.h> |
|
38 #include <AknWaitDialog.h> |
|
39 |
|
40 |
|
41 // User includes |
|
42 #include "VeiTrimForMmsContainer.h" |
|
43 #include "VeiVideoDisplay.h" |
|
44 #include "VideoEditorCommon.h" |
|
45 //#include "VideoEditorHelp.hlp.hrh" // Topic contexts (literals) |
|
46 #include "veiframetaker.h" |
|
47 #include "VeiTrimForMmsView.h" |
|
48 #include "VeiCutterBar.h" |
|
49 #include "VeiVideoEditorSettings.h" |
|
50 #include "VideoEditorUtils.h" |
|
51 #include "VideoEditorDebugUtils.h" |
|
52 |
|
53 void CVeiTrimForMmsContainer::DialogDismissedL( TInt /*aButtonId*/ ) |
|
54 { |
|
55 iProgressInfo = NULL; |
|
56 } |
|
57 |
|
58 |
|
59 CVeiTrimForMmsContainer* CVeiTrimForMmsContainer::NewL( const TRect& aRect, |
|
60 CVedMovie& aMovie, CVeiTrimForMmsView& aView ) |
|
61 { |
|
62 CVeiTrimForMmsContainer* self = CVeiTrimForMmsContainer::NewLC( aRect, |
|
63 aMovie, |
|
64 aView ); |
|
65 CleanupStack::Pop( self ); |
|
66 |
|
67 return self; |
|
68 } |
|
69 |
|
70 CVeiTrimForMmsContainer* CVeiTrimForMmsContainer::NewLC( const TRect& aRect, |
|
71 CVedMovie& aMovie, |
|
72 CVeiTrimForMmsView& aView) |
|
73 { |
|
74 CVeiTrimForMmsContainer* self = |
|
75 new(ELeave)CVeiTrimForMmsContainer( aMovie, aView ); |
|
76 |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL( aRect ); |
|
79 |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 CVeiTrimForMmsContainer::CVeiTrimForMmsContainer( CVedMovie& aMovie, CVeiTrimForMmsView& aView ): |
|
85 iLastKeyLeftOrRight(EFalse), |
|
86 iMovie(aMovie), |
|
87 iView( aView ) |
|
88 |
|
89 { |
|
90 } |
|
91 |
|
92 |
|
93 void CVeiTrimForMmsContainer::ConstructL( const TRect& aRect ) |
|
94 { |
|
95 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::ConstructL: in"); |
|
96 |
|
97 // Make this compound control window-owning. |
|
98 CreateWindowL(); |
|
99 |
|
100 iMovie.RegisterMovieObserverL( this ); |
|
101 |
|
102 // Read the texts shown above the thumbnails from resources |
|
103 iStartText = StringLoader::LoadL( R_VED_THUMBNAIL_START_TEXT, iEikonEnv ); |
|
104 iEndText = StringLoader::LoadL( R_VED_THUMBNAIL_END_TEXT, iEikonEnv ); |
|
105 |
|
106 iSeekPos = TTimeIntervalMicroSeconds( 0 ); |
|
107 |
|
108 iVideoDisplayStart = CVeiVideoDisplay::NewL( iVideoDisplayStartRect, this, *this ); |
|
109 |
|
110 iVideoDisplayEnd = CVeiVideoDisplay::NewL( iVideoDisplayEndRect, this, *this ); |
|
111 |
|
112 iCutterBar = CVeiCutterBar::NewL( this ); |
|
113 iCutterBar->SetPlayHeadVisible( EFalse ); |
|
114 iVideoDisplay = CVeiVideoDisplay::NewL( aRect, this, *this ); |
|
115 |
|
116 iFrameTaker = CVeiFrameTaker::NewL( *this ); |
|
117 |
|
118 /* Timer to keep back light on when user is not giving key events */ |
|
119 iScreenLight = CVeiDisplayLighter::NewL(); |
|
120 CVeiVideoEditorSettings::GetMaxMmsSizeL( iMaxMmsSize ); |
|
121 /* SharedData returns maxmmssize in kbytes. Change it to bytes(1000) and |
|
122 add some margin to final value.*/ |
|
123 iMaxMmsSize = STATIC_CAST( TInt, iMaxMmsSize*0.98 ); |
|
124 iBlack = EFalse; |
|
125 |
|
126 // Set this control extent. |
|
127 SetRect( aRect ); |
|
128 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse ); |
|
129 |
|
130 ActivateL(); |
|
131 |
|
132 iKeyEnable = EFalse; |
|
133 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::ConstructL: out"); |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 CVeiTrimForMmsContainer::~CVeiTrimForMmsContainer() |
|
139 { |
|
140 iMovie.UnregisterMovieObserver( this ); |
|
141 |
|
142 delete iEndText; |
|
143 delete iStartText; |
|
144 delete iScreenLight; |
|
145 |
|
146 delete iCutterBar; |
|
147 |
|
148 delete iVideoDisplayStart; |
|
149 delete iVideoDisplayEnd; |
|
150 if( iVideoDisplay ) |
|
151 { |
|
152 delete iVideoDisplay; |
|
153 iVideoDisplay = NULL; |
|
154 } |
|
155 |
|
156 if (iFrameTaker) |
|
157 { |
|
158 delete iFrameTaker; |
|
159 iFrameTaker = NULL; |
|
160 } |
|
161 |
|
162 if ( iProgressNote ) |
|
163 { |
|
164 delete iProgressNote; |
|
165 iProgressNote = NULL; |
|
166 } |
|
167 iProgressInfo = NULL; |
|
168 |
|
169 delete iBgContext; |
|
170 } |
|
171 |
|
172 void CVeiTrimForMmsContainer::SetMaxMmsSize( TInt aMaxSizeInBytes ) |
|
173 { |
|
174 iMaxMmsSize = aMaxSizeInBytes; |
|
175 } |
|
176 |
|
177 const TTimeIntervalMicroSeconds& CVeiTrimForMmsContainer::CutInTime() const |
|
178 { |
|
179 return iSeekPos; |
|
180 } |
|
181 |
|
182 |
|
183 const TTimeIntervalMicroSeconds& CVeiTrimForMmsContainer::CutOutTime() const |
|
184 { |
|
185 return iSeekEndPos; |
|
186 } |
|
187 |
|
188 |
|
189 // ---------------------------------------------------------------------------- |
|
190 // CVeiTrimForMmsContainer::ComponentControl(...) const |
|
191 // |
|
192 // Gets the specified component of a compound control. |
|
193 // ---------------------------------------------------------------------------- |
|
194 // |
|
195 CCoeControl* CVeiTrimForMmsContainer::ComponentControl( TInt aIndex ) const |
|
196 { |
|
197 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::ComponentControl()"); |
|
198 |
|
199 switch( aIndex ) |
|
200 { |
|
201 // |
|
202 // iCutterDisplay |
|
203 // |
|
204 case ECutFrame: |
|
205 { |
|
206 return iCutterBar; |
|
207 } |
|
208 // |
|
209 // iVideoDisplayStart |
|
210 // |
|
211 case EVideoDisplayStart: |
|
212 { |
|
213 return iVideoDisplayStart; |
|
214 } |
|
215 // |
|
216 // iVideoDisplayEnd |
|
217 // |
|
218 case EVideoDisplayEnd: |
|
219 { |
|
220 return iVideoDisplayEnd; |
|
221 } |
|
222 // |
|
223 // iVideoDisplay |
|
224 // |
|
225 case EVideoPreview: |
|
226 { |
|
227 return iVideoDisplay; |
|
228 |
|
229 } |
|
230 |
|
231 // |
|
232 // Default |
|
233 // |
|
234 default: |
|
235 { |
|
236 return NULL; |
|
237 } |
|
238 } |
|
239 |
|
240 } |
|
241 |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
|
244 // CVeiTrimForMmsContainer::CountComponentControls() const |
|
245 // |
|
246 // Gets the number of controls contained in a compound control. |
|
247 // ---------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CVeiTrimForMmsContainer::CountComponentControls() const |
|
250 { |
|
251 return ENumberOfControls; |
|
252 } |
|
253 |
|
254 |
|
255 void CVeiTrimForMmsContainer::Draw( const TRect& aRect ) const |
|
256 { |
|
257 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::Draw(): In"); |
|
258 |
|
259 CWindowGc& gc = SystemGc(); |
|
260 gc.Clear( aRect ); |
|
261 |
|
262 // Black backbround for the preview |
|
263 if ( iBlack ) |
|
264 { |
|
265 iVideoDisplay->MakeVisible( EFalse ); |
|
266 gc.SetPenStyle( CWindowGc::ENullPen ); |
|
267 gc.SetBrushColor( KRgbBlack ); |
|
268 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
269 gc.DrawRect( aRect ); |
|
270 gc.SetPenStyle( CWindowGc::ESolidPen ); |
|
271 gc.DrawRoundRect(aRect, TSize(4,4)); |
|
272 return; |
|
273 } |
|
274 else |
|
275 { |
|
276 // Draw skin background |
|
277 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
278 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
279 AknsDrawUtils::Background( skin, cc, this, gc, aRect ); |
|
280 |
|
281 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont ); |
|
282 TBuf<95> startVisualText; |
|
283 TPoint startTextPoint; |
|
284 TBuf<95> endVisualText; |
|
285 TPoint endTextPoint; |
|
286 |
|
287 startTextPoint.iY = iStartTextBox.iTl.iY + font->HeightInPixels(); |
|
288 endTextPoint.iY = iEndTextBox.iTl.iY + font->HeightInPixels(); |
|
289 |
|
290 gc.UseFont( font ); |
|
291 |
|
292 TBidiText::TDirectionality textDirectionality; |
|
293 |
|
294 textDirectionality = AknTextUtils::CurrentScriptDirectionality(); |
|
295 |
|
296 TInt maxWidthNonClippingStart = iStartTextBox.Width(); |
|
297 |
|
298 AknBidiTextUtils::ConvertToVisualAndClip( *iStartText, startVisualText, *font, maxWidthNonClippingStart, |
|
299 maxWidthNonClippingStart ); |
|
300 /** check text alignment */ |
|
301 if ( textDirectionality == TBidiText::ELeftToRight ) |
|
302 { |
|
303 startTextPoint.iX = iVideoDisplayStartRect.iTl.iX; |
|
304 } |
|
305 else |
|
306 { |
|
307 startTextPoint.iX = iVideoDisplayStartRect.iBr.iX - font->TextWidthInPixels( startVisualText ); |
|
308 } |
|
309 |
|
310 gc.DrawText( startVisualText, startTextPoint ); |
|
311 |
|
312 |
|
313 TInt maxWidthNonClippingEnd = iEndTextBox.Width(); |
|
314 |
|
315 AknBidiTextUtils::ConvertToVisualAndClip( *iEndText, endVisualText, *font, maxWidthNonClippingEnd, |
|
316 maxWidthNonClippingEnd ); |
|
317 /** check text alignment */ |
|
318 if ( textDirectionality == TBidiText::ELeftToRight ) |
|
319 { |
|
320 endTextPoint.iX = iVideoDisplayEndRect.iTl.iX; |
|
321 } |
|
322 else |
|
323 { |
|
324 endTextPoint.iX = iVideoDisplayEndRect.iBr.iX - font->TextWidthInPixels( endVisualText ); |
|
325 } |
|
326 |
|
327 gc.DrawText( endVisualText, endTextPoint ); |
|
328 |
|
329 gc.DiscardFont(); |
|
330 |
|
331 // Draw Start/End displays |
|
332 iVideoDisplayStart->SetRect( iVideoDisplayStartRect ); |
|
333 iVideoDisplayEnd->SetRect( iVideoDisplayEndRect ); |
|
334 |
|
335 if( iPreviewState == EPlaying ) |
|
336 { |
|
337 iVideoDisplay->MakeVisible( ETrue ); |
|
338 } |
|
339 else |
|
340 { |
|
341 iVideoDisplay->MakeVisible( EFalse ); |
|
342 } |
|
343 |
|
344 } |
|
345 |
|
346 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::Draw(): Out"); |
|
347 } |
|
348 |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CVeiTrimForMmsContainer::GetHelpContext(...) const |
|
352 // |
|
353 // Gets the control's help context. Associates the control with a particular |
|
354 // Help file and topic in a context sensitive application. |
|
355 // ---------------------------------------------------------------------------- |
|
356 // |
|
357 void CVeiTrimForMmsContainer::GetHelpContext( TCoeHelpContext& /*aContext*/ ) const |
|
358 { |
|
359 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::GetHelpContext(): In"); |
|
360 |
|
361 // Set UID of the CS Help file (same as application UID). |
|
362 //aContext.iMajor = KUidVideoEditor; |
|
363 |
|
364 // Set the context/topic. |
|
365 //aContext.iContext = KVED_HLP_TRIM_FOR_MMS_VIEW; |
|
366 |
|
367 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::GetHelpContext(): Out"); |
|
368 } |
|
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CVeiTrimForMmsContainer::SizeChanged() |
|
372 // |
|
373 // The function is called whenever SetExtent(), SetSize(), SetRect(), |
|
374 // SetCornerAndSize(), or SetExtentToWholeScreen() are called on the control. |
|
375 // ---------------------------------------------------------------------------- |
|
376 // |
|
377 void CVeiTrimForMmsContainer::SizeChanged() |
|
378 { |
|
379 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::SizeChanged(): In"); |
|
380 |
|
381 TRect rect = Rect(); |
|
382 if ( iBgContext ) |
|
383 { |
|
384 iBgContext->SetRect( rect ); |
|
385 } |
|
386 |
|
387 if ( VideoEditorUtils::IsLandscapeScreenOrientation() ) //Landscape |
|
388 { |
|
389 // Start Text rect |
|
390 TInt startTextTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.00962 ); |
|
391 TInt startTextTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.01389 ); |
|
392 TInt startTextBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.49512 ); |
|
393 TInt startTextBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.09375 ); |
|
394 |
|
395 iStartTextBox = TRect(startTextTlX, startTextTlY, startTextBrX, |
|
396 startTextBrY); |
|
397 // End Text rect |
|
398 TInt endTextTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.50481 ); |
|
399 TInt endTextTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.01389 ); |
|
400 TInt endTextBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.99039 ); |
|
401 TInt endTextBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.09375 ); |
|
402 |
|
403 iEndTextBox = TRect(endTextTlX, endTextTlY, endTextBrX, |
|
404 endTextBrY); |
|
405 |
|
406 // Start Video rect |
|
407 TInt startVideoTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.00962 ); |
|
408 TInt startVideoTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.10764 ); |
|
409 TInt startVideoBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.49512 ); |
|
410 TInt startVideoBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.68056 ); |
|
411 |
|
412 iVideoDisplayStartRect = TRect(startVideoTlX, startVideoTlY, startVideoBrX, |
|
413 startVideoBrY); |
|
414 // End Video rect |
|
415 TInt endVideoTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.50481 ); |
|
416 TInt endVideoTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.10764 ); |
|
417 TInt endVideoBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.99039 ); |
|
418 TInt endVideoBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.68056 ); |
|
419 |
|
420 iVideoDisplayEndRect = TRect(endVideoTlX, endVideoTlY, endVideoBrX, |
|
421 endVideoBrY); |
|
422 |
|
423 // Timeline rect |
|
424 TInt timeLineTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.0114 ); |
|
425 TInt timeLineTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.80208 ); |
|
426 |
|
427 TSize cutBarSize = TSize(STATIC_CAST( TInt, rect.iBr.iX*0.9773 ), |
|
428 STATIC_CAST( TInt, rect.iBr.iY*0.0973 ) ); |
|
429 |
|
430 iTimelineRect = TRect( TPoint(timeLineTlX, timeLineTlY), cutBarSize ); |
|
431 } |
|
432 else // Portrait |
|
433 { |
|
434 // Start Text rect |
|
435 TInt startTextTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.01136 ); |
|
436 TInt startTextTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.01389 ); |
|
437 TInt startTextBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.49432 ); |
|
438 TInt startTextBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.10417 ); |
|
439 |
|
440 iStartTextBox = TRect(startTextTlX, startTextTlY, startTextBrX, |
|
441 startTextBrY); |
|
442 |
|
443 // End Text rect |
|
444 TInt endTextTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.50568 ); |
|
445 TInt endTextTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.01389 ); |
|
446 TInt endTextBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.98864 ); |
|
447 TInt endTextBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.10417 ); |
|
448 |
|
449 iEndTextBox = TRect(endTextTlX, endTextTlY, endTextBrX, |
|
450 endTextBrY); |
|
451 |
|
452 // Start Video rect |
|
453 TInt startVideoTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.01136 ); |
|
454 TInt startVideoTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.11806 ); |
|
455 TInt startVideoBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.49432 ); |
|
456 TInt startVideoBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.60069 ); |
|
457 |
|
458 iVideoDisplayStartRect = TRect(startVideoTlX, startVideoTlY, startVideoBrX, |
|
459 startVideoBrY); |
|
460 |
|
461 // End Video rect |
|
462 TInt endVideoTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.50568 ); |
|
463 TInt endVideoTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.11806 ); |
|
464 TInt endVideoBrX = STATIC_CAST( TInt, rect.iBr.iX * 0.98864 ); |
|
465 TInt endVideoBrY = STATIC_CAST( TInt, rect.iBr.iY * 0.60069 ); |
|
466 |
|
467 iVideoDisplayEndRect = TRect(endVideoTlX, endVideoTlY, endVideoBrX, |
|
468 endVideoBrY); |
|
469 |
|
470 // Timeline rect |
|
471 TInt timeLineTlX = STATIC_CAST( TInt, rect.iBr.iX * 0.0114 ); |
|
472 TInt timeLineTlY = STATIC_CAST( TInt, rect.iBr.iY * 0.767361 ); |
|
473 |
|
474 |
|
475 TSize cutBarSize = TSize(STATIC_CAST( TInt, rect.iBr.iX*0.9773 ), |
|
476 STATIC_CAST( TInt, rect.iBr.iY*0.0973 ) ); |
|
477 |
|
478 iTimelineRect = TRect(TPoint(timeLineTlX, timeLineTlY), cutBarSize); |
|
479 } |
|
480 |
|
481 iCutterBar->SetRect( iTimelineRect ); |
|
482 |
|
483 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::SizeChanged(): Out"); |
|
484 } |
|
485 |
|
486 |
|
487 TKeyResponse CVeiTrimForMmsContainer::OfferKeyEventL( |
|
488 const TKeyEvent& aKeyEvent, |
|
489 TEventCode aType ) |
|
490 { |
|
491 if( iKeyEnable ) |
|
492 { |
|
493 switch( aType ) |
|
494 { |
|
495 // |
|
496 // Key down event |
|
497 // |
|
498 case EEventKeyDown: |
|
499 { |
|
500 if( iPreviewState == EPlaying ) |
|
501 { |
|
502 // iView.SetTrimStateL( CVeiTrimForMmsView::ESeek ); |
|
503 // Stop( ETrue ); |
|
504 return EKeyWasConsumed; |
|
505 } |
|
506 else |
|
507 { |
|
508 iKeyRepeatCount = 0; |
|
509 |
|
510 iMovie.VideoClipSetCutInTime( 0,TTimeIntervalMicroSeconds(0) ); |
|
511 iMovie.VideoClipSetCutOutTime( 0, iDuration ); |
|
512 return EKeyWasConsumed; |
|
513 } |
|
514 } |
|
515 // |
|
516 // The key event |
|
517 // |
|
518 case EEventKey: |
|
519 { |
|
520 if( iPreviewState == EPlaying ) |
|
521 { |
|
522 return EKeyWasConsumed; |
|
523 } |
|
524 switch( aKeyEvent.iCode ) |
|
525 { |
|
526 // |
|
527 // Navi-key right |
|
528 // |
|
529 case EKeyRightArrow: |
|
530 { |
|
531 if( iSeekEndPos != iDuration ) |
|
532 { |
|
533 iSeekEvent = ETrue; |
|
534 iLastKeyLeftOrRight = ETrue; |
|
535 if(iKeyRepeatCount < 18) |
|
536 { |
|
537 iKeyRepeatCount++; |
|
538 } |
|
539 |
|
540 TInt adjustment = TimeIncrement( iKeyRepeatCount ); |
|
541 TInt64 newPos = iSeekPos.Int64() + adjustment; |
|
542 |
|
543 TTimeIntervalMicroSeconds endTime(0); |
|
544 iMovie.GetDurationEstimateL( iMaxMmsSize, newPos, endTime ); |
|
545 |
|
546 if ( endTime.Int64() >= iDuration.Int64() - adjustment ) |
|
547 { |
|
548 iKeyRepeatCount-=3; |
|
549 adjustment = TimeIncrement( iKeyRepeatCount ); |
|
550 endTime = iDuration; |
|
551 newPos+=adjustment; |
|
552 } |
|
553 |
|
554 iSeekPos = TTimeIntervalMicroSeconds( newPos ); |
|
555 |
|
556 iSeekEndPos = endTime; |
|
557 iCutterBar->SetInPoint(iSeekPos); |
|
558 iCutterBar->SetOutPoint(endTime); |
|
559 } |
|
560 |
|
561 return EKeyWasConsumed; |
|
562 } |
|
563 // |
|
564 // Navi-key left |
|
565 // |
|
566 case EKeyLeftArrow: |
|
567 { |
|
568 if( iSeekPos.Int64() > 0 ) |
|
569 { |
|
570 iSeekEvent = ETrue; |
|
571 iLastKeyLeftOrRight = ETrue; |
|
572 // Process the command only when repeat count is zero. |
|
573 iKeyRepeatCount++; |
|
574 |
|
575 |
|
576 TInt adjustment = TimeIncrement( iKeyRepeatCount ); |
|
577 |
|
578 TInt64 newPos = iSeekPos.Int64() - adjustment; |
|
579 if ( newPos < 0 ) |
|
580 { |
|
581 newPos = 0; |
|
582 } |
|
583 iSeekPos = TTimeIntervalMicroSeconds( newPos ); |
|
584 |
|
585 TTimeIntervalMicroSeconds endTime(0); |
|
586 iMovie.GetDurationEstimateL( iMaxMmsSize, newPos, endTime ); |
|
587 |
|
588 iSeekEndPos = endTime; |
|
589 |
|
590 iCutterBar->SetInPoint(iSeekPos); |
|
591 iCutterBar->SetOutPoint(endTime); |
|
592 } |
|
593 return EKeyWasConsumed; |
|
594 } |
|
595 // |
|
596 // Default |
|
597 // |
|
598 default: |
|
599 { |
|
600 return EKeyWasNotConsumed; |
|
601 } |
|
602 } |
|
603 } |
|
604 // |
|
605 // Key up event |
|
606 // |
|
607 |
|
608 case EEventKeyUp: |
|
609 { |
|
610 if( iPreviewState == EPlaying ) |
|
611 { |
|
612 iView.SetTrimStateL( CVeiTrimForMmsView::ESeek ); |
|
613 |
|
614 Stop( ETrue ); |
|
615 return EKeyWasConsumed; |
|
616 } |
|
617 else |
|
618 { |
|
619 if ( iLastKeyLeftOrRight ) |
|
620 { |
|
621 iView.ProcessNeeded( ETrue ); |
|
622 iMovie.VideoClipSetCutInTime( 0, iSeekPos ); |
|
623 iMovie.VideoClipSetCutOutTime( 0, iSeekEndPos ); |
|
624 iView.UpdateNaviPaneL( iMovie.GetSizeEstimateL()/1024,iMovie.Duration() ); |
|
625 iLastKeyLeftOrRight = EFalse; |
|
626 if( iSeekEvent ) |
|
627 { |
|
628 StartFrameTakerL( iClipIndex ); |
|
629 iSeekEvent = EFalse; |
|
630 } |
|
631 return EKeyWasConsumed; |
|
632 } |
|
633 } |
|
634 break; |
|
635 } |
|
636 // |
|
637 // Default |
|
638 // |
|
639 default: |
|
640 return EKeyWasNotConsumed; |
|
641 } |
|
642 } //iKeyEnable |
|
643 return EKeyWasNotConsumed; |
|
644 } |
|
645 |
|
646 |
|
647 |
|
648 TInt CVeiTrimForMmsContainer::TimeIncrement(TInt aKeyCount) const |
|
649 { |
|
650 if ( aKeyCount < 3 ) |
|
651 { |
|
652 return 100000; |
|
653 } |
|
654 else if ( aKeyCount < 6 ) // 4 |
|
655 { |
|
656 return 300000; |
|
657 } |
|
658 else if ( aKeyCount < 9 ) // 5 |
|
659 { |
|
660 return 500000; |
|
661 } |
|
662 else if ( aKeyCount < 12 ) // 10 |
|
663 { |
|
664 return 1000000; |
|
665 } |
|
666 else if ( aKeyCount < 15 ) // 13 |
|
667 { |
|
668 return 2000000; |
|
669 } |
|
670 else if ( aKeyCount < 18 ) // 15 |
|
671 { |
|
672 return 3000000; |
|
673 } |
|
674 else |
|
675 { |
|
676 return 5000000; |
|
677 } |
|
678 } |
|
679 |
|
680 |
|
681 void CVeiTrimForMmsContainer::NotifyVideoDisplayEvent( const TPlayerEvent aEvent, const TInt& aInfo ) |
|
682 { |
|
683 switch (aEvent) |
|
684 { |
|
685 case MVeiVideoDisplayObserver::EOpenComplete: |
|
686 { |
|
687 iVideoDisplay->SetRect( iPreviewRect ); |
|
688 if ( !VideoEditorUtils::IsLandscapeScreenOrientation() ) //Portrait |
|
689 { |
|
690 iVideoDisplay->SetRotationL( EVideoRotationClockwise90 ); |
|
691 } |
|
692 iPreviewState = ELoading; |
|
693 |
|
694 iVideoDisplay->SetPositionL( CutInTime() ); |
|
695 iVideoDisplay->PlayL( iMovie.VideoClipInfo( iClipIndex )->FileName(), CutInTime(), CutOutTime() ); |
|
696 |
|
697 break; |
|
698 } |
|
699 |
|
700 case MVeiVideoDisplayObserver::ELoadingComplete: |
|
701 { |
|
702 |
|
703 iVideoDisplay->MakeVisible( ETrue ); |
|
704 iPreviewState = EPlaying; |
|
705 break; |
|
706 } |
|
707 |
|
708 case MVeiVideoDisplayObserver::EStop: |
|
709 { |
|
710 iPreviewState = EIdle; |
|
711 iView.SetTrimStateL( CVeiTrimForMmsView::ESeek ); |
|
712 |
|
713 iVideoDisplay->MakeVisible(EFalse); |
|
714 |
|
715 DrawDeferred(); |
|
716 break; |
|
717 } |
|
718 case MVeiVideoDisplayObserver::EPlayComplete: |
|
719 { |
|
720 iView.SetTrimStateL( CVeiTrimForMmsView::ESeek ); |
|
721 Stop( ETrue ); |
|
722 if (KErrNoMemory == aInfo) |
|
723 { |
|
724 iView.ShowGlobalErrorNoteL( KErrNoMemory ); |
|
725 } |
|
726 break; |
|
727 } |
|
728 default: |
|
729 { |
|
730 break; |
|
731 } |
|
732 } |
|
733 } |
|
734 |
|
735 |
|
736 /** |
|
737 * Called to notify that a new video clip has been successfully |
|
738 * added to the movie. Note that the indices and the start and end times |
|
739 * of the video clips after the new clip have also changed as a result. |
|
740 * Note that the transitions may also have changed. |
|
741 * |
|
742 * @param aMovie movie |
|
743 * @param aIndex index of video clip in movie |
|
744 */ |
|
745 void CVeiTrimForMmsContainer::NotifyVideoClipAdded( CVedMovie& aMovie, TInt aIndex ) |
|
746 { |
|
747 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::NotifyVideoClipAdded: in"); |
|
748 |
|
749 iSeekPos = TTimeIntervalMicroSeconds(0); |
|
750 |
|
751 aMovie.GetDurationEstimateL( iMaxMmsSize, iSeekPos, iSeekEndPos ); |
|
752 LOGFMT3(KVideoEditorLogFile, "CVeiTrimForMmsContainer::NotifyVideoClipAdded: 1, iMaxMmsSize:%d, iSeekPos:%Ld, iSeekEndPos:%Ld", |
|
753 iMaxMmsSize, iSeekPos.Int64(), iSeekEndPos.Int64()); |
|
754 |
|
755 iCutterBar->SetInPoint( iSeekPos ); |
|
756 iCutterBar->SetOutPoint( iSeekEndPos ); |
|
757 iCutterBar->SetTotalDuration( aMovie.Duration() ); |
|
758 iDuration = aMovie.Duration(); |
|
759 |
|
760 iClipIndex = aIndex; |
|
761 |
|
762 aMovie.VideoClipSetCutInTime( 0, iSeekPos ); |
|
763 aMovie.VideoClipSetCutOutTime( 0, iSeekEndPos ); |
|
764 |
|
765 TInt movieSizeLimit = static_cast<TInt>(iMaxMmsSize*0.9); |
|
766 aMovie.SetMovieSizeLimit( movieSizeLimit ); |
|
767 |
|
768 LOGFMT(KVideoEditorLogFile, "CVeiTrimForMmsContainer::NotifyVideoClipAdded(): 2, movie size set to:%d", movieSizeLimit); |
|
769 |
|
770 StartFrameTakerL( iClipIndex ); |
|
771 |
|
772 iSeekEvent = EFalse; |
|
773 |
|
774 |
|
775 iView.UpdateNaviPaneL( iMovie.GetSizeEstimateL()/1024,iMovie.Duration() ); |
|
776 |
|
777 iKeyEnable = ETrue; |
|
778 |
|
779 LOG(KVideoEditorLogFile, "CVeiTrimForMmsContainer::NotifyVideoClipAdded: out"); |
|
780 } |
|
781 |
|
782 |
|
783 void CVeiTrimForMmsContainer::NotifyVideoClipAddingFailed( CVedMovie& /*aMovie*/, |
|
784 TInt /*aError*/ ) |
|
785 { |
|
786 } |
|
787 |
|
788 void CVeiTrimForMmsContainer::NotifyVideoClipRemoved( CVedMovie& /*aMovie*/, |
|
789 TInt /*aIndex*/ ) |
|
790 { |
|
791 } |
|
792 |
|
793 void CVeiTrimForMmsContainer::NotifyVideoClipIndicesChanged( CVedMovie& /*aMovie*/, |
|
794 TInt /*aOldIndex*/, |
|
795 TInt /*aNewIndex*/ ) |
|
796 { |
|
797 } |
|
798 |
|
799 void CVeiTrimForMmsContainer::NotifyVideoClipTimingsChanged( |
|
800 CVedMovie& /*aMovie*/, |
|
801 TInt /*aIndex*/ ) |
|
802 { |
|
803 } |
|
804 |
|
805 void CVeiTrimForMmsContainer::NotifyVideoClipColorEffectChanged( |
|
806 CVedMovie& /*aMovie*/, |
|
807 TInt /*aIndex*/ ) |
|
808 { |
|
809 } |
|
810 |
|
811 void CVeiTrimForMmsContainer::NotifyVideoClipAudioSettingsChanged( |
|
812 CVedMovie& /*aMovie*/, |
|
813 TInt /*aIndex*/ ) |
|
814 { |
|
815 } |
|
816 |
|
817 void CVeiTrimForMmsContainer::NotifyVideoClipGeneratorSettingsChanged( |
|
818 CVedMovie& /*aMovie*/, |
|
819 TInt /*aIndex*/ ) |
|
820 { |
|
821 } |
|
822 |
|
823 void CVeiTrimForMmsContainer::NotifyVideoClipDescriptiveNameChanged( |
|
824 CVedMovie& /*aMovie*/, |
|
825 TInt /*aIndex*/ ) |
|
826 { |
|
827 } |
|
828 |
|
829 void CVeiTrimForMmsContainer::NotifyStartTransitionEffectChanged( |
|
830 CVedMovie& /*aMovie*/ ) |
|
831 { |
|
832 } |
|
833 |
|
834 |
|
835 void CVeiTrimForMmsContainer::NotifyMiddleTransitionEffectChanged( |
|
836 CVedMovie& /*aMovie*/, |
|
837 TInt /*aIndex*/ ) |
|
838 { |
|
839 } |
|
840 |
|
841 void CVeiTrimForMmsContainer::NotifyEndTransitionEffectChanged( |
|
842 CVedMovie& /*aMovie*/ ) |
|
843 { |
|
844 } |
|
845 |
|
846 void CVeiTrimForMmsContainer::NotifyAudioClipAdded( CVedMovie& /*aMovie*/, |
|
847 TInt /*aIndex*/ ) |
|
848 { |
|
849 } |
|
850 |
|
851 void CVeiTrimForMmsContainer::NotifyAudioClipAddingFailed( |
|
852 CVedMovie& /*aMovie*/, |
|
853 TInt /*aError*/ ) |
|
854 { |
|
855 } |
|
856 |
|
857 void CVeiTrimForMmsContainer::NotifyAudioClipRemoved( CVedMovie& /*aMovie*/, |
|
858 TInt /*aIndex*/ ) |
|
859 { |
|
860 } |
|
861 |
|
862 void CVeiTrimForMmsContainer::NotifyAudioClipIndicesChanged( |
|
863 CVedMovie& /*aMovie*/, |
|
864 TInt /*aOldIndex*/, |
|
865 TInt /*aNewIndex*/ ) |
|
866 { |
|
867 } |
|
868 |
|
869 void CVeiTrimForMmsContainer::NotifyAudioClipTimingsChanged( |
|
870 CVedMovie& /*aMovie*/, |
|
871 TInt /*aIndex*/ ) |
|
872 { |
|
873 } |
|
874 |
|
875 void CVeiTrimForMmsContainer::NotifyMovieQualityChanged( CVedMovie& /*aMovie*/ ) |
|
876 { |
|
877 } |
|
878 |
|
879 |
|
880 void CVeiTrimForMmsContainer::NotifyMovieReseted( CVedMovie& /*aMovie*/ ) |
|
881 { |
|
882 } |
|
883 |
|
884 void CVeiTrimForMmsContainer::NotifyMovieOutputParametersChanged(CVedMovie& /*aMovie*/) |
|
885 { |
|
886 } |
|
887 |
|
888 void CVeiTrimForMmsContainer::NotifyAudioClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/, |
|
889 TInt /*aClipIndex*/, |
|
890 TInt /*aMarkIndex*/) |
|
891 { |
|
892 } |
|
893 |
|
894 void CVeiTrimForMmsContainer::NotifyAudioClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, |
|
895 TInt /*aClipIndex*/, |
|
896 TInt /*aMarkIndex*/) |
|
897 { |
|
898 } |
|
899 |
|
900 void CVeiTrimForMmsContainer::NotifyVideoClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/, |
|
901 TInt /*aClipIndex*/, |
|
902 TInt /*aMarkIndex*/) |
|
903 { |
|
904 } |
|
905 |
|
906 void CVeiTrimForMmsContainer::NotifyVideoClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, |
|
907 TInt /*aClipIndex*/, |
|
908 TInt /*aMarkIndex*/) |
|
909 { |
|
910 } |
|
911 |
|
912 void CVeiTrimForMmsContainer::PlayL( const TDesC& aFilename, const TRect& aRect ) |
|
913 { |
|
914 iCutterBar->MakeVisible( EFalse ); |
|
915 iVideoDisplayStart->MakeVisible( EFalse ); |
|
916 iVideoDisplayEnd->MakeVisible( EFalse ); |
|
917 iVideoDisplay->MakeVisible( EFalse ); |
|
918 |
|
919 iVideoDisplay->ShowBlackScreen(); |
|
920 |
|
921 iPreviewRect = aRect; |
|
922 iBlack = ETrue; |
|
923 iScreenLight->Start(); |
|
924 |
|
925 iPreviewState = EOpeningFile; |
|
926 iVideoDisplay->OpenFileL( aFilename ); |
|
927 } |
|
928 |
|
929 void CVeiTrimForMmsContainer::Stop( TBool aCloseStream ) |
|
930 { |
|
931 iCutterBar->MakeVisible( ETrue ); |
|
932 iVideoDisplayStart->MakeVisible( ETrue ); |
|
933 iVideoDisplayEnd->MakeVisible( ETrue ); |
|
934 iBlack = EFalse; |
|
935 iScreenLight->Stop(); |
|
936 iVideoDisplay->Stop( aCloseStream ); |
|
937 DrawNow(); |
|
938 } |
|
939 |
|
940 void CVeiTrimForMmsContainer::PauseL() |
|
941 { |
|
942 iPreviewState = EPause; |
|
943 iVideoDisplay->PauseL(); |
|
944 iVideoDisplay->MakeVisible(EFalse); |
|
945 DrawNow(); |
|
946 } |
|
947 |
|
948 TInt CVeiTrimForMmsContainer::PreviewState() const |
|
949 { |
|
950 return iPreviewState; |
|
951 } |
|
952 |
|
953 void CVeiTrimForMmsContainer::NotifyFramesCompleted( CFbsBitmap* aFirstFrame, |
|
954 CFbsBitmap* aLastFrame, CFbsBitmap* /*aTimelineFrame*/, TInt aError ) |
|
955 { |
|
956 if( aError==KErrNone ) |
|
957 { |
|
958 iVideoDisplayStart->ShowPictureL( *aFirstFrame ); |
|
959 iVideoDisplayEnd->ShowPictureL( *aLastFrame ); |
|
960 } |
|
961 |
|
962 if( iProgressNote ) |
|
963 { |
|
964 iProgressInfo->SetAndDraw(100); |
|
965 iProgressNote->ProcessFinishedL(); |
|
966 } |
|
967 } |
|
968 |
|
969 void CVeiTrimForMmsContainer::StartFrameTakerL( TInt aIndex ) |
|
970 { |
|
971 iProgressNote = |
|
972 new (ELeave) CAknProgressDialog(REINTERPRET_CAST(CEikDialog**, &iProgressNote), ETrue); |
|
973 iProgressNote->SetCallback(this); |
|
974 iProgressNote->ExecuteDlgLD( R_VEI_PROGRESS_NOTE ); |
|
975 |
|
976 HBufC* stringholder; |
|
977 stringholder = StringLoader::LoadL( R_VEI_PROGRESS_NOTE_PROCESSING, iEikonEnv ); |
|
978 CleanupStack::PushL( stringholder ); |
|
979 iProgressNote->SetTextL( *stringholder ); |
|
980 CleanupStack::PopAndDestroy( stringholder ); |
|
981 |
|
982 iProgressInfo = iProgressNote->GetProgressInfoL(); |
|
983 iProgressInfo->SetFinalValue(100); |
|
984 iProgressInfo->SetAndDraw(50); |
|
985 |
|
986 // First frame is shown in main display so it is bigger.. Last frame is always |
|
987 // on transition display and one frame for the video timeline. |
|
988 TSize firstThumbResolution = iVideoDisplayStart->GetScreenSize(); |
|
989 TSize lastThumbResolution = iVideoDisplayEnd->GetScreenSize(); |
|
990 TSize timelineThumbResolution = TSize( 34, 28 ); |
|
991 |
|
992 TInt frameCount = iMovie.VideoClipInfo(aIndex)->VideoFrameCount(); |
|
993 |
|
994 TInt firstThumbNailIndex = iMovie.VideoClipInfo(aIndex)->GetVideoFrameIndexL( CutInTime() ); |
|
995 TInt lastThumbNailIndex = iMovie.VideoClipInfo(aIndex)->GetVideoFrameIndexL( CutOutTime() ); |
|
996 if ( lastThumbNailIndex >= frameCount ) |
|
997 { |
|
998 lastThumbNailIndex = frameCount-1; |
|
999 } |
|
1000 |
|
1001 |
|
1002 iFrameTaker->GetFramesL( *iMovie.VideoClipInfo(aIndex), |
|
1003 firstThumbNailIndex, &firstThumbResolution, |
|
1004 lastThumbNailIndex, &lastThumbResolution, |
|
1005 firstThumbNailIndex, &timelineThumbResolution, |
|
1006 EPriorityLow ); |
|
1007 } |
|
1008 |
|
1009 TTypeUid::Ptr CVeiTrimForMmsContainer::MopSupplyObject( TTypeUid aId ) |
|
1010 { |
|
1011 if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext ) |
|
1012 { |
|
1013 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
1014 } |
|
1015 return CCoeControl::MopSupplyObject( aId ); |
|
1016 } |
|
1017 // End of File |
|
1018 |