43 |
43 |
44 // local to this file, non standard mimetype used for ASF parsing with helix |
44 // local to this file, non standard mimetype used for ASF parsing with helix |
45 _LIT( KHxMimeTypeWma, "audio/x-hx-wma" ); |
45 _LIT( KHxMimeTypeWma, "audio/x-hx-wma" ); |
46 _LIT( KHxMimeTypeWmv, "video/x-hx-wmv" ); |
46 _LIT( KHxMimeTypeWmv, "video/x-hx-wmv" ); |
47 |
47 |
|
48 const TInt KMaxRenameTimes = 10; |
|
49 const TInt KRenameThreshold = 100 * 1000; // (100 millisec) |
|
50 |
48 // ----------------------------------------------------------------------------- |
51 // ----------------------------------------------------------------------------- |
49 // MmMtpDpUtility::FormatFromFilename |
52 // MmMtpDpUtility::FormatFromFilename |
50 // Utility function to get the type of an object from the filename |
53 // Utility function to get the type of an object from the filename |
51 // The recommended way from the MS implementation |
54 // The recommended way from the MS implementation |
52 // These should be kept in sync with the object formats supported |
55 // These should be kept in sync with the object formats supported |
162 else |
171 else |
163 return EFalse; |
172 return EFalse; |
164 } |
173 } |
165 |
174 |
166 // ----------------------------------------------------------------------------- |
175 // ----------------------------------------------------------------------------- |
167 // MmMtpDpUtility::IsVideo (Slow Version) |
|
168 // Utility function to determine whether a format is Video or not |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C TBool MmMtpDpUtility::IsVideo( const TDesC& aFullFileName ) |
|
172 { |
|
173 PRINT1( _L( "MM MTP => MmMtpDpUtility::IsVideoL (Slow Version) aFullFileName = %S" ), &aFullFileName ); |
|
174 |
|
175 TParsePtrC pathParser( aFullFileName ); |
|
176 TPtrC ext( pathParser.Ext() ); |
|
177 |
|
178 if ( ext.Length() <= 0 ) |
|
179 { |
|
180 PRINT( _L( "MM MTP <> MmMtpDpUtility::IsVideoL ext len <= 0, return false" ) ); |
|
181 return EFalse; |
|
182 } |
|
183 |
|
184 // move WMV early to optmize comparison |
|
185 if ( ext.CompareF( KTxtExtensionWMV ) == 0 ) |
|
186 { |
|
187 return ETrue; |
|
188 } |
|
189 else if ( ext.CompareF( KTxtExtensionMP4 ) == 0 |
|
190 || ext.CompareF( KTxtExtension3GP ) == 0 |
|
191 || ext.CompareF( KTxtExtension3G2 ) == 0 |
|
192 || ext.CompareF( KTxtExtensionODF ) == 0 |
|
193 || ext.CompareF( KTxtExtensionASF ) == 0 ) |
|
194 { |
|
195 HBufC8* mimetype = ContainerMimeType( aFullFileName ); |
|
196 if ( mimetype != NULL ) |
|
197 { |
|
198 TMmMtpSubFormatCode subFormatCode; |
|
199 |
|
200 TInt err = SubFormatCodeFromMime(*mimetype, subFormatCode); |
|
201 PRINT1( _L( "MM MTP <> MmMtpDpUtility::IsVideoL SubFormatCodeFromMime err = %d" ), err ); |
|
202 |
|
203 if ( subFormatCode == EMTPSubFormatCodeVideo ) |
|
204 { |
|
205 return ETrue; |
|
206 } |
|
207 } |
|
208 } |
|
209 else if ( ext.CompareF( KTxtExtensionO4V ) == 0 ) |
|
210 return ETrue; |
|
211 |
|
212 // NOTE: Treate all non-video files as audio files even it's not audio |
|
213 // since the entry is not going to be find out in MPX |
|
214 // we can handle that situation gracefully. |
|
215 return EFalse; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // MmMtpDpUtility::IsVideoL (Fast Version) |
|
220 // Utility function to determine whether a format is Video or not |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TBool MmMtpDpUtility::IsVideoL( const TDesC& aFullFileName, |
|
224 const MMTPDataProviderFramework& aFramework ) |
|
225 { |
|
226 PRINT1( _L( "MM MTP => MmMtpDpUtility::IsVideoL (Fast Version) aFullFileName = %S" ), &aFullFileName ); |
|
227 |
|
228 CMTPObjectMetaData* info = CMTPObjectMetaData::NewLC(); // + info |
|
229 aFramework.ObjectMgr().ObjectL( aFullFileName, *info ); |
|
230 |
|
231 TUint formatCode = info->Uint( CMTPObjectMetaData::EFormatCode ); |
|
232 TUint subFormatCode = info->Uint( CMTPObjectMetaData::EFormatSubCode ); |
|
233 TBool ifNeedParse = ( ( formatCode == EMTPFormatCodeMP4Container ) |
|
234 || ( formatCode == EMTPFormatCode3GPContainer ) |
|
235 || ( formatCode== EMTPFormatCodeASF ) ) |
|
236 && ( subFormatCode == EMTPSubFormatCodeUnknown ); |
|
237 TBool isVideo = EFalse; |
|
238 if ( ifNeedParse ) |
|
239 { |
|
240 isVideo = MmMtpDpUtility::IsVideo( aFullFileName ); |
|
241 subFormatCode = isVideo ? EMTPSubFormatCodeVideo : EMTPSubFormatCodeAudio; |
|
242 |
|
243 // Once we got the subformat code, set it into fw db |
|
244 aFramework.ObjectMgr().ModifyObjectL( *info ); |
|
245 } |
|
246 else |
|
247 { |
|
248 isVideo = MmMtpDpUtility::IsVideoL( formatCode, subFormatCode ); |
|
249 } |
|
250 |
|
251 CleanupStack::PopAndDestroy( info ); // - info |
|
252 |
|
253 return isVideo; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // MmMtpDpUtility::IsVideoL (Fast Version) |
|
258 // Utility function to determine whether a format is Video or not |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 TBool MmMtpDpUtility::IsVideoL( TUint aFormatCode, TUint aSubFormatCode ) |
|
262 { |
|
263 if ( aFormatCode == KMTPFormatsAll ) |
|
264 User::Leave( KErrArgument ); |
|
265 |
|
266 if ( aFormatCode == EMTPFormatCodeWMV ) |
|
267 { |
|
268 return ETrue; |
|
269 } |
|
270 else if ( ( aFormatCode == EMTPFormatCodeMP4Container ) |
|
271 || ( aFormatCode == EMTPFormatCode3GPContainer ) |
|
272 || ( aFormatCode == EMTPFormatCodeASF ) ) |
|
273 { |
|
274 if ( aSubFormatCode == EMTPSubFormatCodeAudio ) |
|
275 { |
|
276 return EFalse; |
|
277 } |
|
278 else if ( aSubFormatCode == EMTPSubFormatCodeVideo ) |
|
279 { |
|
280 return ETrue; |
|
281 } |
|
282 } |
|
283 |
|
284 PRINT( _L( "MM MTP <= MmMtpDpUtility::IsVideoL (Fast Version)" ) ); |
|
285 |
|
286 // other format, as audio |
|
287 return EFalse; |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // MmMtpDpUtility::ValidateFilename |
176 // MmMtpDpUtility::ValidateFilename |
292 // Check the filename to see if it exceeds Symbian 256 limit. |
177 // Check the filename to see if it exceeds Symbian 256 limit. |
293 // ----------------------------------------------------------------------------- |
178 // ----------------------------------------------------------------------------- |
294 // |
179 // |
295 TBool MmMtpDpUtility::ValidateFilename( const TDesC& aPathName, |
180 TBool MmMtpDpUtility::ValidateFilename( const TDesC& aPathName, |
321 // ----------------------------------------------------------------------------- |
206 // ----------------------------------------------------------------------------- |
322 // MmMtpDpUtility::GetDateModifiedL |
207 // MmMtpDpUtility::GetDateModifiedL |
323 // Get the file date modified. |
208 // Get the file date modified. |
324 // ----------------------------------------------------------------------------- |
209 // ----------------------------------------------------------------------------- |
325 // |
210 // |
326 TTime MmMtpDpUtility::GetObjectDateModifiedL( RFs& aFs, const TDesC& aFullFileName ) |
211 void MmMtpDpUtility::GetObjectDateModifiedL( RFs& aFs, const TDesC& aFullFileName, TDes& aDateModified ) |
327 { |
212 { |
328 TTime dataModified; |
213 TTime date; |
329 TEntry fileInfo; |
214 TEntry fileInfo; |
330 // Shouldn't leave |
215 // Shouldn't leave |
331 User::LeaveIfError( aFs.Entry( aFullFileName, fileInfo ) ); |
216 User::LeaveIfError( aFs.Entry( aFullFileName, fileInfo ) ); |
332 |
217 date = fileInfo.iModified; |
333 dataModified = fileInfo.iModified; |
218 date.FormatL( aDateModified, KMtpDateTimeFormat ); |
334 |
|
335 return dataModified; |
|
336 } |
219 } |
337 |
220 |
338 // ----------------------------------------------------------------------------- |
221 // ----------------------------------------------------------------------------- |
339 // MmMtpDpUtility::GetProtectionStatusL |
222 // MmMtpDpUtility::GetProtectionStatusL |
340 // Get the file protection status. |
223 // Get the file protection status. |
418 |
306 |
419 //Uint32 properties |
307 //Uint32 properties |
420 case EMTPObjectPropCodeWidth: // 0xDC87 |
308 case EMTPObjectPropCodeWidth: // 0xDC87 |
421 case EMTPObjectPropCodeHeight: // 0xDC88 |
309 case EMTPObjectPropCodeHeight: // 0xDC88 |
422 case EMTPObjectPropCodeDuration: // 0xDC89 |
310 case EMTPObjectPropCodeDuration: // 0xDC89 |
423 case EMTPObjectPropCodeUseCount: // 0xDC91 |
|
424 case EMTPObjectPropCodeSampleRate: // 0xDE93 |
311 case EMTPObjectPropCodeSampleRate: // 0xDE93 |
425 case EMTPObjectPropCodeAudioWAVECodec: // 0xDE99 |
312 case EMTPObjectPropCodeAudioWAVECodec: // 0xDE99 |
426 case EMTPObjectPropCodeAudioBitRate: // 0xDE9A |
313 case EMTPObjectPropCodeAudioBitRate: // 0xDE9A |
427 case EMTPObjectPropCodeVideoFourCCCodec: // 0xDE9B |
314 case EMTPObjectPropCodeVideoFourCCCodec: // 0xDE9B |
428 case EMTPObjectPropCodeFramesPerThousandSeconds: // 0xDE9D |
315 case EMTPObjectPropCodeFramesPerThousandSeconds: // 0xDE9D |
491 else |
387 else |
492 { |
388 { |
493 aNewName.Insert( 0, ptr ); |
389 aNewName.Insert( 0, ptr ); |
494 } |
390 } |
495 |
391 |
496 return aFs.Rename( aFullFileName, aNewName ); |
392 TInt ret = KErrNone; |
|
393 // Some other component might be holding on to the file (MDS background harvesting), |
|
394 // try again after 100 millisec, up to 10 times, before give up |
|
395 TInt count = KMaxRenameTimes; |
|
396 while ( count > 0 ) |
|
397 { |
|
398 ret = aFs.Rename( aFullFileName, aNewName ); |
|
399 if ( ( ret == KErrInUse ) && ( count > 1 ) ) |
|
400 { |
|
401 User::After( KRenameThreshold ); |
|
402 count--; |
|
403 } |
|
404 else |
|
405 { |
|
406 break; |
|
407 } |
|
408 } |
|
409 |
|
410 PRINT1( _L( "MM MTP <> MmMtpDpUtility::UpdateObjectFileName, ret = %d" ), ret ); |
|
411 |
|
412 return ret; |
497 } |
413 } |
498 |
414 |
499 // ----------------------------------------------------------------------------- |
415 // ----------------------------------------------------------------------------- |
500 // MetadataAccessWrapper::ContainerMimeType |
416 // MetadataAccessWrapper::ContainerMimeType |
501 // Get mime type from file |
417 // Get mime type from file |
772 // ----------------------------------------------------------------------------- |
688 // ----------------------------------------------------------------------------- |
773 // MetadataAccessWrapper::SubFormatCodeFromMime |
689 // MetadataAccessWrapper::SubFormatCodeFromMime |
774 // Get subformat code from mime string |
690 // Get subformat code from mime string |
775 // ----------------------------------------------------------------------------- |
691 // ----------------------------------------------------------------------------- |
776 // |
692 // |
777 TInt MmMtpDpUtility::SubFormatCodeFromMime( const TDesC8& aMimeType, |
693 TMmMtpSubFormatCode MmMtpDpUtility::SubFormatCodeFromMime( const TDesC8& aMimeType ) |
778 TMmMtpSubFormatCode& aSubFormatCode ) |
|
779 { |
694 { |
780 PRINT( _L( "MM MTP => MmMtpDpUtility::SubFormatCodeFromMime" ) ); |
695 PRINT( _L( "MM MTP => MmMtpDpUtility::SubFormatCodeFromMime" ) ); |
|
696 |
|
697 TMmMtpSubFormatCode subFormatCode = EMTPSubFormatCodeUnknown; |
781 |
698 |
782 if ( aMimeType.CompareF( KMimeTypeVideoMp4 ) == 0 |
699 if ( aMimeType.CompareF( KMimeTypeVideoMp4 ) == 0 |
783 || aMimeType.CompareF( KMimeTypeVideo3gpp ) == 0 |
700 || aMimeType.CompareF( KMimeTypeVideo3gpp ) == 0 |
784 #ifdef __WINDOWS_MEDIA |
701 #ifdef __WINDOWS_MEDIA |
785 || aMimeType.CompareF( KMimeTypeVideoWm ) == 0 |
702 || aMimeType.CompareF( KMimeTypeVideoWm ) == 0 |
786 #endif |
703 #endif |
787 ) |
704 ) |
788 { |
705 { |
789 aSubFormatCode = EMTPSubFormatCodeVideo; |
706 subFormatCode = EMTPSubFormatCodeVideo; |
790 } |
707 } |
791 else if ( aMimeType.CompareF( KMimeTypeAudioMp4 ) == 0 |
708 else if ( aMimeType.CompareF( KMimeTypeAudioMp4 ) == 0 |
792 || aMimeType.CompareF( KMimeTypeAudio3gpp ) == 0 |
709 || aMimeType.CompareF( KMimeTypeAudio3gpp ) == 0 |
793 #ifdef __WINDOWS_MEDIA |
710 #ifdef __WINDOWS_MEDIA |
794 || aMimeType.CompareF( KMimeTypeAudioWm ) == 0 |
711 || aMimeType.CompareF( KMimeTypeAudioWm ) == 0 |
795 #endif |
712 #endif |
796 ) |
713 ) |
797 { |
714 { |
798 aSubFormatCode = EMTPSubFormatCodeAudio; |
715 subFormatCode = EMTPSubFormatCodeAudio; |
799 } |
716 } |
800 else |
717 else |
801 { |
718 { |
802 PRINT( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime format not supported" ) ); |
719 PRINT( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime format not supported" ) ); |
803 return KErrNotFound; |
720 subFormatCode = EMTPSubFormatCodeUndefine; |
804 } |
721 } |
805 |
722 |
806 PRINT( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime" ) ); |
723 PRINT1( _L( "MM MTP <= MmMtpDpUtility::SubFormatCodeFromMime SubFormatCode = %d" ), subFormatCode ); |
807 return KErrNone; |
724 |
|
725 return subFormatCode; |
808 } |
726 } |
809 |
727 |
810 // ----------------------------------------------------------------------------- |
728 // ----------------------------------------------------------------------------- |
811 // MetadataAccessWrapper::GetDrmStatus |
729 // MetadataAccessWrapper::GetDrmStatus |
812 // Get drm status code from file |
730 // Get drm status code from file |