40 * Play Duration, QWORD, 64 |
39 * Play Duration, QWORD, 64 |
41 * Send Duration, QWORD, 64 |
40 * Send Duration, QWORD, 64 |
42 * Preroll, QWORD, 64 |
41 * Preroll, QWORD, 64 |
43 * Flags, DWORD, 32 |
42 * Flags, DWORD, 32 |
44 */ |
43 */ |
45 const TInt KDurationOffset = 64; // duration offset from File Property object |
44 const TInt KDurationOffset = 64; // duration offset in File Property object |
46 const TInt KPrerollOffset = 80; // preRoll offset from File Property object |
45 const TInt KPrerollOffset = 80; // preRoll offset in File Property object |
47 const TInt KFlagsOffset = 88; // flags offset from File Property object |
46 const TInt KFlagsOffset = 88; // flags offset in File Property object |
|
47 const TInt KSampleRateOffset = 82; // sample rate offset in stream properties object |
|
48 const TInt KBitRateOffset = 86; // bit rate offset in stream properties object |
|
49 |
48 |
50 |
49 // ASF Header Object GUIDs |
51 // ASF Header Object GUIDs |
50 |
52 |
51 _LIT8 (KASFContentDescriptionObject, "75B22633668E11CFA6D900AA0062CE6C"); |
53 _LIT8 (KASFContentDescriptionObject, "75B22633668E11CFA6D900AA0062CE6C"); |
52 _LIT8 (KASFExtendedContentDescriptionObject, "D2D0A440E30711D297F000A0C95EA850"); |
54 _LIT8 (KASFExtendedContentDescriptionObject, "D2D0A440E30711D297F000A0C95EA850"); |
68 _LIT(KWMSharedUserRating, "WM/SharedUserRating\0"); |
70 _LIT(KWMSharedUserRating, "WM/SharedUserRating\0"); |
69 _LIT(KWMDate, "WM/OriginalReleaseTime\0"); |
71 _LIT(KWMDate, "WM/OriginalReleaseTime\0"); |
70 #ifdef __WINDOWS_MEDIA |
72 #ifdef __WINDOWS_MEDIA |
71 _LIT(KWMProvider, "WM/Provider\0"); |
73 _LIT(KWMProvider, "WM/Provider\0"); |
72 #endif |
74 #endif |
|
75 _LIT8 (KASFStreamPropertiesObject, "B7DC0791A9B711CF8EE600C00C205365"); |
73 |
76 |
74 |
77 |
75 // ============================ MEMBER FUNCTIONS =============================== |
78 // ============================ MEMBER FUNCTIONS =============================== |
76 |
79 |
77 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
181 TRAP(err, GetDurationL()); |
184 TRAP(err, GetDurationL()); |
182 TRAP(err, GetExtContDesEntryL(EMetaDataDate, iDateOffset)); |
185 TRAP(err, GetExtContDesEntryL(EMetaDataDate, iDateOffset)); |
183 #ifdef __WINDOWS_MEDIA |
186 #ifdef __WINDOWS_MEDIA |
184 TRAP(err, GetExtContDesEntryL(EMetaDataVendor, iProviderOffset)); |
187 TRAP(err, GetExtContDesEntryL(EMetaDataVendor, iProviderOffset)); |
185 #endif |
188 #endif |
|
189 TRAP(err, GetSampleRateL()); |
|
190 TRAP(err, GetBitRateL()); |
186 } |
191 } |
187 else |
192 else |
188 { |
193 { |
189 // Look for it in the wanted field array |
194 // Look for it in the wanted field array |
190 TInt count( aWantedFields.Count() ); |
195 TInt count( aWantedFields.Count() ); |
334 KASFHeaderExtensionObject) |
345 KASFHeaderExtensionObject) |
335 { |
346 { |
336 iHeaderExtensionObjectExists = ETrue; |
347 iHeaderExtensionObjectExists = ETrue; |
337 iHeaderExtensionOffset = objOffset; |
348 iHeaderExtensionOffset = objOffset; |
338 } |
349 } |
|
350 if(!iStreamPropertiesObjectExists && objGUID == |
|
351 KASFStreamPropertiesObject) |
|
352 { |
|
353 iStreamPropertiesObjectExists = ETrue; |
|
354 iStreamPropertiesOffset = objOffset; |
|
355 } |
339 TBuf8<8> size = iHeaderData->Mid(objOffset + 16, 8); |
356 TBuf8<8> size = iHeaderData->Mid(objOffset + 16, 8); |
340 TInt objSize = ConvertToInt64(size); // upper 32 bits? |
357 TInt objSize = ConvertToInt64(size); // upper 32 bits? |
341 if(0 > objSize) |
358 if(0 > objSize) |
342 { |
359 { |
343 return EFalse; |
360 return EFalse; |
344 } |
361 } |
345 objOffset += objSize; |
362 objOffset += objSize; |
346 if(objOffset >= headerSize - 30 || |
363 if(objOffset >= headerSize - 30 || |
347 (iContentDescriptionObjectExists && iFilePropertiesObjectExists |
364 (iContentDescriptionObjectExists && iFilePropertiesObjectExists |
348 && iExtendedContentDescriptionObjectExists && iHeaderExtensionObjectExists) ) |
365 && iExtendedContentDescriptionObjectExists && iHeaderExtensionObjectExists |
|
366 && iStreamPropertiesObjectExists) ) |
349 { |
367 { |
350 loop = EFalse; |
368 loop = EFalse; |
351 } |
369 } |
352 else |
370 else |
353 { |
371 { |
394 copyGUID[i] = aGUID[i]; |
412 copyGUID[i] = aGUID[i]; |
395 } |
413 } |
396 aGUID.Delete(0, 32); |
414 aGUID.Delete(0, 32); |
397 for(i = 0; i <16; i++) |
415 for(i = 0; i <16; i++) |
398 { |
416 { |
399 aGUID.AppendNumFixedWidthUC(copyGUID[i], EHex, 2); |
417 aGUID.AppendNumFixedWidthUC(copyGUID[i], EHex, 2); |
400 } |
418 } |
401 } |
419 } |
402 |
420 |
403 // ----------------------------------------------------------------------------- |
421 // ----------------------------------------------------------------------------- |
404 // CMetaDataParserWMA::ConvertToInt64 |
422 // CMetaDataParserWMA::ConvertToInt64 |
405 // ----------------------------------------------------------------------------- |
423 // ----------------------------------------------------------------------------- |
406 // |
424 // |
407 TInt64 CMetaDataParserWMA::ConvertToInt64(TDesC8& aDes) |
425 TInt64 CMetaDataParserWMA::ConvertToInt64(TDesC8& aDes) |
408 { |
426 { |
409 TInt64 num = 0; |
427 TInt64 num = 0; |
410 TInt i; |
428 TInt i; |
411 for(i = 7 ; i >= 0; i--) |
429 for(i = 7 ; i >= 0; i--) |
412 { |
430 { |
413 num <<= 8; |
431 num <<= 8; |
414 num |= aDes[i]; |
432 num |= aDes[i]; |
415 } |
433 } |
416 return num; |
434 return num; |
417 } |
435 } |
418 |
436 |
419 // ----------------------------------------------------------------------------- |
437 // ----------------------------------------------------------------------------- |
420 // CMetaDataParserWMA::ConvertToInt32 |
438 // CMetaDataParserWMA::ConvertToInt32 |
421 // ----------------------------------------------------------------------------- |
439 // ----------------------------------------------------------------------------- |
422 // |
440 // |
423 TInt CMetaDataParserWMA::ConvertToInt32(TDesC8& aDes) |
441 TInt CMetaDataParserWMA::ConvertToInt32(TDesC8& aDes) |
424 { |
442 { |
425 TInt num = 0; |
443 TInt num = 0; |
426 for(TInt i = 3 ; i >= 0; i--) |
444 for(TInt i = 3 ; i >= 0; i--) |
427 { |
445 { |
428 num <<= 8; |
446 num <<= 8; |
429 num |= aDes[i]; |
447 num |= aDes[i]; |
430 } |
448 } |
431 return num; |
449 return num; |
432 } |
450 } |
433 |
451 |
434 |
452 |
435 // ----------------------------------------------------------------------------- |
453 // ----------------------------------------------------------------------------- |
436 // CMetaDataParserWMA::ConvertToInt16 |
454 // CMetaDataParserWMA::ConvertToInt16 |
437 // ----------------------------------------------------------------------------- |
455 // ----------------------------------------------------------------------------- |
438 // |
456 // |
439 TInt CMetaDataParserWMA::ConvertToInt16(TDesC8& aDes) |
457 TInt CMetaDataParserWMA::ConvertToInt16(TDesC8& aDes) |
440 { |
458 { |
441 TInt num = 0; |
459 TInt num = 0; |
442 for(TInt i = 1 ; i >= 0; i--) |
460 for(TInt i = 1 ; i >= 0; i--) |
443 { |
461 { |
444 num <<= 8; |
462 num <<= 8; |
445 num |= aDes[i]; |
463 num |= aDes[i]; |
446 } |
464 } |
447 return num; |
465 return num; |
448 } |
466 } |
449 |
467 |
450 // ----------------------------------------------------------------------------- |
468 // ----------------------------------------------------------------------------- |
451 // CMetaDataParserWMA::ConvertDes8toDes16 |
469 // CMetaDataParserWMA::ConvertDes8toDes16 |
452 // ----------------------------------------------------------------------------- |
470 // ----------------------------------------------------------------------------- |
453 // |
471 // |
571 // ----------------------------------------------------------------------------- |
589 // ----------------------------------------------------------------------------- |
572 // CMetaDataParserWMA::GetJpegL |
590 // CMetaDataParserWMA::GetJpegL |
573 // ----------------------------------------------------------------------------- |
591 // ----------------------------------------------------------------------------- |
574 // |
592 // |
575 void CMetaDataParserWMA::GetJpegL() |
593 void CMetaDataParserWMA::GetJpegL() |
576 { |
594 { |
577 if (iPictureOffset <= 0) |
595 if (iPictureOffset <= 0) |
578 { |
596 { |
579 return; |
597 return; |
580 } |
598 } |
581 |
599 |
582 TInt offset = iPictureOffset; |
600 TInt offset = iPictureOffset; |
583 if(!iMetadatLibraryObjectJpegExists) |
601 if(!iMetadatLibraryObjectJpegExists) |
584 { |
602 { |
585 TPtrC8 dataType = iHeaderData->Mid(offset, 2); |
603 TPtrC8 dataType = iHeaderData->Mid(offset, 2); |
586 offset += 2; |
604 offset += 2; |
587 TInt dataTypeInt = ConvertToInt16(dataType); |
605 TInt dataTypeInt = ConvertToInt16(dataType); |
588 if(dataTypeInt != 1) |
606 if(dataTypeInt != 1) |
589 { |
607 { |
601 TPtrC8 picData = iHeaderData->Mid(offset, 1); |
619 TPtrC8 picData = iHeaderData->Mid(offset, 1); |
602 offset += 1; |
620 offset += 1; |
603 TInt picType = 0; |
621 TInt picType = 0; |
604 picType |= picData[0]; |
622 picType |= picData[0]; |
605 if(picType != 3) |
623 if(picType != 3) |
606 { |
624 { |
607 return; // only Front Album Cover supported |
625 return; // only Front Album Cover supported |
608 } |
626 } |
609 |
627 |
610 TPtrC8 picLengthData = iHeaderData->Mid(offset, 4); |
628 TPtrC8 picLengthData = iHeaderData->Mid(offset, 4); |
611 offset += 4; |
629 offset += 4; |
612 TInt picLength = ConvertToInt32(picLengthData); |
630 TInt picLength = ConvertToInt32(picLengthData); |
613 if(picLength <= 0) |
631 if(picLength <= 0) |
614 { |
632 { |
615 return; |
633 return; |
616 } |
634 } |
617 |
635 |
618 _LIT8(KNULL, "\0\0"); |
636 _LIT8(KNULL, "\0\0"); |
619 TPtrC8 data = iHeaderData->Mid(offset, picLength); |
637 TPtrC8 data = iHeaderData->Mid(offset, picLength); |
620 TInt pos = data.Find(KNULL); |
638 TInt pos = data.Find(KNULL); |
621 if(pos != 0) |
639 if(pos != 0) |
622 { |
640 { |
623 pos++; // for unicode coding for strings. |
641 pos++; // for unicode coding for strings. |
624 } |
642 } |
625 // check mime type |
643 // check mime type |
626 if(pos != KErrNotFound) |
644 if(pos != KErrNotFound) |
627 { |
645 { |
628 HBufC8 *mimeType = iHeaderData->Mid(offset, pos + 2).AllocLC(); |
646 HBufC8 *mimeType = iHeaderData->Mid(offset, pos + 2).AllocLC(); |
629 offset += pos + 2; |
647 offset += pos + 2; |
630 HBufC* name16 = HBufC::NewLC( (pos+2)/2); |
648 HBufC* name16 = HBufC::NewLC( (pos+2)/2); |
631 TPtr mimeType16( name16->Des() ); |
649 TPtr mimeType16( name16->Des() ); |
632 ConvertDes8toDes16(*mimeType, mimeType16); |
650 ConvertDes8toDes16(*mimeType, mimeType16); |
633 _LIT(KJPEG, "image/jpeg\0"); |
651 _LIT(KJPEG, "image/jpeg\0"); |
634 _LIT(KJPG, "image/jpg\0"); |
652 _LIT(KJPG, "image/jpg\0"); |
635 if(mimeType16.Compare(KJPEG) != 0 && mimeType16.Compare(KJPG) != 0) |
653 if(mimeType16.Compare(KJPEG) != 0 && mimeType16.Compare(KJPG) != 0) |
636 { |
654 { |
637 CleanupStack::PopAndDestroy(2, mimeType); |
655 CleanupStack::PopAndDestroy(2, mimeType); |
638 return; // only JPEG & JPG supported |
656 return; // only JPEG & JPG supported |
639 } |
657 } |
640 CleanupStack::PopAndDestroy(2); // mimeType16, mimeType |
658 CleanupStack::PopAndDestroy(2); // mimeType16, mimeType |
641 } |
659 } |
642 |
660 |
643 // skip the picture description |
661 // skip the picture description |
644 TPtrC8 picDesc = iHeaderData->Mid(offset, picLength); |
662 TPtrC8 picDesc = iHeaderData->Mid(offset, picLength); |
645 pos = picDesc.Find(KNULL); |
663 pos = picDesc.Find(KNULL); |
646 if(pos != 0) |
664 if(pos != 0) |
647 { |
665 { |
648 pos++; // for unicode coding for strings. |
666 pos++; // for unicode coding for strings. |
649 } |
667 } |
650 offset += pos + 2; |
668 offset += pos + 2; |
651 |
669 |
652 // picture data |
670 // picture data |
653 TPtrC8 pic8 = iHeaderData->Mid(offset, picLength); |
671 TPtrC8 pic8 = iHeaderData->Mid(offset, picLength); |
654 iContainer->AppendL( EMetaDataJpeg, pic8 ); |
672 iContainer->AppendL( EMetaDataJpeg, pic8 ); |
655 } |
673 } |
656 |
674 |
657 |
675 |
658 // ----------------------------------------------------------------------------- |
676 // ----------------------------------------------------------------------------- |
659 // CMetaDataParserWMA::GetExtContDesEntryL |
677 // CMetaDataParserWMA::GetExtContDesEntryL |
660 // ----------------------------------------------------------------------------- |
678 // ----------------------------------------------------------------------------- |
661 // |
679 // |
662 TBool CMetaDataParserWMA::GetExtContDesEntryL(TMetaDataFieldId aFieldId, TInt aOffset) |
680 TBool CMetaDataParserWMA::GetExtContDesEntryL(TMetaDataFieldId aFieldId, TInt aOffset) |
663 { |
681 { |
664 TBool ret = EFalse; |
682 TBool ret = EFalse; |
665 if(iExtendedContentDescriptionCount == 0) |
683 if(iExtendedContentDescriptionCount == 0) |
666 { |
684 { |
667 return ret; |
685 return ret; |
668 } |
686 } |
782 // CMetaDataParserWMA::ParseContentDescriptionObject |
800 // CMetaDataParserWMA::ParseContentDescriptionObject |
783 // ----------------------------------------------------------------------------- |
801 // ----------------------------------------------------------------------------- |
784 // |
802 // |
785 void CMetaDataParserWMA::ParseContentDescriptionObject() |
803 void CMetaDataParserWMA::ParseContentDescriptionObject() |
786 { |
804 { |
787 TBuf8<2> data = iHeaderData->Mid(iContentDescriptionOffset + 24, 2); |
805 TBuf8<2> data = iHeaderData->Mid(iContentDescriptionOffset + 24, 2); |
788 iTitleLength = ConvertToInt16(data); |
806 iTitleLength = ConvertToInt16(data); |
789 data = iHeaderData->Mid(iContentDescriptionOffset + 26, 2); |
807 data = iHeaderData->Mid(iContentDescriptionOffset + 26, 2); |
790 iAuthorLength = ConvertToInt16(data); |
808 iAuthorLength = ConvertToInt16(data); |
791 data = iHeaderData->Mid(iContentDescriptionOffset + 28, 2); |
809 data = iHeaderData->Mid(iContentDescriptionOffset + 28, 2); |
792 iCopyrightLength = ConvertToInt16(data); |
810 iCopyrightLength = ConvertToInt16(data); |
793 data = iHeaderData->Mid(iContentDescriptionOffset + 30, 2); |
811 data = iHeaderData->Mid(iContentDescriptionOffset + 30, 2); |
794 iDescriptionLength = ConvertToInt16(data); |
812 iDescriptionLength = ConvertToInt16(data); |
795 data = iHeaderData->Mid(iContentDescriptionOffset + 32, 2); |
813 data = iHeaderData->Mid(iContentDescriptionOffset + 32, 2); |
796 iRatingLength = ConvertToInt16(data); |
814 iRatingLength = ConvertToInt16(data); |
797 return; |
815 return; |
798 } |
816 } |
799 |
817 |
800 |
818 |
801 // ----------------------------------------------------------------------------- |
819 // ----------------------------------------------------------------------------- |
802 // CMetaDataParserWMA::ParseExtendedContentDescriptionObjectL |
820 // CMetaDataParserWMA::ParseExtendedContentDescriptionObjectL |
1004 loop = EFalse; |
1022 loop = EFalse; |
1005 } |
1023 } |
1006 } |
1024 } |
1007 } |
1025 } |
1008 |
1026 |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // CMetaDataParserWMA::GetSampleRateL |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // |
|
1031 void CMetaDataParserWMA::GetSampleRateL() |
|
1032 { |
|
1033 #ifdef _DEBUG |
|
1034 RDebug::Print(_L("CMetaDataParserWMA::GetSampleRateL")); |
|
1035 #endif |
|
1036 if(!iStreamPropertiesObjectExists) |
|
1037 { |
|
1038 return; |
|
1039 } |
|
1040 TInt offset = iStreamPropertiesOffset + KSampleRateOffset; |
|
1041 TPtrC8 sampleRate = iHeaderData->Mid(offset, 4); |
|
1042 if(offset+4 > iHeaderData->Length()) //Header Size is too small |
|
1043 { |
|
1044 return ; |
|
1045 } |
|
1046 |
|
1047 TInt sampleRateValue = ConvertToInt32(sampleRate); |
|
1048 TBuf16<20> des16; |
|
1049 des16.Num(sampleRateValue); // convert to string |
|
1050 |
|
1051 iContainer->AppendL( EMetaDataSampleRate, des16 ); |
|
1052 |
|
1053 #ifdef _DEBUG |
|
1054 RDebug::Print(_L("CMetaDataParserWMA::GetSampleRateL(), SampleRate=%S"), &des16); |
|
1055 #endif |
|
1056 } |
|
1057 |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // CMetaDataParserWMA::GetBitRateL |
|
1060 // ----------------------------------------------------------------------------- |
|
1061 // |
|
1062 void CMetaDataParserWMA::GetBitRateL() |
|
1063 { |
|
1064 #ifdef _DEBUG |
|
1065 RDebug::Print(_L("CMetaDataParserWMA::GetBitRateL")); |
|
1066 #endif |
|
1067 if(!iStreamPropertiesObjectExists) |
|
1068 { |
|
1069 return; |
|
1070 } |
|
1071 TInt offset = iStreamPropertiesOffset + KBitRateOffset; |
|
1072 if(offset+4 > iHeaderData->Length()) //Header Size is too small |
|
1073 { |
|
1074 return ; |
|
1075 } |
|
1076 TPtrC8 byteRate = iHeaderData->Mid(offset, 4); // byte rate |
|
1077 |
|
1078 TInt bitRateValue = ConvertToInt32(byteRate) * 8; // multiply by 8 to get bit rate |
|
1079 TBuf16<20> des16; |
|
1080 des16.Num(bitRateValue); // convert to string |
|
1081 |
|
1082 iContainer->AppendL( EMetaDataBitRate, des16 ); |
|
1083 #ifdef _DEBUG |
|
1084 RDebug::Print(_L("CMetaDataParserWMA::GetBitRateL(), bitRate=%S"), &des16); |
|
1085 #endif |
|
1086 } |
|
1087 |
1009 // End of File |
1088 // End of File |