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 #ifndef _SIMPLEVIDEOEDITORIMPL_H_ |
|
21 #define _SIMPLEVIDEOEDITORIMPL_H_ |
|
22 |
|
23 //<IBUDSW> |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32std.h> |
|
27 #include <coemain.h> |
|
28 #include <ConeResLoader.h> |
|
29 #include <aknappui.h> |
|
30 #include <VedMovie.h> |
|
31 #include <aknprogressdialog.h> |
|
32 #include <aknwaitdialog.h> |
|
33 #include <VedAudioClipInfo.h> |
|
34 #include "SimpleVideoEditorExitObserver.h" |
|
35 #include "ExtProgressDialog.h" |
|
36 #include "VeiImageClipGenerator.h" |
|
37 #include "VeiTitleClipGenerator.h" |
|
38 |
|
39 #include "SimpleVideoEditor.h" |
|
40 #include "veisettings.h" |
|
41 |
|
42 // FORWARD DECLATATIONS |
|
43 class CVeiTempMaker; |
|
44 class CExtProgressDialog; |
|
45 class CDummyControl; |
|
46 class CErrorUI; |
|
47 |
|
48 |
|
49 // CLASS DECLARATION |
|
50 NONSHARABLE_CLASS(CSimpleVideoEditorImpl) : public CActive, |
|
51 public MVedMovieObserver, |
|
52 public MVedMovieProcessingObserver, |
|
53 public MVeiImageClipGeneratorObserver, |
|
54 public MProgressDialogCallback, |
|
55 public MExtProgressDialogCallback, |
|
56 public MCoeForegroundObserver, |
|
57 public MVedAudioClipInfoObserver |
|
58 { |
|
59 public: // Constructor and destructor |
|
60 |
|
61 static CSimpleVideoEditorImpl* NewL(MSimpleVideoEditorExitObserver& aExitObserver); |
|
62 ~CSimpleVideoEditorImpl(); |
|
63 |
|
64 public: // New functions |
|
65 |
|
66 void StartMerge( const TDesC& aSourceFileName ); |
|
67 void StartChangeAudio( const TDesC& aSourceFileName ); |
|
68 void StartAddText( const TDesC& aSourceFileName ); |
|
69 |
|
70 void StartWaitDialogL(); |
|
71 void StartProgressDialogL(); |
|
72 void StartAnimatedProgressDialogL (); |
|
73 void CancelMovieProcessing(); |
|
74 |
|
75 private: // from CActive |
|
76 |
|
77 void DoCancel(); |
|
78 void RunL(); |
|
79 TInt RunError(TInt aError); |
|
80 |
|
81 private: // from MProgressDialogCallback |
|
82 |
|
83 void DialogDismissedL( TInt aButtonId ); |
|
84 |
|
85 private: //from MVedMovieObserver |
|
86 |
|
87 void NotifyVideoClipAdded(CVedMovie& aMovie, TInt aIndex); |
|
88 void NotifyVideoClipAddingFailed(CVedMovie& aMovie, TInt aError); |
|
89 void NotifyVideoClipRemoved(CVedMovie& aMovie, TInt aIndex); |
|
90 void NotifyVideoClipIndicesChanged(CVedMovie& aMovie, TInt aOldIndex, TInt aNewIndex); |
|
91 void NotifyVideoClipTimingsChanged(CVedMovie& aMovie, TInt aIndex); |
|
92 void NotifyVideoClipSettingsChanged(CVedMovie& aMovie, TInt aIndex); |
|
93 void NotifyVideoClipColorEffectChanged(CVedMovie& aMovie, TInt aIndex); |
|
94 void NotifyVideoClipAudioSettingsChanged(CVedMovie& aMovie, TInt aIndex); |
|
95 void NotifyVideoClipGeneratorSettingsChanged(CVedMovie& aMovie, TInt aIndex); |
|
96 void NotifyVideoClipDescriptiveNameChanged(CVedMovie& aMovie, TInt aIndex); |
|
97 void NotifyStartTransitionEffectChanged(CVedMovie& aMovie); |
|
98 void NotifyMiddleTransitionEffectChanged(CVedMovie& aMovie, TInt aIndex); |
|
99 void NotifyEndTransitionEffectChanged(CVedMovie& aMovie); |
|
100 void NotifyAudioClipAdded(CVedMovie& aMovie, TInt aIndex); |
|
101 void NotifyAudioClipAddingFailed(CVedMovie& aMovie, TInt aError); |
|
102 void NotifyAudioClipRemoved(CVedMovie& aMovie, TInt aIndex); |
|
103 void NotifyAudioClipIndicesChanged(CVedMovie& aMovie, TInt aOldIndex, TInt aNewIndex); |
|
104 void NotifyAudioClipTimingsChanged(CVedMovie& aMovie, TInt aIndex); |
|
105 void NotifyMovieQualityChanged(CVedMovie& aMovie); |
|
106 void NotifyMovieReseted(CVedMovie& aMovie); |
|
107 void NotifyMovieOutputParametersChanged(CVedMovie& aMovie); |
|
108 void NotifyAudioClipDynamicLevelMarkInserted(CVedMovie& aMovie, TInt aClipIndex, TInt aMarkIndex); |
|
109 void NotifyAudioClipDynamicLevelMarkRemoved(CVedMovie& aMovie, TInt aClipIndex, TInt aMarkIndex); |
|
110 void NotifyVideoClipDynamicLevelMarkInserted(CVedMovie& aMovie, TInt aClipIndex, TInt aMarkIndex); |
|
111 void NotifyVideoClipDynamicLevelMarkRemoved(CVedMovie& aMovie, TInt aClipIndex, TInt aMarkIndex); |
|
112 |
|
113 private: //from MVedMovieProcessingObserver |
|
114 |
|
115 void NotifyMovieProcessingStartedL(CVedMovie& aMovie); |
|
116 void NotifyMovieProcessingProgressed(CVedMovie& aMovie, TInt aPercentage); |
|
117 void NotifyMovieProcessingCompleted(CVedMovie& aMovie, TInt aError); |
|
118 |
|
119 public: // from MVedAudioClipInfoObserver |
|
120 |
|
121 void NotifyAudioClipInfoReady( CVedAudioClipInfo& aInfo, TInt aError ); |
|
122 |
|
123 public: //from MVeiImageClipGeneratorObserver |
|
124 |
|
125 void NotifyImageClipGeneratorInitializationComplete(CVeiImageClipGenerator& aGenerator, TInt aError); |
|
126 |
|
127 private: // From MCoeForegroundObserver |
|
128 |
|
129 virtual void HandleGainingForeground(); |
|
130 virtual void HandleLosingForeground(); |
|
131 |
|
132 private: // Construct |
|
133 |
|
134 CSimpleVideoEditorImpl(MSimpleVideoEditorExitObserver& aExitObserver); |
|
135 void ConstructL(); |
|
136 |
|
137 private: // New functions |
|
138 |
|
139 // Helper functions to keep RunL function smaller |
|
140 void InitializeOperationL(); |
|
141 void GetMergeInputFileL(); |
|
142 void GetAudioFileL(); |
|
143 void GetTextL(); |
|
144 |
|
145 TInt ShowListQueryL( TInt& aPosition, TInt aHeadingResourceId, TInt aQueryResourceId ) const; |
|
146 |
|
147 void StartMovieProcessingL(const TDesC& aSourceFile); |
|
148 |
|
149 void RestoreOrientation(); |
|
150 |
|
151 /** FilterError |
|
152 * |
|
153 * Sets error code based on current values of iState and iOperationMode |
|
154 * i.e this is a context sensitive error mapping function |
|
155 * |
|
156 * @param |
|
157 * @return new error code |
|
158 */ |
|
159 TInt FilterError() const; |
|
160 |
|
161 /** CompleteRequest |
|
162 * |
|
163 * Force RunL |
|
164 * |
|
165 * @param - |
|
166 * @return - |
|
167 */ |
|
168 void CompleteRequest(); |
|
169 |
|
170 /** |
|
171 * Shows error note with given message. |
|
172 * |
|
173 * @param aResourceId No description. |
|
174 */ |
|
175 void ShowErrorNote( const TInt aResourceId ) const; |
|
176 |
|
177 /** |
|
178 * HandleError |
|
179 * |
|
180 * @param aErr Error code |
|
181 */ |
|
182 void HandleError(); |
|
183 |
|
184 /* QueryAudioInsertionL |
|
185 * |
|
186 * Launches a query dialog in case audio clip is shorter or longer |
|
187 * than the video clip |
|
188 * |
|
189 * @param - |
|
190 * @return 0 if user selects "No", |
|
191 * 1 if video and audio clips are the same length or |
|
192 * the user selects "Yes" |
|
193 */ |
|
194 TInt QueryAudioInsertionL( TTimeIntervalMicroSeconds aVideoDuration, |
|
195 TTimeIntervalMicroSeconds aAudioDuration ); |
|
196 |
|
197 /** |
|
198 * ProcessingOkL |
|
199 * |
|
200 * Called after succesfull processing |
|
201 */ |
|
202 void ProcessingOkL(); |
|
203 |
|
204 /** |
|
205 * ProcessingFailed |
|
206 * |
|
207 * Called after unsuccesfull processing |
|
208 */ |
|
209 void ProcessingFailed(); |
|
210 |
|
211 /** QueryAndSaveL |
|
212 * |
|
213 * Displays Avkon file handling queries |
|
214 * |
|
215 * @param aSourceFileName name of the video clip that |
|
216 * is selected to be merged |
|
217 * @return TInt 1 if the video should be saved, |
|
218 * 0 if the user has cancelled the saving |
|
219 * |
|
220 */ |
|
221 TInt QueryAndSaveL(const TDesC& aSourceFileName); |
|
222 |
|
223 /* LaunchSaveVideoQueryL |
|
224 * |
|
225 * Launches a query dialog "Save video:" with items |
|
226 * "Replace original" and "Save with a new name" |
|
227 * |
|
228 * @param - |
|
229 * @return - list query id or -1 if the user selects No |
|
230 */ |
|
231 TInt LaunchSaveVideoQueryL (); |
|
232 |
|
233 /* LaunchSaveChangesQueryL |
|
234 * |
|
235 * Launches a query dialog "Save changes?" query. |
|
236 * |
|
237 * @param - |
|
238 * @return 0 if user selects "No", otherwise 1 |
|
239 */ |
|
240 TInt LaunchListQueryDialogL (MDesCArray * aTextItems, |
|
241 const TDesC & aPrompt); |
|
242 |
|
243 void ResolveCaptionNameL( TApaAppCaption& aCaption ) const; |
|
244 |
|
245 private: // Data |
|
246 |
|
247 enum TOperationMode |
|
248 { |
|
249 EOperationModeMin = 0, // invalid |
|
250 EOperationModeMerge, |
|
251 EOperationModeMergeWithVideo, |
|
252 EOperationModeMergeWithImage, |
|
253 EOperationModeChangeAudio, |
|
254 EOperationModeAddText, |
|
255 EOperationModeMax // invalid |
|
256 } iOperationMode; |
|
257 |
|
258 enum TState |
|
259 { |
|
260 EStateMin = 0, // Invalid |
|
261 EStateInitializing, |
|
262 EStateInsertInputFirst, |
|
263 EStateInsertInputSecond, |
|
264 EStateInsertVideo, |
|
265 EStateCreateImageGenerator, |
|
266 EStateInsertImage, |
|
267 EStateCheckAudioLength, |
|
268 EStateInsertAudio, |
|
269 EStateInsertTextToBegin, |
|
270 EStateInsertTextToEnd, |
|
271 EStateProcessing, |
|
272 EStateProcessingOk, |
|
273 EStateProcessingFailed, |
|
274 EStateFinalizing, |
|
275 EStateReady, |
|
276 EOpMax // Invalid |
|
277 } iState; |
|
278 |
|
279 CEikonEnv& iEnv; |
|
280 |
|
281 // Dummy control to eat key presses while dialogs are not active |
|
282 CDummyControl* iDummyControl; |
|
283 |
|
284 // Interface to notify completion |
|
285 MSimpleVideoEditorExitObserver& iExitObserver; |
|
286 |
|
287 RConeResourceLoader iResLoader; |
|
288 |
|
289 // |
|
290 CVedMovie* iMovie; |
|
291 |
|
292 // Temporary file name for storing preview clip. |
|
293 HBufC* iTempFile; |
|
294 |
|
295 // Owned by iMovie |
|
296 CVeiImageClipGenerator* iImageClipGenerator; |
|
297 |
|
298 // Owned by iMovie |
|
299 CVeiTitleClipGenerator* iTextGenerator; |
|
300 |
|
301 // Input and output file names |
|
302 TFileName iSourceFileName; |
|
303 TFileName iMergeFileName; |
|
304 TFileName iAudioFileName; |
|
305 HBufC* iAddText; |
|
306 TFileName iOutputFileName; |
|
307 |
|
308 // Store the original orientation when forcing to portrait |
|
309 CAknAppUiBase::TAppUiOrientation iOriginalOrientation; |
|
310 |
|
311 // For process priority manipulation |
|
312 TProcessPriority iOriginalProcessPriority; |
|
313 TBool iProcessPriorityAltered; |
|
314 |
|
315 // Progress dialog. |
|
316 CAknProgressDialog* iProgressDialog; |
|
317 |
|
318 // Progress dialog. |
|
319 CExtProgressDialog* iAnimatedProgressDialog; |
|
320 |
|
321 // Wait dialog. |
|
322 CAknWaitDialog* iWaitDialog; |
|
323 |
|
324 TInt iPercentagesProcessed; |
|
325 TInt iCancelPercentage; |
|
326 TInt iError; |
|
327 |
|
328 // Position where the image or video will be merged |
|
329 // 0 if to the beginning, 1 if to the end. |
|
330 TInt iVideoOrImageIndex; |
|
331 |
|
332 /** Error UI */ |
|
333 CErrorUI* iErrorUI; |
|
334 |
|
335 /** Pointer to an instance of CVedAudioClipInfo */ |
|
336 CVedAudioClipInfo* iAudioClipInfo; |
|
337 |
|
338 /** Allowed audio mime types, used as playback in video */ |
|
339 CDesCArrayFlat *iAcceptedAudioTypes; |
|
340 |
|
341 /** Used to figure out if the CVeiImageClipGenerator::NewL() has |
|
342 * completed in a situation where the action is cancelled. */ |
|
343 TBool iGeneratorComplete; |
|
344 TBool iDialogDismissed; |
|
345 }; |
|
346 |
|
347 //</IBUDSW> |
|
348 #endif |
|
349 |
|
350 // End of file |
|