videditor/ManualVideoEditor/src/VeiCutVideoContainer.cpp
branchRCL_3
changeset 3 e0b5df5c0969
parent 0 951a5db380a0
child 5 4c409de21d23
equal deleted inserted replaced
0:951a5db380a0 3:e0b5df5c0969
     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 // INCLUDE FILES
       
    21 // System includes
       
    22 #include <manualvideoeditor.rsg>
       
    23 #include <videoeditoruicomponents.mbg>
       
    24 #include <eikbtgpc.h>
       
    25 #include <vedvideoclipinfo.h>
       
    26 #include <coemain.h>
       
    27 #include <eikenv.h>
       
    28 #include <aknsbasicbackgroundcontrolcontext.h> 
       
    29 #include <aknsdrawutils.h> 
       
    30 #include <aknsdatacontext.h> 
       
    31 #include <stringloader.h>
       
    32 #include <aknnotewrappers.h> 
       
    33 #include <pathinfo.h> 
       
    34 #include <eikprogi.h>
       
    35 #include <aknlayoutscalable_avkon.cdl.h>
       
    36 #include <aknlayoutscalable_apps.cdl.h>
       
    37 // User includes
       
    38 #include "VeiAppUi.h"
       
    39 #include "VeiCutterBar.h"
       
    40 #include "VeiCutVideoContainer.h"
       
    41 #include "VeiCutVideoView.h"
       
    42 #include "veitextdisplay.h"
       
    43 #include "VideoEditorHelp.hlp.hrh"  // Topic contexts (literals)
       
    44 #include "VideoEditorCommon.h"
       
    45 #include "VideoEditorUtils.h"
       
    46 #include "VeiErrorUi.h"
       
    47 
       
    48 
       
    49 // ================= MEMBER FUNCTIONS =======================
       
    50 void CleanupRarray( TAny* object )
       
    51     {
       
    52     (( RImageTypeDescriptionArray*)object)->ResetAndDestroy();
       
    53     }
       
    54 
       
    55 CVeiCutVideoContainer* CVeiCutVideoContainer::NewL( const TRect& aRect, CVeiCutVideoView& aView, CVeiErrorUI& aErrorUI )
       
    56     {
       
    57     CVeiCutVideoContainer* self = CVeiCutVideoContainer::NewLC( aRect, aView, aErrorUI );
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 CVeiCutVideoContainer* CVeiCutVideoContainer::NewLC( const TRect& aRect, CVeiCutVideoView& aView, CVeiErrorUI& aErrorUI )
       
    63     {
       
    64     CVeiCutVideoContainer* self = new (ELeave) CVeiCutVideoContainer( aRect, aView, aErrorUI );
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL( aRect, aView, aErrorUI );
       
    67     return self;
       
    68     }
       
    69 
       
    70 void CVeiCutVideoContainer::ConstructL( const TRect& aRect, CVeiCutVideoView& /*aView*/, CVeiErrorUI& /*aErrorUI*/ )
       
    71     {
       
    72     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::ConstructL: in");
       
    73     CreateWindowL();
       
    74 
       
    75     iInternalVolume = 0;
       
    76 
       
    77     iState = EStateInitializing;
       
    78     iFrameReady = EFalse;
       
    79     iPlayOrPlayMarked = EFalse;
       
    80 
       
    81     iSeekPos = TTimeIntervalMicroSeconds( 0 );
       
    82     iSeeking = EFalse;
       
    83     iCutVideoBar = CVeiCutterBar::NewL( this );
       
    84 
       
    85     iConverter = CVeiImageConverter::NewL( this );
       
    86     iTakeSnapshot = EFalse;
       
    87     iVideoDisplay = CVeiVideoDisplay::NewL( iDisplayRect, this, *this );
       
    88     iCutTimeDisplay = CVeiTextDisplay::NewL( iCutTimeDisplayRect, this );
       
    89 
       
    90     TFileName mbmPath( VideoEditorUtils::IconFileNameAndPath(KVideoEditorUiComponentsIconFileId) ); 
       
    91 
       
    92     AknIconUtils::CreateIconL( iPauseBitmap, iPauseBitmapMask,
       
    93             mbmPath, EMbmVideoeditoruicomponentsQgn_prop_ve_pause, 
       
    94             EMbmVideoeditoruicomponentsQgn_prop_ve_pause_mask );
       
    95 
       
    96     SetRect( aRect );
       
    97 
       
    98     iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse );
       
    99     iVideoBarTimer = CPeriodic::NewL( CActive::EPriorityLow );
       
   100 
       
   101     EnableDragEvents();
       
   102 
       
   103     ActivateL();
       
   104 
       
   105     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::ConstructL: out");
       
   106     }
       
   107 
       
   108 CVeiCutVideoContainer::CVeiCutVideoContainer( const TRect& /*aRect*/, CVeiCutVideoView& aView, CVeiErrorUI& aErrorUI ):iView( aView ), iErrorUI( aErrorUI )
       
   109     {
       
   110     }
       
   111 
       
   112 
       
   113 CVeiCutVideoContainer::~CVeiCutVideoContainer()
       
   114     {
       
   115     if ( iCutVideoBar )
       
   116         {
       
   117         delete iCutVideoBar;
       
   118         }
       
   119     if ( iBgContext )
       
   120         {
       
   121         delete iBgContext;
       
   122         }
       
   123     if ( iVideoDisplay )
       
   124         {
       
   125         delete iVideoDisplay;
       
   126         }
       
   127     if ( iCutTimeDisplay )
       
   128         {
       
   129         delete iCutTimeDisplay;
       
   130         }
       
   131     if ( iVideoClipInfo )
       
   132         {
       
   133         delete iVideoClipInfo;
       
   134         iVideoClipInfo = NULL;
       
   135         }
       
   136     if ( iConverter )
       
   137         {
       
   138         iConverter->Cancel();
       
   139         delete iConverter;
       
   140         }
       
   141     if ( iVideoBarTimer )
       
   142         {
       
   143         iVideoBarTimer->Cancel();
       
   144         delete iVideoBarTimer;
       
   145         }
       
   146 
       
   147     if ( iProgressDialog )
       
   148         {
       
   149         delete iProgressDialog;
       
   150         iProgressDialog = NULL;
       
   151         }
       
   152     if ( iSaveToFileName )
       
   153         {
       
   154         delete iSaveToFileName;
       
   155         iSaveToFileName = NULL;
       
   156         }
       
   157 
       
   158     delete iPauseBitmap;
       
   159     delete iPauseBitmapMask;
       
   160 
       
   161     delete iRemConTarget;
       
   162     
       
   163     delete iCallBackSaveSnapshot;
       
   164     delete iCallBackTakeSnapshot;
       
   165     }
       
   166 
       
   167 void CVeiCutVideoContainer::DialogDismissedL( TInt aButtonId )
       
   168     {
       
   169     if ( aButtonId == -1 )
       
   170         { // when pressing cancel button.
       
   171         CancelSnapshotSave();
       
   172         }
       
   173     iTakeSnapshot = EFalse;
       
   174     }
       
   175 
       
   176 void CVeiCutVideoContainer::SizeChanged()
       
   177     {
       
   178     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SizeChanged(): In");
       
   179 	TSize videoScreenSize;
       
   180     TRect rect( Rect() ); 
       
   181 	if ( iBgContext )
       
   182 		{
       
   183 		iBgContext->SetRect( rect );
       
   184 		}
       
   185 	LOGFMT2(KVideoEditorLogFile, "CVeiCutVideoContainer::SizeChanged(): Rect(): %d,%d", rect.iBr.iX, rect.iBr.iY);
       
   186 
       
   187 	// Scissor icon
       
   188 	TAknLayoutRect scissorsIconLayout;
       
   189 	scissorsIconLayout.LayoutRect(Rect(),AknLayoutScalable_Apps::main_vded_pane_g1());
       
   190 	iCutVideoBar->SetComponentRect(CVeiCutterBar::EScissorsIcon, scissorsIconLayout.Rect());
       
   191 		
       
   192 	// Progress bar
       
   193 	TAknLayoutRect progressBarLayout; 
       
   194 	progressBarLayout.LayoutRect(Rect(),AknLayoutScalable_Apps::vded_slider_pane());
       
   195 	iCutVideoBar->SetComponentRect(CVeiCutterBar::EProgressBar, progressBarLayout.Rect());
       
   196 
       
   197 	// left end of the slider when that part is unselected
       
   198 	TAknLayoutRect sliderLeftEndLayout;
       
   199 	sliderLeftEndLayout.LayoutRect( progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g3() );
       
   200 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderLeftEndIcon, sliderLeftEndLayout.Rect() );
       
   201 		
       
   202 	// middle part of the slider when that part is unselected	
       
   203 	TAknLayoutRect sliderMiddleLayout;
       
   204 	sliderMiddleLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g5());
       
   205 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderMiddleIcon, sliderMiddleLayout.Rect() );		
       
   206 	
       
   207 	// right end of the slider when that part is unselected
       
   208 	TAknLayoutRect sliderRightEndLayout;
       
   209 	sliderRightEndLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g4());
       
   210 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderRightEndIcon, sliderRightEndLayout.Rect() );	
       
   211 		
       
   212 	// left end of the cut selection slider 
       
   213 	TAknLayoutRect sliderSelectedLeftEndLayout;
       
   214 	sliderSelectedLeftEndLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g3());
       
   215 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderSelectedLeftEndIcon, sliderSelectedLeftEndLayout.Rect() );
       
   216 		
       
   217 	// middle part of the cut selection slider 
       
   218 	TAknLayoutRect sliderSelectedMiddleLayout;
       
   219 	sliderSelectedMiddleLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g5());
       
   220 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderSelectedMiddleIcon, sliderSelectedMiddleLayout.Rect() );		
       
   221 	
       
   222 	// right end of the cut selection slider 
       
   223 	TAknLayoutRect sliderSelectedRightEndLayout;
       
   224 	sliderSelectedRightEndLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g4());
       
   225 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ESliderSelectedRightEndIcon, sliderSelectedRightEndLayout.Rect() ); 
       
   226 
       
   227     // playhead
       
   228     TAknLayoutRect playheadLayout;
       
   229 	playheadLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g1());
       
   230 	iCutVideoBar->SetComponentRect( CVeiCutterBar::EPlayheadIcon, playheadLayout.Rect() ); 
       
   231 
       
   232     // left/right border of cut selection slider
       
   233     TAknLayoutRect cutAreaBorderLayout;
       
   234 	cutAreaBorderLayout.LayoutRect(progressBarLayout.Rect(),AknLayoutScalable_Apps::vded_slider_pane_g2());
       
   235 	iCutVideoBar->SetComponentRect( CVeiCutterBar::ECutAreaBorderIcon, cutAreaBorderLayout.Rect() ); 
       
   236 		
       
   237 		
       
   238 	// Start cut time text
       
   239 	TAknLayoutText startTimeTextLayout;
       
   240 	startTimeTextLayout.LayoutText(rect, AknLayoutScalable_Apps::main_vded_pane_t1() );
       
   241 	iCutTimeDisplay->SetComponentRect(CVeiTextDisplay::EStartTimeText, startTimeTextLayout.TextRect());
       
   242 	
       
   243 	// End cut time text
       
   244 	TAknLayoutText endTimeTextLayout;
       
   245 	endTimeTextLayout.LayoutText(rect, AknLayoutScalable_Apps::main_vded_pane_t2() );
       
   246 	iCutTimeDisplay->SetComponentRect(CVeiTextDisplay::EEndTimeText, endTimeTextLayout.TextRect());
       
   247 	
       
   248 	// Start cut time icon
       
   249 	TAknLayoutRect startTimeIconLayout;
       
   250 	startTimeIconLayout.LayoutRect(rect, AknLayoutScalable_Apps::main_vded_pane_g2() );
       
   251 	iCutTimeDisplay->SetComponentRect(CVeiTextDisplay::EStartTimeIcon, startTimeIconLayout.Rect());
       
   252 	
       
   253 	// End cut time icon
       
   254 	TAknLayoutRect endTimeIconLayout;
       
   255 	endTimeIconLayout.LayoutRect(rect, AknLayoutScalable_Apps::main_vded_pane_g3() );
       
   256 	iCutTimeDisplay->SetComponentRect(CVeiTextDisplay::EEndTimeIcon, endTimeIconLayout.Rect());
       
   257 		
       
   258 	// Pause icon
       
   259 	
       
   260 
       
   261 
       
   262 	// Video Display	
       
   263 	TAknLayoutRect videoDisplayLayout;
       
   264 	videoDisplayLayout.LayoutRect(Rect(),AknLayoutScalable_Apps::vded_video_pane());
       
   265 	iVideoDisplay->SetRect(videoDisplayLayout.Rect());
       
   266 	
       
   267 	iDisplayRect = videoDisplayLayout.Rect();	
       
   268 	iIconDisplayRect = videoDisplayLayout.Rect();
       
   269 	LOGFMT2(KVideoEditorLogFile, "CVeiCutVideoContainer::SizeChanged(): iDisplayRect: %d,%d", iDisplayRect.iBr.iX, iDisplayRect.iBr.iY);
       
   270 
       
   271 	//CVeiCutterBar
       
   272 	// : Change this when LAF data is ready
       
   273 	TPoint cutBarTl = TPoint(STATIC_CAST( TInt, rect.iBr.iX*0.0114 ),
       
   274 		STATIC_CAST( TInt, rect.iBr.iY*0.875 ) );
       
   275 	TSize cutBarSize = TSize(STATIC_CAST( TInt, rect.iBr.iX*0.9773 ),
       
   276 		STATIC_CAST( TInt, rect.iBr.iY*0.0973 ) );
       
   277 
       
   278 	TRect cutBarRect( cutBarTl, cutBarSize );
       
   279 	iCutVideoBar->SetRect( cutBarRect );
       
   280 
       
   281 	//CVeiTextDisplay
       
   282 	// : Change this when LAF data is ready
       
   283 	TPoint cutTimeDisplayTl = TPoint(cutBarTl.iX,
       
   284 		STATIC_CAST( TInt, rect.iBr.iY*0.757 ) );
       
   285 	TSize cutTimeDisplaySize = TSize(cutBarSize.iWidth,
       
   286 		STATIC_CAST( TInt, rect.iBr.iY*0.0903 ) );
       
   287 
       
   288 	iCutTimeDisplayRect = TRect( cutTimeDisplayTl, cutTimeDisplaySize );
       
   289 	iCutTimeDisplay->SetRect( iCutTimeDisplayRect );
       
   290 	iCutTimeDisplay->SetLayout( CVeiTextDisplay::ECutInCutOut );
       
   291 
       
   292 		
       
   293 	TInt iconWidth = STATIC_CAST( TInt, rect.iBr.iX * 0.07954545455 );
       
   294 	AknIconUtils::SetSize( iPauseBitmap, TSize(iconWidth,iconWidth), EAspectRatioNotPreserved );
       
   295         
       
   296     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SizeChanged(): Out");
       
   297     }
       
   298 
       
   299 TTypeUid::Ptr CVeiCutVideoContainer::MopSupplyObject( TTypeUid aId )
       
   300     {
       
   301     if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext )
       
   302         {
       
   303         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   304         }
       
   305     return CCoeControl::MopSupplyObject( aId );
       
   306     }
       
   307 
       
   308 TInt CVeiCutVideoContainer::CountComponentControls() const
       
   309     {
       
   310     return 3; 
       
   311     }
       
   312 
       
   313 CCoeControl* CVeiCutVideoContainer::ComponentControl( TInt aIndex ) const
       
   314     {
       
   315     switch ( aIndex )
       
   316         {
       
   317         case 0:
       
   318             return iCutVideoBar;
       
   319         case 1:
       
   320             return iVideoDisplay;
       
   321         case 2:
       
   322             return iCutTimeDisplay;
       
   323         default:
       
   324             return NULL;
       
   325         }
       
   326     }
       
   327 
       
   328 void CVeiCutVideoContainer::Draw( const TRect& aRect ) const
       
   329     {
       
   330     CWindowGc& gc = SystemGc();
       
   331     // draw skin background
       
   332     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   333     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );    
       
   334     AknsDrawUtils::Background( skin, cc, this, gc, aRect );
       
   335 
       
   336     if ( EStatePaused == iState )
       
   337         {       
       
   338         TPoint pauseIconTl = TPoint( iIconDisplayRect.iTl.iX - STATIC_CAST( TInt, Rect().iBr.iX*0.105),
       
   339             iIconDisplayRect.iTl.iY + STATIC_CAST( TInt, Rect().iBr.iY*0.178 ));
       
   340         gc.BitBltMasked( pauseIconTl, iPauseBitmap, 
       
   341             TRect( TPoint(0,0), iPauseBitmap->SizeInPixels() ), 
       
   342             iPauseBitmapMask, EFalse );
       
   343         }
       
   344     }
       
   345 
       
   346 
       
   347 // ----------------------------------------------------------------------------
       
   348 // CVeiCutVideoContainer::GetHelpContext(...) const
       
   349 //
       
   350 // Gets the control's help context. Associates the control with a particular
       
   351 // Help file and topic in a context sensitive application.
       
   352 // ----------------------------------------------------------------------------
       
   353 //
       
   354 void CVeiCutVideoContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   355     {
       
   356     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetHelpContext(): In");
       
   357 
       
   358     // Set UID of the CS Help file (same as application UID).
       
   359     aContext.iMajor = KUidVideoEditor;
       
   360 
       
   361     // Set the context/topic.
       
   362     aContext.iContext = KVED_HLP_CUT_VIDEO_VIEW;
       
   363 
       
   364     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetHelpContext(): Out");
       
   365     }
       
   366 
       
   367 
       
   368 void CVeiCutVideoContainer::HandleControlEventL(
       
   369     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
       
   370     {
       
   371     }
       
   372 
       
   373 // ----------------------------------------------------------------------------
       
   374 // CVeiCutVideoContainer::HandlePointerEventL
       
   375 // From CCoeControl
       
   376 // ----------------------------------------------------------------------------
       
   377 //		
       
   378 void CVeiCutVideoContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   379 	{
       
   380 	LOG( KVideoEditorLogFile, "CVeiCutVideoContainer::HandlePointerEventL(): In" );
       
   381 	if( AknLayoutUtils::PenEnabled() && iCutVideoBar )
       
   382 		{
       
   383 		CCoeControl::HandlePointerEventL( aPointerEvent );
       
   384 		
       
   385 		switch( aPointerEvent.iType )
       
   386 			{
       
   387 			case TPointerEvent::EButton1Down:
       
   388 				{
       
   389 				iIsMarkDrag = EFalse;
       
   390 				iIsMarkTapped = EFalse;
       
   391 				TRect startMarkRect = iCutVideoBar->StartMarkRect();
       
   392 				TRect endMarkRect = iCutVideoBar->EndMarkRect();				
       
   393 				// check if the pen goes down inside the start mark
       
   394 				if (startMarkRect.Contains(aPointerEvent.iPosition)) 
       
   395 					{
       
   396 					iIsMarkTapped = ETrue;
       
   397 					iTappedMark = EStartMark;
       
   398 					}
       
   399 				// check if the pen goes down inside the end mark	
       
   400 				else if (endMarkRect.Contains(aPointerEvent.iPosition))
       
   401 					{
       
   402 					iIsMarkTapped = ETrue;
       
   403 					iTappedMark = EEndMark;
       
   404 					}					
       
   405 				
       
   406 				TRect progressBarRect(iCutVideoBar->ProgressBarRect());	
       
   407 				// check if the pen goes down inside the progress bar				
       
   408 				if( progressBarRect.Contains( aPointerEvent.iPosition ) )
       
   409 					{
       
   410 					iIsMarkDrag = EFalse;					
       
   411 					}
       
   412 				break;
       
   413 				}
       
   414 			case TPointerEvent::EDrag:
       
   415 				{
       
   416 				
       
   417 				TRect progressBarRect(iCutVideoBar->ProgressBarRect());
       
   418 				if ( progressBarRect.Contains( aPointerEvent.iPosition ) )
       
   419 				{
       
   420 					
       
   421 					if (iIsMarkTapped)
       
   422 						{
       
   423 						iIsMarkDrag = ETrue;
       
   424 						HandleProgressBarTouchL( progressBarRect, 
       
   425 												 aPointerEvent.iPosition.iX,
       
   426 												 ETrue,
       
   427 												 iTappedMark );
       
   428 						}
       
   429 					else 
       
   430 						{
       
   431 						
       
   432 						HandleProgressBarTouchL( progressBarRect, 
       
   433 												 aPointerEvent.iPosition.iX,
       
   434 												 EFalse);
       
   435 						}
       
   436 				}
       
   437 				break;		
       
   438 				}
       
   439 			case TPointerEvent::EButton1Up:
       
   440 				{
       
   441 				// pen up event is handled if it wasn't dragged
       
   442 				if (!iIsMarkDrag)
       
   443 					{
       
   444 					TRect progressBarRect(iCutVideoBar->ProgressBarRect());					
       
   445 					// Check if pressed position is in progress bar's rect
       
   446 					if( progressBarRect.Contains( aPointerEvent.iPosition ) )
       
   447 						{
       
   448 						HandleProgressBarTouchL( progressBarRect, 
       
   449 											 aPointerEvent.iPosition.iX,
       
   450 											 EFalse);
       
   451 						}
       
   452 					}
       
   453 				break;
       
   454 				}		
       
   455 			default:
       
   456 				{
       
   457 				break;	
       
   458 				}	
       
   459 			}
       
   460 		}	
       
   461 	LOG( KVideoEditorLogFile, "CVeiCutVideoContainer::HandlePointerEventL(): Out" );		
       
   462 	}
       
   463 
       
   464 
       
   465 // ----------------------------------------------------------------------------
       
   466 // CVeiCutVideoContainer::HandleProgressBarTouchL
       
   467 // 
       
   468 // ----------------------------------------------------------------------------
       
   469 //	
       
   470 void CVeiCutVideoContainer::HandleProgressBarTouchL( TRect aPBRect, 
       
   471 												 TInt aPressedPoint,
       
   472 												 TBool aDragMarks,
       
   473 												 CVeiCutVideoContainer::TCutMark aCutMark )
       
   474 	{
       
   475 	if (( AknLayoutUtils::PenEnabled() ) && ( iState!=EStateInitializing ))
       
   476 		{	
       
   477 		LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::HandleProgressBarTouchL(): In");
       
   478 
       
   479 		if ( iState == EStatePlaying )		
       
   480 			{
       
   481 			StopL();	
       
   482 			}
       
   483 		
       
   484 		// Progress Bar start and end points, and length
       
   485 		TInt pbEndPoint( aPBRect.iBr.iX );
       
   486 		TInt pbStartPoint = ( aPBRect.iTl.iX );		
       
   487 		TInt totalPBLength( pbEndPoint - pbStartPoint );
       
   488 				
       
   489 		// calculate the time position from the tapped progress bar coordinates 
       
   490 		TTimeIntervalMicroSeconds newPosition( 
       
   491 										( ( aPressedPoint - pbStartPoint ) * 
       
   492 							  			iVideoClipInfo->Duration().Int64() ) / 
       
   493 							  			totalPBLength );
       
   494 		
       
   495 		// move cut marks
       
   496 		if (aDragMarks)
       
   497 		{
       
   498 			// check that the start mark doesn't go past the end mark
       
   499 			// and not to the beginning			
       
   500 			if ((aCutMark == EStartMark) && 
       
   501 			    (newPosition.Int64() > 0) &&
       
   502 				(aPressedPoint < iCutVideoBar->EndMarkPoint() - 2*iCutVideoBar->EndMarkRect().Width()))
       
   503 				{				
       
   504 				iView.MoveStartOrEndMarkL(newPosition, EStartMark);				
       
   505 				iCutVideoBar->SetInPoint( newPosition	);
       
   506 				iCutTimeDisplay->SetCutIn( newPosition );
       
   507 				}
       
   508 			// check that the end mark doesn't go before the start mark	
       
   509 			// and not too close to the beginning			
       
   510 			else if ((aCutMark == EEndMark) && 
       
   511 				(newPosition.Int64() >= KMinCutVideoLength) &&			
       
   512 				(aPressedPoint > iCutVideoBar->StartMarkPoint() + 2*iCutVideoBar->StartMarkRect().Width()))
       
   513                 
       
   514 				{				
       
   515 				iView.MoveStartOrEndMarkL(newPosition, EEndMark);				
       
   516 				iCutVideoBar->SetOutPoint( newPosition	);
       
   517 				iCutTimeDisplay->SetCutOut( newPosition );
       
   518 				}
       
   519 		}
       
   520 				
       
   521 		// move playhead
       
   522 		else if (( newPosition != iLastPosition ) && !aDragMarks)
       
   523 			{
       
   524 			iLastPosition = newPosition;
       
   525 			
       
   526 			iSeekPos = TTimeIntervalMicroSeconds( newPosition );
       
   527 			
       
   528 			iCutVideoBar->SetCurrentPoint(( static_cast<TInt32>(iSeekPos.Int64() / 1000) ));
       
   529 			iVideoDisplay->SetPositionL( iSeekPos );
       
   530 			GetThumbAtL( iSeekPos );
       
   531 					
       
   532 			iView.UpdateTimeL();
       
   533 			}	
       
   534 			
       
   535 		LOG( KVideoEditorLogFile, "CVeiCutVideoContainer::HandleProgressBarTouchL(): Out" );
       
   536 			
       
   537 		}// PenEnabled
       
   538 		
       
   539 	}
       
   540 
       
   541 
       
   542 
       
   543 
       
   544 void CVeiCutVideoContainer::PlayL( const TDesC& aFilename )
       
   545     {
       
   546     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PlayL: in");   
       
   547     iVideoDisplay->SetPositionL( iSeekPos );
       
   548     
       
   549     if (iVideoClipInfo && !iFrameReady)
       
   550         {                               
       
   551         iVideoClipInfo->CancelFrame();
       
   552         }
       
   553     iVideoDisplay->PlayL( aFilename );
       
   554     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PlayL: out");
       
   555     }
       
   556 
       
   557 void CVeiCutVideoContainer::PlayMarkedL( const TDesC& aFilename,
       
   558                                     const TTimeIntervalMicroSeconds& aStartTime, 
       
   559                                     const TTimeIntervalMicroSeconds& aEndTime )
       
   560     {
       
   561     LOGFMT3(KVideoEditorLogFile, "CVeiCutVideoContainer::PlayMarkedL, In, aStartTime:%Ld, aEndTime:%Ld, aFilename:%S", aStartTime.Int64(), aEndTime.Int64(), &aFilename);
       
   562     iPlayOrPlayMarked = ETrue;
       
   563 
       
   564     if (iVideoClipInfo && !iFrameReady)
       
   565         {                               
       
   566         iVideoClipInfo->CancelFrame();
       
   567         }
       
   568     iVideoDisplay->PlayL( aFilename, aStartTime, aEndTime );
       
   569     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PlayMarkedL, Out");
       
   570     }
       
   571 
       
   572 void CVeiCutVideoContainer::StopL()
       
   573     {
       
   574     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::StopL, in");
       
   575     iVideoDisplay->Stop( EFalse );
       
   576 
       
   577     iSeekPos = TTimeIntervalMicroSeconds( 0 );
       
   578     
       
   579     SetStateL( EStateStopped );
       
   580     PlaybackPositionL();
       
   581     
       
   582     if (iVideoBarTimer)
       
   583         {       
       
   584         iVideoBarTimer->Cancel();
       
   585         }
       
   586     
       
   587     iCutVideoBar->SetFinishedStatus( ETrue );
       
   588     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::StopL, in");
       
   589     }
       
   590 
       
   591 void CVeiCutVideoContainer::TakeSnapshotL()
       
   592     {
       
   593     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::TakeSnapshotL in");
       
   594     
       
   595     if( !iVideoClipInfo || !iFrameReady )
       
   596         {
       
   597         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::TakeSnapshotL: 1");
       
   598         if (!iFrameReady)
       
   599             {
       
   600             iTakeSnapshotWaiting = ETrue;   
       
   601             }       
       
   602         return;
       
   603         }
       
   604         
       
   605     iTakeSnapshotWaiting = EFalse;
       
   606     iTakeSnapshot = ETrue;
       
   607     const TTimeIntervalMicroSeconds& pos = PlaybackPositionL();
       
   608 
       
   609     GetThumbAtL( pos );
       
   610     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::TakeSnapshotL out");
       
   611     }
       
   612 
       
   613 void CVeiCutVideoContainer::PauseL( TBool aUpdateCBA )
       
   614     {
       
   615     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PauseL: In");
       
   616 
       
   617     if (EStatePlaying == iState)
       
   618         {       
       
   619         iLastPosition = iVideoDisplay->PositionL();                 
       
   620         iSeekPos = iLastPosition;
       
   621         // to set next start point
       
   622         iVideoDisplay->SetPositionL(iSeekPos);
       
   623         }
       
   624 
       
   625     iVideoDisplay->PauseL();
       
   626     if (iVideoBarTimer)
       
   627         {       
       
   628         iVideoBarTimer->Cancel();
       
   629         }
       
   630 
       
   631     #ifdef GET_PAUSE_THUMBNAIL
       
   632     GetThumbAtL( iLastPosition );
       
   633     #endif
       
   634 
       
   635     if (EStateStoppedInitial == iState || EStateStopped == iState ||
       
   636         (EStateGettingFrame == iState && 
       
   637             (EStateStoppedInitial == iPreviousState || EStateStopped == iPreviousState)))
       
   638         {
       
   639         // just to trigger cba-update
       
   640         SetStateL( iState, aUpdateCBA );
       
   641         }   
       
   642     else if (EStateInitializing != iState) 
       
   643         {
       
   644         SetStateL( EStatePaused, aUpdateCBA );
       
   645         }
       
   646     else
       
   647         {
       
   648         SetStateL( EStateStoppedInitial );
       
   649         }
       
   650             
       
   651     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PauseL: Out");
       
   652     }
       
   653 
       
   654 void CVeiCutVideoContainer::SaveSnapshotL()
       
   655     {
       
   656     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SaveSnapshotL: In");   
       
   657     //first we have to encode bitmap
       
   658     // get encoder types 
       
   659     RImageTypeDescriptionArray imageTypes; 
       
   660     iConverter->GetEncoderImageTypesL( imageTypes );    
       
   661 
       
   662     CleanupStack::PushL( TCleanupItem( CleanupRarray, &imageTypes ) );
       
   663 
       
   664     TInt selectedIdx = 0;
       
   665 
       
   666     for( TInt i=0; i<imageTypes.Count(); i++ ) 
       
   667         {
       
   668         if ( imageTypes[i]->Description() == KEncoderType )
       
   669             {
       
   670             selectedIdx = i;
       
   671             }
       
   672         }
       
   673 
       
   674     RFs&    fs = iEikonEnv->FsSession();
       
   675 
       
   676     TParse file;
       
   677     TFileName newname;
       
   678     TFileName snapshotdir;
       
   679 
       
   680     TVeiSettings saveSettings;
       
   681     // Get default snapshot name from settings view
       
   682 
       
   683     STATIC_CAST( CVeiAppUi*, iEikonEnv->AppUi() )->ReadSettingsL( saveSettings );   
       
   684 
       
   685     CAknMemorySelectionDialog::TMemory memory( saveSettings.MemoryInUse() );
       
   686 
       
   687     newname.Append( saveSettings.DefaultSnapshotName() );
       
   688     newname.Append( _L(".JPEG") );
       
   689     file.Set( newname, NULL, NULL );
       
   690 
       
   691     TInt error = KErrNone;
       
   692 
       
   693     snapshotdir.Zero();
       
   694 
       
   695     if ( memory == CAknMemorySelectionDialog::EPhoneMemory )
       
   696         {
       
   697         snapshotdir.Append( PathInfo::PhoneMemoryRootPath() ); 
       
   698         }
       
   699     else
       
   700         {
       
   701         snapshotdir.Append( PathInfo::MemoryCardRootPath() ); 
       
   702         }
       
   703     snapshotdir.Append( PathInfo::ImagesPath() );
       
   704 
       
   705     error = fs.MkDirAll( file.Path() );
       
   706     if ( ( error != KErrAlreadyExists ) && ( error != KErrNone ) )
       
   707         {
       
   708         return;
       
   709         }
       
   710 
       
   711     newname.Zero();
       
   712     newname.Append( file.NameAndExt() );
       
   713     newname.Insert( 0, snapshotdir );
       
   714     CApaApplication::GenerateFileName( fs, newname );
       
   715 
       
   716     //for cancellation
       
   717     if ( iSaveToFileName )
       
   718         {
       
   719         delete iSaveToFileName;
       
   720         iSaveToFileName = NULL;
       
   721         }
       
   722     iSaveToFileName = HBufC::NewL( newname.Length() );
       
   723     *iSaveToFileName = newname;
       
   724 
       
   725     // request the actuall save/encode
       
   726     // asynchronous, the result is reported via callback NotifyCompletion
       
   727     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SaveSnapshotL: 1, calling iConverter->StartToEncodeL");    
       
   728     iConverter->StartToEncodeL( newname, 
       
   729         imageTypes[selectedIdx]->ImageType(), imageTypes[selectedIdx]->SubType());
       
   730 
       
   731     CleanupStack::PopAndDestroy( &imageTypes );
       
   732     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SaveSnapshotL: Out");  
       
   733     }
       
   734 
       
   735 void CVeiCutVideoContainer::CancelSnapshotSave()
       
   736     {
       
   737     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::CancelSnapshotSave: in");
       
   738     if ( iConverter )
       
   739         {
       
   740         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::CancelSnapshotSave: 1");
       
   741         iConverter->Cancel();
       
   742         iConverter->CancelEncoding(); //also close the file
       
   743         }
       
   744     if ( iSaveToFileName )
       
   745         {
       
   746         LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::CancelSnapshotSave: 2, iSaveToFileName:%S", iSaveToFileName);
       
   747 
       
   748         RFs&    fs = iEikonEnv->FsSession(); 
       
   749         /*TInt result =*/ fs.Delete( *iSaveToFileName ); 
       
   750         delete iSaveToFileName;
       
   751         iSaveToFileName = NULL;
       
   752         }
       
   753     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::CancelSnapshotSave: out"); 
       
   754     }
       
   755 
       
   756 void CVeiCutVideoContainer::CloseStreamL()
       
   757     {
       
   758     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::CloseStreamL, in");
       
   759     if( !iFrameReady && iVideoClipInfo )
       
   760         {
       
   761         iVideoClipInfo->CancelFrame();
       
   762         }
       
   763     PlaybackPositionL();
       
   764     SetStateL( EStateStopped, EFalse );
       
   765     iView.UpdateCBAL(iState);
       
   766     
       
   767     iVideoDisplay->Stop( ETrue );
       
   768     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::CloseStreamL, out");
       
   769     }
       
   770 
       
   771 void CVeiCutVideoContainer::SetInTime( const TTimeIntervalMicroSeconds& aTime )
       
   772     {
       
   773     if ( iCutTimeDisplay )
       
   774         {
       
   775         iCutTimeDisplay->SetCutIn( aTime );
       
   776         }
       
   777     if ( iCutVideoBar )
       
   778         {
       
   779         iCutVideoBar->SetInPoint( aTime );
       
   780         }
       
   781     }
       
   782 
       
   783 void CVeiCutVideoContainer::SetOutTime( const TTimeIntervalMicroSeconds& aTime )
       
   784     {
       
   785     if ( iCutTimeDisplay )
       
   786         {
       
   787         iCutTimeDisplay->SetCutOut( aTime );
       
   788         }
       
   789 
       
   790     if ( iCutVideoBar )
       
   791         {
       
   792         iCutVideoBar->SetOutPoint( aTime );
       
   793         }
       
   794     }
       
   795 
       
   796 TTimeIntervalMicroSeconds CVeiCutVideoContainer::PlaybackPositionL()
       
   797     {
       
   798     if ( ( iSeeking ) || ( EStateStopped == iState ) )
       
   799         {
       
   800         return iSeekPos;
       
   801         }
       
   802     if ( iState != EStatePlaying  )
       
   803         {
       
   804         return iLastPosition;
       
   805         }
       
   806 
       
   807     if ( iVideoClipInfo && (iVideoDisplay->PositionL() < iVideoClipInfo->Duration()) )
       
   808         {
       
   809         iLastPosition = iVideoDisplay->PositionL();
       
   810         }
       
   811 
       
   812     if ( ( iLastPosition == TTimeIntervalMicroSeconds( 0 ) ) &&
       
   813          ( iSeekPos != TTimeIntervalMicroSeconds( 0 ) ) )
       
   814         {
       
   815         return iSeekPos;
       
   816         }
       
   817 
       
   818     return iLastPosition;
       
   819     }
       
   820 
       
   821 TKeyResponse CVeiCutVideoContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   822     {
       
   823     if ( aType == EEventKeyDown ) 
       
   824         {
       
   825         iKeyRepeatCount = 0;
       
   826 
       
   827         TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift );
       
   828         if( shiftKeyPressed )
       
   829             {
       
   830             if( iView.IsEnoughFreeSpaceToSaveL() && (iTakeSnapshot == EFalse )) 
       
   831                 {
       
   832                 /*if (EStatePlaying == iState)
       
   833                     {
       
   834                     PauseL();   
       
   835                     }
       
   836                     */
       
   837                 TakeSnapshotL();
       
   838                 }
       
   839             return EKeyWasConsumed;
       
   840             }   
       
   841 
       
   842         return EKeyWasNotConsumed;
       
   843         }
       
   844     else if ( aType == EEventKeyUp ) 
       
   845         {
       
   846         if ( iSeeking == EFalse )
       
   847             {
       
   848             return EKeyWasNotConsumed;
       
   849             }
       
   850         iLastPosition = iSeekPos;
       
   851         iVideoDisplay->SetPositionL( iSeekPos );
       
   852 
       
   853         iSeeking = EFalse;
       
   854 
       
   855         if ( ( ( EStateStopped == iState ) || ( EStateStoppedInitial == iState )
       
   856             || ( EStatePaused == iState )) && 
       
   857              ( ( iLastKeyCode == EKeyLeftArrow ) || ( iLastKeyCode == EKeyRightArrow ) ) )
       
   858             {
       
   859             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::OfferKeyEventL: 1, calling GetThumbAtL()");
       
   860             GetThumbAtL( iSeekPos );
       
   861             return EKeyWasConsumed;
       
   862             }
       
   863         else if ( EStatePlaying == iState )
       
   864             {
       
   865             if ( iVideoBarTimer->IsActive() )
       
   866                 {
       
   867                 iVideoBarTimer->Cancel();
       
   868                 }
       
   869 
       
   870             if ( iVideoClipInfo &&  (iSeekPos >= iVideoClipInfo->Duration()) )
       
   871                 {
       
   872                 LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::OfferKeyEventL: 2, calling iVideoDisplay->Stop");
       
   873                 iVideoDisplay->Stop( EFalse );
       
   874                 }
       
   875             else
       
   876                 {
       
   877                 iVideoDisplay->SetPositionL( iSeekPos );
       
   878                 iVideoDisplay->ShowBlackScreen();
       
   879                 if (iVideoClipInfo && !iFrameReady)
       
   880                     {                               
       
   881                     iVideoClipInfo->CancelFrame();
       
   882                     }
       
   883                 iVideoDisplay->Play();
       
   884                 }
       
   885             return EKeyWasConsumed;
       
   886             }
       
   887         else
       
   888             {
       
   889             return EKeyWasConsumed;
       
   890             }
       
   891         }
       
   892     else if ( aType == EEventKey )
       
   893         {
       
   894         iLastKeyCode = aKeyEvent.iCode;
       
   895 
       
   896         switch (aKeyEvent.iCode)
       
   897             {
       
   898             case EKeyOK:
       
   899                 {
       
   900                 iView.HandleCommandL( EAknSoftkeyOk );
       
   901                 return EKeyWasConsumed;
       
   902                 }
       
   903             case EKeyDownArrow:
       
   904             case EKeyUpArrow:
       
   905                 {
       
   906                 iVideoDisplay->OfferKeyEventL( aKeyEvent, aType );
       
   907                 return EKeyWasConsumed;
       
   908                 }
       
   909             case EKeyRightArrow:
       
   910                 {
       
   911                 iKeyRepeatCount++;
       
   912 
       
   913                 if ( (iKeyRepeatCount > 2)  && (iSeeking == EFalse) )
       
   914                     {
       
   915                     if ( EStatePlaying == iState )
       
   916                         {
       
   917                         iSeekPos = iVideoDisplay->PositionL();
       
   918                         }
       
   919     
       
   920                     iVideoDisplay->PauseL();
       
   921                     iSeeking = ETrue;
       
   922                     iKeyRepeatCount = 0;                
       
   923                     }
       
   924 
       
   925                 if ( iSeeking && ( iState!=EStateInitializing ) &&
       
   926                     ( iState!=EStatePlayingMenuOpen ) )
       
   927                     {
       
   928                     TInt adjustment = TimeIncrement( iKeyRepeatCount );
       
   929 
       
   930                     TInt64 newPos = iSeekPos.Int64() + adjustment;
       
   931                     if ( iVideoClipInfo && (newPos > iVideoClipInfo->Duration().Int64()) )
       
   932                         {
       
   933                         newPos = iVideoClipInfo->Duration().Int64();
       
   934                         }
       
   935     
       
   936                     iSeekPos = TTimeIntervalMicroSeconds( newPos );
       
   937                     
       
   938                     iCutVideoBar->SetCurrentPoint( (static_cast<TInt32>(iSeekPos.Int64() / 1000)));
       
   939 
       
   940                     iView.UpdateTimeL();
       
   941                     return EKeyWasConsumed;
       
   942                     }
       
   943                 return EKeyWasNotConsumed;
       
   944                 }
       
   945 
       
   946             case EKeyLeftArrow:
       
   947                 {
       
   948                 iKeyRepeatCount++;
       
   949 
       
   950                 if ( (iKeyRepeatCount > 2)  && (iSeeking == EFalse) )
       
   951                     {
       
   952                     
       
   953                     if ( EStatePlaying == iState )
       
   954                         {
       
   955                         iSeekPos = iVideoDisplay->PositionL();
       
   956                         }
       
   957 
       
   958                     iVideoDisplay->PauseL();
       
   959                     iSeeking = ETrue;
       
   960                     iKeyRepeatCount = 0;                
       
   961                     }
       
   962 
       
   963                 if ( iSeeking && ( iState!=EStateInitializing ) &&
       
   964                     ( iState!=EStatePlayingMenuOpen ) )
       
   965                     {
       
   966 
       
   967                     TInt adjustment = TimeIncrement( iKeyRepeatCount );
       
   968 
       
   969                     TInt64 newPos = iSeekPos.Int64() - adjustment;
       
   970                     if ( newPos < 0 ) 
       
   971                         {
       
   972                         newPos = 0;
       
   973                         }
       
   974                     iSeekPos = TTimeIntervalMicroSeconds( newPos ); 
       
   975 
       
   976                     iCutVideoBar->SetCurrentPoint( static_cast<TInt32>((iSeekPos.Int64() / 1000)) );
       
   977 
       
   978                     iView.UpdateTimeL();
       
   979 
       
   980                     return EKeyWasConsumed;
       
   981                     }
       
   982                 return EKeyWasNotConsumed;
       
   983                 }
       
   984             case EKeyBackspace:     //Clear 
       
   985                 {
       
   986                 if (EStatePlaying != iState)
       
   987                     {
       
   988                     iView.ClearInOutL( ETrue, ETrue );                      
       
   989                     }
       
   990                 
       
   991                 return EKeyWasConsumed;
       
   992                 }
       
   993             default:
       
   994                 {
       
   995                 return EKeyWasNotConsumed;
       
   996                 }
       
   997             }
       
   998         }
       
   999     else
       
  1000         {
       
  1001         return EKeyWasNotConsumed;
       
  1002         }
       
  1003     }
       
  1004 
       
  1005 
       
  1006 
       
  1007 TInt CVeiCutVideoContainer::TimeIncrement(TInt aKeyCount) const
       
  1008     {
       
  1009     if ( aKeyCount < 3 )
       
  1010         {
       
  1011         return 100000;
       
  1012         }
       
  1013     else if ( aKeyCount < 4 )
       
  1014         {
       
  1015         return 300000;
       
  1016         }
       
  1017     else if ( aKeyCount < 5 )
       
  1018         {
       
  1019         return 500000;
       
  1020         }
       
  1021     else if ( aKeyCount < 10 )
       
  1022         {
       
  1023         return 1000000;
       
  1024         }
       
  1025     else if ( aKeyCount < 13 )
       
  1026         {
       
  1027         return 2000000;
       
  1028         }
       
  1029     else if ( aKeyCount < 15 )
       
  1030         {
       
  1031         return 3000000;
       
  1032         }
       
  1033     else
       
  1034         {
       
  1035         return 5000000;
       
  1036         }   
       
  1037     }
       
  1038 
       
  1039 TInt CVeiCutVideoContainer::UpdateProgressNoteL()
       
  1040     {
       
  1041     TTime intervalTime;
       
  1042     intervalTime.HomeTime();
       
  1043     intervalTime += TTimeIntervalMicroSeconds( 50000 );
       
  1044     TTime currentTime;
       
  1045     currentTime.HomeTime();
       
  1046     while ( intervalTime > currentTime )
       
  1047         {
       
  1048         currentTime.HomeTime();
       
  1049         }
       
  1050 
       
  1051     iProgressInfo->IncrementAndDraw( 1 );
       
  1052 
       
  1053     if ( KProgressbarFinalValue <= iProgressInfo->CurrentValue() )
       
  1054         {
       
  1055         return 0;
       
  1056         }
       
  1057     return 1;
       
  1058     }
       
  1059 
       
  1060 
       
  1061 void CVeiCutVideoContainer::GetThumbL( const TDesC& aFilename )
       
  1062     {
       
  1063     if ( iVideoClipInfo )
       
  1064         {
       
  1065         delete iVideoClipInfo;
       
  1066         iVideoClipInfo = NULL;      
       
  1067         }
       
  1068 
       
  1069     /*iVideoClipInfo = */CVedVideoClipInfo::NewL( aFilename, *this );
       
  1070     }
       
  1071 
       
  1072 
       
  1073 void CVeiCutVideoContainer::GetThumbAtL( const TTimeIntervalMicroSeconds& aTime )
       
  1074     {
       
  1075     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetThumbAtL: In");
       
  1076     if( !iVideoClipInfo || ( !iFrameReady ) )
       
  1077         {
       
  1078         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetThumbAtL: 1");
       
  1079         return;
       
  1080         }
       
  1081 
       
  1082     TRect clipResolution = iVideoClipInfo->Resolution();
       
  1083     TSize resolution( iVideoDisplay->Size() );
       
  1084 
       
  1085     TInt frameIndex;
       
  1086     TInt totalFrameCount;
       
  1087 
       
  1088     frameIndex = iVideoClipInfo->GetVideoFrameIndexL( aTime );
       
  1089     totalFrameCount = iVideoClipInfo->VideoFrameCount();
       
  1090 
       
  1091     if ( frameIndex > totalFrameCount )
       
  1092         {
       
  1093         frameIndex = totalFrameCount;
       
  1094         }
       
  1095 
       
  1096     //Generates a thumbnail bitmap of the given frame from video clip
       
  1097     if ( iTakeSnapshot )
       
  1098         {
       
  1099         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetThumbAtL: 2");
       
  1100         TDisplayMode displayMode = ENone;
       
  1101         TBool enhance = ETrue;
       
  1102         TSize resol( clipResolution.iBr.iX, clipResolution.iBr.iY ); 
       
  1103                 
       
  1104         /* :
       
  1105          check out on every phone before releasing whether videodisplay should be stopped before starting
       
  1106          asynchronous GetFrameL()
       
  1107          see how EStateGettingFrame is handled in SetPreviewState 
       
  1108          Stopping frees memory and it is needed in memory sensible devices 
       
  1109         */
       
  1110         iVideoClipInfo->GetFrameL( *this, frameIndex, &resol, displayMode, enhance );
       
  1111         SetStateL( EStateGettingFrame );
       
  1112         iFrameReady = EFalse;           
       
  1113         ShowProgressNoteL();        
       
  1114         }
       
  1115     else
       
  1116         {
       
  1117         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetThumbAtL: 3");              
       
  1118         /* :
       
  1119          check out on every phone before releasing whether videodisplay should be stopped before starting
       
  1120          asynchronous GetFrameL()
       
  1121          see how EStateGettingFrame is handled in SetPreviewState 
       
  1122          Stopping frees memory and it is needed in memory sensible devices 
       
  1123         */
       
  1124         iVideoClipInfo->GetFrameL( *this, frameIndex, &resolution );
       
  1125         SetStateL( EStateGettingFrame );
       
  1126         iFrameReady = EFalse;       
       
  1127         }
       
  1128     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::GetThumbAtL: out");    
       
  1129     }
       
  1130 
       
  1131 void CVeiCutVideoContainer::NotifyCompletion( TInt aErr ) 
       
  1132     {
       
  1133     LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyCompletion: In, aErr:%d", aErr);  
       
  1134 
       
  1135     if (EStateTerminating == iState)
       
  1136         {
       
  1137         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyCompletion(): app is closing...");
       
  1138         return;
       
  1139         }
       
  1140 
       
  1141     if ( KErrNone == aErr )
       
  1142         {
       
  1143         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyCompletion: 1");
       
  1144 
       
  1145         if (iProgressDialog)
       
  1146             {
       
  1147             TRAP_IGNORE(iProgressDialog->GetProgressInfoL()->SetAndDraw( KProgressbarFinalValue );
       
  1148                         iProgressDialog->ProcessFinishedL());
       
  1149             }
       
  1150         }
       
  1151     else
       
  1152         {
       
  1153         if (iProgressDialog)
       
  1154             {
       
  1155             TRAP_IGNORE(iProgressDialog->GetProgressInfoL()->SetAndDraw( KProgressbarFinalValue );
       
  1156                         iProgressDialog->ProcessFinishedL());
       
  1157             }
       
  1158         iErrorUI.ShowGlobalErrorNote( aErr );
       
  1159         }
       
  1160 
       
  1161     //  to eliminate previous (wrong) output file from being deleted in CancelSnapshotSave()
       
  1162     delete iSaveToFileName;
       
  1163     iSaveToFileName = NULL;
       
  1164 
       
  1165     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyCompletion: Out");   
       
  1166     }
       
  1167 
       
  1168 void CVeiCutVideoContainer::NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo, 
       
  1169                                           TInt aError )
       
  1170     {
       
  1171     LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipInfoReady, In, aError:%d", aError);
       
  1172     if (KErrNone == aError)
       
  1173         {
       
  1174         if (iVideoClipInfo)     
       
  1175             {
       
  1176             delete iVideoClipInfo;
       
  1177             iVideoClipInfo = NULL;  
       
  1178             }
       
  1179         iVideoClipInfo = &aInfo;    
       
  1180 
       
  1181         TRect clipResolution = Rect();
       
  1182         iDuration = iVideoClipInfo->Duration();
       
  1183         iCutVideoBar->SetTotalDuration( iDuration );
       
  1184         iView.DrawTimeNaviL();
       
  1185 
       
  1186         TSize resolution( clipResolution.iBr.iX, clipResolution.iBr.iY-KVeiCutBarHeight ); 
       
  1187         iFrameReady = EFalse;
       
  1188         iVideoClipInfo->GetFrameL( *this, 0, &resolution );
       
  1189         }
       
  1190     SetStateL( EStateStoppedInitial );          
       
  1191     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipInfoReady, Out");
       
  1192     }
       
  1193 
       
  1194 
       
  1195 void CVeiCutVideoContainer::NotifyVideoClipFrameCompleted(CVedVideoClipInfo& /*aInfo*/, 
       
  1196                                                TInt aError, 
       
  1197                                                CFbsBitmap* aFrame)
       
  1198     {
       
  1199     LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted, In, aError:%d", aError);
       
  1200     iFrameReady = ETrue;
       
  1201     
       
  1202     if (EStateGettingFrame == iState)
       
  1203         {
       
  1204         SetStateL(iPreviousState);          
       
  1205         }       
       
  1206     
       
  1207     if (KErrNone == aError && aFrame)
       
  1208         {
       
  1209         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted 1");         
       
  1210 
       
  1211         if ( iTakeSnapshot )
       
  1212             {
       
  1213             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted 2");         
       
  1214             iConverter->SetBitmap( aFrame );
       
  1215             if (! iCallBackSaveSnapshot)
       
  1216                 {       
       
  1217                 TCallBack cb (CVeiCutVideoContainer::AsyncSaveSnapshot, this);
       
  1218                 iCallBackSaveSnapshot = new (ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard);
       
  1219                 }
       
  1220             iCallBackSaveSnapshot->CallBack();
       
  1221             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted 3");
       
  1222             }
       
  1223         else
       
  1224             {
       
  1225             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted 4");
       
  1226             TRAP_IGNORE(iVideoDisplay->ShowPictureL( *aFrame ));
       
  1227             delete aFrame;
       
  1228             aFrame = NULL;
       
  1229             
       
  1230             if (iTakeSnapshotWaiting)
       
  1231                 {
       
  1232                 if (! iCallBackTakeSnapshot)
       
  1233                     {       
       
  1234                     TCallBack cb (CVeiCutVideoContainer::AsyncTakeSnapshot, this);
       
  1235                     iCallBackTakeSnapshot = new (ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard);
       
  1236                     }
       
  1237                 iCallBackTakeSnapshot->CallBack();              
       
  1238                 }
       
  1239             }
       
  1240         }
       
  1241     else
       
  1242         {
       
  1243         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted 5");
       
  1244         if (aFrame) 
       
  1245             {
       
  1246             delete aFrame;
       
  1247             aFrame = NULL;  
       
  1248             }       
       
  1249         
       
  1250         if (iProgressDialog)
       
  1251             {
       
  1252             iProgressInfo->SetAndDraw( KProgressbarFinalValue );
       
  1253             TRAP_IGNORE(iProgressDialog->ProcessFinishedL());
       
  1254             }       
       
  1255         }
       
  1256     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoClipFrameCompleted, Out");  
       
  1257     }
       
  1258 
       
  1259 TInt CVeiCutVideoContainer::AsyncSaveSnapshot(TAny* aThis)
       
  1260     {
       
  1261     LOG( KVideoEditorLogFile, "CVeiCutVideoView::AsyncSaveSnapshot in");
       
  1262     
       
  1263     // In the asynchronous version, trap the rest of the functions 
       
  1264     // to make sure that the caller's TRequestStatus is always 
       
  1265     // completed, also in case of failures.
       
  1266     CVeiCutVideoContainer* container = static_cast<CVeiCutVideoContainer*>(aThis);
       
  1267     TInt err = KErrNone;
       
  1268     TRAP(err, container->SaveSnapshotL());
       
  1269     LOGFMT( KVideoEditorLogFile, "CVeiEditVideoView::AsyncSaveSnapshot 2, err:%d", err);
       
  1270     
       
  1271     if (KErrNone != err)
       
  1272         {
       
  1273         container->StopProgressDialog();
       
  1274         container->ShowGlobalErrorNote(err);
       
  1275         }  
       
  1276     LOG( KVideoEditorLogFile, "CVeiEditVideoView::AsyncSaveSnapshot 3, returning");
       
  1277     return KErrNone;                
       
  1278     }       
       
  1279     
       
  1280 void CVeiCutVideoContainer::ShowGlobalErrorNote(const TInt aErr)
       
  1281     {       
       
  1282     iErrorUI.ShowGlobalErrorNote( aErr );
       
  1283     }
       
  1284 
       
  1285 void CVeiCutVideoContainer::StopProgressDialog()
       
  1286     {
       
  1287     if (iProgressDialog)
       
  1288         {
       
  1289         TRAP_IGNORE(iProgressDialog->GetProgressInfoL()->SetAndDraw( KProgressbarFinalValue );
       
  1290                     iProgressDialog->ProcessFinishedL());
       
  1291         }   
       
  1292     }
       
  1293 
       
  1294 void CVeiCutVideoContainer::NotifyVideoDisplayEvent( const TPlayerEvent aEvent, const TInt& aInfo  )
       
  1295     {
       
  1296     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, In");
       
  1297 
       
  1298     if (EStateTerminating == iState)
       
  1299         {
       
  1300         LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent(): app is closing...");
       
  1301         return;
       
  1302         }
       
  1303 
       
  1304     switch (aEvent)
       
  1305         {
       
  1306         case MVeiVideoDisplayObserver::ELoadingStarted:
       
  1307             {   
       
  1308             SetStateL(EStateOpening);
       
  1309             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent() MVeiVideoDisplayObserver::ELoadingStarted");
       
  1310             break;
       
  1311             }
       
  1312         case MVeiVideoDisplayObserver::EOpenComplete:
       
  1313             {
       
  1314             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::EOpenComplete 1");      
       
  1315             iVideoDisplay->SetRotationL( EVideoRotationNone );
       
  1316             TTimeIntervalMicroSeconds cutInTime = iView.GetVideoClipCutInTime();
       
  1317             TTimeIntervalMicroSeconds cutOutTime = iView.GetVideoClipCutOutTime();
       
  1318 
       
  1319             if ( iView.IsForeground() )
       
  1320                 {               
       
  1321                 if (iVideoClipInfo && !iFrameReady)
       
  1322                     {                               
       
  1323                     iVideoClipInfo->CancelFrame();
       
  1324                     }                           
       
  1325                 if ( iPlayOrPlayMarked )
       
  1326                     {
       
  1327                     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::EOpenComplete 2");                  
       
  1328                     iVideoDisplay->PlayMarkedL( cutInTime, cutOutTime );
       
  1329                     }
       
  1330                 else
       
  1331                     {
       
  1332                     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::EOpenComplete 3");  
       
  1333                     iVideoDisplay->Play();
       
  1334                     }
       
  1335                 iPlayOrPlayMarked = EFalse;             
       
  1336                 }
       
  1337             else
       
  1338                 {
       
  1339                 LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent() MVeiVideoDisplayObserver::EOpenComplete 4");                 
       
  1340                 PauseL();                   
       
  1341                 }   
       
  1342             break;
       
  1343             }
       
  1344         case MVeiVideoDisplayObserver::EBufferingStarted:
       
  1345             {
       
  1346             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent() MVeiVideoDisplayObserver::EBufferingStarted");           
       
  1347             SetStateL( EStateBuffering );
       
  1348             if ( iVideoBarTimer )
       
  1349                 {
       
  1350                 iVideoBarTimer->Cancel();
       
  1351                 }
       
  1352             break;
       
  1353             }   
       
  1354         case MVeiVideoDisplayObserver::ELoadingComplete:
       
  1355             {           
       
  1356             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::ELoadingComplete 1");
       
  1357             // if VED is put to background in the middle of the buffering
       
  1358             // iVideoDisplay->PauseL(); cannot be called during the buffering, so its called here
       
  1359             if (EStatePaused == iState)
       
  1360                 {
       
  1361                 iVideoDisplay->PauseL();    
       
  1362                 }
       
  1363             else
       
  1364                 {                           
       
  1365                 SetStateL( EStatePlaying );                     
       
  1366                 if (iVideoClipInfo && !iFrameReady)
       
  1367                     {                               
       
  1368                     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::ELoadingComplete 2");
       
  1369                     iVideoClipInfo->CancelFrame();
       
  1370                     }
       
  1371                 if ( !iVideoBarTimer->IsActive() )
       
  1372                     {
       
  1373                     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::ELoadingComplete 3");               
       
  1374                     const TUint delay = 100000;
       
  1375                     iVideoBarTimer->Start( delay, delay, TCallBack( CVeiCutVideoContainer::DoAudioBarUpdate, this ) );
       
  1376                     }
       
  1377                 iVideoDisplay->ShowBlackScreen();           
       
  1378                 DrawDeferred();
       
  1379                 }
       
  1380             break;
       
  1381             }
       
  1382         case MVeiVideoDisplayObserver::EPlayComplete:
       
  1383             {
       
  1384             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::EPlayComplete");
       
  1385             iVideoDisplay->SetBlackScreen( EFalse );            
       
  1386             iSeekPos = TTimeIntervalMicroSeconds( 0 );
       
  1387 
       
  1388             iLastPosition = TotalLength();
       
  1389             iView.StopNaviPaneUpdateL();
       
  1390             iCutVideoBar->SetFinishedStatus( ETrue );
       
  1391             
       
  1392             if (iVideoBarTimer)
       
  1393                 {
       
  1394                 iVideoBarTimer->Cancel();   
       
  1395                 }           
       
  1396 
       
  1397             GetThumbAtL(0);
       
  1398 
       
  1399             SetStateL( EStateStopped );
       
  1400             
       
  1401             if (KErrNoMemory == aInfo || KErrSessionClosed == aInfo)
       
  1402                 {
       
  1403                 iErrorUI.ShowGlobalErrorNote( aInfo );                  
       
  1404                 StopL();
       
  1405                 CloseStreamL();
       
  1406                 }
       
  1407 
       
  1408             DrawDeferred();
       
  1409             break;
       
  1410             }
       
  1411         case MVeiVideoDisplayObserver::EStop:
       
  1412             {
       
  1413             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent() MVeiVideoDisplayObserver::EStop");
       
  1414             
       
  1415             if (EStateGettingFrame == iState)
       
  1416                 {
       
  1417                 break;  
       
  1418                 }              
       
  1419             
       
  1420             if ( iVideoBarTimer )
       
  1421                 {                
       
  1422                 iVideoBarTimer->Cancel();
       
  1423                 }
       
  1424             iSeekPos = TTimeIntervalMicroSeconds( 0 );
       
  1425 
       
  1426             GetThumbAtL(0);
       
  1427             iLastPosition = TotalLength();
       
  1428             iView.StopNaviPaneUpdateL();
       
  1429             iCutVideoBar->SetFinishedStatus( ETrue );
       
  1430         
       
  1431             SetStateL( EStateStopped );
       
  1432             DrawDeferred();
       
  1433             break;
       
  1434             }                                                               
       
  1435         case MVeiVideoDisplayObserver::EVolumeLevelChanged:
       
  1436             {
       
  1437             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::EVolumeLevelChanged");
       
  1438             TInt playerVolume = iVideoDisplay->Volume();
       
  1439             iView.ShowVolumeLabelL( playerVolume );
       
  1440             break;
       
  1441             }
       
  1442         case MVeiVideoDisplayObserver::EError:
       
  1443             {
       
  1444             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent() MVeiVideoDisplayObserver::EError");
       
  1445 //          iErrorUI.ShowGlobalErrorNoteL( KErrGeneral );
       
  1446             SetStateL( EStateStoppedInitial );
       
  1447             break;
       
  1448             }
       
  1449         default:
       
  1450             {
       
  1451             LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, MVeiVideoDisplayObserver::default");
       
  1452             break;
       
  1453             };
       
  1454         }
       
  1455     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::NotifyVideoDisplayEvent, Out");
       
  1456     }
       
  1457 
       
  1458 
       
  1459 void CVeiCutVideoContainer::SetStateL(CVeiCutVideoContainer::TCutVideoState aState, TBool aUpdateCBA)
       
  1460     {
       
  1461     LOGFMT2(KVideoEditorLogFile, "CVeiCutVideoContainer::SetStateL: in, iState:%d, aState:%d", iState, aState);
       
  1462     if (EStateGettingFrame == aState)
       
  1463         {
       
  1464         iPreviousState = iState;    
       
  1465         }
       
  1466         
       
  1467     iState = aState;
       
  1468     if (EStatePaused == iState)
       
  1469         {
       
  1470         DrawNow();  
       
  1471         }
       
  1472 
       
  1473     // If the foreground is lost while an arrow key is down, we do not get
       
  1474     // the key up -event, and iSeeking remains true. Reseting it here just in case.
       
  1475     iSeeking = EFalse;
       
  1476 
       
  1477     if ( aUpdateCBA )
       
  1478         {
       
  1479         iView.UpdateCBAL( iState );
       
  1480         }
       
  1481 
       
  1482     // While playing, grab the volume keys for adjusting playback volume.
       
  1483     // In other states let them pass e.g. to the music player.
       
  1484     if(EStatePlaying == iState)
       
  1485         {
       
  1486         if (!iRemConTarget)
       
  1487             {
       
  1488             iRemConTarget = CVeiRemConTarget::NewL( *this );
       
  1489             }
       
  1490         }
       
  1491     else
       
  1492         {
       
  1493         delete iRemConTarget;
       
  1494         iRemConTarget = NULL;
       
  1495         }
       
  1496 
       
  1497     if (EStateGettingFrame == aState)
       
  1498         {   
       
  1499         /* :
       
  1500          check out on every phone before releasing whether videodisplay should be stopped before starting
       
  1501          asynchronous GetFrameL()
       
  1502          see how EStateGettingFrame is handled in SetPreviewState 
       
  1503          Stopping frees memory and it is needed in memory sensible devices 
       
  1504         */
       
  1505         //iVideoDisplay->Stop(ETrue);           
       
  1506         }
       
  1507 
       
  1508     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::SetStateL:: out");
       
  1509     }
       
  1510 
       
  1511 void CVeiCutVideoContainer::MarkedInL()
       
  1512     {
       
  1513     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedInL, In");
       
  1514     if ( EStateInitializing == iState )
       
  1515         {
       
  1516         return;
       
  1517         }
       
  1518     const TTimeIntervalMicroSeconds& position = PlaybackPositionL();
       
  1519     iSeekPos = position;
       
  1520 
       
  1521     LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedInL, 2, setting cutINpoint:%Ld", position.Int64());
       
  1522     iCutVideoBar->SetInPoint( position  );
       
  1523     iCutTimeDisplay->SetCutIn( position );
       
  1524     PauseL();
       
  1525     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedInL, Out");
       
  1526     }
       
  1527 
       
  1528 void CVeiCutVideoContainer::MarkedOutL()
       
  1529     {
       
  1530     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedOutL, In");
       
  1531     if ( EStateInitializing == iState )
       
  1532         {
       
  1533         return;
       
  1534         }
       
  1535     const TTimeIntervalMicroSeconds& position = PlaybackPositionL();
       
  1536     iSeekPos = position;
       
  1537 
       
  1538     LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedOutL, 2, setting cutOUTpoint:%Ld", position.Int64());
       
  1539     iCutVideoBar->SetOutPoint( position );
       
  1540     iCutTimeDisplay->SetCutOut( position );
       
  1541 
       
  1542     PauseL();
       
  1543     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::MarkedOutL, Out");
       
  1544     }
       
  1545 
       
  1546 void CVeiCutVideoContainer::ShowInformationNoteL( const TDesC& aMessage ) const
       
  1547     {
       
  1548     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
  1549     note->ExecuteLD( aMessage );
       
  1550     }
       
  1551 
       
  1552 void CVeiCutVideoContainer::ShowProgressNoteL() 
       
  1553     {
       
  1554     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::ShowProgressNoteL, in");
       
  1555     iProgressDialog = new ( ELeave ) CAknProgressDialog( REINTERPRET_CAST( CEikDialog**, 
       
  1556                     &iProgressDialog ), ETrue);
       
  1557     iProgressDialog->SetCallback( this );
       
  1558     iProgressDialog->PrepareLC( R_VEI_PROGRESS_NOTE_WITH_CANCEL );
       
  1559 
       
  1560     HBufC* stringholder  = StringLoader::LoadL( R_VEI_PROGRESS_NOTE_SAVING_IMAGE, iEikonEnv );
       
  1561     CleanupStack::PushL( stringholder );
       
  1562 
       
  1563     iProgressDialog->SetTextL( *stringholder );
       
  1564     CleanupStack::PopAndDestroy( stringholder );
       
  1565 
       
  1566     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
  1567     iProgressInfo->SetFinalValue( KProgressbarFinalValue );
       
  1568     iProgressDialog->RunLD();
       
  1569 
       
  1570     iProgressInfo->SetAndDraw( 50 );
       
  1571     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::ShowProgressNoteL, Out");
       
  1572     }
       
  1573 
       
  1574 TInt CVeiCutVideoContainer::DoAudioBarUpdate( TAny* aThis )
       
  1575     {
       
  1576     STATIC_CAST( CVeiCutVideoContainer*, aThis )->DoUpdate();
       
  1577     return 42;
       
  1578     }
       
  1579 
       
  1580 void CVeiCutVideoContainer::DoUpdate()
       
  1581     {
       
  1582     TTimeIntervalMicroSeconds time;
       
  1583     time = iVideoDisplay->PositionL();
       
  1584     if ( iSeeking )
       
  1585         {
       
  1586         time = iSeekPos;
       
  1587         LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::DoUpdate(): 1, time:%Ld", time.Int64());
       
  1588         }
       
  1589     else
       
  1590         {           
       
  1591         LOGFMT(KVideoEditorLogFile, "CVeiCutVideoContainer::DoUpdate(): 2, time:%Ld", time.Int64());
       
  1592         }
       
  1593     iCutVideoBar->SetCurrentPoint( static_cast<TInt32>((time.Int64() / 1000)));
       
  1594     iCutVideoBar->DrawDeferred();
       
  1595     }
       
  1596 void CVeiCutVideoContainer::MuteL()
       
  1597     {
       
  1598     iVideoDisplay->SetMuteL( ETrue );
       
  1599     }
       
  1600 
       
  1601 //=============================================================================
       
  1602 void CVeiCutVideoContainer::HandleVolumeUpL()
       
  1603     {
       
  1604     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::HandleVolumeUpL: in");
       
  1605 
       
  1606     iVideoDisplay->AdjustVolumeL( 1 );
       
  1607 
       
  1608     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::HandleVolumeUpL: out");
       
  1609     }
       
  1610 
       
  1611 //=============================================================================
       
  1612 void CVeiCutVideoContainer::HandleVolumeDownL()
       
  1613     {
       
  1614     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::HandleVolumeDownL: in");
       
  1615 
       
  1616     iVideoDisplay->AdjustVolumeL( -1 );
       
  1617 
       
  1618     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::HandleVolumeDownL: out");
       
  1619     }
       
  1620 
       
  1621 //=============================================================================
       
  1622 void CVeiCutVideoContainer::PrepareForTerminationL()
       
  1623     {
       
  1624     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PrepareForTerminationL: in");
       
  1625 
       
  1626     SetStateL( EStateTerminating );
       
  1627 
       
  1628     if( !iFrameReady && iVideoClipInfo )
       
  1629         {
       
  1630         iVideoClipInfo->CancelFrame();
       
  1631         }
       
  1632     iState = EStateTerminating;
       
  1633     iVideoDisplay->Stop( ETrue );
       
  1634 
       
  1635     LOG(KVideoEditorLogFile, "CVeiCutVideoContainer::PrepareForTerminationL: out");
       
  1636     }
       
  1637 
       
  1638 
       
  1639 TInt CVeiCutVideoContainer::AsyncTakeSnapshot(TAny* aThis)
       
  1640     {
       
  1641     LOG( KVideoEditorLogFile, "CVeiCutVideoContainer::AsyncTakeSnapshot");
       
  1642     
       
  1643     // In the asynchronous version, trap the rest of the functions 
       
  1644     // to make sure that the caller's TRequestStatus is always 
       
  1645     // completed, also in case of failures.
       
  1646     CVeiCutVideoContainer* container = static_cast<CVeiCutVideoContainer*>(aThis);
       
  1647     TInt err = KErrNone;
       
  1648     TRAP(err, container->TakeSnapshotL());
       
  1649     LOGFMT( KVideoEditorLogFile, "CVeiCutVideoContainer::AsyncTakeSnapshot 1, err:%d", err);    
       
  1650     User::LeaveIfError(err);        
       
  1651     return KErrNone;                
       
  1652     }
       
  1653 // End of File