0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#ifndef PARSERS_H
|
|
17 |
#define PARSERS_H
|
|
18 |
|
|
19 |
#include "readers.h"
|
|
20 |
|
|
21 |
//
|
|
22 |
// Utility class for performing bit operations.
|
|
23 |
//
|
|
24 |
class TFlags
|
|
25 |
{
|
|
26 |
public:
|
|
27 |
TFlags()
|
|
28 |
: iFlags(0)
|
|
29 |
{
|
|
30 |
}
|
|
31 |
|
|
32 |
void SetExtensionFlag(){ iFlags |= KBit0; }
|
|
33 |
void SetBit(TUint32 aMask) { iFlags |= aMask; }
|
|
34 |
|
|
35 |
TUint32 GetBitField(TUint32 aMask, TUint8 aRightShift = 0)
|
|
36 |
{
|
|
37 |
return ((iFlags & aMask) >> aRightShift);
|
|
38 |
}
|
|
39 |
|
|
40 |
private:
|
|
41 |
TUint32 iFlags;
|
|
42 |
};
|
|
43 |
|
|
44 |
|
|
45 |
//
|
|
46 |
// An ID3 tag parser.
|
|
47 |
//
|
|
48 |
class TID3Parser
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
static TBool ReadAndSkipID3L(CReader& aReader);
|
|
52 |
};
|
|
53 |
|
|
54 |
|
|
55 |
//
|
|
56 |
// A raw-AAC audio file parser.
|
|
57 |
//
|
|
58 |
class TAACParser
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
62 |
|
|
63 |
protected:
|
|
64 |
TAACParser(CReader& aReader, TFlags& aFlags);
|
|
65 |
void ParseL();
|
|
66 |
TInt CheckForFrameHeaderL(TInt& aFrameLength);
|
|
67 |
|
|
68 |
private:
|
|
69 |
CReader& iReader;
|
|
70 |
TFlags& iFlags;
|
|
71 |
};
|
|
72 |
|
|
73 |
|
|
74 |
//
|
|
75 |
// A raw-MP3 audio file parser.
|
|
76 |
//
|
|
77 |
class TMP3Parser
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
81 |
|
|
82 |
protected:
|
|
83 |
TMP3Parser(CReader& aReader, TFlags& aFlags);
|
|
84 |
void ParseL();
|
|
85 |
TInt CheckForFrameHeaderL(TInt& aFrameLength);
|
|
86 |
|
|
87 |
private:
|
|
88 |
CReader& iReader;
|
|
89 |
TFlags& iFlags;
|
|
90 |
};
|
|
91 |
|
|
92 |
|
|
93 |
//
|
|
94 |
// An MPEG4 container file format parser.
|
|
95 |
//
|
|
96 |
#define KMPEG4BoxTitleLen 4
|
|
97 |
|
|
98 |
class TMPEG4Parser
|
|
99 |
{
|
|
100 |
public:
|
|
101 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
102 |
|
|
103 |
protected:
|
|
104 |
TMPEG4Parser(CReader& aReader, TFlags& aFlags);
|
|
105 |
const TText8* MatchFileType(const TDesC& aExt);
|
|
106 |
static TInt IsCompatibleBrand(TUint32 aBrand, TInt aStartPos = 0);
|
|
107 |
|
|
108 |
// Parsing routines.
|
|
109 |
void ParseL();
|
|
110 |
void SkipCurrentBoxL();
|
|
111 |
void ReadBoxHeaderL();
|
|
112 |
void ReadFileTypeL();
|
|
113 |
void ReadMovieL();
|
|
114 |
void ReadTrackL();
|
|
115 |
void ReadTrackHeaderL();
|
|
116 |
void ReadMediaL();
|
|
117 |
void ReadHandlerL();
|
|
118 |
|
|
119 |
private:
|
|
120 |
// Data members.
|
|
121 |
TUint32 iTitle; // The title of the current box.
|
|
122 |
TInt iBrandIndex;
|
|
123 |
TBool iIsFinished;
|
|
124 |
TInt64 iSize; // The current box's size.
|
|
125 |
TBool iSizeIn32bit;
|
|
126 |
CReader& iReader;
|
|
127 |
TFlags& iFlags;
|
|
128 |
TBool iVideoAssumed;
|
|
129 |
};
|
|
130 |
|
|
131 |
|
|
132 |
//
|
|
133 |
// An MPEG2 container file format parser.
|
|
134 |
//
|
|
135 |
class TMPEG2Parser
|
|
136 |
{
|
|
137 |
public:
|
|
138 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
139 |
|
|
140 |
protected:
|
|
141 |
TMPEG2Parser(CReader& aReader, TFlags& aFlags);
|
|
142 |
void ParseL();
|
|
143 |
TBool NextStartCodeL();
|
|
144 |
void ReadPackHeaderL();
|
|
145 |
void SkipL();
|
|
146 |
const TText8* MatchExtension(const TDesC& aExt);
|
|
147 |
|
|
148 |
private:
|
|
149 |
CReader& iReader;
|
|
150 |
TFlags& iFlags;
|
|
151 |
};
|
|
152 |
|
|
153 |
|
|
154 |
//
|
|
155 |
// A Matroska container file format parser.
|
|
156 |
//
|
|
157 |
class TMatroskaParser
|
|
158 |
{
|
|
159 |
public:
|
|
160 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
161 |
|
|
162 |
protected:
|
|
163 |
TMatroskaParser(CReader& aReader, TFlags& aFlags);
|
|
164 |
void ParseL();
|
|
165 |
TUint64 ReadDataL(TBool aTurnOffHighestSetBit = EFalse);
|
|
166 |
void ReadElementL(TUint64& aElementID, TInt64& aSize);
|
|
167 |
TBool ReadSegmentL(TUint64& aNextID, TInt64& aNextSize);
|
|
168 |
TBool ReadTrackL(TInt64 aTrackSize);
|
|
169 |
const TText8* MatchExtension(const TDesC& aExt);
|
|
170 |
|
|
171 |
private:
|
|
172 |
CReader& iReader;
|
|
173 |
TFlags& iFlags;
|
|
174 |
};
|
|
175 |
|
|
176 |
|
|
177 |
//
|
|
178 |
// A Windows Media ASF file format parser.
|
|
179 |
//
|
|
180 |
class TASFParser
|
|
181 |
{
|
|
182 |
public:
|
|
183 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
184 |
|
|
185 |
protected:
|
|
186 |
TASFParser(CReader& aReader, TFlags& aFlags);
|
|
187 |
void ParseL();
|
|
188 |
void ReadObjectL(TDes8& aGUID, TInt64& aSize);
|
|
189 |
void ReadGUIDL(TDes8& aGUID);
|
|
190 |
const TText8* MatchExtension(const TDesC& aExt, TBool aVideo);
|
|
191 |
|
|
192 |
private:
|
|
193 |
CReader& iReader;
|
|
194 |
TFlags& iFlags;
|
|
195 |
};
|
|
196 |
|
|
197 |
|
|
198 |
//
|
|
199 |
// A RealMedia file format parser.
|
|
200 |
//
|
|
201 |
class TRMParser
|
|
202 |
{
|
|
203 |
public:
|
|
204 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
205 |
|
|
206 |
protected:
|
|
207 |
TRMParser(CReader& aReader, TFlags& aFlags);
|
|
208 |
void ParseL();
|
|
209 |
void ReadChunkHeaderL(TUint32& aObjectId, TUint32& aSize, TBool aFirstChunk = EFalse);
|
|
210 |
void MatchExtension(const TDesC& aFileExt);
|
|
211 |
TBool ReadMediaPropertiesL();
|
|
212 |
|
|
213 |
private:
|
|
214 |
CReader& iReader;
|
|
215 |
TFlags& iFlags;
|
|
216 |
};
|
|
217 |
|
|
218 |
|
|
219 |
//
|
|
220 |
// A RAM file parser.
|
|
221 |
//
|
|
222 |
class TRAMParser
|
|
223 |
{
|
|
224 |
public:
|
|
225 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
226 |
};
|
|
227 |
|
|
228 |
|
|
229 |
//
|
|
230 |
// An SDP file parser.
|
|
231 |
//
|
|
232 |
class TSDPParser
|
|
233 |
{
|
|
234 |
public:
|
|
235 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
236 |
};
|
|
237 |
|
|
238 |
|
|
239 |
//
|
|
240 |
// An XPS file parser.
|
|
241 |
//
|
|
242 |
class TXPSParser
|
|
243 |
{
|
|
244 |
public:
|
|
245 |
static void DoRecognise(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
|
|
246 |
};
|
|
247 |
|
|
248 |
#endif
|