|
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 // INCLUDES |
|
21 #include "SimpleVideoEditorImpl.h" |
|
22 #include <SimpleVideoEditor.rsg> |
|
23 #include <e32std.h> |
|
24 #include <aknutils.h> |
|
25 #include <bautils.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <mgfetch.h> |
|
28 #include <sysutil.h> |
|
29 #include <stringloader.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <eikenv.h> |
|
32 #include <errorui.h> |
|
33 #include <PathInfo.h> |
|
34 #include <eikprogi.h> |
|
35 #include <stringloader.h> |
|
36 #include <VedAudioClipInfo.h> |
|
37 #include <CAknMemorySelectionDialog.h> |
|
38 #include <CAknFileNamePromptDialog.h> |
|
39 #include <AknCommonDialogsDynMem.h> |
|
40 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
41 #include <apgcli.h> |
|
42 |
|
43 #include "VideoEditorUtils.h" |
|
44 #include "VeiAddQueue.h" |
|
45 #include "VideoEditorCommon.h" |
|
46 #include "VideoEditorDebugUtils.h" |
|
47 #include "VeiTempMaker.h" |
|
48 #include "ExtProgressDialog.h" |
|
49 #include "VeiMGFetchVerifier.h" |
|
50 #include "VeiImageClipGenerator.h" |
|
51 #include "DummyControl.h" |
|
52 #include "CMultiLineQueryDialog.h" |
|
53 |
|
54 // CONSTANTS |
|
55 _LIT(KResourceFile, "SimpleVideoEditor.rsc"); |
|
56 const TProcessPriority KLowPriority = EPriorityLow; |
|
57 const TInt KAudioLevelMin = -127; |
|
58 const TUint KFadeInTimeMicroSeconds = 50000; |
|
59 |
|
60 #define KMediaGalleryUID3 0x101F8599 |
|
61 |
|
62 //======================================================================================================= |
|
63 CSimpleVideoEditorImpl* CSimpleVideoEditorImpl::NewL(MSimpleVideoEditorExitObserver& aExitObserver) |
|
64 { |
|
65 CSimpleVideoEditorImpl* self = new (ELeave) CSimpleVideoEditorImpl(aExitObserver); |
|
66 CleanupStack::PushL (self); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop (self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 //======================================================================================================= |
|
73 CSimpleVideoEditorImpl::~CSimpleVideoEditorImpl() |
|
74 { |
|
75 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::~CSimpleVideoEditorImpl, In"); |
|
76 |
|
77 // Remove foreground event observer |
|
78 iEnv.RemoveForegroundObserver( *this ); |
|
79 |
|
80 Cancel(); |
|
81 iResLoader.Close(); |
|
82 |
|
83 if ( iMovie ) |
|
84 { |
|
85 iMovie->Reset(); |
|
86 iMovie->UnregisterMovieObserver( this ); |
|
87 delete iMovie; |
|
88 iMovie = NULL; |
|
89 } |
|
90 |
|
91 if ( iTempFile ) |
|
92 { |
|
93 (void) iEnv.FsSession().Delete( *iTempFile ); |
|
94 delete iTempFile; |
|
95 iTempFile = NULL; |
|
96 } |
|
97 |
|
98 if ( iProgressDialog ) |
|
99 { |
|
100 iProgressDialog->SetCallback( NULL ); |
|
101 delete iProgressDialog; |
|
102 iProgressDialog = NULL; |
|
103 } |
|
104 |
|
105 if ( iWaitDialog ) |
|
106 { |
|
107 iWaitDialog->SetCallback(NULL); |
|
108 delete iWaitDialog; |
|
109 iWaitDialog = NULL; |
|
110 } |
|
111 if ( iAnimatedProgressDialog ) |
|
112 { |
|
113 delete iAnimatedProgressDialog; |
|
114 } |
|
115 |
|
116 if (iImageClipGenerator) |
|
117 { |
|
118 delete iImageClipGenerator; |
|
119 } |
|
120 |
|
121 if (iTextGenerator) |
|
122 { |
|
123 delete iTextGenerator; |
|
124 } |
|
125 |
|
126 if (iAddText) |
|
127 { |
|
128 delete iAddText; |
|
129 } |
|
130 |
|
131 if ( iErrorUI ) |
|
132 { |
|
133 delete iErrorUI; |
|
134 } |
|
135 |
|
136 if ( iAudioClipInfo ) |
|
137 { |
|
138 delete iAudioClipInfo; |
|
139 } |
|
140 |
|
141 if ( iAcceptedAudioTypes ) |
|
142 { |
|
143 delete iAcceptedAudioTypes; |
|
144 iAcceptedAudioTypes = 0; |
|
145 } |
|
146 |
|
147 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::~CSimpleVideoEditorImpl, Out"); |
|
148 } |
|
149 |
|
150 //======================================================================================================= |
|
151 void CSimpleVideoEditorImpl::RestoreOrientation() |
|
152 { |
|
153 CAknAppUiBase* appUi = static_cast<CAknAppUiBase *>( iEnv.EikAppUi() ); |
|
154 CAknAppUiBase::TAppUiOrientation orientation = appUi->Orientation(); |
|
155 |
|
156 if (orientation != iOriginalOrientation) |
|
157 { |
|
158 TRAP_IGNORE( appUi->SetOrientationL(iOriginalOrientation) ); |
|
159 |
|
160 // Send screen device change event to validate screen |
|
161 TWsEvent event; |
|
162 |
|
163 RWsSession& rws = iEnv.WsSession(); |
|
164 event.SetType( EEventScreenDeviceChanged ); |
|
165 event.SetTimeNow(); |
|
166 event.SetHandle( rws.WsHandle() ); |
|
167 |
|
168 (void)rws.SendEventToAllWindowGroups( event ); |
|
169 } |
|
170 } |
|
171 |
|
172 //======================================================================================================= |
|
173 CSimpleVideoEditorImpl::CSimpleVideoEditorImpl(MSimpleVideoEditorExitObserver& aExitObserver) |
|
174 : CActive (EPriorityStandard), |
|
175 iEnv( *CEikonEnv::Static() ), |
|
176 iExitObserver (aExitObserver), |
|
177 iResLoader( iEnv ), |
|
178 iGeneratorComplete( ETrue ), |
|
179 iDialogDismissed( EFalse ) |
|
180 { |
|
181 CActiveScheduler::Add(this); |
|
182 } |
|
183 |
|
184 //======================================================================================================= |
|
185 void CSimpleVideoEditorImpl::ConstructL() |
|
186 { |
|
187 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ConstructL: In"); |
|
188 |
|
189 // Locate and open the resource file |
|
190 TFileName fileName; |
|
191 TParse p; |
|
192 |
|
193 Dll::FileName(fileName); |
|
194 p.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, &fileName); |
|
195 fileName = p.FullName(); |
|
196 |
|
197 LOGFMT(KVideoEditorLogFile, "\tLoading resource file: %S", &fileName); |
|
198 iResLoader.OpenL( fileName ); // RConeResourceLoader selects the correct language file |
|
199 |
|
200 // Always use automatic save quality for the result movie |
|
201 iMovie = CVedMovie::NewL( NULL ); |
|
202 iMovie->RegisterMovieObserverL( this ); |
|
203 iMovie->SetQuality( CVedMovie::EQualityAutomatic ); |
|
204 |
|
205 CVeiTempMaker* maker = CVeiTempMaker::NewLC(); |
|
206 // this call can leave even though it does not end with 'L' |
|
207 maker->EmptyTempFolder(); |
|
208 CleanupStack::PopAndDestroy(maker); |
|
209 //delete maker; |
|
210 |
|
211 iEnv.AddForegroundObserverL( *this ); |
|
212 |
|
213 |
|
214 iErrorUI = CErrorUI::NewL( iEnv ); |
|
215 |
|
216 iAcceptedAudioTypes = new ( ELeave ) CDesCArrayFlat( 4 ); |
|
217 |
|
218 iAcceptedAudioTypes->Reset(); |
|
219 |
|
220 iAcceptedAudioTypes->AppendL( _L( "audio/mpeg" ) ); |
|
221 iAcceptedAudioTypes->AppendL( _L( "audio/aac" ) ); |
|
222 iAcceptedAudioTypes->AppendL( _L( "audio/amr" ) ); |
|
223 iAcceptedAudioTypes->AppendL( _L( "audio/mp3" ) ); |
|
224 iAcceptedAudioTypes->AppendL( _L( "audio/x-mp3" ) ); |
|
225 iAcceptedAudioTypes->AppendL( _L( "audio/3gpp" ) ); |
|
226 iAcceptedAudioTypes->AppendL( _L( "audio/3gpp2" ) ); |
|
227 iAcceptedAudioTypes->AppendL( _L( "audio/m4a" ) ); |
|
228 iAcceptedAudioTypes->AppendL( _L( "audio/mp4" ) ); |
|
229 iAcceptedAudioTypes->AppendL( _L( "audio/mpeg4" ) ); |
|
230 iAcceptedAudioTypes->AppendL( _L( "audio/wav" ) ); |
|
231 iAcceptedAudioTypes->AppendL( _L( "audio/x-wav" ) ); |
|
232 iAcceptedAudioTypes->AppendL( _L( "audio/x-realaudio" ) ); |
|
233 iAcceptedAudioTypes->AppendL( _L( "audio/wma" ) ); |
|
234 |
|
235 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ConstructL: Out"); |
|
236 } |
|
237 |
|
238 //======================================================================================================= |
|
239 void CSimpleVideoEditorImpl::StartMerge( const TDesC& aSourceFileName ) |
|
240 { |
|
241 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMerge: In"); |
|
242 |
|
243 iSourceFileName = aSourceFileName; |
|
244 iOperationMode = EOperationModeMerge; |
|
245 iState = EStateInitializing; |
|
246 |
|
247 CompleteRequest(); |
|
248 |
|
249 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMerge: Out"); |
|
250 } |
|
251 |
|
252 //======================================================================================================= |
|
253 void CSimpleVideoEditorImpl::StartChangeAudio( const TDesC& aSourceFileName ) |
|
254 { |
|
255 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartChangeAudio: In"); |
|
256 |
|
257 iSourceFileName = aSourceFileName; |
|
258 iOperationMode = EOperationModeChangeAudio; |
|
259 iState = EStateInitializing; |
|
260 |
|
261 CompleteRequest(); |
|
262 |
|
263 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartChangeAudio: Out"); |
|
264 } |
|
265 |
|
266 //======================================================================================================= |
|
267 void CSimpleVideoEditorImpl::StartAddText( const TDesC& aSourceFileName ) |
|
268 { |
|
269 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartAddText: In"); |
|
270 |
|
271 iSourceFileName = aSourceFileName; |
|
272 iOperationMode = EOperationModeAddText; |
|
273 iState = EStateInitializing; |
|
274 |
|
275 CompleteRequest(); |
|
276 |
|
277 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartAddText: Out"); |
|
278 } |
|
279 |
|
280 |
|
281 //============================================================================= |
|
282 void CSimpleVideoEditorImpl::RunL() |
|
283 { |
|
284 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: In"); |
|
285 |
|
286 // Resetting these indicators. This is not necessary right now, |
|
287 // but might be in the future if the code is changed so it's reasonable to |
|
288 // to do it anyway, just in case. |
|
289 iGeneratorComplete = ETrue; |
|
290 iDialogDismissed = EFalse; |
|
291 |
|
292 // if RunL() leaves, RunError() is called and iState is changed to EStateFinalizing |
|
293 // (or to EStateReady if already in EStateFinalizing |
|
294 |
|
295 switch (iState) |
|
296 { |
|
297 case EStateInitializing: |
|
298 { |
|
299 InitializeOperationL(); |
|
300 |
|
301 iState = EStateInsertInputFirst; |
|
302 CompleteRequest(); |
|
303 break; |
|
304 } |
|
305 case EStateInsertInputFirst: |
|
306 { |
|
307 // Common to all operation modes: Insert the original video clip to the movie |
|
308 // (Operation continues from the NotifyVideoClipAdded() callback method). |
|
309 iMovie->InsertVideoClipL( iSourceFileName, 0 ); |
|
310 StartWaitDialogL(); |
|
311 |
|
312 break; |
|
313 } |
|
314 case EStateInsertInputSecond: |
|
315 { |
|
316 // Get the input - text, image, video or sound clip |
|
317 switch (iOperationMode) |
|
318 { |
|
319 case EOperationModeMerge: |
|
320 { |
|
321 GetMergeInputFileL(); |
|
322 CompleteRequest(); |
|
323 break; |
|
324 } |
|
325 |
|
326 case EOperationModeChangeAudio: |
|
327 { |
|
328 GetAudioFileL(); |
|
329 CompleteRequest(); |
|
330 break; |
|
331 } |
|
332 |
|
333 case EOperationModeAddText: |
|
334 { |
|
335 GetTextL(); |
|
336 CompleteRequest(); |
|
337 break; |
|
338 } |
|
339 |
|
340 default: |
|
341 User::Invariant(); |
|
342 break; |
|
343 } |
|
344 break; |
|
345 } |
|
346 case EStateCheckAudioLength: |
|
347 { |
|
348 // NotifyAudioClipInfoReady is called instead of RunL |
|
349 break; |
|
350 } |
|
351 case EStateInsertVideo: |
|
352 { |
|
353 iMovie->InsertVideoClipL(iMergeFileName, iVideoOrImageIndex); |
|
354 StartWaitDialogL(); |
|
355 break; |
|
356 } |
|
357 case EStateCreateImageGenerator: |
|
358 { |
|
359 TTimeIntervalMicroSeconds duration( 3000000 ); |
|
360 TRgb background = KRgbBlack; |
|
361 // Setting to false to indicate that the |
|
362 // NewL() called below hasn't yet completed. |
|
363 iGeneratorComplete = EFalse; |
|
364 |
|
365 // Create the image clip generator |
|
366 iImageClipGenerator = CVeiImageClipGenerator::NewL( |
|
367 iMergeFileName, |
|
368 iMovie->Resolution(), |
|
369 duration, |
|
370 background, |
|
371 KVideoClipGenetatorDisplayMode, |
|
372 iEnv.FsSession(), |
|
373 *this ); |
|
374 StartWaitDialogL(); |
|
375 break; |
|
376 } |
|
377 case EStateInsertImage: |
|
378 { |
|
379 TRAPD(err, iMovie->InsertVideoClipL( *iImageClipGenerator, ETrue, iVideoOrImageIndex )); // generator owned by movie |
|
380 if (KErrNone == err) |
|
381 { |
|
382 // Generator is no longer our concern, ownership transferred to iMovie |
|
383 iImageClipGenerator = 0; |
|
384 StartWaitDialogL(); |
|
385 } |
|
386 else |
|
387 { |
|
388 iError = err; |
|
389 iError = FilterError(); |
|
390 iState = EStateFinalizing; |
|
391 CompleteRequest(); |
|
392 } |
|
393 break; |
|
394 } |
|
395 |
|
396 case EStateInsertAudio: |
|
397 { |
|
398 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: Inserting audio clip %S", &iAudioFileName); |
|
399 |
|
400 iMovie->AddAudioClipL( iAudioFileName, TTimeIntervalMicroSeconds( 0 )); |
|
401 StartWaitDialogL(); |
|
402 break; |
|
403 } |
|
404 |
|
405 case EStateInsertTextToBegin: |
|
406 { |
|
407 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 1"); |
|
408 |
|
409 |
|
410 iTextGenerator = CVeiTitleClipGenerator::NewL( iMovie->Resolution(), |
|
411 EVeiTitleClipTransitionNone, |
|
412 EVeiTitleClipHorizontalAlignmentCenter, |
|
413 EVeiTitleClipVerticalAlignmentCenter); |
|
414 |
|
415 HBufC* descriptiveName = StringLoader::LoadLC(R_VESM_EDIT_VIEW_TITLE_NAME, &iEnv ); |
|
416 iTextGenerator->SetDescriptiveNameL(*descriptiveName); |
|
417 CleanupStack::PopAndDestroy(descriptiveName); |
|
418 iTextGenerator->SetTextL(*iAddText); |
|
419 |
|
420 iTextGenerator->SetTransitionAndAlignmentsL(EVeiTitleClipTransitionNone, |
|
421 EVeiTitleClipHorizontalAlignmentCenter, |
|
422 EVeiTitleClipVerticalAlignmentCenter); |
|
423 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 2"); |
|
424 TRAPD(err, iMovie->InsertVideoClipL( *iTextGenerator, ETrue, 0)); |
|
425 |
|
426 if (KErrNone == err) |
|
427 { |
|
428 // Generator is no longer our concern, ownership transferred to iMovie |
|
429 iTextGenerator = 0; |
|
430 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 3"); |
|
431 StartWaitDialogL(); |
|
432 } |
|
433 else |
|
434 { |
|
435 iError = err; |
|
436 iError = FilterError(); |
|
437 iState = EStateFinalizing; |
|
438 CompleteRequest(); |
|
439 } |
|
440 break; |
|
441 } |
|
442 |
|
443 case EStateInsertTextToEnd: |
|
444 { |
|
445 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 4"); |
|
446 |
|
447 iTextGenerator = CVeiTitleClipGenerator::NewL( iMovie->Resolution(), |
|
448 EVeiTitleClipTransitionScrollBottomToTop, |
|
449 EVeiTitleClipHorizontalAlignmentCenter, |
|
450 EVeiTitleClipVerticalAlignmentCenter); |
|
451 |
|
452 HBufC* descriptiveName = StringLoader::LoadLC(R_VESM_EDIT_VIEW_TITLE_NAME, &iEnv ); |
|
453 iTextGenerator->SetDescriptiveNameL(*descriptiveName); |
|
454 CleanupStack::PopAndDestroy(descriptiveName); |
|
455 iTextGenerator->SetTextL(*iAddText); |
|
456 |
|
457 iTextGenerator->SetTransitionAndAlignmentsL(EVeiTitleClipTransitionScrollBottomToTop, |
|
458 EVeiTitleClipHorizontalAlignmentCenter, |
|
459 EVeiTitleClipVerticalAlignmentCenter); |
|
460 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 5"); |
|
461 |
|
462 TRAPD(err, iMovie->InsertVideoClipL( *iTextGenerator, ETrue, 1)); |
|
463 |
|
464 if (KErrNone == err) |
|
465 { |
|
466 // Generator is no longer our concern, ownership transferred to iMovie |
|
467 iTextGenerator = 0; |
|
468 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: 6"); |
|
469 StartWaitDialogL(); |
|
470 } |
|
471 else |
|
472 { |
|
473 iError = err; |
|
474 iError = FilterError(); |
|
475 iState = EStateFinalizing; |
|
476 CompleteRequest(); |
|
477 } |
|
478 break; |
|
479 } |
|
480 |
|
481 case EStateProcessing: |
|
482 { |
|
483 StartMovieProcessingL(iSourceFileName); |
|
484 break; |
|
485 } |
|
486 |
|
487 case EStateProcessingOk: |
|
488 { |
|
489 ProcessingOkL(); |
|
490 CompleteRequest(); |
|
491 break; |
|
492 } |
|
493 |
|
494 case EStateProcessingFailed: |
|
495 { |
|
496 ProcessingFailed(); |
|
497 CompleteRequest(); |
|
498 break; |
|
499 } |
|
500 |
|
501 case EStateFinalizing: |
|
502 { |
|
503 // Show possible error dialog etc. |
|
504 // in TRAP because endless call loop may otherwise be resulted in case of leave in HandleErrorL |
|
505 // @ : should FilterError() be called only from here? |
|
506 HandleError(); |
|
507 iState = EStateReady; |
|
508 CompleteRequest(); |
|
509 break; |
|
510 } |
|
511 |
|
512 case EStateReady: |
|
513 { |
|
514 // Notify completion to observer |
|
515 iExitObserver.HandleSimpleVideoEditorExit( iError, iOutputFileName ); |
|
516 break; |
|
517 } |
|
518 |
|
519 default: |
|
520 { |
|
521 User::Invariant(); |
|
522 break; |
|
523 } |
|
524 } |
|
525 |
|
526 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunL: Out"); |
|
527 } |
|
528 |
|
529 //============================================================================= |
|
530 void CSimpleVideoEditorImpl::DoCancel() |
|
531 { |
|
532 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DoCancel: In"); |
|
533 CancelMovieProcessing(); |
|
534 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DoCancel: Out"); |
|
535 } |
|
536 //============================================================================= |
|
537 |
|
538 void CSimpleVideoEditorImpl::CancelMovieProcessing() |
|
539 { |
|
540 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::CancelMovieProcessing: In"); |
|
541 |
|
542 if (iMovie) |
|
543 { |
|
544 iMovie->CancelProcessing(); |
|
545 } |
|
546 |
|
547 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::CancelMovieProcessing: Out"); |
|
548 } |
|
549 //============================================================================= |
|
550 |
|
551 TInt CSimpleVideoEditorImpl::RunError( TInt aError ) |
|
552 { |
|
553 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::RunError: %d", aError); |
|
554 //@ : think how to solve this |
|
555 |
|
556 // Show possible error dialog etc. |
|
557 iError = aError; |
|
558 // @: if leave and error happens so that Notify callbacks are not called |
|
559 iError = FilterError(); |
|
560 |
|
561 // if leave happens in HandleError, iState must be changed to prevent same leave happening eternally |
|
562 if (EStateReady == iState) |
|
563 { |
|
564 iExitObserver.HandleSimpleVideoEditorExit( iError, iOutputFileName ); |
|
565 } |
|
566 else |
|
567 { |
|
568 iState = EStateReady; |
|
569 HandleError(); |
|
570 iExitObserver.HandleSimpleVideoEditorExit( iError, iOutputFileName ); |
|
571 // If CompleteRequest() is called here, system crashes because ~CSimpleVideoEditorImpl() gets |
|
572 // called from iExitObserver.HandleSimpleVideoEditorExitL(), stray signal resulted |
|
573 //CompleteRequest(); |
|
574 } |
|
575 |
|
576 return KErrNone; |
|
577 } |
|
578 //======================================================================================================= |
|
579 |
|
580 void CSimpleVideoEditorImpl::InitializeOperationL() |
|
581 { |
|
582 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::InitializeOperationL: In"); |
|
583 |
|
584 iOutputFileName.Zero(); |
|
585 |
|
586 if( !AknLayoutUtils::PenEnabled() && EOperationModeAddText == iOperationMode ) |
|
587 { |
|
588 // Text input is always inserted in portrait mode. |
|
589 // Store the original screen orientation. |
|
590 CAknAppUiBase* appUi = static_cast<CAknAppUiBase *>( iEnv.EikAppUi() ); |
|
591 iOriginalOrientation = appUi->Orientation(); |
|
592 appUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait); |
|
593 } |
|
594 |
|
595 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::InitializeOperationL: Out"); |
|
596 } |
|
597 |
|
598 //======================================================================================================= |
|
599 void CSimpleVideoEditorImpl::GetMergeInputFileL() |
|
600 { |
|
601 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: In"); |
|
602 |
|
603 iVideoOrImageIndex = 0; |
|
604 |
|
605 CDesCArrayFlat* selectedFiles = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
606 CleanupStack::PushL(selectedFiles); |
|
607 |
|
608 CDesCArrayFlat* mimetypesVideo = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
609 CleanupStack::PushL(mimetypesVideo); |
|
610 mimetypesVideo->AppendL(_L("video/*")); |
|
611 |
|
612 CDesCArrayFlat* mimetypesImage = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
613 CleanupStack::PushL(mimetypesImage); |
|
614 mimetypesImage->AppendL(_L("image/*")); |
|
615 |
|
616 TInt videoOrImage = -1; |
|
617 TBool chosen = EFalse; |
|
618 |
|
619 // Select the input type: video clip or image |
|
620 if ( ShowListQueryL(videoOrImage, R_VEI_QUERY_HEADING_MERGE_WITH, R_VED_VIDEO_OR_IMAGE_QUERY) ) |
|
621 { |
|
622 CVeiMGFetchVerifier* mgFetchVerifier = CVeiMGFetchVerifier::NewLC(); |
|
623 if (0 == videoOrImage) // video chosen |
|
624 { |
|
625 if ( MGFetch::RunL( *selectedFiles, EVideoFile, EFalse, KNullDesC(), KNullDesC(), mimetypesVideo, mgFetchVerifier)) |
|
626 { |
|
627 chosen = ETrue; |
|
628 } |
|
629 } |
|
630 else if (1 == videoOrImage) // image chosen |
|
631 { |
|
632 if ( MGFetch::RunL( *selectedFiles, EImageFile, EFalse, KNullDesC(), KNullDesC(), mimetypesImage, mgFetchVerifier)) |
|
633 { |
|
634 chosen = ETrue; |
|
635 } |
|
636 } |
|
637 CleanupStack::PopAndDestroy( mgFetchVerifier ); |
|
638 |
|
639 if (chosen) |
|
640 { |
|
641 iMergeFileName = selectedFiles->MdcaPoint(0); |
|
642 TInt headingResourceId = R_VIE_QUERY_HEADING_ADD_VIDEO_TO; |
|
643 if (0 == videoOrImage) // video chosen |
|
644 { |
|
645 iOperationMode = EOperationModeMergeWithVideo; |
|
646 iState = EStateInsertVideo; |
|
647 headingResourceId = R_VIE_QUERY_HEADING_ADD_VIDEO_TO; |
|
648 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: 4"); |
|
649 } |
|
650 else if (1 == videoOrImage) // image chosen |
|
651 { |
|
652 iOperationMode = EOperationModeMergeWithImage; |
|
653 iState = EStateCreateImageGenerator; |
|
654 headingResourceId = R_VIE_QUERY_HEADING_ADD_IMAGE_TO; |
|
655 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: 5"); |
|
656 } |
|
657 |
|
658 TInt begOrEnd = -1; |
|
659 if ( ShowListQueryL(begOrEnd, headingResourceId, R_VED_INSERT_POSITION_QUERY) ) |
|
660 { |
|
661 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: 6"); |
|
662 |
|
663 if (0 == begOrEnd) // video or image to the beginning |
|
664 { |
|
665 iVideoOrImageIndex = 0; |
|
666 } |
|
667 else // video or image to end |
|
668 { |
|
669 iVideoOrImageIndex = 1; |
|
670 } |
|
671 } |
|
672 else |
|
673 { |
|
674 iState = EStateFinalizing; |
|
675 } |
|
676 } // if (chosen) |
|
677 else |
|
678 { |
|
679 iState = EStateFinalizing; |
|
680 } |
|
681 } // if ( ShowListQueryL for image or video |
|
682 else |
|
683 { |
|
684 iState = EStateFinalizing; |
|
685 } |
|
686 |
|
687 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: 7"); |
|
688 CleanupStack::PopAndDestroy(mimetypesImage); |
|
689 CleanupStack::PopAndDestroy(mimetypesVideo); |
|
690 CleanupStack::PopAndDestroy(selectedFiles); |
|
691 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetMergeInputFileL: Out"); |
|
692 } |
|
693 |
|
694 //======================================================================================================= |
|
695 void CSimpleVideoEditorImpl::GetAudioFileL() |
|
696 { |
|
697 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetAudioFileL: In"); |
|
698 |
|
699 TFileName outputFile; |
|
700 |
|
701 CDesCArrayFlat* selectedFiles = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
702 CleanupStack::PushL(selectedFiles); |
|
703 CVeiMGFetchVerifier* mgFetchVerifier = CVeiMGFetchVerifier::NewLC(); |
|
704 |
|
705 if ( MGFetch::RunL( *selectedFiles, EAudioFile, EFalse, KNullDesC, KNullDesC , iAcceptedAudioTypes, mgFetchVerifier ) ) |
|
706 { |
|
707 iAudioFileName = selectedFiles->MdcaPoint(0); |
|
708 iAudioClipInfo = CVedAudioClipInfo::NewL( iAudioFileName, *this ); |
|
709 iState = EStateCheckAudioLength; |
|
710 } |
|
711 else |
|
712 { |
|
713 iState = EStateFinalizing; |
|
714 } |
|
715 |
|
716 CleanupStack::PopAndDestroy( mgFetchVerifier ); |
|
717 CleanupStack::PopAndDestroy(selectedFiles); |
|
718 |
|
719 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetAudioFileL: Out"); |
|
720 } |
|
721 |
|
722 //======================================================================================================= |
|
723 void CSimpleVideoEditorImpl::GetTextL() |
|
724 { |
|
725 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetTextL: In"); |
|
726 |
|
727 // Ask for text. |
|
728 iAddText = HBufC::NewL(AKNTEXT_QUERY_WIDTH * AKNTEXT_QUERY_LINES); // think what these limit values should be? |
|
729 TPtr textPtr = iAddText->Des(); |
|
730 CMultiLineQueryDialog* textQuery = CMultiLineQueryDialog::NewL(textPtr); |
|
731 textQuery->SetMaxLength(AKNTEXT_QUERY_WIDTH * AKNTEXT_QUERY_LINES); |
|
732 //textQuery->SetPredictiveTextInputPermitted(ETrue); |
|
733 |
|
734 if (textQuery->ExecuteLD(R_VESM_EDITVIDEO_TITLESCREEN_TEXT_QUERY)) |
|
735 { |
|
736 // Restore the original screen orientation immediately after the text input ends |
|
737 RestoreOrientation(); |
|
738 |
|
739 TInt begOrEnd = -1; |
|
740 |
|
741 if ( ShowListQueryL(begOrEnd, R_VEI_QUERY_HEADING_ADD_TEXT_TO, R_VED_INSERT_POSITION_QUERY) ) |
|
742 { |
|
743 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetTextL: 1"); |
|
744 |
|
745 if (0 == begOrEnd) // text to begin |
|
746 { |
|
747 iState = EStateInsertTextToBegin; |
|
748 } |
|
749 else // text to end in credits style (rolling down the screen) |
|
750 { |
|
751 iState = EStateInsertTextToEnd; |
|
752 } |
|
753 } |
|
754 else |
|
755 { |
|
756 iState = EStateFinalizing; |
|
757 } |
|
758 } |
|
759 else |
|
760 { |
|
761 // Restore the original screen orientation immediately after the text input ends |
|
762 RestoreOrientation(); |
|
763 iState = EStateFinalizing; |
|
764 } |
|
765 |
|
766 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::GetTextL: Out"); |
|
767 } |
|
768 |
|
769 //======================================================================================================= |
|
770 TInt CSimpleVideoEditorImpl::ShowListQueryL (TInt& aPosition, |
|
771 TInt aHeadingResourceId, |
|
772 TInt aQueryResourceId) const |
|
773 { |
|
774 CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &aPosition ); |
|
775 dlg->PrepareLC( aQueryResourceId ); |
|
776 |
|
777 CAknPopupHeadingPane* heading = dlg->QueryHeading(); |
|
778 HBufC* noteText = StringLoader::LoadLC( aHeadingResourceId, &iEnv ); |
|
779 heading->SetTextL( noteText->Des() ); |
|
780 CleanupStack::PopAndDestroy( noteText ); |
|
781 |
|
782 return dlg->RunLD(); |
|
783 } |
|
784 |
|
785 //======================================================================================================= |
|
786 void CSimpleVideoEditorImpl::StartMovieProcessingL(const TDesC& aSourceFile) |
|
787 { |
|
788 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMovieProcessingL: In"); |
|
789 |
|
790 RFs& fs = iEnv.FsSession(); |
|
791 |
|
792 if (QueryAndSaveL(aSourceFile)) |
|
793 { |
|
794 // Generate temp file. |
|
795 // Take the drive from the target file name. |
|
796 CAknMemorySelectionDialog::TMemory memory( CAknMemorySelectionDialog::EMemoryCard ); |
|
797 if( 0 != iOutputFileName.Left(1).CompareF( PathInfo::MemoryCardRootPath().Left(1) ) ) |
|
798 { |
|
799 memory = CAknMemorySelectionDialog::EPhoneMemory; |
|
800 } |
|
801 |
|
802 iTempFile = HBufC::NewL(KMaxFileName); |
|
803 CVeiTempMaker* maker = CVeiTempMaker::NewL(); |
|
804 maker->GenerateTempFileName( *iTempFile, memory, iMovie->Format() ); |
|
805 delete maker; |
|
806 |
|
807 // Start rendering video to the temporary file. |
|
808 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMovieProcessingL: 1, calling iMovie->ProcessL(%S)", iTempFile); |
|
809 iMovie->ProcessL(*iTempFile, *this); |
|
810 } |
|
811 else |
|
812 { |
|
813 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMovieProcessingL: User cancelled saving"); |
|
814 iState = EStateProcessingFailed; |
|
815 CompleteRequest(); |
|
816 } |
|
817 |
|
818 // Next: wait for MVedMovieProcessingObserver callback |
|
819 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartMovieProcessingL: Out"); |
|
820 } |
|
821 |
|
822 //============================================================================= |
|
823 TInt CSimpleVideoEditorImpl::QueryAndSaveL(const TDesC& aSourceFileName) |
|
824 { |
|
825 |
|
826 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::QueryAndSaveL: in"); |
|
827 |
|
828 TBool ret = EFalse; |
|
829 |
|
830 RFs fs = CCoeEnv::Static()->FsSession(); |
|
831 |
|
832 // launch query with choices "Replace original" and "Save with a new file name" |
|
833 TInt userSelection = LaunchSaveVideoQueryL(); |
|
834 |
|
835 if(userSelection == 0) |
|
836 // the user selects to save with a new file name |
|
837 { |
|
838 CAknMemorySelectionDialog::TMemory selectedMemory(CAknMemorySelectionDialog::EPhoneMemory); |
|
839 |
|
840 // Multiple drive support |
|
841 #ifdef RD_MULTIPLE_DRIVE |
|
842 |
|
843 TDriveNumber driveNumber; |
|
844 TFileName driveAndPath; |
|
845 CAknMemorySelectionDialogMultiDrive* multiDriveDlg = CAknMemorySelectionDialogMultiDrive::NewL(ECFDDialogTypeSave, EFalse ); |
|
846 CleanupStack::PushL(multiDriveDlg); |
|
847 |
|
848 // launch "Select memory" query |
|
849 if (multiDriveDlg->ExecuteL( driveNumber, &driveAndPath, NULL )) |
|
850 { |
|
851 iOutputFileName.Zero(); |
|
852 |
|
853 // Generate a default name for the new file |
|
854 TInt err = VideoEditorUtils::GenerateFileNameL ( |
|
855 fs, |
|
856 aSourceFileName, |
|
857 iOutputFileName, |
|
858 iMovie->Format(), |
|
859 iMovie->GetSizeEstimateL(), |
|
860 driveAndPath); |
|
861 |
|
862 driveAndPath.Append( PathInfo::VideosPath() ); |
|
863 |
|
864 if ( KErrNone == err ) |
|
865 { |
|
866 // launch file name prompt dialog |
|
867 if (CAknFileNamePromptDialog::RunDlgLD(iOutputFileName, driveAndPath, KNullDesC)) |
|
868 { |
|
869 driveAndPath.Append(iOutputFileName); |
|
870 iOutputFileName = driveAndPath; |
|
871 ret = ETrue; |
|
872 } |
|
873 } |
|
874 else // err != KErrNone |
|
875 { |
|
876 iErrorUI->ShowGlobalErrorNoteL( err ); |
|
877 ret = EFalse; |
|
878 } |
|
879 } |
|
880 CleanupStack::PopAndDestroy( multiDriveDlg ); |
|
881 |
|
882 #else // no multiple drive support |
|
883 |
|
884 // launch "Select memory" query |
|
885 if (CAknMemorySelectionDialog::RunDlgLD(selectedMemory)) |
|
886 { |
|
887 // create path for the image |
|
888 TFileName driveAndPath; |
|
889 VideoEditor::TMemory memorySelection = VideoEditor::EMemPhoneMemory; |
|
890 if (selectedMemory == CAknMemorySelectionDialog::EPhoneMemory) |
|
891 { |
|
892 memorySelection = VideoEditor::EMemPhoneMemory; |
|
893 driveAndPath.Copy( PathInfo::PhoneMemoryRootPath() ); |
|
894 driveAndPath.Append( PathInfo::VideosPath() ); |
|
895 } |
|
896 else if (selectedMemory == CAknMemorySelectionDialog::EMemoryCard) |
|
897 { |
|
898 memorySelection = VideoEditor::EMemMemoryCard; |
|
899 driveAndPath.Copy( PathInfo::MemoryCardRootPath() ); |
|
900 driveAndPath.Append( PathInfo::VideosPath() ); |
|
901 } |
|
902 |
|
903 |
|
904 // GenerateNewDocumentNameL also checks disk space |
|
905 iOutputFileName.Zero(); |
|
906 TInt err = VideoEditorUtils::GenerateNewDocumentNameL ( |
|
907 fs, |
|
908 aSourceFileName, |
|
909 iOutputFileName, |
|
910 iMovie->Format(), |
|
911 iMovie->GetSizeEstimateL(), |
|
912 memorySelection); |
|
913 |
|
914 if ( KErrNone == err ) |
|
915 { |
|
916 // launch file name prompt dialog |
|
917 if (CAknFileNamePromptDialog::RunDlgLD(iOutputFileName, driveAndPath, KNullDesC)) |
|
918 { |
|
919 driveAndPath.Append(iOutputFileName); |
|
920 iOutputFileName = driveAndPath; |
|
921 ret = ETrue; |
|
922 } |
|
923 } |
|
924 else // err != KErrNone |
|
925 { |
|
926 ret = EFalse; |
|
927 } |
|
928 } |
|
929 #endif |
|
930 } |
|
931 // user selects to overwrite |
|
932 else if (userSelection == 1) |
|
933 |
|
934 { |
|
935 iOutputFileName = aSourceFileName; |
|
936 return ETrue; |
|
937 } |
|
938 else // user cancelled |
|
939 { |
|
940 ret = EFalse; |
|
941 } |
|
942 |
|
943 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::QueryAndSaveL: out: %d", ret); |
|
944 |
|
945 return ret; |
|
946 } |
|
947 |
|
948 |
|
949 |
|
950 //============================================================================= |
|
951 TInt CSimpleVideoEditorImpl::LaunchListQueryDialogL ( |
|
952 MDesCArray * aTextItems, |
|
953 const TDesC & aPrompt |
|
954 ) |
|
955 { |
|
956 |
|
957 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::LaunchListQueryDialogL: in"); |
|
958 // Selected text item index |
|
959 TInt index (-1); |
|
960 |
|
961 // Create a new list dialog |
|
962 CAknListQueryDialog * dlg = new (ELeave) CAknListQueryDialog (&index); |
|
963 |
|
964 // Prepare list query dialog |
|
965 dlg->PrepareLC (R_VIE_LIST_QUERY); |
|
966 |
|
967 // Set heading |
|
968 dlg->QueryHeading()->SetTextL (aPrompt); |
|
969 |
|
970 // Set text item array |
|
971 dlg->SetItemTextArray (aTextItems); |
|
972 |
|
973 // Set item ownership |
|
974 dlg->SetOwnershipType (ELbmDoesNotOwnItemArray); |
|
975 |
|
976 // Execute |
|
977 if (dlg->RunLD()) |
|
978 { |
|
979 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::LaunchListQueryDialogL: out: return %d", index); |
|
980 return index; |
|
981 } |
|
982 else |
|
983 { |
|
984 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::LaunchListQueryDialogL: out: return -1"); |
|
985 return -1; |
|
986 } |
|
987 } |
|
988 |
|
989 //============================================================================= |
|
990 TInt CSimpleVideoEditorImpl::LaunchSaveVideoQueryL () |
|
991 { |
|
992 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::LaunchSaveVideoQueryL: in"); |
|
993 // Create dialog heading and options |
|
994 HBufC * heading = CEikonEnv::Static()->AllocReadResourceLC (R_VIE_QUERY_HEADING_SAVE); |
|
995 HBufC * option1 = CEikonEnv::Static()->AllocReadResourceLC (R_VIE_QUERY_SAVE_NEW); |
|
996 HBufC * option2 = CEikonEnv::Static()->AllocReadResourceLC (R_VIE_QUERY_SAVE_REPLACE); |
|
997 |
|
998 // Query dialog texts |
|
999 CDesCArray * options = new (ELeave) CDesCArraySeg (2); |
|
1000 CleanupStack::PushL (options); |
|
1001 options->AppendL( option1->Des() ); |
|
1002 options->AppendL( option2->Des() ); |
|
1003 |
|
1004 // Execute query dialog |
|
1005 TInt ret = LaunchListQueryDialogL (options, *heading); |
|
1006 |
|
1007 options->Reset(); |
|
1008 |
|
1009 CleanupStack::PopAndDestroy( options ); |
|
1010 CleanupStack::PopAndDestroy( option2 ); |
|
1011 CleanupStack::PopAndDestroy( option1 ); |
|
1012 CleanupStack::PopAndDestroy( heading ); |
|
1013 |
|
1014 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::LaunchListQueryDialogL: out: return %d", ret); |
|
1015 return ret; |
|
1016 } |
|
1017 |
|
1018 |
|
1019 |
|
1020 //======================================================================================================= |
|
1021 void CSimpleVideoEditorImpl::HandleLosingForeground() |
|
1022 { |
|
1023 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleLosingForeground(): In"); |
|
1024 |
|
1025 // Set the priority to low. This is needed to handle the situations |
|
1026 // where the engine is performing heavy processing while the application |
|
1027 // is in background. |
|
1028 RProcess myProcess; |
|
1029 iOriginalProcessPriority = myProcess.Priority(); |
|
1030 LOGFMT3(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleLosingForeground: changing priority of process %Ld from %d to %d", myProcess.Id().Id(), iOriginalProcessPriority, KLowPriority); |
|
1031 myProcess.SetPriority( KLowPriority ); |
|
1032 iProcessPriorityAltered = ETrue; |
|
1033 |
|
1034 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleLosingForeground(): Out"); |
|
1035 } |
|
1036 |
|
1037 //======================================================================================================= |
|
1038 void CSimpleVideoEditorImpl::HandleGainingForeground() |
|
1039 { |
|
1040 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleGainingForeground(): In"); |
|
1041 |
|
1042 // Return to normal priority. |
|
1043 RProcess myProcess; |
|
1044 TProcessPriority priority = myProcess.Priority(); |
|
1045 if ( priority < iOriginalProcessPriority ) |
|
1046 { |
|
1047 myProcess.SetPriority( iOriginalProcessPriority ); |
|
1048 } |
|
1049 iProcessPriorityAltered = EFalse; |
|
1050 |
|
1051 LOGFMT2(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleGainingForeground: Out: process %Ld back to normal priority %d", myProcess.Id().Id(), priority); |
|
1052 } |
|
1053 |
|
1054 //======================================================================================================= |
|
1055 TInt CSimpleVideoEditorImpl::FilterError(/*const TInt& aErrEngine, const TInt& aErrUi*/) const |
|
1056 { |
|
1057 // here standard leave codes are converted to our own codes having correspondent localized error messages |
|
1058 if (KErrNone != iError && KErrCancel != iError) |
|
1059 { |
|
1060 if (EStateInsertInputFirst == iState ) |
|
1061 { |
|
1062 return KErrUnableToEditVideo; |
|
1063 } |
|
1064 else if (EStateInsertVideo == iState) |
|
1065 { |
|
1066 if (KErrNotSupported == iError) |
|
1067 { |
|
1068 return KErrVideoFormatNotSupported; |
|
1069 } |
|
1070 else return KErrUnableToInsertVideo; |
|
1071 } |
|
1072 else if (EStateInsertImage == iState || EStateCreateImageGenerator == iState) |
|
1073 { |
|
1074 if (KErrNotSupported == iError) |
|
1075 { |
|
1076 return KErrImageFormatNotSupported; |
|
1077 } |
|
1078 else return KErrUnableToInsertImage; |
|
1079 } |
|
1080 else if (EStateInsertAudio == iState || EStateCheckAudioLength == iState ) |
|
1081 { |
|
1082 if (KErrNotSupported == iError) |
|
1083 { |
|
1084 return KErrAudioFormatNotSupported; |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 return KErrUnableToInsertSound; |
|
1089 } |
|
1090 } |
|
1091 else if (EStateInsertTextToBegin == iState || EStateInsertTextToEnd == iState) |
|
1092 { |
|
1093 return KErrUnableToInsertText; |
|
1094 } |
|
1095 else if (EOperationModeMergeWithVideo == iOperationMode) |
|
1096 { |
|
1097 return KErrUnableToMergeVideos; |
|
1098 } |
|
1099 else if (EOperationModeMergeWithImage == iOperationMode) |
|
1100 { |
|
1101 return KErrUnableToMergeVideoAndImage; |
|
1102 } |
|
1103 else if (EOperationModeChangeAudio == iOperationMode) |
|
1104 { |
|
1105 return KErrUnableToChangeSound; |
|
1106 } |
|
1107 else if (EOperationModeAddText == iOperationMode) |
|
1108 { |
|
1109 if (iError == KErrNoMemory) return KErrNoMemory; |
|
1110 return KErrUnableToInsertText; |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 return iError; |
|
1115 } |
|
1116 |
|
1117 |
|
1118 //============================================================================= |
|
1119 void CSimpleVideoEditorImpl::CompleteRequest() |
|
1120 { |
|
1121 if ( IsActive() ) |
|
1122 { |
|
1123 Cancel(); |
|
1124 } |
|
1125 TRequestStatus * p = &iStatus; |
|
1126 SetActive(); |
|
1127 User::RequestComplete (p, KErrNone); |
|
1128 } |
|
1129 |
|
1130 //============================================================================= |
|
1131 void CSimpleVideoEditorImpl::HandleError() |
|
1132 { |
|
1133 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleErrorL: In, iError:%d", iError); |
|
1134 |
|
1135 if (KErrNone != iError && KErrCancel != iError) |
|
1136 { |
|
1137 |
|
1138 if (iTempFile) |
|
1139 { |
|
1140 TInt delErr = iEnv.FsSession().Delete( *iTempFile ); |
|
1141 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleErrorL: 1, delErr:%d", delErr); |
|
1142 delete iTempFile; |
|
1143 iTempFile = NULL; |
|
1144 } |
|
1145 |
|
1146 switch (iError) |
|
1147 { |
|
1148 case KErrInUse: |
|
1149 { |
|
1150 ShowErrorNote(R_VEI_IN_USE); |
|
1151 break; |
|
1152 } |
|
1153 case KErrUnableToEditVideo: |
|
1154 { |
|
1155 ShowErrorNote(R_VEI_UNABLE_TO_EDIT); |
|
1156 break; |
|
1157 } |
|
1158 case KErrUnableToInsertVideo: |
|
1159 { |
|
1160 ShowErrorNote(R_VEI_UNABLE_TO_INSERT_VIDEO); |
|
1161 break; |
|
1162 } |
|
1163 case KErrUnableToInsertSound: |
|
1164 { |
|
1165 ShowErrorNote(R_VEI_UNABLE_TO_INSERT_SOUND); |
|
1166 break; |
|
1167 } |
|
1168 case KErrUnableToInsertImage: |
|
1169 { |
|
1170 ShowErrorNote(R_VEI_UNABLE_TO_INSERT_IMAGE); |
|
1171 break; |
|
1172 } |
|
1173 case KErrUnableToInsertText: |
|
1174 { |
|
1175 ShowErrorNote(R_VEI_UNABLE_TO_INSERT_TEXT); |
|
1176 break; |
|
1177 } |
|
1178 case KErrUnableToMergeVideos: |
|
1179 { |
|
1180 ShowErrorNote(R_VEI_UNABLE_TO_MERGE_VIDEOS); |
|
1181 break; |
|
1182 } |
|
1183 case KErrUnableToMergeVideoAndImage: |
|
1184 { |
|
1185 ShowErrorNote(R_VEI_UNABLE_TO_MERGE_VIDEO_IMAGE); |
|
1186 break; |
|
1187 } |
|
1188 case KErrUnableToChangeSound: |
|
1189 { |
|
1190 ShowErrorNote(R_VEI_UNABLE_TO_CHANGE_SOUND); |
|
1191 break; |
|
1192 } |
|
1193 case KErrVideoFormatNotSupported: |
|
1194 { |
|
1195 ShowErrorNote(R_VEI_UNABLE_TO_INSERT_VIDEO); |
|
1196 break; |
|
1197 } |
|
1198 case KErrAudioFormatNotSupported: |
|
1199 { |
|
1200 ShowErrorNote(R_VEI_AUDIO_FORMAT_NOT_SUPPORTED); |
|
1201 break; |
|
1202 } |
|
1203 case KErrImageFormatNotSupported: |
|
1204 { |
|
1205 ShowErrorNote(R_VEI_IMAGE_FORMAT_NOT_SUPPORTED); |
|
1206 break; |
|
1207 } |
|
1208 case KErrNoMemory: |
|
1209 { |
|
1210 ShowErrorNote(R_VEI_NOT_ENOUGH_MEMORY); |
|
1211 break; |
|
1212 } |
|
1213 default: |
|
1214 { |
|
1215 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleErrorL: 4"); |
|
1216 ShowErrorNote(R_VEI_ERROR_NOTE); |
|
1217 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleErrorL: 5"); |
|
1218 break; |
|
1219 } |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::HandleErrorL: Out"); |
|
1224 } |
|
1225 |
|
1226 //============================================================================= |
|
1227 void CSimpleVideoEditorImpl::ShowErrorNote( const TInt aResourceId ) const |
|
1228 { |
|
1229 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ShowErrorNoteL: In"); |
|
1230 |
|
1231 TRAP_IGNORE( |
|
1232 HBufC* stringholder = StringLoader::LoadLC( aResourceId, &iEnv ); |
|
1233 CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote( ETrue ); |
|
1234 dlg->ExecuteLD( *stringholder ); |
|
1235 CleanupStack::PopAndDestroy( stringholder ); |
|
1236 ); |
|
1237 |
|
1238 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ShowErrorNoteL: out"); |
|
1239 } |
|
1240 |
|
1241 //======================================================================================================= |
|
1242 void CSimpleVideoEditorImpl::StartWaitDialogL() |
|
1243 { |
|
1244 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartWaitDialogL: In"); |
|
1245 if (iWaitDialog) |
|
1246 { |
|
1247 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartWaitDialogL: 2"); |
|
1248 delete iWaitDialog; |
|
1249 iWaitDialog = NULL; |
|
1250 } |
|
1251 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartWaitDialogL: 3"); |
|
1252 |
|
1253 iWaitDialog = new ( ELeave ) CAknWaitDialog( |
|
1254 reinterpret_cast<CEikDialog**>(&iWaitDialog), ETrue ); // !!! |
|
1255 iWaitDialog->PrepareLC(R_VEI_WAIT_NOTE_WITH_CANCEL); |
|
1256 iWaitDialog->SetCallback( this ); |
|
1257 |
|
1258 HBufC* stringholder = StringLoader::LoadLC( R_VEI_NOTE_PROCESSING, &iEnv ); |
|
1259 iWaitDialog->SetTextL( *stringholder ); |
|
1260 CleanupStack::PopAndDestroy(stringholder); |
|
1261 |
|
1262 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartWaitDialogL: 4"); |
|
1263 iWaitDialog->RunLD(); |
|
1264 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartWaitDialogL: Out"); |
|
1265 } |
|
1266 |
|
1267 //======================================================================================================= |
|
1268 void CSimpleVideoEditorImpl::StartProgressDialogL() |
|
1269 { |
|
1270 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartProgressDialogL: In"); |
|
1271 |
|
1272 if (iProgressDialog) |
|
1273 { |
|
1274 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartProgressDialogL: 1"); |
|
1275 delete iProgressDialog; |
|
1276 iProgressDialog = NULL; |
|
1277 } |
|
1278 |
|
1279 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartProgressDialogL: 2"); |
|
1280 |
|
1281 iProgressDialog = new (ELeave) CAknProgressDialog( |
|
1282 reinterpret_cast<CEikDialog**>(&iProgressDialog), ETrue ); |
|
1283 iProgressDialog->PrepareLC(R_VESM_PROGRESS_NOTE_WITH_CANCEL); |
|
1284 iProgressDialog->SetCallback( this ); |
|
1285 |
|
1286 TInt resId = -1; |
|
1287 HBufC* stringholder = NULL; |
|
1288 switch (iOperationMode) |
|
1289 { |
|
1290 case EOperationModeMergeWithVideo: |
|
1291 case EOperationModeMergeWithImage: |
|
1292 TApaAppCaption caption; |
|
1293 TRAPD( err, ResolveCaptionNameL( caption ) ); |
|
1294 |
|
1295 // If something goes wrong, show basic "Saving" note |
|
1296 if ( err ) |
|
1297 { |
|
1298 stringholder = iEnv.AllocReadResourceLC( R_VEI_NOTE_PROCESSING ); |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 stringholder = StringLoader::LoadLC( R_VEI_NOTE_MERGING, caption, &iEnv ); |
|
1303 } |
|
1304 break; |
|
1305 case EOperationModeChangeAudio: |
|
1306 resId = R_VEI_NOTE_ADDING_AUDIO; |
|
1307 stringholder = StringLoader::LoadLC( resId, &iEnv ); |
|
1308 break; |
|
1309 case EOperationModeAddText: |
|
1310 resId = R_VEI_NOTE_ADDING_TEXT; |
|
1311 stringholder = StringLoader::LoadLC( resId, &iEnv ); |
|
1312 break; |
|
1313 default : |
|
1314 resId = R_VEI_NOTE_PROCESSING; |
|
1315 stringholder = StringLoader::LoadLC( resId, &iEnv ); |
|
1316 break; |
|
1317 } |
|
1318 |
|
1319 iProgressDialog->SetTextL( *stringholder ); |
|
1320 CleanupStack::PopAndDestroy(stringholder); |
|
1321 |
|
1322 iProgressDialog->GetProgressInfoL()->SetFinalValue( 100 ); |
|
1323 iProgressDialog->RunLD(); |
|
1324 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::StartProgressDialogL: Out"); |
|
1325 } |
|
1326 |
|
1327 //============================================================================= |
|
1328 void CSimpleVideoEditorImpl::ResolveCaptionNameL( TApaAppCaption& aCaption ) const |
|
1329 { |
|
1330 RApaLsSession appArcSession; |
|
1331 CleanupClosePushL( appArcSession ); |
|
1332 User::LeaveIfError( appArcSession.Connect() ); |
|
1333 |
|
1334 // Get Media Gallery caption |
|
1335 TApaAppInfo appInfo; |
|
1336 User::LeaveIfError( appArcSession.GetAppInfo( appInfo, TUid::Uid( KMediaGalleryUID3 ) ) ); |
|
1337 |
|
1338 aCaption = appInfo.iCaption; |
|
1339 |
|
1340 CleanupStack::PopAndDestroy( &appArcSession ); |
|
1341 } |
|
1342 |
|
1343 //======================================================================================================= |
|
1344 void CSimpleVideoEditorImpl::StartAnimatedProgressDialogL () |
|
1345 { |
|
1346 delete iAnimatedProgressDialog; |
|
1347 iAnimatedProgressDialog = NULL; |
|
1348 iAnimatedProgressDialog = new (ELeave) CExtProgressDialog( &iAnimatedProgressDialog ); |
|
1349 |
|
1350 iAnimatedProgressDialog->PrepareLC(R_WAIT_DIALOG); |
|
1351 iAnimatedProgressDialog->SetCallback( this ); |
|
1352 |
|
1353 TInt labelResId = -1; |
|
1354 TInt animResId = -1; |
|
1355 switch (iOperationMode) |
|
1356 { |
|
1357 case EOperationModeMerge: |
|
1358 labelResId = R_VEI_NOTE_MERGING; |
|
1359 animResId = VideoEditor::EAnimationMerging; |
|
1360 break; |
|
1361 case EOperationModeChangeAudio: |
|
1362 labelResId = R_VEI_NOTE_ADDING_AUDIO; |
|
1363 animResId = VideoEditor::EAnimationChangeAudio; |
|
1364 break; |
|
1365 case EOperationModeAddText: |
|
1366 labelResId = R_VEI_NOTE_ADDING_TEXT; |
|
1367 animResId = VideoEditor::EAnimationAddText; |
|
1368 break; |
|
1369 default : |
|
1370 labelResId = R_VEI_NOTE_PROCESSING; |
|
1371 // @ : what is best default animation? |
|
1372 animResId = VideoEditor::EAnimationMerging; |
|
1373 break; |
|
1374 } |
|
1375 |
|
1376 HBufC* stringholder = StringLoader::LoadLC( labelResId, &iEnv ); |
|
1377 iAnimatedProgressDialog->SetTextL( *stringholder ); |
|
1378 CleanupStack::PopAndDestroy(stringholder); |
|
1379 |
|
1380 iAnimatedProgressDialog->SetAnimationResourceIdL( animResId ); |
|
1381 |
|
1382 iAnimatedProgressDialog->GetProgressInfoL()->SetFinalValue( 100 ); |
|
1383 iAnimatedProgressDialog->StartAnimationL(); |
|
1384 iAnimatedProgressDialog->RunLD(); |
|
1385 } |
|
1386 |
|
1387 |
|
1388 //======================================================================================================= |
|
1389 void CSimpleVideoEditorImpl::NotifyMovieProcessingStartedL(CVedMovie& /*aMovie*/) |
|
1390 { |
|
1391 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingStartedL: In"); |
|
1392 |
|
1393 iPercentagesProcessed = 0; |
|
1394 |
|
1395 StartProgressDialogL(); |
|
1396 //StartAnimatedProgressDialogL(); |
|
1397 |
|
1398 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingStartedL: Out"); |
|
1399 } |
|
1400 |
|
1401 //======================================================================================================= |
|
1402 void CSimpleVideoEditorImpl::NotifyMovieProcessingProgressed(CVedMovie& /*aMovie*/, TInt aPercentage) |
|
1403 { |
|
1404 iPercentagesProcessed = aPercentage; |
|
1405 User::ResetInactivityTime(); |
|
1406 if (iAnimatedProgressDialog) |
|
1407 { |
|
1408 TRAP_IGNORE( iAnimatedProgressDialog->GetProgressInfoL()->SetAndDraw( aPercentage ) ); |
|
1409 } |
|
1410 |
|
1411 if (iProgressDialog) |
|
1412 { |
|
1413 TRAP_IGNORE( iProgressDialog->GetProgressInfoL()->SetAndDraw( aPercentage ) ); |
|
1414 } |
|
1415 |
|
1416 if ( iCancelPercentage <= aPercentage ) |
|
1417 { |
|
1418 iCancelPercentage = 101; |
|
1419 } |
|
1420 } |
|
1421 |
|
1422 //======================================================================================================= |
|
1423 void CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted(CVedMovie& /*aMovie*/, TInt aError) |
|
1424 { |
|
1425 LOGFMT2(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: In, aError:%d, iPercentagesProcessed:%d", aError, iPercentagesProcessed); |
|
1426 |
|
1427 iError = aError; |
|
1428 iError = FilterError(); |
|
1429 |
|
1430 if (KErrNone == aError) |
|
1431 { |
|
1432 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: 1"); |
|
1433 iState = EStateProcessingOk; |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: 2"); |
|
1438 iState = EStateProcessingFailed; |
|
1439 } |
|
1440 |
|
1441 if (iAnimatedProgressDialog) |
|
1442 { |
|
1443 TRAP_IGNORE( iAnimatedProgressDialog->GetProgressInfoL()->SetAndDraw( 100 ) ); |
|
1444 delete iAnimatedProgressDialog; |
|
1445 iAnimatedProgressDialog = NULL; |
|
1446 } |
|
1447 if (iProgressDialog) |
|
1448 { |
|
1449 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: 3"); |
|
1450 TRAP_IGNORE( iProgressDialog->GetProgressInfoL()->SetAndDraw( 100 ) ); |
|
1451 TRAP_IGNORE( iProgressDialog->ProcessFinishedL() ); |
|
1452 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: 4"); |
|
1453 } |
|
1454 |
|
1455 // CompleteRequest() moved to DialogDismissed() |
|
1456 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyMovieProcessingCompleted: Out"); |
|
1457 } |
|
1458 |
|
1459 |
|
1460 |
|
1461 //======================================================================================================= |
|
1462 void CSimpleVideoEditorImpl::NotifyAudioClipInfoReady( CVedAudioClipInfo& aInfo, TInt aError ) |
|
1463 { |
|
1464 |
|
1465 LOGFMT( KVideoEditorLogFile, "CVeiEditVideoView::NotifyAudioClipInfoReady: in, aError:%d", aError ); |
|
1466 |
|
1467 if ( aError == KErrNone ) |
|
1468 { |
|
1469 LOG( KVideoEditorLogFile, "CVeiEditVideoView::NotifyAudioClipInfoReady: 1" ); |
|
1470 |
|
1471 TTimeIntervalMicroSeconds audioDuration = aInfo.Duration(); |
|
1472 TTimeIntervalMicroSeconds videoDuration = iMovie->Duration(); |
|
1473 TInt changeSound = 1; |
|
1474 |
|
1475 TRAP_IGNORE( changeSound = QueryAudioInsertionL( videoDuration, audioDuration )); |
|
1476 |
|
1477 if ( changeSound ) |
|
1478 { |
|
1479 iState = EStateInsertAudio; |
|
1480 } |
|
1481 else |
|
1482 { |
|
1483 iState = EStateFinalizing; |
|
1484 } |
|
1485 CompleteRequest(); |
|
1486 |
|
1487 LOG( KVideoEditorLogFile, "CVeiEditVideoView::NotifyAudioClipInfoReady: 2" ); |
|
1488 } |
|
1489 else |
|
1490 { |
|
1491 iError = aError; |
|
1492 iError = FilterError(); |
|
1493 iState = EStateFinalizing; |
|
1494 CompleteRequest(); |
|
1495 } |
|
1496 |
|
1497 LOG( KVideoEditorLogFile, "CVeiEditVideoView::NotifyAudioClipInfoReady: out" ); |
|
1498 } |
|
1499 |
|
1500 |
|
1501 //======================================================================================================= |
|
1502 TInt CSimpleVideoEditorImpl::QueryAudioInsertionL( TTimeIntervalMicroSeconds aVideoDuration, |
|
1503 TTimeIntervalMicroSeconds aAudioDuration ) |
|
1504 { |
|
1505 TInt changeSound = 1; |
|
1506 |
|
1507 // round the durations to seconds so that the comparing will be more realistic |
|
1508 TTimeIntervalSeconds videoDurationInSeconds = aVideoDuration.Int64()/1000000; |
|
1509 TTimeIntervalSeconds audioDurationInSeconds = aAudioDuration.Int64()/1000000; |
|
1510 |
|
1511 if ( audioDurationInSeconds < videoDurationInSeconds ) |
|
1512 { |
|
1513 HBufC* queryString = StringLoader::LoadLC( R_VIE_QUERY_INSERT_SHORT_AUDIO ); |
|
1514 CAknQueryDialog* dlg = new( ELeave )CAknQueryDialog( *queryString, CAknQueryDialog::ENoTone ); |
|
1515 changeSound = dlg->ExecuteLD( R_VIE_CONFIRMATION_QUERY ); |
|
1516 CleanupStack::PopAndDestroy( queryString ); |
|
1517 } |
|
1518 else if ( audioDurationInSeconds > videoDurationInSeconds ) |
|
1519 { |
|
1520 HBufC* queryString = StringLoader::LoadLC( R_VIE_QUERY_INSERT_LONG_AUDIO ); |
|
1521 CAknQueryDialog* dlg = new( ELeave )CAknQueryDialog( *queryString, CAknQueryDialog::ENoTone ); |
|
1522 changeSound = dlg->ExecuteLD( R_VIE_CONFIRMATION_QUERY ); |
|
1523 CleanupStack::PopAndDestroy( queryString ); |
|
1524 } |
|
1525 //else the audio clip is the same length as the video clip |
|
1526 |
|
1527 return changeSound; |
|
1528 } |
|
1529 |
|
1530 |
|
1531 |
|
1532 //======================================================================================================= |
|
1533 |
|
1534 void CSimpleVideoEditorImpl::ProcessingOkL() |
|
1535 { |
|
1536 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingOkL: In"); |
|
1537 RFs& fs = iEnv.FsSession(); |
|
1538 CFileMan* fileman = CFileMan::NewL( fs ); |
|
1539 CleanupStack::PushL( fileman ); |
|
1540 |
|
1541 TInt moveErr( KErrNone ); |
|
1542 if ( iTempFile->Left(1) == iOutputFileName.Left(1) ) |
|
1543 { |
|
1544 moveErr = fileman->Rename( *iTempFile, iOutputFileName ); |
|
1545 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingOkL: 1 renamed temp file: err %d", moveErr); |
|
1546 } |
|
1547 else |
|
1548 { |
|
1549 moveErr = fileman->Move( *iTempFile, iOutputFileName ); |
|
1550 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingOkL: 2 moved tem file: err %d", moveErr); |
|
1551 } |
|
1552 CleanupStack::PopAndDestroy( fileman ); |
|
1553 |
|
1554 delete iTempFile; |
|
1555 iTempFile = NULL; |
|
1556 iError = moveErr; |
|
1557 |
|
1558 iState = EStateFinalizing; |
|
1559 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingOkL: Out"); |
|
1560 } |
|
1561 //======================================================================================================= |
|
1562 |
|
1563 void CSimpleVideoEditorImpl::ProcessingFailed() |
|
1564 { |
|
1565 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingFailed: In"); |
|
1566 TInt delErr = iEnv.FsSession().Delete( *iTempFile ); |
|
1567 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingFailed: 1, delErr:%d", delErr); |
|
1568 if ( delErr ) |
|
1569 { |
|
1570 // @: should something be done? |
|
1571 } |
|
1572 delete iTempFile; |
|
1573 iTempFile = NULL; |
|
1574 iState = EStateFinalizing; |
|
1575 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::ProcessingFailed: Out"); |
|
1576 } |
|
1577 |
|
1578 //======================================================================================================= |
|
1579 void CSimpleVideoEditorImpl::NotifyVideoClipAdded(CVedMovie& /*aMovie*/, TInt /*aIndex*/) |
|
1580 { |
|
1581 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyVideoClipAdded: In"); |
|
1582 |
|
1583 if ( EStateInsertInputFirst == iState ) |
|
1584 { |
|
1585 // Next insert the second item (i.e. video|image|audio|text) |
|
1586 iState = EStateInsertInputSecond; |
|
1587 } |
|
1588 else if ( EStateInsertVideo == iState || EStateInsertImage == iState |
|
1589 || EStateInsertTextToBegin == iState || EStateInsertTextToEnd == iState) |
|
1590 { |
|
1591 // Next start processing the movie |
|
1592 iState = EStateProcessing; |
|
1593 } |
|
1594 // if cancel is pressed in the middle of iMovie->InsertVideoClip(), state is put to iStateFinalizing to stop |
|
1595 // the process |
|
1596 else if ( EStateFinalizing == iState || EStateReady == iState ) |
|
1597 { |
|
1598 ; |
|
1599 } |
|
1600 else |
|
1601 { |
|
1602 User::Invariant(); |
|
1603 } |
|
1604 |
|
1605 if ( iWaitDialog ) |
|
1606 { |
|
1607 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
1608 } |
|
1609 //CompleteRequest(); |
|
1610 |
|
1611 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyVideoClipAdded: Out"); |
|
1612 } |
|
1613 |
|
1614 //======================================================================================================= |
|
1615 void CSimpleVideoEditorImpl::NotifyVideoClipAddingFailed(CVedMovie& /*aMovie*/, TInt aError) |
|
1616 { |
|
1617 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyVideoClipAddingFailed: In, aError:%d", aError); |
|
1618 |
|
1619 iError = aError; |
|
1620 iError = FilterError(); |
|
1621 |
|
1622 // Next handle error and exit |
|
1623 iState = EStateFinalizing; |
|
1624 |
|
1625 if ( iWaitDialog ) |
|
1626 { |
|
1627 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
1628 } |
|
1629 |
|
1630 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyVideoClipAddingFailed: Out"); |
|
1631 } |
|
1632 |
|
1633 |
|
1634 |
|
1635 //======================================================================================================= |
|
1636 void CSimpleVideoEditorImpl::NotifyAudioClipAdded(CVedMovie& /*aMovie*/, TInt /*aIndex*/) |
|
1637 { |
|
1638 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyAudioClipAdded: In"); |
|
1639 |
|
1640 ASSERT(iMovie && iMovie->VideoClipCount() == 1); |
|
1641 |
|
1642 if ( EStateInsertAudio == iState ) |
|
1643 { |
|
1644 TInt audioClipCount = iMovie->AudioClipCount(); |
|
1645 TTimeIntervalMicroSeconds currentAudioClipEndTime = iMovie->AudioClipEndTime( audioClipCount - 1 ); // in movie timebase |
|
1646 |
|
1647 TTimeIntervalMicroSeconds videoClipEndTime = iMovie->VideoClipEndTime(0); // in movie timebase |
|
1648 if( currentAudioClipEndTime > videoClipEndTime ) |
|
1649 { |
|
1650 // Adjust the length so that the audio duration does not exceed video duration. |
|
1651 CVedAudioClipInfo* audioClip = iMovie->AudioClipInfo( audioClipCount - 1 ); |
|
1652 TInt64 cutOutTime = audioClip->Duration().Int64() - ( currentAudioClipEndTime.Int64() - videoClipEndTime.Int64() ); |
|
1653 iMovie->AudioClipSetCutOutTime( audioClipCount - 1, TTimeIntervalMicroSeconds(cutOutTime) ); // in clip timebase |
|
1654 } |
|
1655 ASSERT( iMovie->Duration() == videoClipEndTime ); |
|
1656 |
|
1657 TTimeIntervalMicroSeconds audioClipEndTime = iMovie->AudioClipEndTime( audioClipCount - 1); |
|
1658 |
|
1659 ASSERT( audioClipEndTime.Int64() <= videoClipEndTime.Int64() ); |
|
1660 |
|
1661 TInt error = KErrNone; |
|
1662 |
|
1663 if ( audioClipEndTime == videoClipEndTime ) |
|
1664 { |
|
1665 if ( iMovie->VideoClipIsMuteable(0) ) |
|
1666 { |
|
1667 iMovie->VideoClipSetMuted(0, ETrue); |
|
1668 } |
|
1669 } |
|
1670 |
|
1671 // if the audio clip is shorter than the video clip, the original sound |
|
1672 // of the video clip has to be muted until the end of the new sound clip |
|
1673 else if ( audioClipEndTime < videoClipEndTime ) |
|
1674 { |
|
1675 |
|
1676 if ( iMovie->VideoClipEditedHasAudio(0) ) |
|
1677 { |
|
1678 |
|
1679 TVedDynamicLevelMark mark1( TTimeIntervalMicroSeconds(0), KAudioLevelMin ); |
|
1680 |
|
1681 TInt64 time = audioClipEndTime.Int64() - KFadeInTimeMicroSeconds; |
|
1682 |
|
1683 TVedDynamicLevelMark mark2( TTimeIntervalMicroSeconds(time) , KAudioLevelMin ); |
|
1684 |
|
1685 TVedDynamicLevelMark mark3( audioClipEndTime, 0 ); |
|
1686 |
|
1687 TRAP( error, iMovie->VideoClipInsertDynamicLevelMarkL( 0, mark1 ) ); |
|
1688 |
|
1689 if ( error == KErrNone ) |
|
1690 { |
|
1691 TRAP( error, iMovie->VideoClipInsertDynamicLevelMarkL( 0, mark2 ) ); |
|
1692 } |
|
1693 |
|
1694 if ( error == KErrNone ) |
|
1695 { |
|
1696 TRAP( error, iMovie->VideoClipInsertDynamicLevelMarkL( 0, mark3 ) ); |
|
1697 } |
|
1698 |
|
1699 if ( error != KErrNone ) |
|
1700 { |
|
1701 iError = error; |
|
1702 iError = FilterError(); |
|
1703 } |
|
1704 |
|
1705 } |
|
1706 } |
|
1707 |
|
1708 if ( error == KErrNone ) |
|
1709 { |
|
1710 iState = EStateProcessing; |
|
1711 } |
|
1712 else |
|
1713 { |
|
1714 iState = EStateProcessingFailed; |
|
1715 } |
|
1716 } |
|
1717 |
|
1718 if( iWaitDialog ) |
|
1719 { |
|
1720 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
1721 } |
|
1722 |
|
1723 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyAudioClipAdded: Out"); |
|
1724 } |
|
1725 |
|
1726 //======================================================================================================= |
|
1727 void CSimpleVideoEditorImpl::NotifyAudioClipAddingFailed(CVedMovie& /*aMovie*/, TInt aError) |
|
1728 { |
|
1729 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyAudioClipAddingFailed: In, aError:%d", aError); |
|
1730 |
|
1731 iError = aError; |
|
1732 |
|
1733 iError = FilterError(); |
|
1734 |
|
1735 // Next handle error and exit |
|
1736 iState = EStateFinalizing; |
|
1737 if ( iWaitDialog ) |
|
1738 { |
|
1739 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
1740 } |
|
1741 |
|
1742 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyAudioClipAddingFailed: Out"); |
|
1743 } |
|
1744 |
|
1745 //======================================================================================================= |
|
1746 void CSimpleVideoEditorImpl::NotifyImageClipGeneratorInitializationComplete(CVeiImageClipGenerator& /*aGenerator*/, TInt aError) |
|
1747 { |
|
1748 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyImageClipGeneratorInitializationComplete, In, aError:%d", aError); |
|
1749 |
|
1750 iError = aError; |
|
1751 |
|
1752 // If the wait dialog has been dismissed, i.e the action has been cancelled, |
|
1753 // we expect that the DialogDismissedL() method has set the correct state and won't |
|
1754 // set the state ourselves. |
|
1755 iGeneratorComplete = ETrue; |
|
1756 if( !iDialogDismissed ) |
|
1757 { |
|
1758 if (KErrNone == aError) |
|
1759 { |
|
1760 iState = EStateInsertImage; |
|
1761 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyImageClipGeneratorInitializationComplete: 2"); |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 iError = FilterError(); |
|
1766 // Next handle error and exit |
|
1767 |
|
1768 /* |
|
1769 If iImageClipGenerator is deleted here (in NotifyImageClipGeneratorInitializationComplete), endless |
|
1770 loop is resulted, because calling iImageClipGenerator's destructor leads to calling NotifyImageClipGeneratorInitializationComplete |
|
1771 again until stack overdoses etc. |
|
1772 iImageClipGenerator does not have to be deleted here, it is deleted in destructor. |
|
1773 delete iImageClipGenerator; |
|
1774 iImageClipGenerator = 0; |
|
1775 */ |
|
1776 |
|
1777 iState = EStateFinalizing; |
|
1778 } |
|
1779 } |
|
1780 |
|
1781 CompleteRequest(); |
|
1782 |
|
1783 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::NotifyImageClipGeneratorInitializationComplete, Out"); |
|
1784 } |
|
1785 |
|
1786 //======================================================================================================= |
|
1787 void CSimpleVideoEditorImpl::DialogDismissedL( TInt aButtonId ) |
|
1788 { |
|
1789 LOGFMT(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DialogDismissedL, In, aButtonId:%d", aButtonId); |
|
1790 |
|
1791 if ( aButtonId != EAknSoftkeyDone) |
|
1792 { |
|
1793 // If the action was cancelled, we set up the correspondig state |
|
1794 // and also set the iDialogDismissed property to indicate that. |
|
1795 iDialogDismissed = ETrue; |
|
1796 |
|
1797 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DialogDismissedL, 1"); |
|
1798 |
|
1799 if (EStateProcessing == iState && iMovie) |
|
1800 { |
|
1801 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DialogDismissedL, 2, canceling processing..."); |
|
1802 iState = EStateProcessingFailed; |
|
1803 /* |
|
1804 It depends on scheduling of active objects whether NotifyMovieProcessingCompleted() |
|
1805 gets called. If iProgressDialog is NULLed by itself in the time DialogDismissed() gets called |
|
1806 it should be nonrelevant whether NotifyMovieProcessingCompleted() called or not because |
|
1807 in NotifyMovieProcessingCompleted() iProgressDialog->ProcessFinished() is called only if |
|
1808 it is not NULL leading to another call to DialogDismissed(). But even if DialogDismissed() |
|
1809 gets called multiple times it should not cause any harm. |
|
1810 */ |
|
1811 iMovie->CancelProcessing(); |
|
1812 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DialogDismissedL, 4, ...canceling called"); |
|
1813 } |
|
1814 else |
|
1815 { |
|
1816 // if wait dialog is canceled during inserts |
|
1817 iError = KErrCancel; |
|
1818 iState = EStateFinalizing; |
|
1819 } |
|
1820 |
|
1821 // this problem is because in add text mode orientation is forced to portrait in |
|
1822 // such an early stage |
|
1823 // ask Heikki's opinion, why appUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait); |
|
1824 // is called in InitializeOperationL()? |
|
1825 // Can it be moved to where it is neede, in GetText()? |
|
1826 if (EOperationModeAddText == iOperationMode) |
|
1827 { |
|
1828 RestoreOrientation(); |
|
1829 } |
|
1830 } |
|
1831 |
|
1832 // Only if the VeiImageClipGenerator::NewL() called from the RunL() has finished and called |
|
1833 // the NotifyImageClipGeneratorInitializationComplete() method we complete and activate again. |
|
1834 // If not, we rely that the NotifyImageClipGeneratorInitializationComplete() method |
|
1835 // calls CompleteRequest() when it's called. |
|
1836 if( iGeneratorComplete ) |
|
1837 { |
|
1838 CompleteRequest(); |
|
1839 } |
|
1840 |
|
1841 LOG(KVideoEditorLogFile, "CSimpleVideoEditorImpl::DialogDismissedL, Out"); |
|
1842 } |
|
1843 |
|
1844 //======================================================================================================= |
|
1845 void CSimpleVideoEditorImpl::NotifyVideoClipRemoved(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1846 void CSimpleVideoEditorImpl::NotifyVideoClipIndicesChanged(CVedMovie& /*aMovie*/, TInt /*aOldIndex*/, TInt /*aNewIndex*/){} |
|
1847 void CSimpleVideoEditorImpl::NotifyVideoClipTimingsChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1848 void CSimpleVideoEditorImpl::NotifyVideoClipSettingsChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1849 void CSimpleVideoEditorImpl::NotifyVideoClipColorEffectChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1850 void CSimpleVideoEditorImpl::NotifyVideoClipAudioSettingsChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1851 void CSimpleVideoEditorImpl::NotifyVideoClipGeneratorSettingsChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1852 void CSimpleVideoEditorImpl::NotifyVideoClipDescriptiveNameChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1853 void CSimpleVideoEditorImpl::NotifyStartTransitionEffectChanged(CVedMovie& /*aMovie*/){} |
|
1854 void CSimpleVideoEditorImpl::NotifyMiddleTransitionEffectChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1855 void CSimpleVideoEditorImpl::NotifyEndTransitionEffectChanged(CVedMovie& /*aMovie*/){} |
|
1856 void CSimpleVideoEditorImpl::NotifyAudioClipRemoved(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1857 void CSimpleVideoEditorImpl::NotifyAudioClipIndicesChanged(CVedMovie& /*aMovie*/, TInt /*aOldIndex*/, TInt /*aNewIndex*/){} |
|
1858 void CSimpleVideoEditorImpl::NotifyAudioClipTimingsChanged(CVedMovie& /*aMovie*/, TInt /*aIndex*/){} |
|
1859 void CSimpleVideoEditorImpl::NotifyMovieQualityChanged(CVedMovie& /*aMovie*/){} |
|
1860 void CSimpleVideoEditorImpl::NotifyMovieReseted(CVedMovie& /*aMovie*/){} |
|
1861 void CSimpleVideoEditorImpl::NotifyMovieOutputParametersChanged(CVedMovie& /*aMovie*/){} |
|
1862 void CSimpleVideoEditorImpl::NotifyAudioClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/, TInt /*aClipIndex*/, TInt /*aMarkIndex*/){} |
|
1863 void CSimpleVideoEditorImpl::NotifyAudioClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, TInt /*aClipIndex*/, TInt /*aMarkIndex*/){} |
|
1864 void CSimpleVideoEditorImpl::NotifyVideoClipDynamicLevelMarkInserted(CVedMovie& /*aMovie*/, TInt /*aClipIndex*/, TInt /*aMarkIndex*/){} |
|
1865 void CSimpleVideoEditorImpl::NotifyVideoClipDynamicLevelMarkRemoved(CVedMovie& /*aMovie*/, TInt /*aClipIndex*/, TInt /*aMarkIndex*/){} |
|
1866 // End of file |