photosgallery/collectionframework/thumbnailcreator/src/glxtnvideoutility.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:    Utility for creating bitmaps from video files
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  * @internal reviewed 31/07/2007 by Simon Brooks
       
    20  */
       
    21 
       
    22 #include "glxtnvideoutility.h"
       
    23 
       
    24 #include <fbs.h>
       
    25 #include <glxtracer.h>
       
    26 #include <glxpanic.h>
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CGlxtnVideoUtility::CGlxtnVideoUtility() : iDestination(NULL)
       
    33     {
       
    34     TRACER("CGlxtnVideoUtility::CGlxtnVideoUtility()");
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // Destructor
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CGlxtnVideoUtility::~CGlxtnVideoUtility()
       
    42     {
       
    43     TRACER("CGlxtnVideoUtility::~CGlxtnVideoUtility()");
       
    44     delete iVideoInfo;
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // GetVideoFrameL
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CGlxtnVideoUtility::GetVideoFrameL(TRequestStatus* aRequestStatus,
       
    52                             CFbsBitmap*& aDestination, const TDesC& aFileName,
       
    53                                 RArray<TSize>& aTargetSizes, TDisplayMode aMode)
       
    54     {
       
    55     TRACER("void CGlxtnVideoUtility::GetVideoFrameL(TRequestStatus* aRequestStatus, CFbsBitmap*& aDestination, const TDesC& aFileName, RArray<TSize>& aTargetSizes, TDisplayMode aMode)");
       
    56     if ( iRequestStatus )
       
    57         {
       
    58         User::Leave(KErrNotReady);
       
    59         }
       
    60         
       
    61     iDisplayMode = aMode;
       
    62     iSize = aTargetSizes[0];
       
    63             
       
    64     iRequestStatus = aRequestStatus;
       
    65     *iRequestStatus = KRequestPending;
       
    66 
       
    67     iDestination = &aDestination;
       
    68     delete *iDestination;
       
    69     *iDestination = NULL;
       
    70 
       
    71     delete iVideoInfo;
       
    72     iVideoInfo = NULL;
       
    73 #ifdef ENABLE_VED
       
    74     iVideoInfo = CVedVideoClipInfo::NewL(aFileName, *this);
       
    75 #else
       
    76     iVideoInfo = CTNEVideoClipInfo::NewL(aFileName, *this);
       
    77 #endif
       
    78     }
       
    79 
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // Cancel
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CGlxtnVideoUtility::Cancel()
       
    86     {
       
    87     TRACER("void CGlxtnVideoUtility::Cancel()");
       
    88     if ( iVideoInfo )
       
    89         {
       
    90 #ifdef ENABLE_VED
       
    91         iVideoInfo->CancelFrame();
       
    92 #else
       
    93         iVideoInfo->CancelThumb();
       
    94 #endif
       
    95         delete iVideoInfo;
       
    96         iVideoInfo = NULL;
       
    97 
       
    98 	    if (iRequestStatus)
       
    99 	    	{
       
   100 	    	User::RequestComplete(iRequestStatus, KErrCancel);
       
   101 	    	}
       
   102         }
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // NotifyVideoClipInfoReady
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 #ifdef ENABLE_VED
       
   110 void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo,
       
   111                                                         TInt aError )
       
   112 #else
       
   113 void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CTNEVideoClipInfo& aInfo,
       
   114                                                         TInt aError )
       
   115 #endif
       
   116     {
       
   117     TRACER("void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo, TInt aError )");
       
   118     __ASSERT_DEBUG(&aInfo == iVideoInfo, Panic(EGlxPanicIllegalArgument));
       
   119     
       
   120 
       
   121     
       
   122     if ( KErrNone == aError )
       
   123         {
       
   124 #ifdef ENABLE_VED
       
   125         TRAP(aError, iVideoInfo->GetFrameL(*this, KFrameIndexBestThumb,
       
   126                                             NULL /*aResolution*/, iDisplayMode));
       
   127 #else
       
   128         TRAP(aError, iVideoInfo->GetThumbL(*this, KBestThumbIndex,
       
   129                                             NULL/*&iSize*/, iDisplayMode));
       
   130 #endif
       
   131         }
       
   132 
       
   133     if ( KErrNone != aError )
       
   134         {
       
   135         User::RequestComplete(iRequestStatus, aError);
       
   136         }
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // NotifyVideoClipFrameCompleted
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 #ifdef ENABLE_VED
       
   144 void CGlxtnVideoUtility::NotifyVideoClipFrameCompleted(
       
   145                     CVedVideoClipInfo& aInfo, TInt aError, CFbsBitmap* aFrame )
       
   146 #else
       
   147 void CGlxtnVideoUtility::NotifyVideoClipThumbCompleted(
       
   148                     CTNEVideoClipInfo& aInfo, TInt aError, CFbsBitmap* aFrame )
       
   149 #endif
       
   150     {
       
   151     TRACER("void CGlxtnVideoUtility::NotifyVideoClipFrameCompleted( CVedVideoClipInfo& aInfo, TInt aError, CFbsBitmap* aFrame )");
       
   152     __ASSERT_DEBUG(&aInfo == iVideoInfo, Panic(EGlxPanicIllegalArgument));
       
   153     *iDestination = aFrame;
       
   154 
       
   155     User::RequestComplete(iRequestStatus, aError);
       
   156     }