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 VEICUTVIDEOCONTAINER_H |
|
21 #define VEICUTVIDEOCONTAINER_H |
|
22 |
|
23 #include <coecntrl.h> |
|
24 #include <VideoPlayer.h> |
|
25 #include <VedCommon.h> |
|
26 #include <VedMovie.h> |
|
27 #include <aknprogressdialog.h> |
|
28 |
|
29 #include "VeiVideoDisplay.h" |
|
30 #include "VeiImageConverter.h" |
|
31 #include "VeiRemConTarget.h" |
|
32 |
|
33 class CVeiCutVideoView; |
|
34 class CVeiCutterBar; |
|
35 class CAknsBasicBackgroundControlContext; |
|
36 class CVeiErrorUI; |
|
37 class CVeiVideoDisplay; |
|
38 class CVeiTextDisplay; |
|
39 |
|
40 const TInt KMinCutVideoVolumeLevel = 1; |
|
41 const TInt KVeiCutBarHeight = 20; |
|
42 const TInt KProgressbarFinalValue = 50; |
|
43 _LIT( KEncoderType, "JPEG" ); // encoder type for image conversion |
|
44 |
|
45 /** |
|
46 * CVeiCutVideoContainer container control class. |
|
47 * |
|
48 * Container for CVeiCutVideoView. |
|
49 */ |
|
50 class CVeiCutVideoContainer: public CCoeControl, |
|
51 public MCoeControlObserver, |
|
52 public MVedVideoClipFrameObserver, |
|
53 public MVedVideoClipInfoObserver, |
|
54 public MConverterController, |
|
55 public MProgressDialogCallback, |
|
56 public MVeiVideoDisplayObserver, |
|
57 public MVeiMediakeyObserver |
|
58 { |
|
59 public: |
|
60 /** |
|
61 * Edit state. |
|
62 */ |
|
63 enum TCutVideoState |
|
64 { |
|
65 EStateInitializing = 1, |
|
66 EStateOpening, |
|
67 EStateStoppedInitial, |
|
68 EStateStopped, |
|
69 EStatePlaying, |
|
70 EStatePlayingMenuOpen, |
|
71 EStatePaused, |
|
72 EStateGettingFrame, |
|
73 EStateBuffering, |
|
74 EStateTerminating |
|
75 }; |
|
76 |
|
77 |
|
78 /** |
|
79 * Start or end mark. |
|
80 */ |
|
81 enum TCutMark |
|
82 { |
|
83 ENoMark, |
|
84 EStartMark, |
|
85 EEndMark |
|
86 }; |
|
87 |
|
88 |
|
89 |
|
90 public: |
|
91 |
|
92 /** |
|
93 * Creates a CVeiCutVideoContainer object, which will draw itself to aRect. |
|
94 * |
|
95 * @param aRect Frame rectangle for container. |
|
96 * @param aView |
|
97 * |
|
98 * @return a pointer to the created instance of CStoryboardContainer |
|
99 */ |
|
100 static CVeiCutVideoContainer* NewL( const TRect& aRect, |
|
101 CVeiCutVideoView& aView, |
|
102 CVeiErrorUI& aErrorUI ); |
|
103 |
|
104 /** |
|
105 * Creates a CVeiCutVideoContainer object, which will draw itself to aRect. |
|
106 * Leaves the created object in the cleanup stack. |
|
107 * |
|
108 * @param aRect Frame rectangle for container. |
|
109 * @param aMovie movie being edited |
|
110 * |
|
111 * @return a pointer to the created instance of CStoryboardContainer |
|
112 */ |
|
113 static CVeiCutVideoContainer* NewLC( const TRect& aRect, |
|
114 CVeiCutVideoView& aView, |
|
115 CVeiErrorUI& aErrorUI ); |
|
116 |
|
117 /** |
|
118 * Default constructor. |
|
119 * |
|
120 * @param aRect Frame rectangle for container. |
|
121 * @param aView pointer to the view. |
|
122 */ |
|
123 void ConstructL( const TRect& aRect, |
|
124 CVeiCutVideoView& aView, |
|
125 CVeiErrorUI& aErrorUI ); |
|
126 |
|
127 /** |
|
128 * Destructor. |
|
129 */ |
|
130 virtual ~CVeiCutVideoContainer(); |
|
131 |
|
132 public: |
|
133 /** |
|
134 * Takes one thumbnail bitmap from given file. |
|
135 * |
|
136 * @param aFilename name of video clip file |
|
137 */ |
|
138 void GetThumbL( const TDesC& aFilename ); |
|
139 |
|
140 /** |
|
141 * ###Missin' description### |
|
142 * |
|
143 * @param aState |
|
144 */ |
|
145 void SetStateL( CVeiCutVideoContainer::TCutVideoState aState, |
|
146 TBool aUpdateCBA = ETrue); |
|
147 /** |
|
148 * Starts playing. |
|
149 * |
|
150 * @param aStartTime |
|
151 */ |
|
152 void PlayL( const TDesC& aFilename ); |
|
153 void PlayMarkedL( const TDesC& aFilename, |
|
154 const TTimeIntervalMicroSeconds& aStartTime, |
|
155 const TTimeIntervalMicroSeconds& aEndTime ); |
|
156 /** |
|
157 * Stops playing. |
|
158 */ |
|
159 void StopL(); |
|
160 |
|
161 /** |
|
162 * Pauses playing. |
|
163 */ |
|
164 void PauseL( TBool aUpdateCBA = ETrue ); |
|
165 |
|
166 /** |
|
167 * Closes the stream. |
|
168 */ |
|
169 void CloseStreamL(); |
|
170 |
|
171 /** |
|
172 * Returns the playback position. |
|
173 * |
|
174 * @return playback position |
|
175 */ |
|
176 TTimeIntervalMicroSeconds PlaybackPositionL(); |
|
177 |
|
178 /** |
|
179 * Marks the in point. |
|
180 */ |
|
181 void MarkedInL(); |
|
182 |
|
183 /** |
|
184 * Marks the out point. |
|
185 */ |
|
186 void MarkedOutL(); |
|
187 |
|
188 /** |
|
189 * Sets cut in time to cut video bar. |
|
190 * |
|
191 * @param aTime Cut ín time |
|
192 */ |
|
193 void SetInTime( const TTimeIntervalMicroSeconds& aTime ); |
|
194 |
|
195 /** |
|
196 * Sets cut out time to cut video bar. |
|
197 * |
|
198 * @param aTime Cut out time |
|
199 */ |
|
200 void SetOutTime( const TTimeIntervalMicroSeconds& aTime ); |
|
201 |
|
202 /** |
|
203 * Takes the snapshot from current frame |
|
204 */ |
|
205 void TakeSnapshotL(); |
|
206 |
|
207 void MuteL(); |
|
208 public: |
|
209 |
|
210 /** |
|
211 * Update function that is called by the static callback method. |
|
212 */ |
|
213 void DoUpdate(); |
|
214 |
|
215 // from MVeiVideoDisplayObserver |
|
216 virtual void NotifyVideoDisplayEvent( const TPlayerEvent aEvent, |
|
217 const TInt& aInfo = 0 ); |
|
218 |
|
219 virtual void NotifyVideoClipFrameCompleted( CVedVideoClipInfo& aInfo, |
|
220 TInt aError, |
|
221 CFbsBitmap* aFrame); |
|
222 /** |
|
223 * Called to notify that video clip info is ready |
|
224 * for reading. |
|
225 * |
|
226 * Possible error codes: |
|
227 * - <code>KErrNotFound</code> if there is no file with the specified name |
|
228 * in the specified directory (but the directory exists) |
|
229 * - <code>KErrPathNotFound</code> if the specified directory |
|
230 * does not exist |
|
231 * - <code>KErrUnknown</code> if the specified file is of unknown format |
|
232 * |
|
233 * @param aInfo video clip info |
|
234 * @param aError <code>KErrNone</code> if info is ready |
|
235 * for reading; one of the system wide |
|
236 * error codes if reading file failed |
|
237 */ |
|
238 virtual void NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo, |
|
239 TInt aError ); |
|
240 |
|
241 /** |
|
242 * From CCoeControl, OfferKeyEventL. |
|
243 * |
|
244 * @param aKeyEvent key event |
|
245 * @param aType event code |
|
246 */ |
|
247 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
248 |
|
249 /** |
|
250 * From MProgressDialogCallback, DialogDismissedL. |
|
251 * |
|
252 * @param aButtonId button id |
|
253 */ |
|
254 virtual void DialogDismissedL( TInt aButtonId ); |
|
255 |
|
256 /** |
|
257 * Opens a video clip file and initializes videoplayerutility. |
|
258 * |
|
259 * @param aFilename file to open |
|
260 */ |
|
261 void OpenFileL( const TDesC& aFilename /*, TBool aStartPlaying = EFalse */ ); |
|
262 |
|
263 /** |
|
264 * Prepares the control for termination; stops video playback |
|
265 * and sets the state to EStateTerminating. |
|
266 * |
|
267 */ |
|
268 void PrepareForTerminationL(); |
|
269 |
|
270 // From MConverterController |
|
271 void NotifyCompletion( TInt aErr ); |
|
272 |
|
273 private: |
|
274 /** |
|
275 * Callback function for the timer. |
|
276 * |
|
277 * @param aThis self pointer |
|
278 * |
|
279 * @return dummy value |
|
280 */ |
|
281 static TInt DoAudioBarUpdate( TAny* aThis ); |
|
282 |
|
283 /** |
|
284 * Time increment. |
|
285 * |
|
286 * @param aKeyCount number a key events |
|
287 * @return time |
|
288 */ |
|
289 TInt TimeIncrement( TInt aKeyCount )const; |
|
290 |
|
291 /** |
|
292 * Constructor. |
|
293 * |
|
294 * @param aView instance of cut video view |
|
295 * @param aErrorUI instance of CVeiErrorUI |
|
296 */ |
|
297 CVeiCutVideoContainer( const TRect& aRect, |
|
298 CVeiCutVideoView& aView, |
|
299 CVeiErrorUI& aErrorUI ); |
|
300 |
|
301 /** |
|
302 * Gets intra frame bitmap from video clip. |
|
303 * |
|
304 * @param aTime intra frame time. |
|
305 */ |
|
306 void GetThumbAtL( const TTimeIntervalMicroSeconds& aTime ); |
|
307 |
|
308 /** |
|
309 * From CoeControl, MopSupplyObject. |
|
310 * |
|
311 * @param aId |
|
312 */ |
|
313 virtual TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
314 |
|
315 /** |
|
316 * From CoeControl, SizeChanged. |
|
317 */ |
|
318 void SizeChanged(); |
|
319 |
|
320 /** |
|
321 * From CoeControl, CountComponentControls. |
|
322 * |
|
323 * @return number of component controls in this control |
|
324 */ |
|
325 TInt CountComponentControls()const; |
|
326 |
|
327 /** |
|
328 * From CCoeControl, ComponentControl. |
|
329 * |
|
330 * @param aIndex index of the control to return |
|
331 */ |
|
332 CCoeControl* ComponentControl( TInt aIndex )const; |
|
333 |
|
334 /** |
|
335 * From CCoeControl,Draw. |
|
336 * |
|
337 * @param aRect region of the control to be redrawn |
|
338 */ |
|
339 void Draw( const TRect& aRect )const; |
|
340 |
|
341 /** |
|
342 * From CCoeControl, gets the control's help context. Associates the |
|
343 * control with a particular Help file and topic in a context sensitive |
|
344 * application. |
|
345 * |
|
346 * @param aContext Control's help context. |
|
347 */ |
|
348 void GetHelpContext( TCoeHelpContext& aContext )const; |
|
349 |
|
350 /** |
|
351 * From CCoeControl, HandleControlEventL |
|
352 */ |
|
353 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
354 |
|
355 /** |
|
356 * HandlePointerEventL |
|
357 * Handles pen inputs |
|
358 * |
|
359 * @param aPointerEvent pointer event |
|
360 */ |
|
361 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
362 |
|
363 /** |
|
364 * Handles progress bar touch events |
|
365 * @param aPBRect Current progress bar rectangle |
|
366 * @param aPressedPoint The x coordinate value that was pressed |
|
367 * inside the progress bar |
|
368 * @param aDragMarks ETrue if the user drags start or end marks. |
|
369 * EFalse otherwise |
|
370 */ |
|
371 void HandleProgressBarTouchL( TRect aPBRect, TInt aPressedPoint, TBool aDragMarks, CVeiCutVideoContainer::TCutMark aCutMark = ENoMark ); |
|
372 |
|
373 /* |
|
374 * Indicates ProgressNote. |
|
375 * |
|
376 */ |
|
377 void ShowProgressNoteL(); |
|
378 |
|
379 /** |
|
380 * Shows information note with given message. |
|
381 * |
|
382 * @param aMessage message to show. |
|
383 */ |
|
384 void ShowInformationNoteL( const TDesC& aMessage )const; |
|
385 |
|
386 /** |
|
387 * The entity of ProgressCallBackL() function |
|
388 * @return 0 when work is done, otherwise return 1. |
|
389 */ |
|
390 TInt UpdateProgressNoteL(); |
|
391 |
|
392 /** |
|
393 * Saves snapshot. |
|
394 */ |
|
395 void SaveSnapshotL(); |
|
396 |
|
397 /** |
|
398 * Cancels saving of the snapshot. |
|
399 */ |
|
400 void CancelSnapshotSave(); |
|
401 |
|
402 void StopProgressDialog(); |
|
403 |
|
404 void ShowGlobalErrorNote( const TInt aErr ); |
|
405 |
|
406 /** HandleVolumeUpL |
|
407 * |
|
408 * @see MVeiMediakeyObserver |
|
409 */ |
|
410 virtual void HandleVolumeUpL(); |
|
411 |
|
412 /** HandleVolumeDownL |
|
413 * |
|
414 * @see MVeiMediakeyObserver |
|
415 */ |
|
416 virtual void HandleVolumeDownL(); |
|
417 |
|
418 /** Callback function */ |
|
419 static TInt AsyncTakeSnapshot( TAny* aThis ); |
|
420 /** Callback function */ |
|
421 static TInt AsyncSaveSnapshot( TAny* aThis ); |
|
422 |
|
423 private: |
|
424 //data |
|
425 /** cut video view */ |
|
426 CVeiCutVideoView& iView; |
|
427 |
|
428 /** Error UI */ |
|
429 CVeiErrorUI& iErrorUI; |
|
430 |
|
431 /** Video clip info*/ |
|
432 CVedVideoClipInfo* iVideoClipInfo; |
|
433 |
|
434 /** Current state. */ |
|
435 TCutVideoState iState; |
|
436 |
|
437 /** Previous state. */ |
|
438 TCutVideoState iPreviousState; |
|
439 |
|
440 /** Previous state. */ |
|
441 TCutVideoState iPrevState; |
|
442 |
|
443 /** cut video bar. */ |
|
444 CVeiCutterBar* iCutVideoBar; |
|
445 |
|
446 /** Last position. */ |
|
447 TTimeIntervalMicroSeconds iLastPosition; |
|
448 |
|
449 /** Video clip duration */ |
|
450 TTimeIntervalMicroSeconds iDuration; |
|
451 |
|
452 /** |
|
453 * Control context that provides a layout background with a |
|
454 * background bitmap and its layout rectangle. |
|
455 */ |
|
456 CAknsBasicBackgroundControlContext* iBgContext; |
|
457 |
|
458 TInt iInternalVolume; |
|
459 |
|
460 /** Key repeat count in seek function. */ |
|
461 TInt iKeyRepeatCount; |
|
462 |
|
463 /** Seek thumbnail position in video clip. */ |
|
464 TTimeIntervalMicroSeconds iSeekPos; |
|
465 |
|
466 /** Seek - flag. */ |
|
467 TBool iSeeking; |
|
468 |
|
469 /** Frame ready - flag */ |
|
470 TBool iFrameReady; |
|
471 |
|
472 /** Last keycode, used in OfferKeyEventL(); */ |
|
473 TUint iLastKeyCode; |
|
474 |
|
475 /** The actuall calls to ICL are done from this image converter. */ |
|
476 CVeiImageConverter* iConverter; |
|
477 |
|
478 //** Whether we need to take snapshot. */ |
|
479 TBool iTakeSnapshot; |
|
480 |
|
481 /** Progress dialog */ |
|
482 CAknProgressDialog* iProgressDialog; |
|
483 |
|
484 /** Progress info for the progress dialog. */ |
|
485 CEikProgressInfo* iProgressInfo; |
|
486 |
|
487 HBufC* iSaveToFileName; |
|
488 TSize iFrameSize; |
|
489 CPeriodic* iVideoBarTimer; |
|
490 CVeiVideoDisplay* iVideoDisplay; |
|
491 TRect iDisplayRect; |
|
492 TRect iCutTimeDisplayRect; |
|
493 CVeiTextDisplay* iCutTimeDisplay; |
|
494 TBool iPlayOrPlayMarked; |
|
495 |
|
496 TRect iIconDisplayRect; |
|
497 |
|
498 CFbsBitmap* iPauseBitmap; |
|
499 CFbsBitmap* iPauseBitmapMask; |
|
500 |
|
501 /** Callback utilities */ |
|
502 CAsyncCallBack* iCallBackSaveSnapshot; |
|
503 CAsyncCallBack* iCallBackTakeSnapshot; |
|
504 |
|
505 /** Remote connection API used to handle the volume keys. */ |
|
506 CVeiRemConTarget* iRemConTarget; |
|
507 |
|
508 TBool iTakeSnapshotWaiting; |
|
509 |
|
510 /** ETrue if user is dragging the start or end mark with a pen, |
|
511 EFalse otherwise */ |
|
512 TBool iIsMarkDrag; |
|
513 |
|
514 /** ETrue if the pen is in start or end mark area when it goes down, |
|
515 EFalse otherwise */ |
|
516 TBool iIsMarkTapped; |
|
517 |
|
518 /** Indicates which mark the user has tapped */ |
|
519 TCutMark iTappedMark; |
|
520 |
|
521 |
|
522 #include "veicutvideocontainer.inl" |
|
523 |
|
524 }; |
|
525 #endif |
|
526 |
|
527 // End of File |
|