50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" ); |
50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" ); |
51 |
51 |
52 #ifdef RD_MPX_TNM_INTEGRATION |
52 #ifdef RD_MPX_TNM_INTEGRATION |
53 _LIT( KImageFileType, "image/jpeg" ); |
53 _LIT( KImageFileType, "image/jpeg" ); |
54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds |
54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds |
55 const TInt KMPXMaxThumbnailRequest = 2; |
55 const TInt KMPXMaxThumbnailRequest = 2; |
56 #endif //RD_MPX_TNM_INTEGRATION |
56 #endif //RD_MPX_TNM_INTEGRATION |
57 |
57 |
58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
59 _LIT( KNonEmbeddedArtExt, ".alb" ); |
59 _LIT( KNonEmbeddedArtExt, ".alb" ); |
60 #endif |
60 #endif |
184 iFileOpenError = KErrNone; |
184 iFileOpenError = KErrNone; |
185 iObs = NULL; |
185 iObs = NULL; |
186 aNewProperty = NULL; |
186 aNewProperty = NULL; |
187 iFileName = aFile; |
187 iFileName = aFile; |
188 iMetadataOnly = aMetadataOnly; |
188 iMetadataOnly = aMetadataOnly; |
189 |
189 |
190 // populate the task array |
190 // populate the task array |
191 AddTasksL(); |
191 AddTasksL(); |
192 |
192 |
193 // execute all tasks in the array |
193 // execute all tasks in the array |
194 while ( iArrayTasks.Count() ) |
194 while ( iArrayTasks.Count() ) |
195 { |
195 { |
196 // execute task at index 0 |
196 // execute task at index 0 |
197 MPX_TRAPD( error, ExecuteTaskL() ); |
197 MPX_TRAPD( error, ExecuteTaskL() ); |
265 MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()"); |
262 MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()"); |
266 |
263 |
267 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
264 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
268 HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() ); |
265 HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() ); |
269 mimeType8->Des().Append( mimeType ); |
266 mimeType8->Des().Append( mimeType ); |
270 |
267 |
271 // Continue to extract metadata even if fail. |
268 // Continue to extract metadata even if fail. |
272 MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) ); |
269 MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) ); |
273 CleanupStack::PopAndDestroy( mimeType8 ); |
270 CleanupStack::PopAndDestroy( mimeType8 ); |
274 |
271 |
275 // Get MetadataUtility Container |
272 // Get MetadataUtility Container |
276 const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL(); |
273 const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL(); |
277 |
274 |
278 // Get DRM data |
275 // Get DRM data |
279 // Need the protected flag from metadataUtility Container |
276 // Need the protected flag from metadataUtility Container |
280 MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) ); |
277 MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) ); |
281 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data", |
278 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data", |
282 drmerror ); |
279 drmerror ); |
283 |
280 |
284 // Get metadata fields |
281 // Get metadata fields |
285 TInt count( metaCont.Count() ); |
282 TInt count( metaCont.Count() ); |
286 for( TInt i=0; i<count; ++i ) |
283 for( TInt i=0; i<count; ++i ) |
287 { |
284 { |
288 TMetaDataFieldId fieldType; |
285 TMetaDataFieldId fieldType; |
289 |
286 |
290 HBufC* value = NULL; |
287 HBufC* value = NULL; |
291 metaCont.FieldIdAt( i, fieldType ); // get the field type |
288 metaCont.FieldIdAt( i, fieldType ); // get the field type |
292 |
289 |
293 // get the value, except for album art |
290 // get the value, except for album art |
294 if ( fieldType != EMetaDataJpeg ) |
291 if ( fieldType != EMetaDataJpeg ) |
295 { |
292 { |
296 MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() ); |
293 MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() ); |
297 if ( KErrNone != err ) |
294 if ( KErrNone != err ) |
298 { |
295 { |
299 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err); |
296 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err); |
300 continue; |
297 continue; |
301 } |
298 } |
302 CleanupStack::PushL( value ); |
299 CleanupStack::PushL( value ); |
303 } |
300 } |
304 |
301 |
305 switch( fieldType ) |
302 switch( fieldType ) |
306 { |
303 { |
307 case EMetaDataSongTitle: |
304 case EMetaDataSongTitle: |
308 { |
305 { |
309 TPtr valptr = value->Des(); |
306 TPtr valptr = value->Des(); |
407 { |
404 { |
408 iMedia->SetTextValueL( KMPXMediaGeneralCopyright, |
405 iMedia->SetTextValueL( KMPXMediaGeneralCopyright, |
409 *value ); |
406 *value ); |
410 break; |
407 break; |
411 } |
408 } |
412 case EMetaDataDuration: |
409 case EMetaDataDuration: |
413 { |
410 { |
414 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
411 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
415 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType); |
412 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType); |
416 |
413 |
417 // Verify if WMA, get the duration |
414 // Verify if WMA, get the duration |
418 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
415 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
419 { |
416 { |
420 MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA"); |
417 MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA"); |
421 |
418 |
422 // Perform the duration conversion |
419 // Perform the duration conversion |
423 TLex lexer( *value ); |
420 TLex lexer( *value ); |
424 TInt32 duration ( 0 ); |
421 TInt32 duration ( 0 ); |
425 lexer.Val( duration ); // [second] |
422 lexer.Val( duration ); // [second] |
426 duration *= 1000; // [msec] |
423 duration *= 1000; // [msec] |
427 |
424 |
428 iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration, |
425 iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration, |
429 duration ); |
426 duration ); |
430 |
427 |
431 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration); |
428 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration); |
|
429 } |
|
430 break; |
|
431 } |
|
432 case EMetaDataSampleRate: |
|
433 { |
|
434 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
|
435 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType); |
|
436 |
|
437 // Verify if WMA, get the sample rate |
|
438 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
|
439 { |
|
440 MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA"); |
|
441 |
|
442 // Perform the sample rate conversion |
|
443 TLex lexer( *value ); |
|
444 TInt32 sampleRate ( 0 ); |
|
445 lexer.Val( sampleRate ); |
|
446 |
|
447 iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate, |
|
448 sampleRate ); |
|
449 |
|
450 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate); |
|
451 } |
|
452 break; |
|
453 } |
|
454 case EMetaDataBitRate: |
|
455 { |
|
456 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
|
457 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType); |
|
458 |
|
459 // Verify if WMA, get the duration |
|
460 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
|
461 { |
|
462 MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA"); |
|
463 |
|
464 // Perform the duration conversion |
|
465 TLex lexer( *value ); |
|
466 TInt32 bitRate ( 0 ); |
|
467 lexer.Val( bitRate ); |
|
468 |
|
469 iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate, |
|
470 bitRate ); |
|
471 |
|
472 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate); |
432 } |
473 } |
433 break; |
474 break; |
434 } |
475 } |
435 case EMetaDataOriginalArtist: // fall through |
476 case EMetaDataOriginalArtist: // fall through |
436 case EMetaDataVendor: // fall through |
477 case EMetaDataVendor: // fall through |
467 // |
508 // |
468 TInt size( 0 ); |
509 TInt size( 0 ); |
469 if( iFileOpenError == KErrNone ) |
510 if( iFileOpenError == KErrNone ) |
470 { |
511 { |
471 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
512 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType ); |
472 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType); |
513 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType); |
473 iFile.Size( size ); |
514 iFile.Size( size ); |
474 iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size ); |
515 iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size ); |
475 |
516 |
476 // Verify if WMA, skip getting info from MMF |
517 // Verify if WMA, skip getting info from MMF |
477 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
518 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 ) |
478 { |
519 { |
479 // No need to get MMF support |
520 // No need to get MMF support |
480 MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF "); |
521 MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF "); |
481 } |
522 } |
482 else |
523 else |
483 { |
524 { |
484 MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller"); |
525 MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller"); |
485 // Duration, bitrate, samplerate, etc |
526 // Duration, bitrate, samplerate, etc |
486 // |
527 // |
487 if( !iMetadataOnly ) |
528 if( !iMetadataOnly ) |
488 { |
529 { |
489 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL( |
530 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL( |
490 iFile, |
531 iFile, |
491 iMedia->ValueText(KMPXMediaGeneralMimeType))); |
532 iMedia->ValueText(KMPXMediaGeneralMimeType))); |
492 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2); |
533 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2); |
493 if( KErrNone == err2 ) |
534 if( KErrNone == err2 ) |
494 { |
535 { |
495 iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate, |
536 iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate, |
536 |
577 |
537 // --------------------------------------------------------------------------- |
578 // --------------------------------------------------------------------------- |
538 // CMPXMetadataExtractor::ThumbnailPreviewReady |
579 // CMPXMetadataExtractor::ThumbnailPreviewReady |
539 // Callback but not used here |
580 // Callback but not used here |
540 // --------------------------------------------------------------------------- |
581 // --------------------------------------------------------------------------- |
541 void CMPXMetadataExtractor::ThumbnailPreviewReady( |
582 void CMPXMetadataExtractor::ThumbnailPreviewReady( |
542 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) |
583 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) |
543 { |
584 { |
544 MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()"); |
585 MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()"); |
545 } |
586 } |
546 |
587 |
547 |
588 |
548 // --------------------------------------------------------------------------- |
589 // --------------------------------------------------------------------------- |
549 // CMPXMetadataExtractor::ThumbnailReady |
590 // CMPXMetadataExtractor::ThumbnailReady |
550 // Callback but not used here |
591 // Callback but not used here |
551 // --------------------------------------------------------------------------- |
592 // --------------------------------------------------------------------------- |
552 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/, |
593 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/, |
553 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId ) |
594 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId ) |
554 { |
595 { |
555 MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()"); |
596 MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()"); |
556 |
597 |
557 // Remove thumbnail id from array. |
598 // Remove thumbnail id from array. |
558 TInt index = iArrayTNRequestId.Find( aId ); |
599 TInt index = iArrayTNRequestId.Find( aId ); |
559 if ( index >= 0 ) |
600 if ( index >= 0 ) |
560 { |
601 { |
561 iArrayTNRequestId.Remove( index ); |
602 iArrayTNRequestId.Remove( index ); |
590 void CMPXMetadataExtractor::StopWaitLoop() |
631 void CMPXMetadataExtractor::StopWaitLoop() |
591 { |
632 { |
592 MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()"); |
633 MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()"); |
593 // Cancel timer |
634 // Cancel timer |
594 CancelTimeoutTimer(); |
635 CancelTimeoutTimer(); |
595 |
636 |
596 // Stop wait loop to unblock. |
637 // Stop wait loop to unblock. |
597 if ( iTNSyncWait->IsStarted() ) |
638 if ( iTNSyncWait->IsStarted() ) |
598 { |
639 { |
599 MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop."); |
640 MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop."); |
600 iTNSyncWait->AsyncStop(); |
641 iTNSyncWait->AsyncStop(); |
601 } |
642 } |
602 } |
643 } |
603 |
644 |
604 // ---------------------------------------------------------------------------- |
645 // ---------------------------------------------------------------------------- |
605 // Cancel timer. |
646 // Cancel timer. |
606 // ---------------------------------------------------------------------------- |
647 // ---------------------------------------------------------------------------- |
607 void CMPXMetadataExtractor::CancelTimeoutTimer() |
648 void CMPXMetadataExtractor::CancelTimeoutTimer() |
608 { |
649 { |
609 MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()"); |
650 MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()"); |
610 |
651 |
611 // Cancel timer. |
652 // Cancel timer. |
612 if ( iTimer && iTimer->IsActive() ) |
653 if ( iTimer && iTimer->IsActive() ) |
613 { |
654 { |
614 MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling"); |
655 MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling"); |
615 iTimer->Cancel(); |
656 iTimer->Cancel(); |
622 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia ) |
663 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia ) |
623 { |
664 { |
624 MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()"); |
665 MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()"); |
625 TInt err = KErrNone; |
666 TInt err = KErrNone; |
626 iCancelled = EFalse; |
667 iCancelled = EFalse; |
627 |
668 |
628 if ( !aMedia->IsSupported(KMPXMediaGeneralUri) ) |
669 if ( !aMedia->IsSupported(KMPXMediaGeneralUri) ) |
629 { |
670 { |
630 return KErrArgument; |
671 return KErrArgument; |
631 } |
672 } |
632 |
673 |
633 // Get full file name. |
674 // Get full file name. |
634 const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri); |
675 const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri); |
635 MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path ); |
676 MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path ); |
636 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
677 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
637 TParsePtrC parse( path ); |
678 TParsePtrC parse( path ); |
649 TBuf<20> mimeType(KImageFileType); |
690 TBuf<20> mimeType(KImageFileType); |
650 TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData); |
691 TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData); |
651 HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC(); // make a local copy of sampleData |
692 HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC(); // make a local copy of sampleData |
652 source = CThumbnailObjectSource::NewLC( |
693 source = CThumbnailObjectSource::NewLC( |
653 value8, mimeType, path ); // give up ownership of value8 |
694 value8, mimeType, path ); // give up ownership of value8 |
654 |
695 |
655 MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer"); |
696 MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer"); |
656 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
697 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
657 iArrayTNRequestId.Append( tnId ); |
698 iArrayTNRequestId.Append( tnId ); |
658 CleanupStack::PopAndDestroy( source ); |
699 CleanupStack::PopAndDestroy( source ); |
659 CleanupStack::Pop( value8 ); |
700 CleanupStack::Pop( value8 ); |
660 } |
701 } |
661 else |
702 else |
662 { |
703 { |
663 source = CThumbnailObjectSource::NewLC( |
704 source = CThumbnailObjectSource::NewLC( |
664 path, KImageFileType ); |
705 path, KImageFileType ); |
665 |
706 |
666 MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path"); |
707 MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path"); |
667 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
708 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
668 iArrayTNRequestId.Append( tnId ); |
709 iArrayTNRequestId.Append( tnId ); |
669 CleanupStack::PopAndDestroy( source ); |
710 CleanupStack::PopAndDestroy( source ); |
670 } |
711 } |
675 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
716 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
676 // create wanted fields array |
717 // create wanted fields array |
677 RArray<TMetaDataFieldId> wantedFields; |
718 RArray<TMetaDataFieldId> wantedFields; |
678 CleanupClosePushL( wantedFields ); |
719 CleanupClosePushL( wantedFields ); |
679 wantedFields.Append(EMetaDataJpeg); |
720 wantedFields.Append(EMetaDataJpeg); |
680 |
721 |
681 // Open file |
722 // Open file |
682 if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) ) |
723 if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) ) |
683 { |
724 { |
684 const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType ); |
725 const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType ); |
685 MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType ); |
726 MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType ); |
691 else |
732 else |
692 { |
733 { |
693 MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) ); |
734 MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) ); |
694 } |
735 } |
695 CleanupStack::PopAndDestroy( &wantedFields ); |
736 CleanupStack::PopAndDestroy( &wantedFields ); |
696 |
737 |
697 if ( !err ) |
738 if ( !err ) |
698 { |
739 { |
699 //check if can send TN request, If thumbnail creation is ongoing, wait til it is done |
740 //check if can send TN request, If thumbnail creation is ongoing, wait til it is done |
700 CheckBeforeSendRequest(); |
741 CheckBeforeSendRequest(); |
701 MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path )); |
742 MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path )); |
710 } |
751 } |
711 |
752 |
712 // ---------------------------------------------------------------------------- |
753 // ---------------------------------------------------------------------------- |
713 // Add album art to media object. |
754 // Add album art to media object. |
714 // ---------------------------------------------------------------------------- |
755 // ---------------------------------------------------------------------------- |
715 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia, |
756 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia, |
716 const TDesC& aFile ) |
757 const TDesC& aFile ) |
717 { |
758 { |
718 MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()"); |
759 MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()"); |
719 |
760 |
720 // get metadata container. |
761 // get metadata container. |
721 const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL(); |
762 const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL(); |
722 TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg ); |
763 TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg ); |
723 |
764 |
724 if ( data8.Length() ) |
765 if ( data8.Length() ) |
725 { |
766 { |
726 MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist."); |
767 MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist."); |
727 #ifdef RD_MPX_TNM_INTEGRATION |
768 #ifdef RD_MPX_TNM_INTEGRATION |
728 HBufC8* value8 = NULL; |
769 HBufC8* value8 = NULL; |
729 MPX_TRAPD( err, value8 = data8.AllocL() ); |
770 MPX_TRAPD( err, value8 = data8.AllocL() ); |
730 if ( KErrNone != err ) |
771 if ( KErrNone != err ) |
731 { |
772 { |
732 MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err); |
773 MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err); |
733 return; |
774 return; |
734 } |
775 } |
735 CleanupStack::PushL( value8 ); |
776 CleanupStack::PushL( value8 ); |
736 |
777 |
737 TBuf<256> mimeType; |
778 TBuf<256> mimeType; |
738 mimeType.Copy( KImageFileType ); |
779 mimeType.Copy( KImageFileType ); |
739 CThumbnailObjectSource* source = CThumbnailObjectSource::NewL( |
780 CThumbnailObjectSource* source = CThumbnailObjectSource::NewL( |
740 value8, mimeType, aFile ); |
781 value8, mimeType, aFile ); |
741 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
782 TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source ); |
742 iArrayTNRequestId.Append( tnId ); // add thumbnail id to array |
783 iArrayTNRequestId.Append( tnId ); // add thumbnail id to array |
743 CleanupStack::Pop( value8 ); |
784 CleanupStack::Pop( value8 ); |
744 delete source; |
785 delete source; |
745 |
786 |
746 aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile ); |
787 aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile ); |
747 #endif // RD_MPX_TNM_INTEGRATION |
788 #endif // RD_MPX_TNM_INTEGRATION |
748 aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile ); |
789 aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile ); |
749 } |
790 } |
750 } |
791 } |
751 |
792 |
752 // ---------------------------------------------------------------------------- |
793 // ---------------------------------------------------------------------------- |
883 TDataType dataType; |
924 TDataType dataType; |
884 TUid dummyUid(KNullUid); |
925 TUid dummyUid(KNullUid); |
885 iAppArc.AppForDocument(iFileName, dummyUid, dataType); |
926 iAppArc.AppForDocument(iFileName, dummyUid, dataType); |
886 iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() ); |
927 iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() ); |
887 } |
928 } |
888 |
929 |
889 // Initially set default tags. |
930 // Initially set default tags. |
890 SetDefaultL( *iMedia ); |
931 SetDefaultL( *iMedia ); |
891 } |
932 } |
892 |
933 |
893 // ---------------------------------------------------------------------------- |
934 // ---------------------------------------------------------------------------- |
935 if ( iArrayTasks.Count() ) |
976 if ( iArrayTasks.Count() ) |
936 { |
977 { |
937 MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" ); |
978 MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" ); |
938 User::Leave( KErrAbort ); |
979 User::Leave( KErrAbort ); |
939 } |
980 } |
940 |
981 |
941 iCancelled = EFalse; |
982 iCancelled = EFalse; |
942 iFileOpenError = KErrNone; |
983 iFileOpenError = KErrNone; |
943 iFileName = aFile; |
984 iFileName = aFile; |
944 iObs = aObs; |
985 iObs = aObs; |
945 iMetadataOnly = aMetadataOnly; |
986 iMetadataOnly = aMetadataOnly; |
946 |
987 |
947 // populate the task array |
988 // populate the task array |
948 AddTasksL(); |
989 AddTasksL(); |
949 |
990 |
950 // Start task timer to execute task |
991 // Start task timer to execute task |
951 if ( iArrayTasks.Count() ) |
992 if ( iArrayTasks.Count() ) |
952 { |
993 { |
953 if ( iTaskTimer->IsActive() ) |
994 if ( iTaskTimer->IsActive() ) |
954 { |
995 { |
955 iTaskTimer->Cancel(); |
996 iTaskTimer->Cancel(); |
956 } |
997 } |
957 iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this )); |
998 iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this )); |
958 } |
999 } |
959 } |
1000 } |
960 |
1001 |
961 // --------------------------------------------------------------------------- |
1002 // --------------------------------------------------------------------------- |
963 // --------------------------------------------------------------------------- |
1004 // --------------------------------------------------------------------------- |
964 // |
1005 // |
965 TInt CMPXMetadataExtractor::OpenFile() |
1006 TInt CMPXMetadataExtractor::OpenFile() |
966 { |
1007 { |
967 MPX_FUNC("CMPXMetadataExtractor::OpenFile()"); |
1008 MPX_FUNC("CMPXMetadataExtractor::OpenFile()"); |
968 |
1009 |
969 // Open the file |
1010 // Open the file |
970 iFile.Close(); |
1011 iFile.Close(); |
971 TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters ); |
1012 TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters ); |
972 MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error ); |
1013 MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error ); |
973 return error; |
1014 return error; |
979 // |
1020 // |
980 void CMPXMetadataExtractor::AddTasksL() |
1021 void CMPXMetadataExtractor::AddTasksL() |
981 { |
1022 { |
982 MPX_FUNC("CMPXMetadataExtractor::AddTasks()"); |
1023 MPX_FUNC("CMPXMetadataExtractor::AddTasks()"); |
983 iFileOpenError = OpenFile(); |
1024 iFileOpenError = OpenFile(); |
984 |
1025 |
985 // Do not change the order of the task below. |
1026 // Do not change the order of the task below. |
986 iArrayTasks.Reset(); |
1027 iArrayTasks.Reset(); |
987 if ( iFileOpenError == KErrNone ) |
1028 if ( iFileOpenError == KErrNone ) |
988 { |
1029 { |
989 // to avoid resources contention (i.e. accessing sql, file system, etc) |
1030 // to avoid resources contention (i.e. accessing sql, file system, etc) |
1020 // Handle task timer expired |
1061 // Handle task timer expired |
1021 // ---------------------------------------------------------------------------- |
1062 // ---------------------------------------------------------------------------- |
1022 void CMPXMetadataExtractor::HandleTaskTimerExpired() |
1063 void CMPXMetadataExtractor::HandleTaskTimerExpired() |
1023 { |
1064 { |
1024 MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()"); |
1065 MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()"); |
1025 |
1066 |
1026 if ( iTaskTimer && iTaskTimer->IsActive() ) |
1067 if ( iTaskTimer && iTaskTimer->IsActive() ) |
1027 { |
1068 { |
1028 iTaskTimer->Cancel(); |
1069 iTaskTimer->Cancel(); |
1029 } |
1070 } |
1030 // execute task at index 0 |
1071 // execute task at index 0 |
1037 delete iMedia; |
1078 delete iMedia; |
1038 iMedia = NULL; |
1079 iMedia = NULL; |
1039 } |
1080 } |
1040 iArrayTasks.Reset(); |
1081 iArrayTasks.Reset(); |
1041 } |
1082 } |
1042 |
1083 |
1043 // Remove task at index 0. |
1084 // Remove task at index 0. |
1044 if ( iArrayTasks.Count() ) |
1085 if ( iArrayTasks.Count() ) |
1045 { |
1086 { |
1046 iArrayTasks.Remove( 0 ); |
1087 iArrayTasks.Remove( 0 ); |
1047 } |
1088 } |
1048 |
1089 |
1049 // check if we have any more task to run |
1090 // check if we have any more task to run |
1050 if ( iArrayTasks.Count() ) |
1091 if ( iArrayTasks.Count() ) |
1051 { |
1092 { |
1052 // start task timer |
1093 // start task timer |
1053 iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this )); |
1094 iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this )); |
1089 // DB Flags to set |
1130 // DB Flags to set |
1090 TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit); |
1131 TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit); |
1091 // Validate the objects to be used |
1132 // Validate the objects to be used |
1092 MPX_ASSERT(iMedia); |
1133 MPX_ASSERT(iMedia); |
1093 MPX_ASSERT(iDrmMediaUtility); |
1134 MPX_ASSERT(iDrmMediaUtility); |
1094 |
1135 |
1095 // File Path |
1136 // File Path |
1096 TParsePtrC parse( iFileName ); |
1137 TParsePtrC parse( iFileName ); |
1097 iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName ); |
1138 iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName ); |
1098 iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1139 iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1099 MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName); |
1140 MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName); |
1100 |
1141 |
1101 // get the protected flag from MetadataUtility Container |
1142 // get the protected flag from MetadataUtility Container |
1102 TPtrC ptr = aMetaCont.Field( EMetaDataProtected ); |
1143 TPtrC ptr = aMetaCont.Field( EMetaDataProtected ); |
1103 MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr); |
1144 MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr); |
1104 _LIT( KNonProtected, "0" ); |
1145 _LIT( KNonProtected, "0" ); |
1105 if ( ptr.Compare( KNonProtected ) == 0 ) |
1146 if ( ptr.Compare( KNonProtected ) == 0 ) |
1106 { |
1147 { |
1107 // this is non-protected file |
1148 // this is non-protected file |
1108 // prot = EFalse |
1149 // prot = EFalse |
1109 MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected"); |
1150 MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected"); |
1110 iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot ); |
1151 iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot ); |
1111 iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot ); |
1152 iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot ); |
1112 } |
1153 } |
1113 else |
1154 else |
1114 { // DRM file |
1155 { // DRM file |
1115 |
1156 |
1116 // DRM Rights |
1157 // DRM Rights |
1117 // |
1158 // |
1118 CMPXMedia* drm = NULL; |
1159 CMPXMedia* drm = NULL; |
1160 User::LeaveIfError( drmError ); |
1201 User::LeaveIfError( drmError ); |
1161 } |
1202 } |
1162 |
1203 |
1163 iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot ); |
1204 iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot ); |
1164 iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot ); |
1205 iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot ); |
1165 |
1206 |
1166 iDrmMediaUtility->Close(); |
1207 iDrmMediaUtility->Close(); |
1167 |
1208 |
1168 } // DRM file |
1209 } // DRM file |
1169 |
1210 |
1170 |
1211 |
1171 // verify the file open status |
1212 // verify the file open status |
1172 if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound ) |
1213 if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound ) |
1173 { |
1214 { |
1174 dbFlags |= KMPXMediaGeneralFlagsIsInvalid; |
1215 dbFlags |= KMPXMediaGeneralFlagsIsInvalid; |
1175 } |
1216 } |
1176 |
1217 |
1177 // Finally set the db flag |
1218 // Finally set the db flag |
1178 // |
1219 // |
1179 iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags ); |
1220 iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags ); |
1180 |
1221 |
1181 } |
1222 } |