mmappcomponents/harvester/metadataextractor/src/mpxmetadataextractor.cpp
changeset 61 3b098142db83
parent 57 f4fd77a452f2
equal deleted inserted replaced
57:f4fd77a452f2 61:3b098142db83
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Extracts metadata from a file
    14 * Description:  Extracts metadata from a file
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.5.3.8 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.5.3.9 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <badesca.h>
    20 #include <badesca.h>
   458             case EMetaDataBitRate:
   458             case EMetaDataBitRate:
   459                 {
   459                 {
   460                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   460                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   461                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   461                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   462 
   462 
   463                 // Verify if WMA, get the duration
   463                 // Verify if WMA, get the bit rate
   464                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   464                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   465                     {
   465                     {
   466                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   466                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   467 
   467 
   468                     // Perform the duration conversion
   468                     // Perform the bit rate conversion
   469                     TLex lexer( *value );
   469                     TLex lexer( *value );
   470                     TInt32 bitRate ( 0 );
   470                     TInt32 bitRate ( 0 );
   471                     lexer.Val( bitRate );
   471                     lexer.Val( bitRate );
   472 
   472 
   473                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   473                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   474                                                      bitRate );
   474                                                      bitRate );
   475 
   475 
   476                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);
   476                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- bit rate = %i", bitRate);
   477                     }
   477                     }
   478                 break;
   478                 break;
   479                 }
   479                 }
   480             case EMetaDataAlbumArtist:
   480             case EMetaDataAlbumArtist:
   481                 {
   481                 {
   547                           iFile,
   547                           iFile,
   548                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   548                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   549                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   549                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   550                 if( KErrNone == err2 )
   550                 if( KErrNone == err2 )
   551                     {
   551                     {
       
   552                     // Get duration prior getting sample and bit rates
       
   553                     // MMF blocks for accumulating audio data to calculate duration
       
   554 					// but MMF does not block for calculating sample rate or bit rate 
       
   555                     TInt64 duration = (TInt64) iFileInfoUtil->Duration().Int64() / 1000; // ms
       
   556                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
       
   557                                                     duration );
       
   558                                                     
   552                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   559                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   553                                                    iFileInfoUtil->BitRate() );
   560                                                    iFileInfoUtil->BitRate() );
   554                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   561                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   555                                                    iFileInfoUtil->SampleRate() );
   562                                                    iFileInfoUtil->SampleRate() );
   556                     TInt64 duration = (TInt64) iFileInfoUtil->Duration().Int64() / 1000; // ms
       
   557                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
       
   558                                                     duration );
       
   559 
   563 
   560                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   564                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   561                     }
   565                     }
   562 
   566 
   563                 iFileInfoUtil->Reset();
   567                 iFileInfoUtil->Reset();