harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
changeset 41 2290317b9ec5
parent 23 33ae025ac1e8
equal deleted inserted replaced
23:33ae025ac1e8 41:2290317b9ec5
    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 #include <caf/caf.h>
       
    24 #include <pathinfo.h>
    24 
    25 
    25 #include "mdsutils.h"
    26 #include "mdsutils.h"
    26 #include "harvestervideoplugin.h"
    27 #include "harvestervideoplugin.h"
    27 #include "harvesterlog.h"
    28 #include "harvesterlog.h"
    28 #include "harvesterblacklist.h"
    29 #include "harvesterblacklist.h"
    29 #include "mdeobjectwrapper.h"
    30 #include "mdeobjectwrapper.h"
       
    31 #include "mdscommoninternal.h"
    30 
    32 
    31 #include <mdenamespacedef.h>
    33 #include <mdenamespacedef.h>
    32 #include <mdeobjectdef.h>
    34 #include <mdeobjectdef.h>
    33 #include <mdepropertydef.h>
    35 #include <mdepropertydef.h>
    34 #include <mdeobject.h>
    36 #include <mdeobject.h>
    95 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    97 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    96 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    98 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    97 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    99 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    98 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
   100 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
    99 	iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
   101 	iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
       
   102 	iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
   100 
   103 
   101 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
   104 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
   102 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
   105 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
   103 	iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
   106 	iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
   104 	iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
   107 	iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
   161 	{
   164 	{
   162 	delete iPropDefs;
   165 	delete iPropDefs;
   163 	iMimeTypeMappings.Close();
   166 	iMimeTypeMappings.Close();
   164     RMediaIdUtil::ReleaseInstance();
   167     RMediaIdUtil::ReleaseInstance();
   165 
   168 
       
   169     delete iPhoneVideosPath;
       
   170     delete iMmcVideosPath;
       
   171     
   166 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
   172 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
   167 	}
   173 	}
   168 
   174 
   169 /**
   175 /**
   170 * 2nd phase constructor
   176 * 2nd phase constructor
   266     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   272     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling(
   267             KExtensionWmv(), KMimeTypeWmv(), 
   273             KExtensionWmv(), KMimeTypeWmv(), 
   268             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   274             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
   269                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
   275                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
   270             cmp ) );
   276             cmp ) );
       
   277 
       
   278     TFileName videos = PathInfo::VideosPath();
       
   279     
       
   280     TFileName phonePath = PathInfo::PhoneMemoryRootPath();
       
   281     phonePath.Append( videos );
       
   282     iPhoneVideosPath = phonePath.AllocL();
       
   283 
       
   284     TFileName mmcPath = PathInfo::MemoryCardRootPath();
       
   285     mmcPath.Append( videos );
       
   286     iMmcVideosPath = mmcPath.Right( mmcPath.Length() - 1 ).AllocL();
   271     
   287     
   272     iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
   288     iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
   273     }
   289     }
   274 
   290 
   275 
   291 
   396             TRAP_IGNORE( HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
   412             TRAP_IGNORE( HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
   397             }
   413             }
   398     	}
   414     	}
   399     else
   415     else
   400         {
   416         {
   401         WRITELOG1( "CHarvesterVideoPlugin::HarvestSingleFileL() - TRAP error: %d", error );
   417         WRITELOG1( "CHarvesterVideoPlugin::HarvestL() - TRAP error: %d", error );
   402         TInt convertedError = KErrNone;
   418         TInt convertedError = KErrNone;
   403         MdsUtils::ConvertTrapError( error, convertedError );
   419         MdsUtils::ConvertTrapError( error, convertedError );
   404         aHD->SetErrorCode( convertedError );
   420         aHD->SetErrorCode( convertedError );
   405         }
   421         }
   406 
   422 
   431 // ---------------------------------------------------------------------------
   447 // ---------------------------------------------------------------------------
   432 //
   448 //
   433 void CHarvesterVideoPlugin::GatherDataL( CMdEObject& aMetadataObject,
   449 void CHarvesterVideoPlugin::GatherDataL( CMdEObject& aMetadataObject,
   434 		CVideoHarvestData& aVHD )
   450 		CVideoHarvestData& aVHD )
   435     {
   451     {
       
   452 #ifdef _DEBUG
       
   453     TTime dStart, dStop;
       
   454     dStart.UniversalTime();
       
   455     dStop.UniversalTime();
       
   456     WRITELOG1( "CHarvesterVideoPlugin::GatherDataL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
       
   457 #endif
   436     const TDesC& uri = aMetadataObject.Uri();
   458     const TDesC& uri = aMetadataObject.Uri();
   437     
   459     
   438     WRITELOG1( "CHarvesterVideoPlugin - Gather data from file %S", &uri );
   460     WRITELOG1( "CHarvesterVideoPlugin - Gather data from file %S", &uri );
   439     
   461     
   440     RFile64 file;
   462     RFile64 file;
   756         if( mime.Ptr() && ( mime.Length() > 0 ) )
   778         if( mime.Ptr() && ( mime.Length() > 0 ) )
   757         	{
   779         	{
   758         	aVHD.iMimeBuf = mime.Alloc();
   780         	aVHD.iMimeBuf = mime.Alloc();
   759         	}
   781         	}
   760         
   782         
   761         helixMetadata->ResetL();
       
   762         CleanupStack::PopAndDestroy( helixMetadata );
   783         CleanupStack::PopAndDestroy( helixMetadata );
   763         
   784         
   764         // don't destory mime type pointers just clean array
   785         // don't destory mime type pointers just clean array
   765         CleanupStack::PopAndDestroy( &mimes );
   786         CleanupStack::PopAndDestroy( &mimes );
   766         
   787         
   930 #endif
   951 #endif
   931         }
   952         }
   932     WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
   953     WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
   933     CleanupStack::PopAndDestroy( &file );        
   954     CleanupStack::PopAndDestroy( &file );        
   934 
   955 
       
   956 #ifdef _DEBUG
       
   957     dStop.UniversalTime();
       
   958     WRITELOG1( "CHarvesterVideoPlugin::GatherDataL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
       
   959 #endif  
       
   960     
   935     WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
   961     WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
   936     }
   962     }
   937 
   963 
   938 // ---------------------------------------------------------------------------
   964 // ---------------------------------------------------------------------------
   939 // HandleNewObjectL
   965 // HandleNewObjectL
   967     	// Last modified date
   993     	// Last modified date
   968     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd );
   994     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd );
   969     
   995     
   970     	// File size
   996     	// File size
   971     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
   997     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
       
   998     	
       
   999     	// Default folder
       
  1000         const TDesC& uri = mdeObject.Uri();
       
  1001         if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound ||
       
  1002             uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound ||
       
  1003             uri.FindF( KDCIMFolder ) != KErrNotFound ) 
       
  1004             {
       
  1005             TBool inDefaultFolder( ETrue );
       
  1006             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );
       
  1007             }
       
  1008         else
       
  1009             {
       
  1010             TBool inDefaultFolder( EFalse );
       
  1011             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );    
       
  1012             }
   972     	}
  1013     	}
   973 
  1014 
   974     // Item Type
  1015     // Item Type
   975     if( aVHD.iMimeBuf )
  1016     if( aVHD.iMimeBuf )
   976         {
  1017         {
  1087         {
  1128         {
  1088         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
  1129         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd );
  1089         }
  1130         }
  1090     
  1131     
  1091     // Title
  1132     // Title
  1092     if( aVHD.iTitle && aVHD.iTitle->Length() < iMaxTextLength )
  1133     if( aVHD.iTitle && aVHD.iTitle->Length() < KMaxTitleFieldLength )
  1093         {
  1134         {
  1094         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
  1135         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
  1095         }
  1136         }
  1096     
  1137     
  1097     // DRM protection
  1138     // DRM protection