83 _LIT(KInUse, "InUse"); |
83 _LIT(KInUse, "InUse"); |
84 |
84 |
85 const TInt KKiloBytes = 1024; |
85 const TInt KKiloBytes = 1024; |
86 const TReal32 KThousandReal = 1000.0; |
86 const TReal32 KThousandReal = 1000.0; |
87 |
87 |
88 CHarvesterVideoPluginPropertyDefs::CHarvesterVideoPluginPropertyDefs() : CBase(), |
88 CHarvesterVideoPluginPropertyDefs::CHarvesterVideoPluginPropertyDefs() : CBase() |
89 iCreationDatePropertyDef( NULL ) |
|
90 { |
89 { |
91 } |
90 } |
92 |
91 |
93 void CHarvesterVideoPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef) |
92 void CHarvesterVideoPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef) |
94 { |
93 { |
95 SetByObjectDefL( aObjectDef ); |
94 CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef(); |
|
95 |
|
96 // Common property definitions |
|
97 CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject ); |
|
98 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty ); |
|
99 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty ); |
|
100 iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty ); |
|
101 iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty ); |
|
102 iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty ); |
|
103 iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty ); |
|
104 iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder ); |
|
105 |
|
106 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject ); |
|
107 iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty ); |
|
108 iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty ); |
|
109 iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty ); |
|
110 iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty ); |
|
111 iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty ); |
|
112 iBitratePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KBitrateProperty ); |
|
113 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty ); |
|
114 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty ); |
|
115 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty ); |
|
116 iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty ); |
|
117 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty ); |
|
118 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty ); |
|
119 |
|
120 iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty ); |
|
121 |
|
122 // Video property definitions |
|
123 CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject ); |
|
124 iFrameratePropertyDef = &videoDef.GetPropertyDefL( Video::KFramerateProperty ); |
|
125 |
|
126 // Audio property definitions |
|
127 CMdEObjectDef& audioDef = nsDef.GetObjectDefL( Audio::KAudioObject ); |
|
128 iSamplingFrequencyPropertyDef = &audioDef.GetPropertyDefL( Audio::KSamplingFrequencyProperty ); |
96 } |
129 } |
97 |
130 |
98 CHarvesterVideoPluginPropertyDefs* CHarvesterVideoPluginPropertyDefs::NewL() |
131 CHarvesterVideoPluginPropertyDefs* CHarvesterVideoPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef) |
99 { |
132 { |
100 CHarvesterVideoPluginPropertyDefs* self = |
133 CHarvesterVideoPluginPropertyDefs* self = |
101 new (ELeave) CHarvesterVideoPluginPropertyDefs(); |
134 new (ELeave) CHarvesterVideoPluginPropertyDefs(); |
102 return self; |
135 CleanupStack::PushL( self ); |
103 } |
136 self->ConstructL( aObjectDef ); |
104 |
137 CleanupStack::Pop( self ); |
105 void CHarvesterVideoPluginPropertyDefs::SetByObjectDefL( CMdEObjectDef& aObjectDef ) |
138 return self; |
106 { |
139 } |
107 CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef(); |
|
108 |
|
109 // Common property definitions |
|
110 CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject ); |
|
111 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty ); |
|
112 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty ); |
|
113 iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty ); |
|
114 iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty ); |
|
115 iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty ); |
|
116 iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty ); |
|
117 iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder ); |
|
118 |
|
119 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject ); |
|
120 iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty ); |
|
121 iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty ); |
|
122 iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty ); |
|
123 iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty ); |
|
124 iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty ); |
|
125 iBitratePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KBitrateProperty ); |
|
126 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty ); |
|
127 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty ); |
|
128 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty ); |
|
129 iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty ); |
|
130 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty ); |
|
131 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDRMProperty ); |
|
132 |
|
133 iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty ); |
|
134 |
|
135 // Video property definitions |
|
136 CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject ); |
|
137 iFrameratePropertyDef = &videoDef.GetPropertyDefL( Video::KFramerateProperty ); |
|
138 |
|
139 // Audio property definitions |
|
140 CMdEObjectDef& audioDef = nsDef.GetObjectDefL( Audio::KAudioObject ); |
|
141 iSamplingFrequencyPropertyDef = &audioDef.GetPropertyDefL( Audio::KSamplingFrequencyProperty ); |
|
142 } |
|
143 |
140 |
144 /** |
141 /** |
145 * Default constructor |
142 * Default constructor |
146 */ |
143 */ |
147 CHarvesterVideoPlugin::CHarvesterVideoPlugin() : CHarvesterPlugin(), iPropDefs( NULL ) |
144 CHarvesterVideoPlugin::CHarvesterVideoPlugin() : CHarvesterPlugin(), iPropDefs( NULL ) |
166 * Destruction |
163 * Destruction |
167 */ |
164 */ |
168 CHarvesterVideoPlugin::~CHarvesterVideoPlugin() |
165 CHarvesterVideoPlugin::~CHarvesterVideoPlugin() |
169 { |
166 { |
170 delete iPropDefs; |
167 delete iPropDefs; |
171 iPropDefs = NULL; |
|
172 iMimeTypeMappings.Close(); |
168 iMimeTypeMappings.Close(); |
173 RMediaIdUtil::ReleaseInstance(); |
169 RMediaIdUtil::ReleaseInstance(); |
174 |
170 |
175 delete iPhoneVideosPath; |
171 delete iPhoneVideosPath; |
176 iPhoneVideosPath = NULL; |
|
177 delete iMmcVideosPath; |
172 delete iMmcVideosPath; |
178 iMmcVideosPath = NULL; |
|
179 |
173 |
180 WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()"); |
174 WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()"); |
181 } |
175 } |
182 |
176 |
183 /** |
177 /** |
184 * 2nd phase constructor |
178 * 2nd phase constructor |
185 */ |
179 */ |
186 void CHarvesterVideoPlugin::ConstructL() |
180 void CHarvesterVideoPlugin::ConstructL() |
187 { |
181 { |
188 WRITELOG( "CHarvesterVideoPlugin::ConstructL() - begin" ); |
182 WRITELOG( "CHarvesterVideoPlugin::ConstructL() - begin" ); |
189 |
|
190 iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL(); |
|
191 |
183 |
192 TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction ); |
184 TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction ); |
193 |
185 |
194 // MPEG4 |
186 // MPEG4 |
195 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
187 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
554 } |
546 } |
555 } |
547 } |
556 |
548 |
557 if( !dataExtracted ) |
549 if( !dataExtracted ) |
558 { |
550 { |
559 // If file could be opened, use file handle to fetch base data, otherwise |
551 TEntry entry; |
560 // attempt to fetch the data from TEntry |
552 const TInt errorcode = iFs.Entry( uri, entry ); |
561 if( error == KErrNone ) |
553 |
|
554 if ( errorcode != KErrNone ) |
562 { |
555 { |
563 User::LeaveIfError( file.Modified( aVHD.iModified ) ); |
556 WRITELOG1( "CHarvesterVideoPlugin - Error getting entry: %d", errorcode ); |
564 User::LeaveIfError( file.Size( aVHD.iFileSize ) ); |
557 CleanupStack::PopAndDestroy( &file ); |
|
558 User::Leave( errorcode ); |
565 } |
559 } |
566 else |
560 |
567 { |
561 aVHD.iModified = entry.iModified; |
568 TEntry entry; |
562 aVHD.iFileSize = (TUint)entry.iSize; |
569 const TInt errorcode = iFs.Entry( uri, entry ); |
|
570 |
|
571 if ( errorcode != KErrNone ) |
|
572 { |
|
573 WRITELOG1( "CHarvesterVideoPlugin - Error getting entry: %d", errorcode ); |
|
574 CleanupStack::PopAndDestroy( &file ); |
|
575 User::Leave( errorcode ); |
|
576 } |
|
577 |
|
578 aVHD.iModified = entry.iModified; |
|
579 aVHD.iFileSize = (TUint)entry.iSize; |
|
580 } |
|
581 |
563 |
582 WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize ); |
564 WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize ); |
583 } |
565 } |
|
566 |
|
567 // now the minimum information has been harvested |
|
568 // from now on the harvested data should always be stored |
|
569 |
|
570 const THarvestingHandling* mapping = FindHandler( uri ); |
|
571 |
|
572 if( !mapping ) |
|
573 { |
|
574 CleanupStack::PopAndDestroy( &file ); |
|
575 User::Leave( KErrNotFound ); |
|
576 } |
584 |
577 |
585 aVHD.iVideoObject = aMetadataObject.Def().Name().Compare( KVideo ) == 0; |
578 aVHD.iVideoObject = aMetadataObject.Def().Name().Compare( KVideo ) == 0; |
586 |
579 |
587 if( error != KErrNone ) |
580 if( error != KErrNone ) |
588 { |
581 { |
589 WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error ); |
582 WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error ); |
590 CleanupStack::PopAndDestroy( &file ); |
583 CleanupStack::PopAndDestroy( &file ); |
591 User::Leave( KErrCompletion ); |
584 User::Leave( KErrCompletion ); |
592 } |
585 } |
593 |
586 |
594 // now the minimum information has been harvested |
|
595 // from now on the harvested data should always be stored |
|
596 |
|
597 const THarvestingHandling* mapping = FindHandler( uri ); |
|
598 |
|
599 if( !mapping ) |
|
600 { |
|
601 CleanupStack::PopAndDestroy( &file ); |
|
602 User::Leave( KErrNotFound ); |
|
603 } |
|
604 |
|
605 if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
587 if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
606 { |
588 { |
607 // doesn't own pointers to MIME types |
589 // doesn't own pointers to MIME types |
608 RPointerArray<HBufC> mimes; |
590 RPointerArray<HBufC> mimes; |
609 CleanupClosePushL( mimes ); |
591 CleanupClosePushL( mimes ); |
610 |
592 |
611 TPtrC ext; |
593 TPtrC ext; |
612 const TBool exists = MdsUtils::GetExt( uri, ext ); |
594 MdsUtils::GetExt( uri, ext ); |
613 |
595 |
614 // Check for possibly protected content |
596 // Check for possibly protected content |
615 if( exists && ext.CompareF( KExtensionWmv ) == 0 ) |
597 if( ext.CompareF( KExtensionWmv ) == 0 ) |
616 { |
598 { |
617 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
599 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri ); |
618 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
600 ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek ); |
619 |
601 |
620 data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected ); |
602 data->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected ); |
1232 |
1215 |
1233 void CHarvesterVideoPlugin::GetRmTypeL( RFile64& aFile, TDes& aType ) |
1216 void CHarvesterVideoPlugin::GetRmTypeL( RFile64& aFile, TDes& aType ) |
1234 { |
1217 { |
1235 TBool possibleVideo = EFalse; |
1218 TBool possibleVideo = EFalse; |
1236 |
1219 |
|
1220 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
|
1221 CleanupStack::PushL( helixMetadata ); |
|
1222 |
1237 TFileName tempName; |
1223 TFileName tempName; |
1238 TUint32 mediaId( 0 ); |
1224 TUint32 mediaId( 0 ); |
1239 TInt blackListError( KErrNone ); |
1225 TInt blackListError( KErrNone ); |
1240 |
1226 |
1241 blackListError = GetFileFullNameAndMediaId( aFile, tempName, mediaId ); |
1227 blackListError = GetFileFullNameAndMediaId( aFile, tempName, mediaId ); |
1242 if( blackListError == KErrNone ) |
1228 if( blackListError == KErrNone ) |
1243 { |
1229 { |
1244 blackListError = AddFileToBlackList( tempName, mediaId ); |
1230 AddFileToBlackList( tempName, mediaId ); |
1245 } |
1231 } |
1246 |
1232 |
1247 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
|
1248 CleanupStack::PushL( helixMetadata ); |
|
1249 |
|
1250 TRAPD( err, helixMetadata->OpenFileL( aFile ) ); |
1233 TRAPD( err, helixMetadata->OpenFileL( aFile ) ); |
1251 aFile.Close(); |
|
1252 |
1234 |
1253 if( err == KErrNone ) |
1235 if( err == KErrNone ) |
1254 { |
1236 { |
1255 // doesn't own pointers to MIME types |
1237 // doesn't own pointers to MIME types |
1256 RPointerArray<HBufC> mimes; |
1238 RPointerArray<HBufC> mimes; |