engine/collectionframework/thumbnailcreator/src/glxtnvideoutility.cpp
changeset 71 27f2d7aec52a
parent 69 45459746d5e8
child 72 0a8e959402e5
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
     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 
       
    20 /**
       
    21  * @internal reviewed 31/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #include "glxtnvideoutility.h"
       
    25 
       
    26 #include <fbs.h>
       
    27 #include <glxtracer.h>
       
    28 #include <glxpanic.h>
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // Constructor
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CGlxtnVideoUtility::CGlxtnVideoUtility() : iDestination(NULL)
       
    35     {
       
    36     TRACER("CGlxtnVideoUtility::CGlxtnVideoUtility()");
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // Destructor
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CGlxtnVideoUtility::~CGlxtnVideoUtility()
       
    44     {
       
    45     TRACER("CGlxtnVideoUtility::~CGlxtnVideoUtility()");
       
    46     delete iVideoInfo;
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // GetVideoFrameL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CGlxtnVideoUtility::GetVideoFrameL(TRequestStatus* aRequestStatus,
       
    54                             CFbsBitmap*& aDestination, const TDesC& aFileName,
       
    55                                 RArray<TSize>& aTargetSizes, TDisplayMode aMode)
       
    56     {
       
    57     TRACER("void CGlxtnVideoUtility::GetVideoFrameL(TRequestStatus* aRequestStatus, CFbsBitmap*& aDestination, const TDesC& aFileName, RArray<TSize>& aTargetSizes, TDisplayMode aMode)");
       
    58     if ( iRequestStatus )
       
    59         {
       
    60         User::Leave(KErrNotReady);
       
    61         }
       
    62         
       
    63     iDisplayMode = aMode;
       
    64     iSize = aTargetSizes[0];
       
    65             
       
    66     iRequestStatus = aRequestStatus;
       
    67     *iRequestStatus = KRequestPending;
       
    68 
       
    69     iDestination = &aDestination;
       
    70     delete *iDestination;
       
    71     *iDestination = NULL;
       
    72 
       
    73     delete iVideoInfo;
       
    74     iVideoInfo = NULL;
       
    75 #ifdef ENABLE_VED
       
    76     iVideoInfo = CVedVideoClipInfo::NewL(aFileName, *this);
       
    77 #else
       
    78     iVideoInfo = CTNEVideoClipInfo::NewL(aFileName, *this);
       
    79 #endif
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // Cancel
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CGlxtnVideoUtility::Cancel()
       
    87     {
       
    88     TRACER("void CGlxtnVideoUtility::Cancel()");
       
    89     if ( iVideoInfo )
       
    90         {
       
    91 #ifdef ENABLE_VED
       
    92         iVideoInfo->CancelFrame();
       
    93 #else
       
    94         iVideoInfo->CancelThumb();
       
    95 #endif
       
    96         delete iVideoInfo;
       
    97         iVideoInfo = NULL;
       
    98         }
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // NotifyVideoClipInfoReady
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 #ifdef ENABLE_VED
       
   106 void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo,
       
   107                                                         TInt aError )
       
   108 #else
       
   109 void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CTNEVideoClipInfo& aInfo,
       
   110                                                         TInt aError )
       
   111 #endif
       
   112     {
       
   113     TRACER("void CGlxtnVideoUtility::NotifyVideoClipInfoReady( CVedVideoClipInfo& aInfo, TInt aError )");
       
   114     __ASSERT_DEBUG(&aInfo == iVideoInfo, Panic(EGlxPanicIllegalArgument));
       
   115 
       
   116     //adding a check if the callback is for iVideoInfo
       
   117 	if ( KErrNone == aError && (&aInfo == iVideoInfo))
       
   118         {
       
   119 #ifdef ENABLE_VED
       
   120         TRAP(aError, iVideoInfo->GetFrameL(*this, KFrameIndexBestThumb,
       
   121                                             NULL /*aResolution*/, iDisplayMode));
       
   122 #else
       
   123         TRAP(aError, iVideoInfo->GetThumbL(*this, KBestThumbIndex,
       
   124                                             &iSize, iDisplayMode));
       
   125 #endif
       
   126         }
       
   127 
       
   128     if ( KErrNone != aError )
       
   129         {
       
   130         User::RequestComplete(iRequestStatus, aError);
       
   131         }
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // NotifyVideoClipFrameCompleted
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 #ifdef ENABLE_VED
       
   139 void CGlxtnVideoUtility::NotifyVideoClipFrameCompleted(
       
   140                     CVedVideoClipInfo& /*aInfo*/, TInt aError, CFbsBitmap* aFrame )
       
   141 #else
       
   142 void CGlxtnVideoUtility::NotifyVideoClipThumbCompleted(
       
   143                     CTNEVideoClipInfo& /*aInfo*/, TInt aError, CFbsBitmap* aFrame )
       
   144 #endif
       
   145     {
       
   146     TRACER("void CGlxtnVideoUtility::NotifyVideoClipFrameCompleted( CVedVideoClipInfo& aInfo, TInt aError, CFbsBitmap* aFrame )");
       
   147 	//removing as this is not used anymore
       
   148    // __ASSERT_DEBUG(&aInfo == iVideoInfo, Panic(EGlxPanicIllegalArgument));
       
   149     *iDestination = aFrame;
       
   150 
       
   151     User::RequestComplete(iRequestStatus, aError);
       
   152     }