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