18 #include <e32base.h> |
18 #include <e32base.h> |
19 #include <e32std.h> |
19 #include <e32std.h> |
20 #include <3gplibrary/mp4lib.h> |
20 #include <3gplibrary/mp4lib.h> |
21 #include <hxmetadatautil.h> |
21 #include <hxmetadatautil.h> |
22 #include <hxmetadatakeys.h> |
22 #include <hxmetadatakeys.h> |
|
23 #include <caf/caf.h> |
23 |
24 |
24 #include "mdsutils.h" |
25 #include "mdsutils.h" |
25 #include "harvestervideoplugin.h" |
26 #include "harvestervideoplugin.h" |
26 #include "harvesterlog.h" |
27 #include "harvesterlog.h" |
27 #include "harvesterblacklist.h" |
28 #include "harvesterblacklist.h" |
107 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty ); |
108 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty ); |
108 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty ); |
109 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty ); |
109 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty ); |
110 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty ); |
110 iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty ); |
111 iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty ); |
111 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty ); |
112 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty ); |
|
113 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty ); |
112 |
114 |
113 iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty ); |
115 iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty ); |
114 |
116 |
115 // Video property definitions |
117 // Video property definitions |
116 CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject ); |
118 CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject ); |
302 if ( error != KErrNone ) |
304 if ( error != KErrNone ) |
303 { |
305 { |
304 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error ); |
306 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error ); |
305 if( error == KErrInUse ) |
307 if( error == KErrInUse ) |
306 { |
308 { |
|
309 #ifdef _DEBUG |
|
310 TPtrC fileName( aUri.Mid(2) ); |
|
311 WRITELOG1( "CHarvesterVideoPlugin :: Checking open file handles to %S", &fileName ); |
|
312 |
|
313 CFileList* fileList = 0; |
|
314 TOpenFileScan fileScan( iFs ); |
|
315 |
|
316 TRAP_IGNORE( fileScan.NextL( fileList ) ); |
|
317 |
|
318 while ( fileList ) |
|
319 { |
|
320 const TInt count( fileList->Count() ); |
|
321 for (TInt i = 0; i < count; i++ ) |
|
322 { |
|
323 if ( (*fileList)[i].iName == aUri.Mid(2) ) |
|
324 { |
|
325 TFullName processName; |
|
326 TFindThread find(_L("*")); |
|
327 while( find.Next( processName ) == KErrNone ) |
|
328 { |
|
329 RThread thread; |
|
330 TInt err = thread.Open( processName ); |
|
331 |
|
332 if ( err == KErrNone ) |
|
333 { |
|
334 if ( thread.Id().Id() == fileScan.ThreadId() ) |
|
335 { |
|
336 processName = thread.Name(); |
|
337 thread.Close(); |
|
338 WRITELOG1( "CHarvesterVideoPlugin:: %S has a file handle open", &processName ); |
|
339 break; |
|
340 } |
|
341 thread.Close(); |
|
342 } |
|
343 } |
|
344 } |
|
345 } |
|
346 fileList = NULL; |
|
347 TRAP_IGNORE( fileScan.NextL( fileList ) ); |
|
348 } |
|
349 #endif |
307 aObjectType.Copy( KInUse() ); |
350 aObjectType.Copy( KInUse() ); |
308 } |
351 } |
309 return; |
352 return; |
310 } |
353 } |
311 |
354 |
397 CleanupClosePushL( file ); |
440 CleanupClosePushL( file ); |
398 if ( error == KErrInUse || |
441 if ( error == KErrInUse || |
399 error == KErrLocked ) |
442 error == KErrLocked ) |
400 { |
443 { |
401 WRITELOG( "CHarvesterVideoPlugin - File is open!" ); |
444 WRITELOG( "CHarvesterVideoPlugin - File is open!" ); |
|
445 #ifdef _DEBUG |
|
446 TPtrC fileName( uri.Mid(2) ); |
|
447 WRITELOG1( "CHarvesterVideoPlugin :: Checking open file handles to %S", &fileName ); |
|
448 |
|
449 CFileList* fileList = 0; |
|
450 TOpenFileScan fileScan( iFs ); |
|
451 |
|
452 fileScan.NextL( fileList ); |
|
453 |
|
454 while ( fileList ) |
|
455 { |
|
456 const TInt count( fileList->Count() ); |
|
457 for (TInt i = 0; i < count; i++ ) |
|
458 { |
|
459 if ( (*fileList)[i].iName == uri.Mid(2) ) |
|
460 { |
|
461 TFullName processName; |
|
462 TFindThread find(_L("*")); |
|
463 while( find.Next( processName ) == KErrNone ) |
|
464 { |
|
465 RThread thread; |
|
466 TInt err = thread.Open( processName ); |
|
467 |
|
468 if ( err == KErrNone ) |
|
469 { |
|
470 if ( thread.Id().Id() == fileScan.ThreadId() ) |
|
471 { |
|
472 processName = thread.Name(); |
|
473 thread.Close(); |
|
474 WRITELOG1( "CHarvesterVideoPlugin:: %S has a file handle open", &processName ); |
|
475 break; |
|
476 } |
|
477 thread.Close(); |
|
478 } |
|
479 } |
|
480 } |
|
481 } |
|
482 fileScan.NextL( fileList ); |
|
483 } |
|
484 #endif |
402 CleanupStack::PopAndDestroy( &file ); |
485 CleanupStack::PopAndDestroy( &file ); |
403 User::Leave( KErrInUse ); |
486 User::Leave( KErrInUse ); |
404 } |
487 } |
405 else if( error == KErrNotFound || |
488 else if( error == KErrNotFound || |
406 error == KErrPathNotFound || |
489 error == KErrPathNotFound || |
416 |
499 |
417 if( dataExtracted ) |
500 if( dataExtracted ) |
418 { |
501 { |
419 CMdEProperty* prop = NULL; |
502 CMdEProperty* prop = NULL; |
420 CMdEObjectDef& objectDef = aMetadataObject.Def(); |
503 CMdEObjectDef& objectDef = aMetadataObject.Def(); |
421 CMdEPropertyDef& sizeDef = objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
|
422 aMetadataObject.Property( sizeDef, prop ); |
|
423 if( prop ) |
|
424 { |
|
425 aVHD.iFileSize = prop->Uint32ValueL(); |
|
426 } |
|
427 else |
|
428 { |
|
429 dataExtracted = EFalse; |
|
430 } |
|
431 CMdEPropertyDef& modifiedDef = objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
504 CMdEPropertyDef& modifiedDef = objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
432 aMetadataObject.Property( modifiedDef, prop ); |
505 aMetadataObject.Property( modifiedDef, prop ); |
433 if( prop ) |
506 if( prop ) |
434 { |
507 { |
435 aVHD.iModified = prop->TimeValueL(); |
508 aVHD.iModified = prop->TimeValueL(); |
452 User::Leave( errorcode ); |
525 User::Leave( errorcode ); |
453 } |
526 } |
454 |
527 |
455 aVHD.iModified = entry.iModified; |
528 aVHD.iModified = entry.iModified; |
456 aVHD.iFileSize = (TUint)entry.iSize; |
529 aVHD.iFileSize = (TUint)entry.iSize; |
457 } |
530 |
458 |
531 WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize ); |
459 WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize ); |
532 } |
460 |
533 |
461 // now the minimum information has been harvested |
534 // now the minimum information has been harvested |
462 // from now on the harvested data should always be stored |
535 // from now on the harvested data should always be stored |
463 |
536 |
464 const THarvestingHandling* mapping = FindHandler( uri ); |
537 const THarvestingHandling* mapping = FindHandler( uri ); |
481 if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
554 if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
482 { |
555 { |
483 // doesn't own pointers to MIME types |
556 // doesn't own pointers to MIME types |
484 RPointerArray<HBufC> mimes; |
557 RPointerArray<HBufC> mimes; |
485 CleanupClosePushL( mimes ); |
558 CleanupClosePushL( mimes ); |
|
559 |
|
560 TPtrC ext; |
|
561 MdsUtils::GetExt( uri, ext ); |
|
562 |
|
563 // Check for possibly protected content |
|
564 if( ext.CompareF( KExtensionWmv ) == 0 ) |
|
565 { |
|
566 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
|
567 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
|
568 |
|
569 data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected ); |
|
570 CleanupStack::PopAndDestroy( 2 ); // content, data |
|
571 } |
486 |
572 |
487 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
573 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
488 CleanupStack::PushL( helixMetadata ); |
574 CleanupStack::PushL( helixMetadata ); |
489 |
575 |
490 TRAP( error, helixMetadata->OpenFileL( file ) ); |
576 TRAP( error, helixMetadata->OpenFileL( file ) ); |
673 helixMetadata->ResetL(); |
759 helixMetadata->ResetL(); |
674 CleanupStack::PopAndDestroy( helixMetadata ); |
760 CleanupStack::PopAndDestroy( helixMetadata ); |
675 |
761 |
676 // don't destory mime type pointers just clean array |
762 // don't destory mime type pointers just clean array |
677 CleanupStack::PopAndDestroy( &mimes ); |
763 CleanupStack::PopAndDestroy( &mimes ); |
|
764 |
|
765 // If parsing failed, check for possible protected content |
|
766 if( error == KErrNotSupported || |
|
767 error == KErrAccessDenied || |
|
768 error == KErrPermissionDenied ) |
|
769 { |
|
770 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
|
771 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
|
772 |
|
773 if( !aVHD.iDrmProtected ) |
|
774 { |
|
775 data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected ); |
|
776 } |
|
777 if( aVHD.iDrmProtected ) |
|
778 { |
|
779 ContentAccess::RStringAttributeSet attrSet; |
|
780 CleanupClosePushL( attrSet ); |
|
781 |
|
782 attrSet.AddL( ContentAccess::EDescription ); |
|
783 attrSet.AddL( ContentAccess::ETitle ); |
|
784 attrSet.AddL( ContentAccess::EAuthor ); |
|
785 attrSet.AddL( ContentAccess::EGenre ); |
|
786 |
|
787 if( data->GetStringAttributeSet(attrSet) == KErrNone ) |
|
788 { |
|
789 TBuf<KMaxDataTypeLength> value; |
|
790 |
|
791 TInt err = attrSet.GetValue( ContentAccess::EDescription, value ); |
|
792 if ( err != KErrNone) |
|
793 { |
|
794 WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting description failed %d", err ); |
|
795 } |
|
796 else if( value.Length() > 0 ) |
|
797 { |
|
798 aVHD.iDescription = value.Alloc(); |
|
799 } |
|
800 |
|
801 err = attrSet.GetValue( ContentAccess::ETitle, value ); |
|
802 if ( err != KErrNone) |
|
803 { |
|
804 WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting title failed %d", err ); |
|
805 } |
|
806 else if( value.Length() > 0 ) |
|
807 { |
|
808 aVHD.iTitle = value.Alloc(); |
|
809 } |
|
810 |
|
811 err = attrSet.GetValue( ContentAccess::EAuthor, value ); |
|
812 if ( err != KErrNone) |
|
813 { |
|
814 WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting author failed %d", err ); |
|
815 } |
|
816 else if( value.Length() > 0 ) |
|
817 { |
|
818 aVHD.iAuthor = value.Alloc(); |
|
819 } |
|
820 |
|
821 err = attrSet.GetValue( ContentAccess::EGenre, value ); |
|
822 if ( err != KErrNone) |
|
823 { |
|
824 WRITELOG1( "CHarvesterVideoPlugin::GatherDataL - ERROR: getting genre failed %d", err ); |
|
825 } |
|
826 else if( value.Length() > 0 ) |
|
827 { |
|
828 aVHD.iGenre = value.Alloc(); |
|
829 } |
|
830 } |
|
831 CleanupStack::PopAndDestroy(); // attrSet |
|
832 } |
|
833 CleanupStack::PopAndDestroy( 2 ); // content, data |
|
834 } |
678 } |
835 } |
679 else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling ) |
836 else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling ) |
680 { |
837 { |
681 MP4Handle handle( 0 ); |
838 MP4Handle handle( 0 ); |
682 MP4Err mp4err = MP4_OK; |
839 MP4Err mp4err = MP4_OK; |
873 } |
1030 } |
874 else |
1031 else |
875 { |
1032 { |
876 if( aVHD.iVideoObject ) |
1033 if( aVHD.iVideoObject ) |
877 { |
1034 { |
878 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd ); |
1035 if( aVHD.iVideoBitrate != 0 ) |
|
1036 { |
|
1037 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd ); |
|
1038 } |
879 } |
1039 } |
880 else // audio object |
1040 else // audio object |
881 { |
1041 { |
882 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd ); |
1042 if( aVHD.iAudioBitrate != 0 ) |
|
1043 { |
|
1044 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd ); |
|
1045 } |
883 } |
1046 } |
884 } |
1047 } |
885 |
1048 |
886 // Copyright |
1049 // Copyright |
887 if( aVHD.iCopyright ) |
1050 if( aVHD.iCopyright ) |