mmserv/metadatautility/Src/MetaDataParserWMA.cpp
changeset 20 b67dd1fc57c5
parent 0 71ca22bcf22a
child 28 ebf79c79991a
equal deleted inserted replaced
19:4a629bc82c5e 20:b67dd1fc57c5
    26 #endif
    26 #endif
    27 
    27 
    28 #include <s32mem.h>
    28 #include <s32mem.h>
    29 
    29 
    30 // CONSTANTS
    30 // CONSTANTS
       
    31 /***
       
    32  *  File Properties Objects:
       
    33  *  Object ID,          GUID,   128 [bits]
       
    34  *  Object Size,        QWORD,  64 
       
    35  *  File ID,            GUID,   128 
       
    36  *  File Size,          QWORD,  64
       
    37  *  Creation Date,      QWORD,  64
       
    38  *  Data Packets Count, QWORD,  64
       
    39  *  Play Duration,      QWORD,  64
       
    40  *  Send Duration,      QWORD,  64
       
    41  *  Preroll,            QWORD,  64
       
    42  *  Flags,              DWORD,  32 
       
    43  */
       
    44 const TInt KDurationOffset  = 64;       // duration offset from File Property object
       
    45 const TInt KPrerollOffset   = 80;       // preRoll offset from File Property object
       
    46 const TInt KFlagsOffset     = 88;       // flags offset from File Property object
       
    47 
    31 // ASF Header Object GUIDs 
    48 // ASF Header Object GUIDs 
    32   
    49   
    33 _LIT8 (KASFContentDescriptionObject, "75B22633668E11CFA6D900AA0062CE6C");
    50 _LIT8 (KASFContentDescriptionObject, "75B22633668E11CFA6D900AA0062CE6C");
    34 _LIT8 (KASFExtendedContentDescriptionObject, "D2D0A440E30711D297F000A0C95EA850");
    51 _LIT8 (KASFExtendedContentDescriptionObject, "D2D0A440E30711D297F000A0C95EA850");
    35 _LIT8 (KASFHeaderObject, "75B22630668E11CFA6D900AA0062CE6C");
    52 _LIT8 (KASFHeaderObject, "75B22630668E11CFA6D900AA0062CE6C");
   693 // CMetaDataParserWMA::GetDurationL
   710 // CMetaDataParserWMA::GetDurationL
   694 // -----------------------------------------------------------------------------
   711 // -----------------------------------------------------------------------------
   695 //
   712 //
   696 void CMetaDataParserWMA::GetDurationL()
   713 void CMetaDataParserWMA::GetDurationL()
   697 	{
   714 	{
   698 	TInt offset = iFilePropertiesOffset + 16;
   715 #ifdef _DEBUG
   699 	TPtrC8 size8 = iHeaderData->Mid(offset, 8);
   716     RDebug::Print(_L("CMetaDataParserWMA::GetDuration()"));
   700 	TInt size = ConvertToInt64(size8);
   717 #endif    
   701 	offset = iFilePropertiesOffset + 88;
   718     TInt offset = iFilePropertiesOffset + KFlagsOffset;
   702 	TPtrC8 flags = iHeaderData->Mid(offset, 4);
   719     TPtrC8 flags = iHeaderData->Mid(offset, 4);
   703 	TInt broadcastBit = (TInt) (flags[0] & 0x01);
   720     TInt broadcastBit = (TInt) (flags[0] & 0x01);
   704 	if(broadcastBit == 1)
   721     if(broadcastBit == 1)
   705 		{
   722         {
   706 		return; // duration not valid.
   723         return; // duration not valid.
   707 		}
   724         }
   708 	//offset = iFilePropertiesOffset + 48;
   725     
   709 	TPtrC8 duration8 = iHeaderData->Mid(offset - 24, 8); // 100 nanosec units
   726     offset = iFilePropertiesOffset + KDurationOffset;
   710 	TReal sec = ((TReal)ConvertToInt64(duration8)) / 10000000; // seconds
   727     TPtrC8 duration8 = iHeaderData->Mid(offset, 8);     // 100 nanosec units
   711 	TBuf16<10> des16;
   728     TReal durationSec = ((TReal)ConvertToInt64(duration8)) / 10000000; // seconds
   712 	des16.Num(sec, TRealFormat (9, 3));
   729     
       
   730     offset = iFilePropertiesOffset + KPrerollOffset;
       
   731     TPtrC8 preRoll8 = iHeaderData->Mid(offset, 8);      // millisec units
       
   732     TReal preRollSec = ((TReal)ConvertToInt64(preRoll8)) / 1000; // seconds
       
   733     TReal sec = durationSec - preRollSec;               // not include preroll
       
   734 
       
   735     TBuf16<10> des16;	
       
   736     TRealFormat format(9, 3);                           // width=9, decimal place=3
       
   737     // Use fixed format, and do not use Triads
       
   738     format.iType = KRealFormatFixed | KDoNotUseTriads; 
       
   739     des16.Num(sec, format);	                            // convert to string
       
   740 	
   713 	iContainer->AppendL( EMetaDataDuration, des16 );
   741 	iContainer->AppendL( EMetaDataDuration, des16 );
       
   742 #ifdef _DEBUG
       
   743     RDebug::Print(_L("CMetaDataParserWMA::GetDuration(), duration=%f"), sec);
       
   744 #endif 	
       
   745 	
   714 	}
   746 	}
   715 
   747 
   716 
   748 
   717 
   749 
   718 // -----------------------------------------------------------------------------
   750 // -----------------------------------------------------------------------------