messagingappbase/msgmedia/src/MsgVideoInfo.cpp
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     1 /*
       
     2 * Copyright (c) 2005 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: MsgVideoInfo implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <videoplayer.h>
       
    23 #include <eikenv.h>
       
    24 
       
    25 #include <hxmetadatakeys.h>
       
    26 #include <hxmetadatautil.h>
       
    27 
       
    28 #include "MsgVideoInfo.h"
       
    29 #include "MsgMediaInfo.h"
       
    30 #include "MsgMedia.hrh"
       
    31 #include "MsgMimeTypes.h"
       
    32 
       
    33 #ifdef __MSGMEDIA_DEBUG
       
    34 #include "MsgMediaLogging.h"
       
    35 #endif
       
    36 
       
    37 // EXTERNAL DATA STRUCTURES
       
    38 
       
    39 // EXTERNAL FUNCTION PROTOTYPES  
       
    40 
       
    41 // CONSTANTS
       
    42 
       
    43 // MACROS
       
    44 
       
    45 // LOCAL CONSTANTS AND MACROS
       
    46 
       
    47 // MODULE DATA STRUCTURES
       
    48 
       
    49 // LOCAL FUNCTION PROTOTYPES
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 
       
    53 // ============================ MEMBER FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CMsgVideoInfo::NewL
       
    57 // -----------------------------------------------------------------------------
       
    58 EXPORT_C CMsgVideoInfo * CMsgVideoInfo::NewL( RFile& aFile, 
       
    59                                              TDataType& aMimeType )
       
    60     {
       
    61     CMsgVideoInfo* self = new ( ELeave ) CMsgVideoInfo( aMimeType );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL( aFile );
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------
       
    69 // CMsgVideoInfo::ConstructL
       
    70 //
       
    71 // 2nd phase constructor.
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 void CMsgVideoInfo::ConstructL( RFile& aFile )
       
    75     {
       
    76     CMsgMediaInfo::ConstructL( aFile );
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CMsgVideoInfo::DoCancel
       
    81 // 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CMsgVideoInfo::DoCancel()
       
    85     {
       
    86     CMsgMediaInfo::DoCancel();
       
    87     iState = EVideoStateIdle;
       
    88     }
       
    89         
       
    90 // -----------------------------------------------------------------------------
       
    91 // CMsgVideoInfo::RunL
       
    92 // 
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CMsgVideoInfo::RunL()
       
    96     {
       
    97     iParseError = iStatus.Int();
       
    98     if ( iParseError )
       
    99         {
       
   100         iState = EVideoStateReady;
       
   101         }
       
   102     switch ( iState )
       
   103         {
       
   104         case EVideoStateIdle:
       
   105             {
       
   106             FreezeRights();
       
   107             ResolveVideoInfoL( iFile );
       
   108             break;
       
   109             }
       
   110         case EVideoStateReady:
       
   111         default:
       
   112             {
       
   113             CompleteObserver();
       
   114             iState = EVideoStateIdle;
       
   115             break;
       
   116             }
       
   117         }
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMsgVideoInfo::ResolveVideoInfoL
       
   122 // -----------------------------------------------------------------------------
       
   123 void CMsgVideoInfo::ResolveVideoInfoL( RFile& aFile )
       
   124     {
       
   125 
       
   126     CHXMetaDataUtility* dataUtil = CHXMetaDataUtility::NewL();
       
   127     
       
   128     CleanupStack::PushL( dataUtil );
       
   129 
       
   130     dataUtil->OpenFileL( aFile );
       
   131 
       
   132     ReadInformationL( *dataUtil );
       
   133     
       
   134     CleanupStack::PopAndDestroy( dataUtil );
       
   135     
       
   136     iState = EVideoStateReady;
       
   137     iParsed = ETrue;
       
   138     
       
   139     CompleteSelf( KErrNone );
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CMsgVideoInfo::CMsgVideoInfo
       
   144 // -----------------------------------------------------------------------------
       
   145 CMsgVideoInfo::CMsgVideoInfo(  TDataType& aMimeType ):
       
   146     CMsgMediaInfo( aMimeType, EMsgMediaVideo ),
       
   147     iBitRate( 0 ),
       
   148     iAudioBitRate( 0 ),
       
   149     iOverallSizeInPixels( 0, 0 ),
       
   150     iFramesPerSecond( 0 )
       
   151     {
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CMsgVideoInfo::Duration
       
   156 // -----------------------------------------------------------------------------
       
   157 CMsgVideoInfo::~CMsgVideoInfo()
       
   158     {
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CMsgVideoInfo::ReadInformationL
       
   163 // -----------------------------------------------------------------------------
       
   164 void CMsgVideoInfo::ReadInformationL( CHXMetaDataUtility& dataUtil )
       
   165     {
       
   166     TUint count = 0;
       
   167     dataUtil.GetMetaDataCount( count );
       
   168     HXMetaDataKeys::EHXMetaDataId id;
       
   169     HBufC* des = NULL;       
       
   170     for( TInt i = 0; i<count; i++ )
       
   171         {
       
   172         dataUtil.GetMetaDataAt( i, id, des );
       
   173         // don’t delete des - it is not owned by the client
       
   174         switch ( id )
       
   175             {
       
   176             case HXMetaDataKeys::EHXDuration:
       
   177                 {
       
   178                 TLex input ( des->Des() );
       
   179                 input.Val( iDuration );
       
   180                 break;
       
   181                 }
       
   182             case HXMetaDataKeys::EHXClipBitRate:
       
   183             case HXMetaDataKeys::EHXVideoBitRate:
       
   184                 {
       
   185                 TLex input ( des->Des() );
       
   186                 input.Val( iBitRate );
       
   187                 break;
       
   188                 }
       
   189             case HXMetaDataKeys::EHXFrameSize:
       
   190                 {
       
   191                 const TChar separator = 'x';// as in e.g."177x144"
       
   192                 TInt separatorLocation = des->Locate( separator );
       
   193                 TLex input (des->Left( separatorLocation ));
       
   194 
       
   195                 input.Val( iOverallSizeInPixels.iWidth );
       
   196                 input = des->Right(des->Length() - separatorLocation - 1);
       
   197                 input.Val( iOverallSizeInPixels.iHeight );
       
   198                 break;
       
   199                 }
       
   200             case HXMetaDataKeys::EHXFramesPerSecond:
       
   201                 {
       
   202                 TLex input ( des->Des() );
       
   203                 input.Val( iFramesPerSecond );
       
   204                 break;
       
   205                 }
       
   206             case HXMetaDataKeys::EHXAudioBitRate:
       
   207                 {
       
   208                 TLex input ( des->Des() );
       
   209                 input.Val( iAudioBitRate );
       
   210                 break;
       
   211                 }
       
   212             default:
       
   213                 break;
       
   214             }
       
   215         }
       
   216     }
       
   217 
       
   218 
       
   219 //  End of File