• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /**
19  * @file pv_avifile.h
20  * @brief avi file parser utility
21  */
22 
23 #ifndef PV_AVIFILE_H_INCLUDED
24 #define PV_AVIFILE_H_INCLUDED
25 
26 #ifndef PV_AVIFILE_TYPEDEFS_H_INCLUDED
27 #include "pv_avifile_typedefs.h"
28 #endif
29 
30 /**
31  * PVAviFile is an avi file parser utility. This allows user to retrieve media data and media data
32  * properties from avi file.
33  */
34 
35 class PVAviFile: public PVAviFileParserStatus
36 {
37     public:
38 
39         /**
40          * Creates parser Object and parse AVI File.
41          *
42          * @param aFileName avi file name
43          * @return arError error occured while parsing
44          * @param aFileServer file server
45          * @param aCPM CMP Plugin Interface
46          * @param aHandle file handle
47          * @return pointer to PVAviFile
48          */
49 
50         OSCL_IMPORT_REF static PVAviFile*  CreateAviFileParser(OSCL_wHeapString<OsclMemAllocator> aFileName, int32& arError,
51                 Oscl_FileServer* aFileServer = NULL, PVMFCPMPluginAccessInterfaceFactory*  aCPM = NULL,
52                 OsclFileHandle*  aHandle = NULL);
53 
54         /**
55          * Destroys parser Object.
56          * @param apAviFileParser pointer to avi parser object
57          */
58 
59         OSCL_IMPORT_REF static void DeleteAviFileParser(PVAviFile* apAviFileParser);
60 
61         /** Destructor */
~PVAviFile()62         virtual ~PVAviFile() {};
63 
64         /**
65          * function to retrieve media samples from avi file.
66          *
67          * @param aBuffer buffer for media sample
68          * @return aStreamNo stream number
69          * @return aSize size of data filled in aBuffer
70          * @return aTimeStamp timestamp of the media sample
71          */
72 
73         OSCL_IMPORT_REF virtual PV_AVI_FILE_PARSER_ERROR_TYPE
74         GetNextMediaSample(uint32& aStreamNo, uint8* aBuffer, uint32& arSize,
75                            uint32& arTimeStamp) = 0;
76 
77         /**
78          * function to retrieve media samples for a stream in avi file. this function
79          * will use index table if present otherwise it will search the movi chunk to
80          * get media sample for the specified stream.
81          *
82          * @param aBuffer buffer for media sample
83          * @param aStreamNo stream number
84          * @return aSize size of data filled in aBuffer
85          * @return aTimeStamp timestamp of the media sample
86          */
87 
88         OSCL_IMPORT_REF virtual PV_AVI_FILE_PARSER_ERROR_TYPE
89         GetNextStreamMediaSample(uint32 aStreamNo, uint8* aBuffer,
90                                  uint32& arSize, uint32& arTimeStamp) = 0;
91 
92 
93         /**
94          * function to retrieve media samples information for a stream in avi file. this function
95          * will use index table if present otherwise it will return failure
96          *
97          * @param aStreamNo stream number
98          * @return arSize sample size
99          * @return arOffset sample offset in file
100          */
101 
102         OSCL_IMPORT_REF virtual PV_AVI_FILE_PARSER_ERROR_TYPE
103         GetNextStreamSampleInfo(uint32 aStreamNo, uint32& arSize, uint32& arOffset) = 0;
104 
105         /**
106          * function to reset stream pointers to retrieve data from the begining. .
107          * @param
108          * @return
109          */
110 
111         OSCL_IMPORT_REF virtual void Reset() = 0;
112 
113         /**
114          * function to reset stream pointer to retrieve stream data from the begining. .
115          * @param aStreamNo stream number
116          * @return
117          */
118 
119         OSCL_IMPORT_REF virtual void Reset(uint32 aStreamNo) = 0;
120 
121         /**
122          * function to retrieve avi file properties.
123          * @param
124          * @return structure of type PVAviFileMainHeaderStruct
125          */
126 
127         OSCL_IMPORT_REF virtual PVAviFileMainHeaderStruct GetMainHeaderStruct() = 0;
128 
129         /**
130          * function to get avi file duration.
131          * @param
132          * @return file duration in Seconds
133          */
134 
135         OSCL_IMPORT_REF virtual uint32 GetFileDuration() = 0;
136 
137         /**
138          * function to retrieve stream numbers.
139          * @param
140          * @return micro seconds per frame.
141          */
142 
143         OSCL_IMPORT_REF virtual uint32 GetFrameDuration() = 0;
144 
145         /**
146          * function to retrieve stream numbers.
147          * @param
148          * @return vector of stream numbers
149          */
150 
151         OSCL_IMPORT_REF virtual Oscl_Vector<uint32, OsclMemAllocator>  GetStreamCountList() = 0;
152 
153         /**
154         * function to retrieve stream numbers.
155         * @param
156         * @return vector of Audio stream numbers
157         */
158 
159         OSCL_IMPORT_REF virtual Oscl_Vector<uint32, OsclMemAllocator>  GetAudioStreamCountList() = 0;
160 
161         /**
162         * function to retrieve stream numbers.
163         * @param
164         * @return vector of Video stream numbers
165         */
166 
167         OSCL_IMPORT_REF virtual Oscl_Vector<uint32, OsclMemAllocator>  GetVideoStreamCountList() = 0;
168 
169         /**
170          * function to retrieve number of streams.
171          * @param
172          * @return number of streams
173          */
174 
175         OSCL_IMPORT_REF virtual uint32 GetNumStreams() = 0;
176 
177         /**
178          * function to retrieve average buffer size of the file.
179          * @param
180          * @return average buffer size.
181          */
182 
183         OSCL_IMPORT_REF virtual uint32 GetFileSuggestedBufferSize() = 0;
184 
185         /**
186          * function to retrieve avi file properties.
187          * @param
188          * @return file data rate.
189          */
190 
191         OSCL_IMPORT_REF virtual uint32 GetFileDataRate() = 0;
192 
193         /**
194          * function to retrieve avi file properties.
195          * @param
196          * @return total frames in file.
197          */
198 
199         OSCL_IMPORT_REF virtual uint32 GetTotalFrames() = 0;
200 
201         /**
202          * function to retrieve avi file properties.
203          * @param
204          * @return number of frames required to be retrieved for interleaved files.
205          */
206 
207         OSCL_IMPORT_REF virtual uint32 GetInitialFrames() = 0;
208 
209         /**
210          * function to retrieve avi file properties.
211          * @param
212          * @return width of video frame
213          */
214 
215         OSCL_IMPORT_REF virtual uint32 GetWidth(int32 aStreamNo = -1) = 0;
216 
217         /**
218          * function to retrieve avi file properties.
219          * @param aStreamNo stream number
220          * @param rBottomUp returns the display orientation(true if bottom up, flase if top down)
221          * @return height of video frame
222          */
223 
224         OSCL_IMPORT_REF virtual uint32 GetHeight(bool& rBottomUp, int32 aStreamNo = -1) = 0;
225 
226         /**
227          * function to retrieve stream properties.
228          * @param aStreamNum stream number
229          * @return Stream duration
230          */
231         OSCL_IMPORT_REF virtual uint32 GetStreamDuration(uint32 aStreamNum) = 0;
232         /**
233          * function to retrieve stream properties.
234          * @param aStreamNum stream number
235          * @return number of bits per sample
236          */
237         OSCL_IMPORT_REF virtual uint32 GetBitsPerSample(uint32 aStreamNum) = 0;
238 
239         /**
240          * function to retrieve stream properties.
241          * @param aStreamNum stream number
242          * @return PVAviFileStreamHeaderStruct structure of stream porperties
243          */
244 
245         OSCL_IMPORT_REF virtual PVAviFileStreamHeaderStruct GetStreamHeaderStruct(uint32 aStreamNum) = 0;
246 
247         /**
248          * function to retrieve stream properties.
249          * @param aStreamNum stream number
250          * @return stream mime type
251          */
252 
253         OSCL_IMPORT_REF virtual OSCL_HeapString<OsclMemAllocator>  GetStreamMimeType(uint32 aStreamNum) = 0;
254 
255         /**
256          * function to retrieve stream properties.
257          * @param aStreamNum stream number
258          * @return suggested biffer size for the stream with stream number aStreamNum
259          */
260 
261         OSCL_IMPORT_REF virtual uint32 GetStreamSuggestedBufferSize(uint32 aStreamNum) = 0;
262 
263         /**
264          * function to retrieve stream properties.
265          * @param aStreamNum stream number
266          * @return aHdlr buffer to store FCC code for the video format
267          * @return aSize size of aHdlr.
268          */
269 
270         OSCL_IMPORT_REF virtual bool GetVideoFormatType(uint8* aHdlr, uint32& arSize, uint32 aStreamNo) = 0;
271 
272         /**
273          * function to retrieve stream properties.
274          * @param aStreamNum stream number
275          * @return audio format type number e.g 1 for WAVE_FORMAT_PCM
276          */
277 
278         OSCL_IMPORT_REF virtual uint32 GetAudioFormatType(uint32 aStreamNo) = 0;
279 
280         /**
281          * function to retrieve stream properties.
282          * @param aStreamNum stream number
283          * @return returns rate. Dividing rate by scale gives the no if samples per second.
284          */
285 
286         OSCL_IMPORT_REF virtual uint32 GetRate(uint32 aStreamNum) = 0;
287 
288         /**
289          * function to retrieve stream properties.
290          * @param aStreamNum stream number
291          * @return returns scale. Dividing rate by scale gives no of samples per second.
292          */
293 
294         OSCL_IMPORT_REF virtual uint32 GetScale(uint32 aStreamNum) = 0;
295 
296         /**
297          * function to retrieve stream properties.
298          * @param aStreamNum stream number
299          * @return for aduio:sampling rate,for video:frames per second
300          */
301 
302         OSCL_IMPORT_REF virtual OsclFloat GetFrameRate(uint32 aStreamNum) = 0;
303 
304         /**
305          * function to retrieve stream properties.
306          * @param aStreamNum stream number
307          * @return number of audio channels
308          */
309 
310         OSCL_IMPORT_REF virtual uint32 GetNumAudioChannels(uint32 aStreamNo) = 0;
311 
312         /**
313          * function to retrieve stream properties.
314          * @param aStreamNum stream number
315          * @return structure rcFrameType for rc frames
316          */
317 
318         OSCL_IMPORT_REF virtual rcFrameType GetRCFrame(uint32 aStreamNum) = 0;
319 
320         /**
321          * function to retrieve stream properties.
322          * @param aStreamNum stream number
323          * @return aFormatSpecificDataFrag stream format specific properties
324          */
325 
326         OSCL_IMPORT_REF virtual bool GetFormatSpecificInfo(uint32 aStreamNum, OsclRefCounterMemFrag& arFormatSpecificDataFrag) = 0;
327 
328         /**
329          * function to retrieve stream properties.
330          * @param aStreamNum stream number
331          * @return aFormatSpecificDataFrag codec specific information.
332          */
333 
334         OSCL_IMPORT_REF virtual bool GetCodecSpecificData(uint32 aStreamNum, OsclRefCounterMemFrag& arFormatSpecificDataFrag) = 0;
335 
336 };
337 
338 #endif      //#ifndef PV_AVIFILE_H_INCLUDED
339 
340