os/mm/mmlibs/mmfw/Recogniser/src/parsers.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/Recogniser/src/parsers.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,248 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef PARSERS_H
    1.20 +#define PARSERS_H
    1.21 +
    1.22 +#include "readers.h"
    1.23 +
    1.24 +//
    1.25 +// Utility class for performing bit operations.
    1.26 +//
    1.27 +class TFlags
    1.28 +	{
    1.29 +public:
    1.30 +	TFlags()
    1.31 +	 : iFlags(0)
    1.32 +		{
    1.33 +		}
    1.34 +		
    1.35 +	void SetExtensionFlag(){ iFlags |= KBit0; }
    1.36 +	void SetBit(TUint32 aMask) { iFlags |= aMask; }
    1.37 +	
    1.38 +	TUint32 GetBitField(TUint32 aMask, TUint8 aRightShift = 0)
    1.39 +		{
    1.40 +		return ((iFlags & aMask) >> aRightShift);
    1.41 +		}
    1.42 +		
    1.43 +private:
    1.44 +	TUint32 iFlags;
    1.45 +	};
    1.46 +
    1.47 +
    1.48 +//
    1.49 +// An ID3 tag parser.
    1.50 +//
    1.51 +class TID3Parser
    1.52 +	{
    1.53 +public:
    1.54 +	static TBool ReadAndSkipID3L(CReader& aReader);
    1.55 +	};
    1.56 +	
    1.57 +
    1.58 +//
    1.59 +// A raw-AAC audio file parser.
    1.60 +//
    1.61 +class TAACParser
    1.62 +	{
    1.63 +public:
    1.64 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
    1.65 +
    1.66 +protected:
    1.67 +	TAACParser(CReader& aReader, TFlags& aFlags);
    1.68 +	void ParseL();
    1.69 +	TInt CheckForFrameHeaderL(TInt& aFrameLength);
    1.70 +	
    1.71 +private:
    1.72 +	CReader& iReader;
    1.73 +	TFlags& iFlags;
    1.74 +	};
    1.75 +
    1.76 +
    1.77 +//
    1.78 +// A raw-MP3 audio file parser.
    1.79 +//
    1.80 +class TMP3Parser
    1.81 +	{
    1.82 +public:
    1.83 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
    1.84 +
    1.85 +protected:
    1.86 +	TMP3Parser(CReader& aReader, TFlags& aFlags);
    1.87 +	void ParseL();
    1.88 +	TInt CheckForFrameHeaderL(TInt& aFrameLength);
    1.89 +
    1.90 +private:
    1.91 +	CReader& iReader;
    1.92 +	TFlags& iFlags;
    1.93 +	};
    1.94 +
    1.95 +
    1.96 +//
    1.97 +// An MPEG4 container file format parser.
    1.98 +//
    1.99 +#define KMPEG4BoxTitleLen		4
   1.100 +
   1.101 +class TMPEG4Parser
   1.102 +	{
   1.103 +public:
   1.104 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.105 +
   1.106 +protected:
   1.107 +	TMPEG4Parser(CReader& aReader, TFlags& aFlags);
   1.108 +	const TText8* MatchFileType(const TDesC& aExt);
   1.109 +	static TInt IsCompatibleBrand(TUint32 aBrand, TInt aStartPos = 0);
   1.110 +
   1.111 +	// Parsing routines.
   1.112 +	void ParseL();
   1.113 +	void SkipCurrentBoxL();
   1.114 +	void ReadBoxHeaderL();
   1.115 +	void ReadFileTypeL();
   1.116 +	void ReadMovieL();
   1.117 +	void ReadTrackL();
   1.118 +	void ReadTrackHeaderL();
   1.119 +	void ReadMediaL();
   1.120 +	void ReadHandlerL();
   1.121 +			
   1.122 +private:
   1.123 +	// Data members.
   1.124 +	TUint32 iTitle;			// The title of the current box.
   1.125 +	TInt iBrandIndex;
   1.126 +	TBool iIsFinished;
   1.127 +	TInt64 iSize; 			// The current box's size.
   1.128 +	TBool iSizeIn32bit;
   1.129 +	CReader& iReader;
   1.130 +	TFlags& iFlags;
   1.131 +	TBool iVideoAssumed;
   1.132 +	};
   1.133 +
   1.134 +
   1.135 +//
   1.136 +// An MPEG2 container file format parser.
   1.137 +//
   1.138 +class TMPEG2Parser
   1.139 +	{
   1.140 +public:
   1.141 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.142 +
   1.143 +protected:
   1.144 +	TMPEG2Parser(CReader& aReader, TFlags& aFlags);
   1.145 +	void ParseL();
   1.146 +	TBool NextStartCodeL();
   1.147 +	void ReadPackHeaderL();
   1.148 +	void SkipL();
   1.149 +	const TText8* MatchExtension(const TDesC& aExt);
   1.150 +	
   1.151 +private:
   1.152 +	CReader& iReader;
   1.153 +	TFlags& iFlags;
   1.154 +	};
   1.155 +
   1.156 +
   1.157 +//
   1.158 +// A Matroska container file format parser.
   1.159 +//
   1.160 +class TMatroskaParser
   1.161 +	{
   1.162 +public:
   1.163 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.164 +
   1.165 +protected:
   1.166 +	TMatroskaParser(CReader& aReader, TFlags& aFlags);
   1.167 +	void ParseL();
   1.168 +	TUint64 ReadDataL(TBool aTurnOffHighestSetBit = EFalse);
   1.169 +	void ReadElementL(TUint64& aElementID, TInt64& aSize);
   1.170 +	TBool ReadSegmentL(TUint64& aNextID, TInt64& aNextSize);
   1.171 +	TBool ReadTrackL(TInt64 aTrackSize);
   1.172 +	const TText8* MatchExtension(const TDesC& aExt);
   1.173 +
   1.174 +private:
   1.175 +	CReader& iReader;
   1.176 +	TFlags& iFlags;
   1.177 +	};
   1.178 +
   1.179 +
   1.180 +//
   1.181 +// A Windows Media ASF file format parser.
   1.182 +//
   1.183 +class TASFParser
   1.184 +	{
   1.185 +public:
   1.186 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.187 +
   1.188 +protected:
   1.189 +	TASFParser(CReader& aReader, TFlags& aFlags);
   1.190 +	void ParseL();
   1.191 +	void ReadObjectL(TDes8& aGUID, TInt64& aSize);
   1.192 +	void ReadGUIDL(TDes8& aGUID);
   1.193 +	const TText8* MatchExtension(const TDesC& aExt, TBool aVideo);
   1.194 +	
   1.195 +private:
   1.196 +	CReader& iReader;
   1.197 +	TFlags& iFlags;
   1.198 +	};
   1.199 +	
   1.200 +
   1.201 +//
   1.202 +// A RealMedia file format parser.
   1.203 +//
   1.204 +class TRMParser
   1.205 +	{
   1.206 +public:
   1.207 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.208 +
   1.209 +protected:
   1.210 +	TRMParser(CReader& aReader, TFlags& aFlags);
   1.211 +	void ParseL();
   1.212 +	void ReadChunkHeaderL(TUint32& aObjectId, TUint32& aSize, TBool aFirstChunk = EFalse);
   1.213 +	void MatchExtension(const TDesC& aFileExt);
   1.214 +	TBool ReadMediaPropertiesL();
   1.215 +	
   1.216 +private:
   1.217 +	CReader& iReader;
   1.218 +	TFlags& iFlags;
   1.219 +	};
   1.220 +
   1.221 +
   1.222 +//
   1.223 +// A RAM file parser.
   1.224 +//
   1.225 +class TRAMParser
   1.226 +	{
   1.227 +public:
   1.228 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.229 +	};
   1.230 +
   1.231 +
   1.232 +//
   1.233 +// An SDP file parser.
   1.234 +//
   1.235 +class TSDPParser
   1.236 +	{
   1.237 +public:
   1.238 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.239 +	};
   1.240 +
   1.241 +
   1.242 +//
   1.243 +// An XPS file parser.
   1.244 +//
   1.245 +class TXPSParser
   1.246 +	{
   1.247 +public:
   1.248 +	static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
   1.249 +	};
   1.250 +
   1.251 +#endif