|
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 __ASYNCFILEPARSER_H |
|
17 #define __ASYNCFILEPARSER_H |
|
18 |
|
19 // INCLUDES |
|
20 #include <e32base.h> |
|
21 #include "mp4atom.h" |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class RFile64; |
|
27 struct MP4HandleStruct; |
|
28 |
|
29 // CLASS DECLARATION |
|
30 |
|
31 /** |
|
32 * Async file parser |
|
33 */ |
|
34 NONSHARABLE_CLASS(CFileAsyncParser) : public CActive |
|
35 { |
|
36 public: // Constructors and destructor |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 */ |
|
41 static CFileAsyncParser* NewL( MP4HandleStruct* aHandle, RFile64& aFile ); |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 ~CFileAsyncParser(); |
|
47 |
|
48 public: // New functions |
|
49 |
|
50 /** |
|
51 * Reads audio frames from file asynchronously |
|
52 * @since 3.1 |
|
53 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
54 */ |
|
55 TInt ReadAudioFrames( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); |
|
56 |
|
57 /** |
|
58 * Reads video frames from file asynchronously |
|
59 * @since 3.1 |
|
60 * @return Error code, KErrNone if no errors, otherwise one of the system wide error codes. |
|
61 */ |
|
62 TInt ReadVideoFrame( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); |
|
63 |
|
64 protected: // Functions from base classes |
|
65 /** |
|
66 * From CActive Cancels async request. |
|
67 */ |
|
68 void DoCancel(); |
|
69 |
|
70 /** |
|
71 * From CActive Called when async request completes. |
|
72 */ |
|
73 void RunL(); |
|
74 |
|
75 private: |
|
76 /** |
|
77 * C++ default constructor. |
|
78 */ |
|
79 CFileAsyncParser(); |
|
80 |
|
81 /** |
|
82 * By default Symbian 2nd phase constructor is private. |
|
83 */ |
|
84 void ConstructL( MP4HandleStruct* aHandle, RFile64& aFile ); |
|
85 |
|
86 /** |
|
87 * By default Symbian 2nd phase constructor is private. |
|
88 */ |
|
89 TInt ReadDataAsync( mp4_u8 *buffer, mp4_i64 aPosition, mp4_u32 aBytesToRead ); |
|
90 |
|
91 /** |
|
92 * Return audio frames to observer |
|
93 */ |
|
94 void ReturnAudioFrames(); |
|
95 |
|
96 /** |
|
97 * Return video frame to observer |
|
98 */ |
|
99 void ReturnVideoFrame(); |
|
100 |
|
101 /** |
|
102 * Calculates audio framecount in buffer |
|
103 */ |
|
104 TInt CalculateAudioFrameCount(); |
|
105 |
|
106 private: |
|
107 // Handle to parsed file structure. |
|
108 MP4HandleStruct* iHandle; |
|
109 |
|
110 // Disk buffer. |
|
111 HBufC8* iDiskBuffer; |
|
112 // Pointer to iDiskBuffer data |
|
113 TPtr8 iDiskBufferPointer; |
|
114 // Disk buffer size |
|
115 TInt iReadBufferSize; |
|
116 // Position of last read Diskbuffer in file |
|
117 TInt64 iCurrentDiskReadPosition; |
|
118 // Position of last read inside iDiskBuffer. |
|
119 TUint iCurrentBufferReadPosition; |
|
120 // Whether on last parse request all data was found on internal buffer. |
|
121 TBool iAllDataInMemory; |
|
122 |
|
123 // Audio parameters to be filled. |
|
124 // Size of audio frame returned to client. |
|
125 mp4_u32 iAudioSize; |
|
126 // Number of audio frames in buffer. |
|
127 mp4_u32 iReturnedAudioFrames; |
|
128 // Audio frame presentation time in milliseconds from the beginning of the audio sequence. |
|
129 mp4_u32 iAudioTimeStamp; |
|
130 // Audio frame presentation time in timescale from the beginning of the audio sequence |
|
131 mp4_u32 iAudioTimeStamp2; |
|
132 |
|
133 // Video parameter to be filled. |
|
134 // Size of video frame returned to client. |
|
135 mp4_u32 iVideoSize; |
|
136 // Whether returned video frame is keyframe or not. |
|
137 mp4_bool iVideoKeyFrame; |
|
138 // Video frame presentation time in milliseconds from the beginning of the video sequence. |
|
139 mp4_u32 iVideoTimeStamp; |
|
140 // Video frame presentation time in timescale from the beginning of the video sequence |
|
141 mp4_u32 iVideoTimeStamp2; |
|
142 |
|
143 // Read logic variables. |
|
144 // Amount of bytes client wants to read |
|
145 TInt iBytesToRead; |
|
146 // Amount of bytes read. |
|
147 TInt64 iBytesRead; |
|
148 // Flag whether there is async writing going. |
|
149 TBool iAsyncReadOngoing; |
|
150 // Flag whether current read is audio. |
|
151 TBool iProcessingAudio; |
|
152 // Write error code. |
|
153 TInt iError; |
|
154 |
|
155 // Parsed file being read. |
|
156 RFile64* iInputFile; |
|
157 // Output buffer being written to |
|
158 mp4_u8* iBuffer; |
|
159 }; |
|
160 |
|
161 #endif //__ASYNCFILEPARSER_H |
|
162 // End of File |