|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Harvests meta data from video file.* |
|
15 */ |
|
16 |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32std.h> |
|
20 #include <3gplibrary/mp4lib.h> |
|
21 #include <hxmetadatautil.h> |
|
22 #include <hxmetadatakeys.h> |
|
23 |
|
24 #include "mdsutils.h" |
|
25 #include "harvestervideoplugin.h" |
|
26 #include "harvesterlog.h" |
|
27 #include "harvesterblacklist.h" |
|
28 #include "mdeobjectwrapper.h" |
|
29 |
|
30 #include <mdenamespacedef.h> |
|
31 #include <mdeobjectdef.h> |
|
32 #include <mdepropertydef.h> |
|
33 #include <mdeobject.h> |
|
34 #include <harvesterdata.h> |
|
35 #include <mdeconstants.h> |
|
36 |
|
37 using namespace MdeConstants; |
|
38 |
|
39 _LIT( KMimeTypeVideoMp4, "video/mp4" ); |
|
40 _LIT( KMimeTypeAudioMp4, "audio/mp4" ); |
|
41 _LIT( KMimeTypeVideo3gpp, "video/3gpp" ); |
|
42 _LIT( KMimeTypeAudio3gpp, "audio/3gpp" ); |
|
43 _LIT( KMimeTypeRm, "application/vnd.rn-realmedia" ); // can be audio or video |
|
44 _LIT( KMimeTypeRmvb, "application/vnd.rn-realmedia-vbr" ); // can be audio or video |
|
45 _LIT( KMimeTypeRv, "video/vnd.rn-realvideo" ); |
|
46 _LIT( KMimeTypeRa, "audio/vnd.rn-realaudio" ); |
|
47 _LIT( KMimeTypeAvi, "video/avi"); |
|
48 _LIT( KMimeTypeVideoMatroska, "video/x-matroska"); |
|
49 _LIT( KMimeTypeAudioMatroska, "audio/x-matroska"); |
|
50 |
|
51 _LIT( KExtensionMp4, "mp4" ); |
|
52 _LIT( KExtensionMpg4, "mpg4" ); |
|
53 _LIT( KExtensionMpeg4, "mpeg4" ); |
|
54 _LIT( KExtensionM4v, "m4v" ); |
|
55 _LIT( KExtensionM4a, "m4a" ); |
|
56 _LIT( KExtension3gp, "3gp" ); |
|
57 _LIT( KExtension3gpp, "3gpp" ); |
|
58 _LIT( KExtension3g2, "3g2" ); |
|
59 _LIT( KExtensionRm, "rm" ); |
|
60 _LIT( KExtensionRmvb, "rmvb" ); |
|
61 _LIT( KExtensionRv, "rv" ); |
|
62 _LIT( KExtensionAvi, "avi" ); |
|
63 _LIT( KExtensionMkv, "mkv" ); |
|
64 _LIT( KExtensionRa, "ra" ); |
|
65 |
|
66 _LIT(KVideo, "Video"); |
|
67 _LIT(KAudio, "Audio"); |
|
68 |
|
69 _LIT(KAudioAC3, "audio/AC3"); |
|
70 _LIT(KAudioEAC3, "audio/EAC3"); |
|
71 const TUint32 KMDSFourCCCodeAC3 = 0x33434120; //{' ', 'A', 'C', '3'} |
|
72 const TUint32 KMDSFourCCCodeEAC3 = 0x33434145; //{'E', 'A', 'C', '3'} |
|
73 |
|
74 _LIT(KInUse, "InUse"); |
|
75 |
|
76 const TInt KKiloBytes = 1024; |
|
77 const TReal32 KThousandReal = 1000.0; |
|
78 |
|
79 CHarvesterVideoPluginPropertyDefs::CHarvesterVideoPluginPropertyDefs() : CBase() |
|
80 { |
|
81 } |
|
82 |
|
83 void CHarvesterVideoPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef) |
|
84 { |
|
85 CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef(); |
|
86 |
|
87 // Common property definitions |
|
88 CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject ); |
|
89 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty ); |
|
90 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty ); |
|
91 iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty ); |
|
92 iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty ); |
|
93 iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty ); |
|
94 |
|
95 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject ); |
|
96 iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty ); |
|
97 iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty ); |
|
98 iDurationPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDurationProperty ); |
|
99 iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty ); |
|
100 iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty ); |
|
101 iBitratePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KBitrateProperty ); |
|
102 iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty ); |
|
103 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KAuthorProperty ); |
|
104 iGenrePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KGenreProperty ); |
|
105 iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty ); |
|
106 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty ); |
|
107 |
|
108 iAudioFourCCDef = &mediaDef.GetPropertyDefL( MediaObject::KAudioFourCCProperty ); |
|
109 |
|
110 // Video property definitions |
|
111 CMdEObjectDef& videoDef = nsDef.GetObjectDefL( Video::KVideoObject ); |
|
112 iFrameratePropertyDef = &videoDef.GetPropertyDefL( Video::KFramerateProperty ); |
|
113 |
|
114 // Audio property definitions |
|
115 CMdEObjectDef& audioDef = nsDef.GetObjectDefL( Audio::KAudioObject ); |
|
116 iSamplingFrequencyPropertyDef = &audioDef.GetPropertyDefL( Audio::KSamplingFrequencyProperty ); |
|
117 } |
|
118 |
|
119 CHarvesterVideoPluginPropertyDefs* CHarvesterVideoPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef) |
|
120 { |
|
121 CHarvesterVideoPluginPropertyDefs* self = |
|
122 new (ELeave) CHarvesterVideoPluginPropertyDefs(); |
|
123 CleanupStack::PushL( self ); |
|
124 self->ConstructL( aObjectDef ); |
|
125 CleanupStack::Pop( self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 /** |
|
130 * Default constructor |
|
131 */ |
|
132 CHarvesterVideoPlugin::CHarvesterVideoPlugin() : CHarvesterPlugin(), iPropDefs( NULL ) |
|
133 { |
|
134 } |
|
135 |
|
136 /** |
|
137 * Construction |
|
138 * @return Harvester image plugin |
|
139 */ |
|
140 CHarvesterVideoPlugin* CHarvesterVideoPlugin::NewL() |
|
141 { |
|
142 WRITELOG("CHarvesterVideoPlugin::NewL()"); |
|
143 CHarvesterVideoPlugin* self = new(ELeave) CHarvesterVideoPlugin(); |
|
144 CleanupStack::PushL(self); |
|
145 self->ConstructL(); |
|
146 CleanupStack::Pop(self); |
|
147 return self; |
|
148 } |
|
149 |
|
150 /** |
|
151 * Destruction |
|
152 */ |
|
153 CHarvesterVideoPlugin::~CHarvesterVideoPlugin() |
|
154 { |
|
155 delete iPropDefs; |
|
156 |
|
157 WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()"); |
|
158 } |
|
159 |
|
160 /** |
|
161 * 2nd phase constructor |
|
162 */ |
|
163 void CHarvesterVideoPlugin::ConstructL() |
|
164 { |
|
165 WRITELOG( "CHarvesterVideoPlugin::ConstructL() - begin" ); |
|
166 |
|
167 TLinearOrder< THarvestingHandling > cmp( THarvestingHandling::CompareFunction ); |
|
168 |
|
169 // MPEG4 |
|
170 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
171 KExtensionMp4(), KNullDesC(), |
|
172 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
173 KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), |
|
174 cmp ) ); |
|
175 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
176 KExtensionMpg4(), KNullDesC(), |
|
177 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
178 KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), |
|
179 cmp ) ); |
|
180 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
181 KExtensionMpeg4(), KNullDesC(), |
|
182 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
183 KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), |
|
184 cmp ) ); |
|
185 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
186 KExtensionM4v(), KMimeTypeVideoMp4(), |
|
187 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KVideo(), |
|
188 KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), |
|
189 cmp ) ); |
|
190 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
191 KExtensionM4a(), KMimeTypeAudioMp4(), |
|
192 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KAudio(), |
|
193 KMimeTypeVideoMp4(), KMimeTypeAudioMp4() ) ), |
|
194 cmp ) ); |
|
195 |
|
196 // 3GP |
|
197 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
198 KExtension3gp(), KNullDesC(), |
|
199 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
200 KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), |
|
201 cmp ) ); |
|
202 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
203 KExtension3gpp(), KNullDesC(), |
|
204 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
205 KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), |
|
206 cmp ) ); |
|
207 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
208 KExtension3g2(), KNullDesC(), |
|
209 TVideoMetadataHandling( TVideoMetadataHandling::EMp4LibHandling, KNullDesC(), |
|
210 KMimeTypeVideo3gpp(), KMimeTypeAudio3gpp() ) ), |
|
211 cmp ) ); |
|
212 |
|
213 // RealMedia |
|
214 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
215 KExtensionRm(), KNullDesC(), |
|
216 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(), |
|
217 KMimeTypeRm(), KMimeTypeRm() ) ), |
|
218 cmp ) ); |
|
219 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
220 KExtensionRmvb(), KNullDesC(), |
|
221 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(), |
|
222 KMimeTypeRmvb(), KMimeTypeRmvb() ) ), |
|
223 cmp ) ); |
|
224 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
225 KExtensionRv(), KMimeTypeRv(), |
|
226 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(), |
|
227 KMimeTypeRv(), KMimeTypeRa() ) ), |
|
228 cmp ) ); |
|
229 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
230 KExtensionRa(), KMimeTypeRa(), |
|
231 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KAudio(), |
|
232 KMimeTypeRv(), KMimeTypeRa() ) ), |
|
233 cmp ) ); |
|
234 |
|
235 // Avi |
|
236 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
237 KExtensionAvi(), KMimeTypeAvi(), |
|
238 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(), |
|
239 KMimeTypeAvi(), KMimeTypeAvi() ) ), |
|
240 cmp ) ); |
|
241 |
|
242 // Matroska |
|
243 User::LeaveIfError( iMimeTypeMappings.InsertInOrder( THarvestingHandling( |
|
244 KExtensionMkv(), KNullDesC(), |
|
245 TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KNullDesC(), |
|
246 KMimeTypeVideoMatroska(), KMimeTypeAudioMatroska() ) ), |
|
247 cmp ) ); |
|
248 } |
|
249 |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // GetObjectType |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CHarvesterVideoPlugin::GetObjectType( const TDesC& aUri, TDes& aObjectType ) |
|
256 { |
|
257 aObjectType.Zero(); |
|
258 |
|
259 const THarvestingHandling* mapping = FindHandler( aUri ); |
|
260 |
|
261 // no matching extension found |
|
262 if( !mapping ) |
|
263 { |
|
264 return; |
|
265 } |
|
266 |
|
267 const TVideoMetadataHandling& handler = mapping->iHandler; |
|
268 |
|
269 // object def is defined by extension |
|
270 if( handler.iObjectDef.Length() > 0 ) |
|
271 { |
|
272 aObjectType.Copy( handler.iObjectDef ); |
|
273 return; |
|
274 } |
|
275 |
|
276 RFile64 file; |
|
277 // File must not be allowed to be written to here. If file passes through |
|
278 // here while it is still open for writing, it will fail in actual harvesting |
|
279 // and will not be processed again until the file is modified |
|
280 const TInt error = file.Open( iFs, aUri, EFileRead | EFileShareReadersOnly ); |
|
281 if ( error != KErrNone ) |
|
282 { |
|
283 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - File open error: %d", error ); |
|
284 if( error == KErrInUse ) |
|
285 { |
|
286 aObjectType.Copy( KInUse() ); |
|
287 } |
|
288 return; |
|
289 } |
|
290 |
|
291 if( handler.iLibrary == TVideoMetadataHandling::EMp4LibHandling ) |
|
292 { |
|
293 GetMp4Type( file, aObjectType ); |
|
294 } |
|
295 else if( handler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
|
296 { |
|
297 TRAP_IGNORE( GetRmTypeL( file, aObjectType ) ); |
|
298 } |
|
299 else |
|
300 { |
|
301 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - ERROR: %S. No handling library found", &aUri ); |
|
302 } |
|
303 |
|
304 file.Close(); |
|
305 } |
|
306 |
|
307 void CHarvesterVideoPlugin::HarvestL( CHarvesterData* aHD ) |
|
308 { |
|
309 CMdEObject& mdeObject = aHD->MdeObject(); |
|
310 CVideoHarvestData* fileData = new (ELeave) CVideoHarvestData; |
|
311 CleanupStack::PushL( fileData ); |
|
312 |
|
313 #ifdef _DEBUG |
|
314 WRITELOG1("CHarvesterVideoPlugin::HarvestL - aHD->Uri() %S", &aHD->Uri() ); |
|
315 WRITELOG1("CHarvesterVideoPlugin::HarvestL - mdeObject.Uri() %S", &mdeObject.Uri() ); |
|
316 #endif |
|
317 |
|
318 TRAPD( error, GatherDataL( mdeObject, *fileData ) ); |
|
319 if ( error == KErrNone || error == KErrCompletion ) |
|
320 { |
|
321 TBool isNewObject( mdeObject.Id() == 0 ); |
|
322 |
|
323 if ( isNewObject || mdeObject.Placeholder() ) |
|
324 { |
|
325 TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, ETrue ) ); |
|
326 mdeObject.SetPlaceholder( EFalse ); |
|
327 } |
|
328 else |
|
329 { |
|
330 TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, EFalse ) ); |
|
331 } |
|
332 |
|
333 if ( error != KErrNone ) |
|
334 { |
|
335 WRITELOG1( "CHarvesterVideoPlugin::HarvestSingleFileL() - Handling object failed: ", error ); |
|
336 } |
|
337 } |
|
338 else |
|
339 { |
|
340 WRITELOG1( "CHarvesterVideoPlugin::HarvestSingleFileL() - TRAP error: %d", error ); |
|
341 TInt convertedError = KErrNone; |
|
342 MdsUtils::ConvertTrapError( error, convertedError ); |
|
343 aHD->SetErrorCode( convertedError ); |
|
344 } |
|
345 |
|
346 CleanupStack::PopAndDestroy( fileData ); |
|
347 } |
|
348 |
|
349 // --------------------------------------------------------------------------- |
|
350 // GatherDataL |
|
351 // --------------------------------------------------------------------------- |
|
352 // |
|
353 void CHarvesterVideoPlugin::GatherDataL( CMdEObject& aMetadataObject, |
|
354 CVideoHarvestData& aVHD ) |
|
355 { |
|
356 const TDesC& uri = aMetadataObject.Uri(); |
|
357 |
|
358 WRITELOG1( "CHarvesterVideoPlugin - Gather data from file %S", &uri ); |
|
359 |
|
360 RFile64 file; |
|
361 TInt error = file.Open( iFs, uri, EFileRead | EFileShareReadersOnly ); |
|
362 CleanupClosePushL( file ); |
|
363 if ( error == KErrInUse || |
|
364 error == KErrLocked ) |
|
365 { |
|
366 WRITELOG( "CHarvesterVideoPlugin - File is open!" ); |
|
367 CleanupStack::PopAndDestroy( &file ); |
|
368 User::Leave( KErrInUse ); |
|
369 } |
|
370 else if( error == KErrNotFound || |
|
371 error == KErrPathNotFound || |
|
372 error == KErrDisMounted || |
|
373 error == KErrBadDescriptor ) |
|
374 { |
|
375 WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error ); |
|
376 CleanupStack::PopAndDestroy( &file ); |
|
377 User::Leave( error ); |
|
378 } |
|
379 |
|
380 TBool dataExtracted( aMetadataObject.Id() == 0 || aMetadataObject.Placeholder() ); |
|
381 |
|
382 if( dataExtracted ) |
|
383 { |
|
384 CMdEProperty* prop = NULL; |
|
385 CMdEObjectDef& objectDef = aMetadataObject.Def(); |
|
386 CMdEPropertyDef& sizeDef = objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
|
387 aMetadataObject.Property( sizeDef, prop ); |
|
388 if( prop ) |
|
389 { |
|
390 aVHD.iFileSize = prop->Uint32ValueL(); |
|
391 } |
|
392 else |
|
393 { |
|
394 dataExtracted = EFalse; |
|
395 } |
|
396 CMdEPropertyDef& modifiedDef = objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
|
397 aMetadataObject.Property( modifiedDef, prop ); |
|
398 if( prop ) |
|
399 { |
|
400 aVHD.iModified = prop->TimeValueL(); |
|
401 } |
|
402 else |
|
403 { |
|
404 dataExtracted = EFalse; |
|
405 } |
|
406 } |
|
407 |
|
408 if( !dataExtracted ) |
|
409 { |
|
410 TEntry entry; |
|
411 const TInt errorcode = iFs.Entry( uri, entry ); |
|
412 |
|
413 if ( errorcode != KErrNone ) |
|
414 { |
|
415 WRITELOG1( "CHarvesterVideoPlugin - Error getting entry: %d", errorcode ); |
|
416 CleanupStack::PopAndDestroy( &file ); |
|
417 User::Leave( errorcode ); |
|
418 } |
|
419 |
|
420 aVHD.iModified = entry.iModified; |
|
421 aVHD.iFileSize = (TUint)entry.iSize; |
|
422 } |
|
423 |
|
424 WRITELOG1( "CHarvesterVideoPlugin - File size: %d", aVHD.iFileSize ); |
|
425 |
|
426 // now the minimum information has been harvested |
|
427 // from now on the harvested data should always be stored |
|
428 |
|
429 const THarvestingHandling* mapping = FindHandler( uri ); |
|
430 |
|
431 if( !mapping ) |
|
432 { |
|
433 CleanupStack::PopAndDestroy( &file ); |
|
434 User::Leave( KErrNotFound ); |
|
435 } |
|
436 |
|
437 aVHD.iVideoObject = aMetadataObject.Def().Name().Compare( KVideo ) == 0; |
|
438 |
|
439 if( error != KErrNone ) |
|
440 { |
|
441 WRITELOG1( "CHarvesterVideoPlugin - File open error: %d", error ); |
|
442 CleanupStack::PopAndDestroy( &file ); |
|
443 User::Leave( KErrCompletion ); |
|
444 } |
|
445 |
|
446 if ( mapping->iHandler.iLibrary == TVideoMetadataHandling::EHexilMetadataHandling ) |
|
447 { |
|
448 // doesn't own pointers to MIME types |
|
449 RPointerArray<HBufC> mimes; |
|
450 CleanupClosePushL( mimes ); |
|
451 |
|
452 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
|
453 CleanupStack::PushL( helixMetadata ); |
|
454 |
|
455 TRAP( error, helixMetadata->OpenFileL( file ) ); |
|
456 |
|
457 if ( error == KErrNone ) |
|
458 { |
|
459 HBufC *buf = NULL; |
|
460 HXMetaDataKeys::EHXMetaDataId metaid; |
|
461 TUint metacount = 0; |
|
462 helixMetadata->GetMetaDataCount( metacount ); |
|
463 TLex lex; |
|
464 for ( TUint i = 0; i < metacount; i++ ) |
|
465 { |
|
466 helixMetadata->GetMetaDataAt( i, metaid, buf ); |
|
467 switch (metaid) |
|
468 { |
|
469 case HXMetaDataKeys::EHXVideoBitRate: |
|
470 { |
|
471 WRITELOG( "CHarvesterVideoPlugin - found videobitrate" ); |
|
472 if( aVHD.iVideoObject ) |
|
473 { |
|
474 lex.Assign( *buf ); |
|
475 if( KErrNone == lex.Val( aVHD.iVideoBitrate ) ) |
|
476 { |
|
477 aVHD.iVideoBitrate /= KKiloBytes; |
|
478 } |
|
479 } |
|
480 break; |
|
481 } |
|
482 case HXMetaDataKeys::EHXAudioBitRate: |
|
483 { |
|
484 WRITELOG( "CHarvesterVideoPlugin - found audiobitrate" ); |
|
485 lex.Assign( *buf ); |
|
486 if( KErrNone == lex.Val( aVHD.iAudioBitrate ) ) |
|
487 { |
|
488 aVHD.iAudioBitrate /= KKiloBytes; |
|
489 } |
|
490 break; |
|
491 } |
|
492 case HXMetaDataKeys::EHXClipBitRate: |
|
493 { |
|
494 WRITELOG( "CHarvesterVideoPlugin - found clipbitrate" ); |
|
495 lex.Assign( *buf ); |
|
496 if( KErrNone == lex.Val( aVHD.iClipBitrate ) ) |
|
497 { |
|
498 aVHD.iClipBitrate /= KKiloBytes; |
|
499 } |
|
500 break; |
|
501 } |
|
502 case HXMetaDataKeys::EHXDuration: |
|
503 { |
|
504 WRITELOG( "CHarvesterVideoPlugin - found duration" ); |
|
505 lex.Assign(*buf); |
|
506 if( KErrNone == lex.Val( aVHD.iDuration ) ) |
|
507 { |
|
508 aVHD.iDuration /= KThousandReal; |
|
509 } |
|
510 break; |
|
511 } |
|
512 case HXMetaDataKeys::EHXFramesPerSecond: |
|
513 { |
|
514 WRITELOG( "CHarvesterVideoPlugin - found framerate" ); |
|
515 lex.Assign( *buf ); |
|
516 lex.Val( aVHD.iFrameRate ); |
|
517 break; |
|
518 } |
|
519 case HXMetaDataKeys::EHXCopyright: |
|
520 { |
|
521 aVHD.iCopyright = buf->Alloc(); |
|
522 break; |
|
523 } |
|
524 case HXMetaDataKeys::EHXAuthor: |
|
525 { |
|
526 aVHD.iAuthor = buf->Alloc(); |
|
527 break; |
|
528 } |
|
529 case HXMetaDataKeys::EHXGenre: |
|
530 { |
|
531 aVHD.iGenre = buf->Alloc(); |
|
532 break; |
|
533 } |
|
534 case HXMetaDataKeys::EHXPerformer: |
|
535 { |
|
536 aVHD.iPerformer = buf->Alloc(); |
|
537 break; |
|
538 } |
|
539 case HXMetaDataKeys::EHXDescription: |
|
540 { |
|
541 aVHD.iDescription = buf->Alloc(); |
|
542 break; |
|
543 } |
|
544 case HXMetaDataKeys::EHXMimeType: |
|
545 { |
|
546 mimes.AppendL( buf ); |
|
547 if( aVHD.iCodec == 0 ) |
|
548 { |
|
549 CheckForCodecSupport( buf, aVHD ); |
|
550 } |
|
551 break; |
|
552 } |
|
553 case HXMetaDataKeys::EHXFrameSize: |
|
554 { |
|
555 const TChar separator = 'x'; // as in e.g."177x144" |
|
556 const TInt separatorLocation = buf->Locate( separator ); |
|
557 TLex input( buf->Left( separatorLocation ) ); |
|
558 |
|
559 input.Val( aVHD.iFrameWidth ); |
|
560 input = buf->Right(buf->Length() - separatorLocation - 1); |
|
561 input.Val( aVHD.iFrameHeight ); |
|
562 break; |
|
563 } |
|
564 default: |
|
565 break; |
|
566 } |
|
567 } |
|
568 } |
|
569 |
|
570 const TInt mimeCount = mimes.Count(); |
|
571 |
|
572 TPtrC mime( NULL, 0 ); |
|
573 |
|
574 // if metadata didn't contain MIME, get it from extension mapping |
|
575 if( mimeCount == 0 ) |
|
576 { |
|
577 if( aVHD.iVideoObject ) |
|
578 { |
|
579 mime.Set( mapping->iHandler.iVideoMime.Ptr(), |
|
580 mapping->iHandler.iVideoMime.Length() ); |
|
581 } |
|
582 else |
|
583 { |
|
584 mime.Set( mapping->iHandler.iAudioMime.Ptr(), |
|
585 mapping->iHandler.iAudioMime.Length() ); |
|
586 } |
|
587 } |
|
588 // otherwise search from MIME type array |
|
589 else |
|
590 { |
|
591 for( TInt i = 0; i < mimeCount; i++ ) |
|
592 { |
|
593 HBufC* mimeTmp = mimes[i]; |
|
594 |
|
595 if( !mimeTmp ) |
|
596 { |
|
597 continue; |
|
598 } |
|
599 |
|
600 mime.Set( mimeTmp->Des().Ptr(), mimeTmp->Des().Length() ); |
|
601 |
|
602 // MIME contains substring "application/vnd.rn-realmedia". |
|
603 // That case MIME matches also with |
|
604 // string "application/vnd.rn-realmedia-vbr". |
|
605 if( MdsUtils::Find( mime, KMimeTypeRm() ) != KErrNotFound ) |
|
606 { |
|
607 break; |
|
608 } |
|
609 // Match MIME type, for video object with "video" substring |
|
610 else if( aVHD.iVideoObject ) |
|
611 { |
|
612 if( MdsUtils::Find( mime, KVideo() ) != KErrNotFound ) |
|
613 { |
|
614 break; |
|
615 } |
|
616 } |
|
617 // Match MIME type for audio object with "audio" substring |
|
618 else if( MdsUtils::Find( mime, KAudio() ) != KErrNotFound ) |
|
619 { |
|
620 break; |
|
621 } |
|
622 } |
|
623 } |
|
624 |
|
625 if( mime.Ptr() && ( mime.Length() > 0 ) ) |
|
626 { |
|
627 aVHD.iMimeBuf = mime.Alloc(); |
|
628 } |
|
629 |
|
630 CleanupStack::PopAndDestroy( helixMetadata ); |
|
631 |
|
632 // don't destory mime type pointers just clean array |
|
633 CleanupStack::PopAndDestroy( &mimes ); |
|
634 } |
|
635 else if( mapping->iHandler.iLibrary == TVideoMetadataHandling::EMp4LibHandling ) |
|
636 { |
|
637 MP4Handle handle( 0 ); |
|
638 MP4Err mp4err = MP4_OK; |
|
639 |
|
640 WRITELOG( "CHarvesterVideoPlugin - Before open file handle to parse" ); |
|
641 |
|
642 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseOpenFileHandle - start" ); |
|
643 |
|
644 mp4err = MP4ParseOpenFileHandle64( &handle, &file ); |
|
645 |
|
646 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseOpenFileHandle - ready" ); |
|
647 |
|
648 if ( mp4err != MP4_OK ) |
|
649 { |
|
650 WRITELOG( "CHarvesterVideoPlugin - Error opening file handle" ); |
|
651 |
|
652 CleanupStack::PopAndDestroy( &file ); |
|
653 User::Leave( KErrCompletion ); |
|
654 } |
|
655 |
|
656 WRITELOG( "CHarvesterVideoPlugin - Start gathering" ); |
|
657 |
|
658 if( aVHD.iVideoObject ) |
|
659 { |
|
660 mp4_u32 videolength( 0 ); |
|
661 mp4_double framerate( 0 ); |
|
662 mp4_u32 videotype( 0 ); |
|
663 mp4_u32 videowidth( 0 ); |
|
664 mp4_u32 videoheight( 0 ); |
|
665 mp4_u32 timescale( 0 ); |
|
666 |
|
667 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestVideoDescription - start" ); |
|
668 mp4err = MP4ParseRequestVideoDescription( handle, &videolength, &framerate, |
|
669 &videotype, &videowidth, &videoheight, ×cale ); |
|
670 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestVideoDescription - ready" ); |
|
671 |
|
672 if ( mp4err == MP4_OK ) |
|
673 { |
|
674 aVHD.iDuration = videolength / KThousandReal; |
|
675 aVHD.iFrameRate = framerate; |
|
676 aVHD.iFrameWidth = videowidth; |
|
677 aVHD.iFrameHeight = videoheight; |
|
678 } |
|
679 |
|
680 mp4_u32 streamSize( 0 ); |
|
681 mp4_u32 avgBitrate( 0 ); |
|
682 |
|
683 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestStreamDescription - start" ); |
|
684 mp4err = MP4ParseRequestStreamDescription( handle, &streamSize, &avgBitrate ); |
|
685 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestStreamDescription - ready" ); |
|
686 |
|
687 if ( mp4err == MP4_OK ) |
|
688 { |
|
689 aVHD.iClipBitrate = avgBitrate / KKiloBytes; |
|
690 } |
|
691 |
|
692 aVHD.iMimeBuf = mapping->iHandler.iVideoMime.Alloc(); |
|
693 } |
|
694 else |
|
695 { |
|
696 mp4_u32 audiolength; |
|
697 mp4_u32 audiotype; |
|
698 mp4_u8 framespersample; |
|
699 mp4_u32 timescale; |
|
700 mp4_u32 averagebitrate; |
|
701 |
|
702 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestVideoDescription - start" ); |
|
703 mp4err = MP4ParseRequestAudioDescription( handle, &audiolength, &audiotype, |
|
704 &framespersample, ×cale, &averagebitrate ); |
|
705 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseRequestAudioDescription - ready" ); |
|
706 |
|
707 if ( mp4err == MP4_OK ) |
|
708 { |
|
709 aVHD.iDuration = audiolength / KThousandReal; |
|
710 aVHD.iSamplingFrequency = timescale; |
|
711 aVHD.iAudioBitrate = averagebitrate / KKiloBytes; |
|
712 } |
|
713 |
|
714 aVHD.iMimeBuf = mapping->iHandler.iAudioMime.Alloc(); |
|
715 } |
|
716 |
|
717 WRITELOG( "CHarvesterVideoPlugin - Stop gathering" ); |
|
718 |
|
719 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseClose - start" ); |
|
720 mp4err = MP4ParseClose( handle ); |
|
721 WRITELOG( "CHarvesterVideoPlugin - GatherDataL - MP4ParseClose - ready" ); |
|
722 if ( mp4err != MP4_OK ) |
|
723 { |
|
724 WRITELOG( "CHarvesterVideoPlugin - Error closing file handle" ); |
|
725 } |
|
726 } |
|
727 WRITELOG( "CHarvesterVideoPlugin - Closing file" ); |
|
728 CleanupStack::PopAndDestroy( &file ); |
|
729 |
|
730 WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" ); |
|
731 } |
|
732 |
|
733 // --------------------------------------------------------------------------- |
|
734 // HandleNewObjectL |
|
735 // --------------------------------------------------------------------------- |
|
736 // |
|
737 void CHarvesterVideoPlugin::HandleObjectPropertiesL( |
|
738 CHarvesterData& aHD, |
|
739 CVideoHarvestData& aVHD, |
|
740 TBool aIsAdd ) |
|
741 { |
|
742 WRITELOG("CHarvesterVideoPlugin::HandleObjectPropertiesL "); |
|
743 |
|
744 CMdEObject& mdeObject = aHD.MdeObject(); |
|
745 |
|
746 if( !iPropDefs ) |
|
747 { |
|
748 CMdEObjectDef& objectDef = mdeObject.Def(); |
|
749 iPropDefs = CHarvesterVideoPluginPropertyDefs::NewL( objectDef ); |
|
750 } |
|
751 |
|
752 TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset(); |
|
753 TTime localModifiedDate = aVHD.iModified + timeOffsetSeconds; |
|
754 |
|
755 if( !mdeObject.Placeholder() ) |
|
756 { |
|
757 // Creation date |
|
758 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd ); |
|
759 |
|
760 // Last modified date |
|
761 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd ); |
|
762 |
|
763 // File size |
|
764 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd ); |
|
765 } |
|
766 |
|
767 // Release date |
|
768 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iReleaseDatePropertyDef, &localModifiedDate, aIsAdd ); |
|
769 |
|
770 // Capture date |
|
771 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCaptureDatePropertyDef, &localModifiedDate, aIsAdd ); |
|
772 |
|
773 // Time offset |
|
774 TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60; |
|
775 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd ); |
|
776 |
|
777 // Item Type |
|
778 if( aVHD.iMimeBuf ) |
|
779 { |
|
780 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, aVHD.iMimeBuf, aIsAdd ); |
|
781 } |
|
782 |
|
783 // Duration |
|
784 if( aVHD.iDuration != 0.0f ) |
|
785 { |
|
786 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDurationPropertyDef, &aVHD.iDuration, aIsAdd ); |
|
787 } |
|
788 |
|
789 if( aVHD.iVideoObject ) |
|
790 { |
|
791 // Width |
|
792 if (aVHD.iFrameWidth != 0) |
|
793 { |
|
794 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iWidthPropertyDef, &aVHD.iFrameWidth, aIsAdd ); |
|
795 } |
|
796 |
|
797 // Height |
|
798 if (aVHD.iFrameHeight != 0) |
|
799 { |
|
800 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iHeightPropertyDef, &aVHD.iFrameHeight, aIsAdd ); |
|
801 } |
|
802 |
|
803 // Framerate |
|
804 if (aVHD.iFrameRate != 0) |
|
805 { |
|
806 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iFrameratePropertyDef, &aVHD.iFrameRate, aIsAdd ); |
|
807 } |
|
808 } |
|
809 else // audio object |
|
810 { |
|
811 // Sampling frequency |
|
812 if (aVHD.iSamplingFrequency != 0.0f) |
|
813 { |
|
814 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSamplingFrequencyPropertyDef, &aVHD.iSamplingFrequency, aIsAdd ); |
|
815 } |
|
816 } |
|
817 |
|
818 // Bitrate |
|
819 if (aVHD.iClipBitrate != 0) |
|
820 { |
|
821 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iClipBitrate, aIsAdd ); |
|
822 } |
|
823 else |
|
824 { |
|
825 if( aVHD.iVideoObject ) |
|
826 { |
|
827 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iVideoBitrate, aIsAdd ); |
|
828 } |
|
829 else // audio object |
|
830 { |
|
831 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitratePropertyDef, &aVHD.iAudioBitrate, aIsAdd ); |
|
832 } |
|
833 } |
|
834 |
|
835 // Copyright |
|
836 if( aVHD.iCopyright ) |
|
837 { |
|
838 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCopyrightPropertyDef, aVHD.iCopyright, aIsAdd ); |
|
839 } |
|
840 |
|
841 // Author |
|
842 if( aVHD.iAuthor ) |
|
843 { |
|
844 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAuthorPropertyDef, aVHD.iAuthor, aIsAdd ); |
|
845 } |
|
846 |
|
847 // Genre |
|
848 if( aVHD.iGenre ) |
|
849 { |
|
850 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iGenrePropertyDef, aVHD.iGenre, aIsAdd ); |
|
851 } |
|
852 |
|
853 // Artist |
|
854 if( aVHD.iPerformer ) |
|
855 { |
|
856 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iArtistPropertyDef, aVHD.iPerformer, aIsAdd ); |
|
857 } |
|
858 |
|
859 // Description |
|
860 if( aVHD.iDescription ) |
|
861 { |
|
862 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDescriptionPropertyDef, aVHD.iDescription, aIsAdd ); |
|
863 } |
|
864 |
|
865 // Codec |
|
866 if( aVHD.iCodec != 0 ) |
|
867 { |
|
868 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iAudioFourCCDef, &aVHD.iCodec, aIsAdd ); |
|
869 } |
|
870 } |
|
871 |
|
872 void CHarvesterVideoPlugin::GetMp4Type( RFile64& aFile, TDes& aType ) |
|
873 { |
|
874 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseOpenFileHandle - start" ); |
|
875 MP4Handle handle; |
|
876 |
|
877 MP4Err mp4err = MP4ParseOpenFileHandle64( &handle, &aFile ); |
|
878 |
|
879 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseOpenFileHandle - ready" ); |
|
880 |
|
881 if ( mp4err != MP4_OK ) |
|
882 { |
|
883 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - Error opening file handle" ); |
|
884 return; |
|
885 } |
|
886 |
|
887 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseRequestVideoDescription - start" ); |
|
888 mp4_u32 videolength; |
|
889 mp4_double framerate; |
|
890 mp4_u32 videowidth; |
|
891 mp4_u32 videoheight; |
|
892 mp4_u32 timescale; |
|
893 mp4_u32 videotype; |
|
894 mp4err = MP4ParseRequestVideoDescription( handle, &videolength, |
|
895 &framerate, &videotype, &videowidth, &videoheight, ×cale ); |
|
896 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - MP4ParseRequestVideoDescription - ready" ); |
|
897 |
|
898 // If no video stream found, set to Audio |
|
899 if ( mp4err == MP4_NO_VIDEO ) |
|
900 { |
|
901 WRITELOG( "CHarvesterVideoPlugin::GetMp4Mime - No video stream found, set to Audio" ); |
|
902 aType.Copy( KAudio() ); |
|
903 } |
|
904 // Otherwise set to Video, regardless how badly file is corrupted |
|
905 else |
|
906 { |
|
907 aType.Copy( KVideo() ); |
|
908 } |
|
909 |
|
910 MP4ParseClose( handle ); |
|
911 } |
|
912 |
|
913 void CHarvesterVideoPlugin::GetRmTypeL( RFile64& aFile, TDes& aType ) |
|
914 { |
|
915 TBool possibleVideo = EFalse; |
|
916 |
|
917 CHXMetaDataUtility* helixMetadata = CHXMetaDataUtility::NewL(); |
|
918 CleanupStack::PushL( helixMetadata ); |
|
919 |
|
920 TRAPD( err, helixMetadata->OpenFileL( aFile ) ); |
|
921 |
|
922 if( err == KErrNone ) |
|
923 { |
|
924 // doesn't own pointers to MIME types |
|
925 RPointerArray<HBufC> mimes; |
|
926 CleanupClosePushL( mimes ); |
|
927 |
|
928 TUint metacount = 0; |
|
929 helixMetadata->GetMetaDataCount(metacount); |
|
930 for (TUint i = 0; i < metacount; i++) |
|
931 { |
|
932 HBufC *buf = NULL; |
|
933 HXMetaDataKeys::EHXMetaDataId metaid; |
|
934 helixMetadata->GetMetaDataAt( i, metaid, buf ); |
|
935 if( metaid == HXMetaDataKeys::EHXMimeType ) |
|
936 { |
|
937 mimes.AppendL( buf ); |
|
938 } |
|
939 else if( metaid == HXMetaDataKeys::EHXVideoBitRate ) |
|
940 { |
|
941 possibleVideo = ETrue; |
|
942 } |
|
943 } |
|
944 |
|
945 const TInt mimeCount = mimes.Count(); |
|
946 |
|
947 // at least one MIME type must be found |
|
948 if( mimeCount == 0 ) |
|
949 { |
|
950 User::Leave( KErrNotFound ); |
|
951 } |
|
952 |
|
953 for( TInt i = 0; i < mimeCount; i++ ) |
|
954 { |
|
955 HBufC* mime = mimes[i]; |
|
956 |
|
957 // "application/vnd.rn-realmedia" or "application/vnd.rn-realmedia-vbr" |
|
958 if( MdsUtils::Find( *mime, KMimeTypeRm() ) != KErrNotFound ) |
|
959 { |
|
960 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - mimetype %S. Object type Rm", mime ); |
|
961 if( possibleVideo ) |
|
962 { |
|
963 aType.Copy( KVideo ); |
|
964 } |
|
965 else |
|
966 { |
|
967 aType.Copy( KAudio ); |
|
968 } |
|
969 |
|
970 break; |
|
971 } |
|
972 else if( MdsUtils::Find( *mime, KVideo() ) != KErrNotFound ) |
|
973 { |
|
974 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - mimetype %S. Object type Video", mime ); |
|
975 aType.Copy( KVideo ); |
|
976 |
|
977 // use MIME with "video" substring, if file might be video |
|
978 if( possibleVideo ) |
|
979 { |
|
980 break; |
|
981 } |
|
982 } |
|
983 else if( MdsUtils::Find( *mime, KAudio() ) != KErrNotFound ) |
|
984 { |
|
985 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - mimetype %S. Object type Audio", mime ); |
|
986 aType.Copy( KAudio ); |
|
987 } |
|
988 // Set to Video, regardless how badly file is corrupted |
|
989 else |
|
990 { |
|
991 aType.Copy( KVideo ); |
|
992 } |
|
993 } |
|
994 |
|
995 // don't destory mime type pointers just clean array |
|
996 CleanupStack::PopAndDestroy( &mimes ); |
|
997 } |
|
998 // Set to Video, regardless how badly file is corrupted |
|
999 else |
|
1000 { |
|
1001 aType.Copy( KVideo ); |
|
1002 } |
|
1003 |
|
1004 CleanupStack::PopAndDestroy( helixMetadata ); |
|
1005 } |
|
1006 |
|
1007 const THarvestingHandling* CHarvesterVideoPlugin::FindHandler( const TDesC& aUri ) |
|
1008 { |
|
1009 TParsePtrC parse( aUri ); |
|
1010 TPtrC ext = parse.Ext(); |
|
1011 |
|
1012 // remove '.' from extension |
|
1013 if ( ext.Length() > 1 ) |
|
1014 { |
|
1015 ext.Set( ext.Mid( 1 ) ); |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - ERROR: %S. No any extension found", &aUri ); |
|
1020 return NULL; |
|
1021 } |
|
1022 |
|
1023 THarvestingHandling finder( ext ); |
|
1024 |
|
1025 TLinearOrder<THarvestingHandling> cmp(THarvestingHandling::CompareFunction); |
|
1026 |
|
1027 TInt pos = iMimeTypeMappings.FindInOrder( finder, cmp ); |
|
1028 |
|
1029 // no matching extension found or extension is missing from filename |
|
1030 if( KErrNotFound == pos || ext.Length() <= 0 ) |
|
1031 { |
|
1032 WRITELOG1( "CHarvesterVideoPlugin::GetObjectType - ERROR: %S. No extension found", &aUri ); |
|
1033 return NULL; |
|
1034 } |
|
1035 |
|
1036 const THarvestingHandling* mapping = &iMimeTypeMappings[pos]; |
|
1037 |
|
1038 return mapping; |
|
1039 } |
|
1040 |
|
1041 void CHarvesterVideoPlugin::CheckForCodecSupport( HBufC* aMimeBuffer, CVideoHarvestData& aVHD ) |
|
1042 { |
|
1043 if( !aMimeBuffer ) |
|
1044 { |
|
1045 return; |
|
1046 } |
|
1047 |
|
1048 TPtrC mime( NULL, 0 ); |
|
1049 mime.Set( aMimeBuffer->Des().Ptr(), aMimeBuffer->Des().Length() ); |
|
1050 |
|
1051 if( MdsUtils::Find( mime, KAudioAC3() ) != KErrNotFound ) |
|
1052 { |
|
1053 aVHD.iCodec = KMDSFourCCCodeAC3; |
|
1054 return; |
|
1055 } |
|
1056 |
|
1057 if( MdsUtils::Find( mime, KAudioEAC3() ) != KErrNotFound ) |
|
1058 { |
|
1059 aVHD.iCodec = KMDSFourCCCodeEAC3; |
|
1060 return; |
|
1061 } |
|
1062 return; |
|
1063 } |
|
1064 |
|
1065 // End of file |
|
1066 |