messagingappbase/msgmedia/src/MsgVideoInfo.cpp
changeset 23 238255e8b033
child 37 518b245aa84c
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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     CCoeEnv* env = CCoeEnv::Static();
       
   126     if ( !env )
       
   127         {
       
   128         User::Leave( KErrNotSupported );
       
   129         }
       
   130 
       
   131     CHXMetaDataUtility* dataUtil = CHXMetaDataUtility::NewL();
       
   132     
       
   133     CleanupStack::PushL( dataUtil );
       
   134 
       
   135     dataUtil->OpenFileL( aFile );
       
   136 
       
   137     ReadInformationL( *dataUtil );
       
   138     
       
   139     CleanupStack::PopAndDestroy( dataUtil );
       
   140     
       
   141     iState = EVideoStateReady;
       
   142     iParsed = ETrue;
       
   143     
       
   144     CompleteSelf( KErrNone );
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CMsgVideoInfo::CMsgVideoInfo
       
   149 // -----------------------------------------------------------------------------
       
   150 CMsgVideoInfo::CMsgVideoInfo(  TDataType& aMimeType ):
       
   151     CMsgMediaInfo( aMimeType, EMsgMediaVideo ),
       
   152     iBitRate( 0 ),
       
   153     iAudioBitRate( 0 ),
       
   154     iOverallSizeInPixels( 0, 0 ),
       
   155     iFramesPerSecond( 0 )
       
   156     {
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CMsgVideoInfo::Duration
       
   161 // -----------------------------------------------------------------------------
       
   162 CMsgVideoInfo::~CMsgVideoInfo()
       
   163     {
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CMsgVideoInfo::ReadInformationL
       
   168 // -----------------------------------------------------------------------------
       
   169 void CMsgVideoInfo::ReadInformationL( CHXMetaDataUtility& dataUtil )
       
   170     {
       
   171     TUint count = 0;
       
   172     dataUtil.GetMetaDataCount( count );
       
   173     HXMetaDataKeys::EHXMetaDataId id;
       
   174     HBufC* des = NULL;       
       
   175     for( TInt i = 0; i<count; i++ )
       
   176         {
       
   177         dataUtil.GetMetaDataAt( i, id, des );
       
   178         // don’t delete des - it is not owned by the client
       
   179         switch ( id )
       
   180             {
       
   181             case HXMetaDataKeys::EHXDuration:
       
   182                 {
       
   183                 TLex input ( des->Des() );
       
   184                 input.Val( iDuration );
       
   185                 break;
       
   186                 }
       
   187             case HXMetaDataKeys::EHXClipBitRate:
       
   188             case HXMetaDataKeys::EHXVideoBitRate:
       
   189                 {
       
   190                 TLex input ( des->Des() );
       
   191                 input.Val( iBitRate );
       
   192                 break;
       
   193                 }
       
   194             case HXMetaDataKeys::EHXFrameSize:
       
   195                 {
       
   196                 const TChar separator = 'x';// as in e.g."177x144"
       
   197                 TInt separatorLocation = des->Locate( separator );
       
   198                 TLex input (des->Left( separatorLocation ));
       
   199 
       
   200                 input.Val( iOverallSizeInPixels.iWidth );
       
   201                 input = des->Right(des->Length() - separatorLocation - 1);
       
   202                 input.Val( iOverallSizeInPixels.iHeight );
       
   203                 break;
       
   204                 }
       
   205             case HXMetaDataKeys::EHXFramesPerSecond:
       
   206                 {
       
   207                 TLex input ( des->Des() );
       
   208                 input.Val( iFramesPerSecond );
       
   209                 break;
       
   210                 }
       
   211             case HXMetaDataKeys::EHXAudioBitRate:
       
   212                 {
       
   213                 TLex input ( des->Des() );
       
   214                 input.Val( iAudioBitRate );
       
   215                 break;
       
   216                 }
       
   217             default:
       
   218                 break;
       
   219             }
       
   220         }
       
   221     }
       
   222 
       
   223 
       
   224 //  End of File