--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Tue Jul 06 14:44:37 2010 +0300
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp Fri Sep 17 16:54:49 2010 +0300
@@ -85,58 +85,61 @@
const TInt KKiloBytes = 1024;
const TReal32 KThousandReal = 1000.0;
-CHarvesterVideoPluginPropertyDefs::CHarvesterVideoPluginPropertyDefs() : CBase()
+CHarvesterVideoPluginPropertyDefs::CHarvesterVideoPluginPropertyDefs() : CBase(),
+ iCreationDatePropertyDef( NULL )
{
}
void CHarvesterVideoPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
{
- CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
-
- // Common property definitions
- CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject );
- iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
- iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
- iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
- iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
- iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
- iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
- iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
-
- CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
- iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
- iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
- iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
- iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
- iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
- iBitratePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KBitrateProperty );
- iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
- iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty );
- iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty );
- iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
- iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
- iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty );
-
- iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty );
-
- // Video property definitions
- CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject );
- iFrameratePropertyDef = &videoDef.GetPropertyDefL( Video::KFramerateProperty );
-
- // Audio property definitions
- CMdEObjectDef& audioDef = nsDef.GetObjectDefL( Audio::KAudioObject );
- iSamplingFrequencyPropertyDef = &audioDef.GetPropertyDefL( Audio::KSamplingFrequencyProperty );
+ SetByObjectDefL( aObjectDef );
}
-CHarvesterVideoPluginPropertyDefs* CHarvesterVideoPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
- {
- CHarvesterVideoPluginPropertyDefs* self =
- new (ELeave) CHarvesterVideoPluginPropertyDefs();
- CleanupStack::PushL( self );
- self->ConstructL( aObjectDef );
- CleanupStack::Pop( self );
- return self;
- }
+CHarvesterVideoPluginPropertyDefs* CHarvesterVideoPluginPropertyDefs::NewL()
+ {
+ CHarvesterVideoPluginPropertyDefs* self =
+ new (ELeave) CHarvesterVideoPluginPropertyDefs();
+ return self;
+ }
+
+void CHarvesterVideoPluginPropertyDefs::SetByObjectDefL( CMdEObjectDef& aObjectDef )
+ {
+ CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
+
+ // Common property definitions
+ CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject );
+ iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
+ iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
+ iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
+ iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
+ iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
+ iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
+ iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
+
+ CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
+ iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
+ iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
+ iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty );
+ iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
+ iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
+ iBitratePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KBitrateProperty );
+ iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
+ iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty );
+ iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty );
+ iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
+ iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
+ iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty );
+
+ iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty );
+
+ // Video property definitions
+ CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject );
+ iFrameratePropertyDef = &videoDef.GetPropertyDefL( Video::KFramerateProperty );
+
+ // Audio property definitions
+ CMdEObjectDef& audioDef = nsDef.GetObjectDefL( Audio::KAudioObject );
+ iSamplingFrequencyPropertyDef = &audioDef.GetPropertyDefL( Audio::KSamplingFrequencyProperty );
+ }
/**
* Default constructor
@@ -165,11 +168,14 @@
CHarvesterVideoPlugin::~CHarvesterVideoPlugin()
{
delete iPropDefs;
+ iPropDefs = NULL;
iMimeTypeMappings.Close();
RMediaIdUtil::ReleaseInstance();
delete iPhoneVideosPath;
+ iPhoneVideosPath = NULL;
delete iMmcVideosPath;
+ iMmcVideosPath = NULL;
WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
}
@@ -181,6 +187,8 @@
{
WRITELOG( "CHarvesterVideoPlugin::ConstructL() - begin" );
+ iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL();
+
TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction );
// MPEG4
@@ -331,7 +339,7 @@
if ( error != KErrNone )
{
WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error );
- if( error == KErrInUse )
+ if( error == KErrInUse || KErrLocked )
{
#ifdef _DEBUG
TPtrC fileName( aUri.Mid(2) );
@@ -548,22 +556,41 @@
if( !dataExtracted )
{
- TEntry entry;
- const TInt errorcode = iFs.Entry( uri, entry );
-
- if ( errorcode != KErrNone )
+ // If file could be opened, use file handle to fetch base data, otherwise
+ // attempt to fetch the data from TEntry
+ if( error == KErrNone )
+ {
+ User::LeaveIfError( file.Modified( aVHD.iModified ) );
+ User::LeaveIfError( file.Size( aVHD.iFileSize ) );
+ }
+ else
{
- WRITELOG1( "CHarvesterVideoPlugin - Error getting entry: %d", errorcode );
- CleanupStack::PopAndDestroy( &file );
- User::Leave( errorcode );
+ TEntry entry;
+ const TInt errorcode = iFs.Entry( uri, entry );
+
+ if ( errorcode != KErrNone )
+ {
+ WRITELOG1( "CHarvesterVideoPlugin - Error getting entry: %d", errorcode );
+ CleanupStack::PopAndDestroy( &file );
+ User::Leave( errorcode );
+ }
+
+ aVHD.iModified = entry.iModified;
+ aVHD.iFileSize = (TUint)entry.iSize;
}
- aVHD.iModified = entry.iModified;
- aVHD.iFileSize = (TUint)entry.iSize;
-
WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize );
}
+ aVHD.iVideoObject = aMetadataObject.Def().Name().Compare( KVideo ) == 0;
+
+ if( error != KErrNone )
+ {
+ WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error );
+ CleanupStack::PopAndDestroy( &file );
+ User::Leave( KErrCompletion );
+ }
+
// now the minimum information has been harvested
// from now on the harvested data should always be stored
@@ -574,15 +601,6 @@
CleanupStack::PopAndDestroy( &file );
User::Leave( KErrNotFound );
}
-
- aVHD.iVideoObject = aMetadataObject.Def().Name().Compare( KVideo ) == 0;
-
- if( error != KErrNone )
- {
- WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error );
- CleanupStack::PopAndDestroy( &file );
- User::Leave( KErrCompletion );
- }
if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling )
{
@@ -591,10 +609,10 @@
CleanupClosePushL( mimes );
TPtrC ext;
- MdsUtils::GetExt( uri, ext );
+ const TBool exists = MdsUtils::GetExt( uri, ext );
// Check for possibly protected content
- if( ext.CompareF( KExtensionWmv ) == 0 )
+ if( exists && ext.CompareF( KExtensionWmv ) == 0 )
{
ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );
ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
@@ -607,6 +625,10 @@
CleanupStack::PushL( helixMetadata );
TRAP( error, helixMetadata->OpenFileL( file ) );
+
+ // No need for the file handle anymore so closing it
+ WRITELOG( "CHarvesterVideoPlugin - Parsing done, file handle can be closed" );
+ file.Close();
if ( error == KErrNone )
{
@@ -789,6 +811,7 @@
aVHD.iMimeBuf = mime.Alloc();
}
+ helixMetadata->ResetL();
CleanupStack::PopAndDestroy( helixMetadata );
// don't destory mime type pointers just clean array
@@ -959,12 +982,12 @@
}
#endif
}
- WRITELOG( "CHarvesterVideoPlugin - Closing file" );
+ WRITELOG( "CHarvesterVideoPlugin - Closing file, if still open" );
CleanupStack::PopAndDestroy( &file );
#ifdef _DEBUG
dStop.UniversalTime();
- WRITELOG1( "CHarvesterVideoPlugin::GatherDataL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
+ WRITELOG1( "CHarvesterVideoPlugin::GatherDataL end %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
#endif
WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
@@ -982,14 +1005,8 @@
WRITELOG("CHarvesterVideoPlugin::HandleObjectPropertiesL ");
CMdEObject& mdeObject = aHD.MdeObject();
-
- if( !iPropDefs )
- {
- CMdEObjectDef& objectDef = mdeObject.Def();
- iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL( objectDef );
- // Prefetch max text lengt for validity checking
- iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
- }
+
+ InitPropDefsL( mdeObject.Def() );
TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
TTime localModifiedDate = aVHD.iModified + timeOffsetSeconds;
@@ -1217,9 +1234,6 @@
{
TBool possibleVideo = EFalse;
- CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
- CleanupStack::PushL( helixMetadata );
-
TFileName tempName;
TUint32 mediaId( 0 );
TInt blackListError( KErrNone );
@@ -1227,10 +1241,14 @@
blackListError = GetFileFullNameAndMediaId( aFile, tempName, mediaId );
if( blackListError == KErrNone )
{
- AddFileToBlackList( tempName, mediaId );
+ blackListError = AddFileToBlackList( tempName, mediaId );
}
+ CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL();
+ CleanupStack::PushL( helixMetadata );
+
TRAPD( err, helixMetadata->OpenFileL( aFile ) );
+ aFile.Close();
if( err == KErrNone )
{
@@ -1257,10 +1275,10 @@
const TInt mimeCount = mimes.Count();
- // at least one MIME type must be found
+ // Set to Video, regardless how badly file is corrupted
if( mimeCount == 0 )
{
- User::Leave( KErrNotFound );
+ aType.Copy( KVideo );
}
for( TInt i = 0; i < mimeCount; i++ )
@@ -1313,13 +1331,14 @@
{
aType.Copy( KVideo );
}
+
+ helixMetadata->ResetL();
+ CleanupStack::PopAndDestroy( helixMetadata );
if( blackListError == KErrNone )
{
RemoveFileFromBlackList( tempName, mediaId );
- }
-
- CleanupStack::PopAndDestroy( helixMetadata );
+ }
}
TInt CHarvesterVideoPlugin::AddFileToBlackList( const TFileName& aFullName, const TUint32& aMediaId )
@@ -1331,7 +1350,7 @@
if( blackListError == KErrNone )
{
WRITELOG( "CHarvesterVideoPlugin::AddFileToBlackList - Adding URI to blacklist" );
- iBlacklist->AddFile( aFullName, aMediaId, modified );
+ blackListError = iBlacklist->AddFile( aFullName, aMediaId, modified );
}
return blackListError;
@@ -1429,5 +1448,15 @@
return;
}
+void CHarvesterVideoPlugin::InitPropDefsL(CMdEObjectDef& aObjectDef)
+ {
+ if( !iPropDefs->iCreationDatePropertyDef )
+ {
+ iPropDefs->SetByObjectDefL( aObjectDef );
+ // Prefetch max text lengt for validity checking
+ iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
+ }
+ }
+
// End of file