mmappcomponents/harvester/metadataextractor/src/mpxmetadataextractor.cpp
branchRCL_3
changeset 67 16db3449d7ba
parent 59 666f9a5a90a9
equal deleted inserted replaced
63:91d5ad76f5c6 67:16db3449d7ba
    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.17 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.14 % << 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>
   252     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   252     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   253                               KNullDesC );
   253                               KNullDesC );
   254     // URL
   254     // URL
   255     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   255     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   256                               KNullDesC );
   256                               KNullDesC );
   257     // AlbumArtist
       
   258     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtist,
       
   259                               KNullDesC );
       
   260     
       
   261     }
   257     }
   262 
   258 
   263 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   264 // Sets media object attributes from metadata utilities
   260 // Sets media object attributes from metadata utilities
   265 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   434                 
   430                 
   435                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);  
   431                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);  
   436                     }
   432                     }
   437                 break;
   433                 break;
   438                 }
   434                 }
   439             case EMetaDataSampleRate:     
       
   440                 {                  
       
   441                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
       
   442                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
       
   443                 
       
   444                 // Verify if WMA, get the sample rate
       
   445                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
       
   446                     {
       
   447                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
       
   448 
       
   449                     // Perform the sample rate conversion
       
   450                     TLex lexer( *value );
       
   451                     TInt32 sampleRate ( 0 );
       
   452                     lexer.Val( sampleRate );         
       
   453                     
       
   454                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
       
   455                                                       sampleRate );
       
   456                            
       
   457                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate);  
       
   458                     }
       
   459                 break;
       
   460                 }
       
   461             case EMetaDataBitRate:     
       
   462                 {                  
       
   463                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
       
   464                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
       
   465                 
       
   466                 // Verify if WMA, get the duration
       
   467                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
       
   468                     {
       
   469                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
       
   470 
       
   471                     // Perform the duration conversion
       
   472                     TLex lexer( *value );
       
   473                     TInt32 bitRate ( 0 );
       
   474                     lexer.Val( bitRate );   
       
   475                 
       
   476                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
       
   477                                                      bitRate );
       
   478                 
       
   479                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);  
       
   480                     }
       
   481                 break;
       
   482                 }
       
   483             case EMetaDataAlbumArtist:
       
   484                 {
       
   485                 TPtr valptr = value->Des();
       
   486                 valptr.Trim();
       
   487                 TInt vallen = value->Length();
       
   488                 if (vallen>0)
       
   489                     {
       
   490                     FindAndReplaceForbiddenChars(valptr, vallen);
       
   491                     iMedia->SetTextValueL(KMPXMediaMusicAlbumArtist, *value);
       
   492                     }
       
   493                 break;
       
   494                 }
       
   495             case EMetaDataOriginalArtist:  // fall through
   435             case EMetaDataOriginalArtist:  // fall through
   496             case EMetaDataVendor:          // fall through
   436             case EMetaDataVendor:          // fall through
   497             case EMetaDataRating:          // fall through
   437             case EMetaDataRating:          // fall through
   498             case EMetaDataUniqueFileIdentifier:  // fall through
   438             case EMetaDataUniqueFileIdentifier:  // fall through
   499             case EMetaDataDate:            // fall through
   439             case EMetaDataDate:            // fall through
   940         }
   880         }
   941     else // other case use apparc to fetch and set mimetype
   881     else // other case use apparc to fetch and set mimetype
   942         {
   882         {
   943         TDataType dataType;
   883         TDataType dataType;
   944         TUid dummyUid(KNullUid);
   884         TUid dummyUid(KNullUid);
   945         // File handle based mime type recogniton required , because AppArc does 
   885         iAppArc.AppForDocument(iFileName, dummyUid, dataType);
   946         // not have All Files capa required for files in private folders 
       
   947         TDataRecognitionResult result;
       
   948         RFs fs;
       
   949 		RFile rFile;
       
   950         User::LeaveIfError(fs.Connect());
       
   951 		CleanupClosePushL(fs);
       
   952         User::LeaveIfError(fs.ShareProtected());
       
   953         User::LeaveIfError(rFile.Open(fs, iFileName, EFileShareReadersOrWriters));
       
   954 		CleanupClosePushL(rFile);
       
   955         User::LeaveIfError(iAppArc.RecognizeData(rFile, result)); 
       
   956         CleanupStack::PopAndDestroy(&rFile);
       
   957         CleanupStack::PopAndDestroy(&fs);
       
   958         dataType = result.iDataType;
       
   959         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   886         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   960         }
   887         }
   961         
   888         
   962     // Initially set default tags.
   889     // Initially set default tags.
   963     SetDefaultL( *iMedia );
   890     SetDefaultL( *iMedia );