|
1 // Copyright (c) 2008-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 C3GPLIBRARY_H |
|
17 #define C3GPLIBRARY_H |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <f32file64.h> |
|
21 #include <caf/content.h> |
|
22 #include <e32base.h> |
|
23 #include <3gplibrary/mp4lib.h> |
|
24 |
|
25 /** |
|
26 Error code for C3GPParse API |
|
27 |
|
28 3GP Parser requires more data before the requested information can be retrieved |
|
29 */ |
|
30 const TInt KErr3gpLibMoreDataRequired = (-12300); |
|
31 |
|
32 class M3GPParseCallback; |
|
33 |
|
34 /** |
|
35 File format to use when composing a file. |
|
36 @publishedPartner |
|
37 @released |
|
38 */ |
|
39 enum T3GPFileFormatType |
|
40 { |
|
41 /** 3GP file format. */ |
|
42 E3GP3GP, |
|
43 /** MPEG-4 file format. */ |
|
44 E3GPMP4, |
|
45 /** 3GPP2 file format. */ |
|
46 E3GP3G2 |
|
47 }; |
|
48 |
|
49 /** |
|
50 Optional flags to be used when composing a file. |
|
51 @publishedPartner |
|
52 @released |
|
53 */ |
|
54 enum T3GPComposeFlag |
|
55 { |
|
56 /** Default value. No special setup. */ |
|
57 E3GPNoFlag = 0x0000, |
|
58 /** Metadata is placed at end of file. */ |
|
59 E3GPMetaDataLast = 0x0001, |
|
60 /** Collect metadata in files instead of storing it in memory. */ |
|
61 E3GPLongClip = 0x0002, |
|
62 }; |
|
63 |
|
64 /** |
|
65 Type of stream contained in the file. |
|
66 @publishedPartner |
|
67 @released |
|
68 */ |
|
69 enum T3GPFrameType |
|
70 { |
|
71 /** Frame contains audio data. */ |
|
72 E3GPAudio, |
|
73 /** Frame contains video data. */ |
|
74 E3GPVideo |
|
75 }; |
|
76 |
|
77 /** |
|
78 Type of video stream contained in the file. |
|
79 @publishedPartner |
|
80 @released |
|
81 */ |
|
82 enum T3GPVideoType |
|
83 { |
|
84 /** No Video */ |
|
85 E3GPNoVideo, |
|
86 /** MPEG-4 video (MPEG-4 Part 2) - Simple and Advance Simple Profiles */ |
|
87 E3GPMpeg4Video, |
|
88 /** H263 Profile 0 */ |
|
89 E3GPH263Profile0, |
|
90 /** H263 Profile 3 */ |
|
91 E3GPH263Profile3, |
|
92 /** AVC (also known as H.264) Baseline Profile */ |
|
93 E3GPAvcProfileBaseline, |
|
94 /** AVC (also known as H.264) Main Profile */ |
|
95 E3GPAvcProfileMain, |
|
96 /** AVC (also known as H.264) Extended Profile */ |
|
97 E3GPAvcProfileExtended, |
|
98 /** AVC (also known as H.264) High Profile */ |
|
99 E3GPAvcProfileHigh |
|
100 }; |
|
101 |
|
102 |
|
103 /** |
|
104 Type of audio stream contained in the file. |
|
105 @publishedPartner |
|
106 @released |
|
107 */ |
|
108 enum T3GPAudioType |
|
109 { |
|
110 /** No audio */ |
|
111 E3GPNoAudio, |
|
112 /** MPEG-4 audio (MPEG-4 Part 3) */ |
|
113 E3GPMpeg4Audio, |
|
114 /** AMR NB */ |
|
115 E3GPAmrNB, |
|
116 /** AMR WB */ |
|
117 E3GPAmrWB, |
|
118 /** QCELP 13K */ |
|
119 E3GPQcelp13K |
|
120 }; |
|
121 |
|
122 |
|
123 /** |
|
124 Location of the user data in the file. |
|
125 @publishedPartner |
|
126 @released |
|
127 */ |
|
128 enum T3GPUdtaLocation |
|
129 { |
|
130 /** User data resides within the Movie Box. */ |
|
131 E3GPUdtaMoov, |
|
132 /** User data resides within the Track Box for video. */ |
|
133 E3GPUdtaVideoTrak, |
|
134 /** User data resides within the Track Box for audio. */ |
|
135 E3GPUdtaAudioTrak |
|
136 }; |
|
137 |
|
138 /** |
|
139 Storage method of QCELP audio stream. |
|
140 @publishedPartner |
|
141 @released |
|
142 */ |
|
143 enum T3GPQcelpStorageMode |
|
144 { |
|
145 /** QCELP Sample Entry ('sqcp') box is used for the storage of QCELP media data. */ |
|
146 E3GPQcelpSampleEntryBox, |
|
147 /** MP4 Audio Sample Entry ('esds') box is used for the storage of QCELP media data. */ |
|
148 E3GPMP4AudioDescriptionBox |
|
149 }; |
|
150 |
|
151 /** |
|
152 Define the dependency information between video frames. |
|
153 @publishedPartner |
|
154 @released |
|
155 */ |
|
156 enum T3GPVideoFrameDependency |
|
157 { |
|
158 /** The dependency of this sample is unknown or the dependency of other |
|
159 samples on this sample is unknown. */ |
|
160 E3GPDependencyUnknown = 0, |
|
161 /** This sample does depend on others or other samples depend on this sample. */ |
|
162 E3GPDependencyExists, |
|
163 /** This sample does not depend on others or no other sample depends on this sample. */ |
|
164 E3GPDependencyNone, |
|
165 }; |
|
166 |
|
167 /** |
|
168 Define the existence of redundant coding in a frame. |
|
169 @publishedPartner |
|
170 @released |
|
171 */ |
|
172 enum T3GPVideoFrameRedundancy |
|
173 { |
|
174 /** It is unknown whether there is redundant coding in this sample. */ |
|
175 E3GPRedundancyUnknown = 0, |
|
176 /** There is redundant coding in this sample. */ |
|
177 E3GPRedundancyExists, |
|
178 /** There is no redundant coding in this sample. */ |
|
179 E3GPRedundancyNone, |
|
180 }; |
|
181 |
|
182 /** |
|
183 Structure containing a frame's dependency information. |
|
184 @publishedPartner |
|
185 @released |
|
186 */ |
|
187 NONSHARABLE_STRUCT(T3GPFrameDependencies) |
|
188 { |
|
189 /** Defines the current frame’s dependency. It can be defined as an I-frame |
|
190 (E3GPDependencyNone), not an I-frame (E3GPDependencyExists), or dependency |
|
191 unknown (E3GPDependencyUnknown). See T3GPVideoFrameDependency. |
|
192 */ |
|
193 T3GPVideoFrameDependency iDependsOn; |
|
194 /** Defines the dependency of other frames on this frame. It can be defined as a disposable |
|
195 frame (E3GPDependencyNone), non-disposable (E3GPDependencyExists), or dependency unknown |
|
196 (E3GPDependencyUnknown). See T3GPVideoFrameDependency. |
|
197 */ |
|
198 T3GPVideoFrameDependency iIsDependedOn; |
|
199 /** Defines the existence of redundant coding in this frame. See T3GPVideoFrameRedundancy. */ |
|
200 T3GPVideoFrameRedundancy iHasRedundancy; |
|
201 }; |
|
202 |
|
203 /** |
|
204 Structure containing video frame properties. |
|
205 @publishedPartner |
|
206 @released |
|
207 */ |
|
208 NONSHARABLE_STRUCT(T3GPFrameInfoParameters) |
|
209 { |
|
210 /** Frame size. */ |
|
211 TUint32 iSize; |
|
212 /** Frame start time. */ |
|
213 TUint32 iStartTime; |
|
214 /** ETrue if frame is an intra or random access point. */ |
|
215 TBool iIsRandomAccessPoint; |
|
216 }; |
|
217 |
|
218 /** |
|
219 This class should not be used directly. It stores common properties amongst all supported |
|
220 types of video data. |
|
221 |
|
222 Note: iTimescale should be chosen so that the duration of each sample is an integer. It should also |
|
223 be chosen so that the duration of the presentation fits into 32 bits. |
|
224 |
|
225 @publishedPartner |
|
226 @released |
|
227 */ |
|
228 NONSHARABLE_CLASS(T3GPVideoPropertiesBase) |
|
229 { |
|
230 protected: |
|
231 /** |
|
232 @internalTechnology |
|
233 */ |
|
234 T3GPVideoPropertiesBase(T3GPVideoType aType, TUint aTimescale, const TSize& aSize); |
|
235 public: |
|
236 /** Type of video stream contained in the file. */ |
|
237 T3GPVideoType iType; |
|
238 /** Timescale of the video data. This is the number of time units that pass in one second. */ |
|
239 TUint iTimescale; |
|
240 /** Video width and height in pixels */ |
|
241 TSize iSize; |
|
242 }; |
|
243 |
|
244 /** |
|
245 This structure stores the common and MPEG-4 video specific properties of video data |
|
246 @publishedPartner |
|
247 @released |
|
248 */ |
|
249 NONSHARABLE_CLASS(T3GPVideoPropertiesMpeg4Video) : public T3GPVideoPropertiesBase |
|
250 { |
|
251 public: |
|
252 IMPORT_C T3GPVideoPropertiesMpeg4Video(TUint aTimescale, const TSize& aSize, TUint aMaxBitRate, TUint aAvgBitRate, const TDesC8& aDecoderSpecificInfo); |
|
253 public: |
|
254 /** Maximum video bit rate */ |
|
255 TUint iMaxBitRate; |
|
256 /** Average video bit rate */ |
|
257 TUint iAvgBitRate; |
|
258 /** MPEG-4 video decoder specific info data stored in an ESDS atom */ |
|
259 const TDesC8& iDecoderSpecificInfo; |
|
260 }; |
|
261 |
|
262 /** |
|
263 This structure stores the common and H.263 specific properties of video data |
|
264 @publishedPartner |
|
265 @released |
|
266 */ |
|
267 NONSHARABLE_CLASS(T3GPVideoPropertiesH263) : public T3GPVideoPropertiesBase |
|
268 { |
|
269 public: |
|
270 enum TProfile { EProfile0, EProfile3 }; |
|
271 |
|
272 public: |
|
273 IMPORT_C T3GPVideoPropertiesH263(TUint aTimescale, const TSize& aSize, TInt aVideoLevel, TProfile aProfile); |
|
274 public: |
|
275 /** Indicates the H263 video level. */ |
|
276 TInt iVideoLevel; |
|
277 }; |
|
278 |
|
279 /** |
|
280 This structure stores the common and AVC-specific properties of video data. |
|
281 @publishedPartner |
|
282 @released |
|
283 */ |
|
284 NONSHARABLE_CLASS(T3GPVideoPropertiesAvc) : public T3GPVideoPropertiesBase |
|
285 { |
|
286 public: |
|
287 IMPORT_C T3GPVideoPropertiesAvc(TUint aTimescale, const TSize& aSize, const TDesC8& aDecoderSpecificInfo); |
|
288 public: |
|
289 /** AVCDecoderConfigurationRecord data that will be stored in the avcC atom. */ |
|
290 const TDesC8& iDecoderSpecificInfo; |
|
291 }; |
|
292 |
|
293 /** |
|
294 This class should not be used directly. This structure stores common properties amongst all supported types of audio data |
|
295 @publishedPartner |
|
296 @released |
|
297 */ |
|
298 NONSHARABLE_CLASS(T3GPAudioPropertiesBase) |
|
299 { |
|
300 protected: |
|
301 /** |
|
302 @internalTechnology |
|
303 */ |
|
304 T3GPAudioPropertiesBase(T3GPAudioType aType, TUint aTimescale, TInt aFramesPerSample); |
|
305 public: |
|
306 /** Type of audio stream contained in the file */ |
|
307 T3GPAudioType iType; |
|
308 /** Timescale of the audio data. This is the number of time units that pass in one second. It |
|
309 must be smaller than 65536. */ |
|
310 TUint iTimescale; |
|
311 /** Frames per sample. It must be smaller than 512. MPEG-4 audio has a fixed value of 1. */ |
|
312 TInt iFramesPerSample; |
|
313 }; |
|
314 |
|
315 /** |
|
316 This structure stores the common and MPEG-4 audio specific properties of audio data |
|
317 @publishedPartner |
|
318 @released |
|
319 */ |
|
320 NONSHARABLE_CLASS(T3GPAudioPropertiesMpeg4Audio) : public T3GPAudioPropertiesBase |
|
321 { |
|
322 public: |
|
323 IMPORT_C T3GPAudioPropertiesMpeg4Audio(TUint aTimescale, const TDesC8& aDecoderSpecificInfo); |
|
324 public: |
|
325 /** MPEG-4 audio decoder specific info data stored in an ESDS atom */ |
|
326 const TDesC8& iDecoderSpecificInfo; |
|
327 }; |
|
328 |
|
329 /** |
|
330 This structure stores the common and AMR specific properties of audio data |
|
331 @publishedPartner |
|
332 @released |
|
333 */ |
|
334 NONSHARABLE_CLASS(T3GPAudioPropertiesAmr) : public T3GPAudioPropertiesBase |
|
335 { |
|
336 public: |
|
337 enum TSpeechCodec{ EAmrWB, EAmrNB }; |
|
338 |
|
339 public: |
|
340 IMPORT_C T3GPAudioPropertiesAmr(TUint aTimescale, TInt aFramesPerSample, TInt aModeSet, TSpeechCodec aCodec); |
|
341 public: |
|
342 /** AMR mode set. */ |
|
343 TInt iModeSet; |
|
344 }; |
|
345 |
|
346 /** |
|
347 This structure stores the common and Qcelp specific properties of audio data |
|
348 @publishedPartner |
|
349 @released |
|
350 */ |
|
351 NONSHARABLE_CLASS(T3GPAudioPropertiesQcelp) : public T3GPAudioPropertiesBase |
|
352 { |
|
353 public: |
|
354 IMPORT_C T3GPAudioPropertiesQcelp(TUint aTimescale, TInt aFramesPerSample, const TDesC8& aDecoderSpecificInfo); |
|
355 IMPORT_C T3GPAudioPropertiesQcelp(TUint aTimescale, TInt aFramesPerSample); |
|
356 public: |
|
357 /** Specifies the mode to store QCELP audio data. |
|
358 In 3G2 files, QCELP can be registered to be stored in two ways: |
|
359 - Use QCELP Sample Entry (‘sqcp’) Box. This is the default mode. |
|
360 - Use MPEG4 Audio Sample Description (‘esds’) Box. If this mode is selected, decoder specific info should be supplied. |
|
361 See T3GPQcelpStorageMode. */ |
|
362 T3GPQcelpStorageMode iMode; |
|
363 /** MPEG-4 audio decoder specific info data stored in an ESDS atom. |
|
364 If this is provided as an input parameter, the storage mode is automatically set to MPEG4 Audio |
|
365 Sample Description Box mode */ |
|
366 const TDesC8& iDecoderSpecificInfo; |
|
367 }; |
|
368 |
|
369 /** |
|
370 @publishedPartner |
|
371 @released |
|
372 |
|
373 The 3GP composer accepts H.263 /H.264 / MPEG-4 / AVC video, and AMR / MPEG-4 AAC / QCELP |
|
374 audio as input to create a 3GP / 3G2 / MP4 file. |
|
375 */ |
|
376 NONSHARABLE_CLASS(C3GPCompose) : public CBase |
|
377 { |
|
378 public: |
|
379 IMPORT_C static C3GPCompose* NewL(); |
|
380 IMPORT_C static C3GPCompose* NewL(TInt aMediaWriteBufferSize, TInt aWriteBufferMaxCount); |
|
381 IMPORT_C ~C3GPCompose(); |
|
382 |
|
383 IMPORT_C TInt Open(T3GPFileFormatType aFileFormat, const T3GPVideoPropertiesBase* aVideo, const T3GPAudioPropertiesBase* aAudio, const TDesC& aFilename, TUint aFlags = E3GPNoFlag); |
|
384 IMPORT_C TInt Open(T3GPFileFormatType aFileFormat, const T3GPVideoPropertiesBase* aVideo, const T3GPAudioPropertiesBase* aAudio, RFile& aFile, TUint aFlags = E3GPNoFlag); |
|
385 IMPORT_C TInt Open(T3GPFileFormatType aFileFormat, const T3GPVideoPropertiesBase* aVideo, const T3GPAudioPropertiesBase* aAudio, RFile64& aFile, TUint aFlags = E3GPNoFlag); |
|
386 IMPORT_C TInt WriteVideoFrame(const TDesC8& aBuffer, TUint aDuration, TBool aKeyFrame); |
|
387 IMPORT_C TInt WriteVideoFrame(const TDesC8& aBuffer, TUint aDuration, TBool aKeyFrame, const T3GPFrameDependencies& aDependencies); |
|
388 IMPORT_C TInt WriteAudioFrames(const TDesC8& aBuffer, TUint aDuration); |
|
389 IMPORT_C TInt SetUserData(T3GPUdtaLocation aLocation, const TDesC8& aBuffer); |
|
390 IMPORT_C TInt Complete(); |
|
391 private: |
|
392 C3GPCompose(TInt aMediaWriteBufferSize = 0, TInt aWriteBufferMaxCount = 0); |
|
393 |
|
394 TInt SymbianOSError(MP4Err aError); |
|
395 mp4_u32 Mp4Type(const T3GPVideoPropertiesBase* aVideo, const T3GPAudioPropertiesBase* aAudio); |
|
396 TInt SetComposeProperties(const T3GPVideoPropertiesBase* aVideo, const T3GPAudioPropertiesBase* aAudio, T3GPFileFormatType aFileFormat, TUint aFlag); |
|
397 TInt SetMPeg4VideoProperties(const T3GPVideoPropertiesBase* aVideo); |
|
398 TInt SetAvcVideoProperties(const T3GPVideoPropertiesBase* aVideo); |
|
399 TInt SetH263VideoProperties(const T3GPVideoPropertiesBase* aVideo); |
|
400 TInt SetMpeg4AudioProperties(const T3GPAudioPropertiesBase* aAudio); |
|
401 TInt SetAmrAudioProperties(const T3GPAudioPropertiesBase* aAudio); |
|
402 TInt SetQcelpAudioProperties(const T3GPAudioPropertiesBase* aAudio); |
|
403 TInt SetComposeFlag(T3GPFileFormatType aFileFormat, TUint aFlag); |
|
404 void Reset(); |
|
405 static void Panic(TInt aPanic); |
|
406 private: |
|
407 MP4Handle iHandler; |
|
408 TInt iMediaWriteBufferSize; |
|
409 TInt iWriteBufferMaxCount; |
|
410 TBool iHasVideo; |
|
411 TBool iHasAudio; |
|
412 TBool iDuplicateFileHandleCreated; |
|
413 RFile64 iFile; |
|
414 }; |
|
415 |
|
416 |
|
417 /** |
|
418 The Parser provides APIs to parse 3GP, 3G2 and MP4 contents (from a file, a CAF object, or given |
|
419 through memory buffer), containing H.263/MPEG-4/H.264 video and AMR/MPEG-4/QCELP audio. |
|
420 @publishedPartner |
|
421 @released |
|
422 */ |
|
423 NONSHARABLE_CLASS(C3GPParse) : public CBase, public M3GPMP4LibAsyncObserver |
|
424 { |
|
425 public: |
|
426 IMPORT_C static C3GPParse* NewL(); |
|
427 IMPORT_C static C3GPParse* NewL(TInt aReadBufferSize); |
|
428 IMPORT_C ~C3GPParse(); |
|
429 |
|
430 IMPORT_C TInt Open(); |
|
431 IMPORT_C TInt Open(const TDesC& aFilename); |
|
432 IMPORT_C TInt Open(const RFile& aFile); |
|
433 IMPORT_C TInt Open(const RFile64& aFile); |
|
434 IMPORT_C TInt Open(const ContentAccess::CData& aData); |
|
435 IMPORT_C TInt InsertData(const TDesC8& aBuffer); |
|
436 IMPORT_C TInt GetVideoProperties(T3GPVideoType& aType, TUint& aLength, TReal& aFrameRate, TUint& aAvgBitRate, TSize& aSize, TUint& aTimeScale) const; |
|
437 IMPORT_C TInt GetAudioProperties(T3GPAudioType& aType, TUint& aLength, TInt& aFramesPerSample, TUint& aAvgBitRate, TUint& aTimeScale) const; |
|
438 IMPORT_C TInt GetContainerProperties(TUint& aSize, TUint& aAvgBitRate) const; |
|
439 IMPORT_C TInt GetNumBufferedBytes(TInt& aNum) const; |
|
440 IMPORT_C TInt GetFrameType(T3GPFrameType& aType) const; |
|
441 IMPORT_C TInt GetVideoFrameSize(TUint& aSize) const; |
|
442 IMPORT_C TInt GetAudioFramesSize(TUint& aSize) const; |
|
443 IMPORT_C TInt GetVideoDecoderSpecificInfoSize(TInt& aSize) const; |
|
444 IMPORT_C TInt GetVideoDecoderSpecificInfo(TDes8& aInfo) const; |
|
445 IMPORT_C TInt GetAudioDecoderSpecificInfoSize(TInt& aSize) const; |
|
446 IMPORT_C TInt GetAudioDecoderSpecificInfo(TDes8& aBuffer) const; |
|
447 IMPORT_C TInt GetVideoTimestamp(TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const; |
|
448 IMPORT_C TInt GetStreamable(TBool& aStreamable) const; |
|
449 IMPORT_C TInt Seek(TUint aPosition, TBool aKeyFrame, TUint& aAudioPosition, TUint& aVideoPosition) const; |
|
450 IMPORT_C TInt GetFrameAvailability(T3GPFrameType aType, TBool& aAvailable) const; |
|
451 IMPORT_C TInt GetNumberOfVideoFrames(TUint& aNum) const; |
|
452 IMPORT_C TInt GetVideoSampleEntryIndex(TUint& aIndex) const; |
|
453 IMPORT_C TInt GetVideoFrameSize(TUint aIndex, TUint& aSize) const; |
|
454 IMPORT_C TInt GetVideoFrameStartTime(TUint aIndex, TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const; |
|
455 IMPORT_C TInt GetVideoFrameKeyType(TUint aIndex, TBool& aKeyFrame) const; |
|
456 IMPORT_C TInt GetAudioSampleEntryIndex(TUint& aIndex) const; |
|
457 IMPORT_C TInt GetQcelpStorageMode(T3GPQcelpStorageMode& aMode) const; |
|
458 IMPORT_C TInt GetH263VideoLevel(TInt& aLevel) const; |
|
459 IMPORT_C TInt GetUserDataAtomSize(TUint32 aType, T3GPUdtaLocation aLocation, TUint& aAtomIndex, TInt& aSize) const; |
|
460 IMPORT_C TInt GetUserDataAtom(TUint32 aType, T3GPUdtaLocation aLocation, TDes8& aBuffer, TUint& aAtomIndex) const; |
|
461 IMPORT_C TInt GetVideoFrameDependencies(T3GPFrameDependencies& aDependencies) const; |
|
462 IMPORT_C TInt GetVideoFrameProperties(TUint aStartIndex, TUint aNumberOfFrames, RArray<T3GPFrameInfoParameters>& aArray) const; |
|
463 IMPORT_C TInt ReadVideoFrame(TDes8& aBuffer, TBool& aKeyFrame, TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const; |
|
464 IMPORT_C void ReadVideoFrame(M3GPParseCallback& aCallback, TDes8& aBuffer); |
|
465 IMPORT_C TInt ReadAudioFrames(TDes8& aBuffer, TInt& aReturnedFrames, TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const; |
|
466 IMPORT_C void ReadAudioFrames(M3GPParseCallback& aCallback, TDes8& aBuffer); |
|
467 IMPORT_C void CancelReadFrame(); |
|
468 IMPORT_C TInt Complete(); |
|
469 private: |
|
470 C3GPParse(TInt aReadBufferSize = 0); |
|
471 |
|
472 TInt SymbianOSError(MP4Err aError) const; |
|
473 TInt DoGetVideoProperties() const; |
|
474 TInt DoGetAudioProperties() const; |
|
475 TInt DoGetStreamProperties() const; |
|
476 T3GPVideoType WrapperVideoType(TUint aType) const; |
|
477 T3GPAudioType WrapperAudioType(TUint aType) const; |
|
478 mp4_u8 UdtaLocation(T3GPUdtaLocation aLocation) const; |
|
479 void Reset(); |
|
480 static void Panic(TInt aPanic); |
|
481 |
|
482 // From M3GPMP4LibAsyncObserver |
|
483 void M3GPMP4LibVideoFrameAvailable(MP4Err aError, mp4_u32 aFrameSize, mp4_u32 aTimeStamp, mp4_bool aKeyFrame, mp4_u32 aTimestamp2); |
|
484 void M3GPMP4LibAudioFramesAvailable(MP4Err aError, mp4_u32 aAudioSize, mp4_u32 aTimeStamp, mp4_u32 aReturnedFrames, mp4_u32 aTimestamp2); |
|
485 |
|
486 private: |
|
487 MP4Handle iHandler; |
|
488 TInt iReadBufferSize; |
|
489 |
|
490 // Async read |
|
491 M3GPParseCallback* iCallback; |
|
492 TDes8* iAsyncReadBuffer; |
|
493 |
|
494 |
|
495 TBool iDuplicateFileHandleCreated; |
|
496 RFile64 iFile; |
|
497 // Video properties |
|
498 mutable T3GPVideoType iVideoType; |
|
499 mutable TUint iVideoLength; |
|
500 mutable TUint iVideoMp4Type; |
|
501 mutable TReal iVideoFrameRate; |
|
502 mutable TSize iVideoSize; |
|
503 mutable TUint iVideoTimeScale; |
|
504 mutable TBool iVideoPropertiesSaved; |
|
505 mutable TInt iVideoError; |
|
506 |
|
507 // Audio Properties |
|
508 mutable T3GPAudioType iAudioType; |
|
509 mutable TUint iAudioLength; |
|
510 mutable TUint iAudioMp4Type; |
|
511 mutable TReal iAudioFramesPerSample; |
|
512 mutable TSize iAudioSize; |
|
513 mutable TUint iAudioTimeScale; |
|
514 mutable TUint iAudioAvgBitRate; |
|
515 mutable TBool iAudioPropertiesSaved; |
|
516 mutable TInt iAudioError; |
|
517 |
|
518 // Stream properties |
|
519 mutable TUint iStreamAvgBitRate; |
|
520 mutable TUint iStreamSize; |
|
521 mutable TBool iStreamPropertiesSaved; |
|
522 mutable TInt iStreamError; |
|
523 }; |
|
524 |
|
525 /** |
|
526 A mixin class to be implemented by the client in order to use the asynchronous frame retrieval |
|
527 APIs provided by the C3GPParse class. The derived class methods are called by C3GPParse when |
|
528 the audio/video frames retrieval completes, successful or not. |
|
529 @publishedPartner |
|
530 @released |
|
531 */ |
|
532 class M3GPParseCallback |
|
533 { |
|
534 public: |
|
535 /** |
|
536 This is called upon the completion of an asynchronous request to retrieve audio |
|
537 frames by the API C3GPParse::ReadAudioFramesAsync. |
|
538 |
|
539 @see C3GPParse::ReadAudioFramesAsync |
|
540 |
|
541 @param aError Returns KErrNone on success. Returns KErrAccessDenied if the 3GP Parser is in buffer mode. |
|
542 Otherwise, returns one of the system wide error codes. See synchronous version of |
|
543 C3GPParse::ReadAudioFrames. |
|
544 @param aReturnedFrames Number of the returned frames or 0 if not known. |
|
545 @param aTimeStampInMs Audio frame presentation time in milliseconds from the beginning of the audio sequence. |
|
546 @param aTimeStampInTimescale Audio frame presentation time in timescale from the beginning of the audio sequence. |
|
547 */ |
|
548 virtual void AudioFramesAvailable(TInt aError, TUint aReturnedFrames, TUint aTimeStampInMs, TUint aTimeStampInTimescale) = 0; |
|
549 |
|
550 /** |
|
551 VideoFrameAvailable is called upon completion of an asynchronous request to retrieve |
|
552 video frames by the API C3GPParse::ReadVideoFrameAsync. |
|
553 |
|
554 @see C3GPParse::ReadVideoFrameAsync |
|
555 |
|
556 @param aError Returns KErrNone on success. Returns KErrAccessDenied if the 3GP Parser is in buffer mode. |
|
557 Otherwise, returns one of the system wide error codes. See synchronous version of |
|
558 C3GPParse::ReadVideoFrame. |
|
559 @param aKeyFrame Returns ETrue if the current frame is a key frame (intra), otherwise the value is EFalse. |
|
560 @param aTimeStampInMs Video frame presentation time in milliseconds from the beginning of the video sequence. |
|
561 @param aTimeStampInTimescale Video frame presentation time in timescale from the beginning of the video sequence. |
|
562 */ |
|
563 virtual void VideoFrameAvailable(TInt aError, TBool aKeyFrame, TUint aTimeStampInMs, TUint aTimeStampInTimescale) = 0; |
|
564 }; |
|
565 |
|
566 #endif // C3GPLIBRARY_H |