sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <c3gplibrary.h>
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
Creates an instance of a 3GP Parser for reading 3GP/3G2/MP4 data using default buffer size.
|
sl@0
|
20 |
|
sl@0
|
21 |
The default value for read buffer size is 8k.
|
sl@0
|
22 |
|
sl@0
|
23 |
@return A pointer to the newly created 3gp parse object.
|
sl@0
|
24 |
|
sl@0
|
25 |
@leave KErrNoMemory Out of memory.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
EXPORT_C C3GPParse* C3GPParse::NewL()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
C3GPParse* self = new (ELeave) C3GPParse();
|
sl@0
|
30 |
return self;
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Creates an instance of a 3GP Parser for reading 3GP/3G2/MP4 data, and sets the
|
sl@0
|
35 |
internal file read buffer size.
|
sl@0
|
36 |
|
sl@0
|
37 |
@param aReadBufferSize Size of file read buffer.
|
sl@0
|
38 |
|
sl@0
|
39 |
@return A pointer to the newly created 3gp parse object.
|
sl@0
|
40 |
|
sl@0
|
41 |
@leave KErrNoMemory Out of memory.
|
sl@0
|
42 |
@leave KErrGeneral General error.
|
sl@0
|
43 |
|
sl@0
|
44 |
@panic C3GPParse KErrArgument if size of file read buffer is not greater than 0.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
EXPORT_C C3GPParse* C3GPParse::NewL(TInt aReadBufferSize)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
__ASSERT_ALWAYS((aReadBufferSize > 0), Panic(KErrArgument));
|
sl@0
|
49 |
C3GPParse* self = new (ELeave) C3GPParse(aReadBufferSize);
|
sl@0
|
50 |
return self;
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
// First phase constructor
|
sl@0
|
54 |
C3GPParse::C3GPParse(TInt aReadBufferSize) :
|
sl@0
|
55 |
iReadBufferSize(aReadBufferSize),
|
sl@0
|
56 |
iDuplicateFileHandleCreated(EFalse),
|
sl@0
|
57 |
iVideoType(E3GPNoVideo),
|
sl@0
|
58 |
iAudioType(E3GPNoAudio)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a buffer and expects data
|
sl@0
|
64 |
to be inserted through subsequent calls to C3GPParse::InsertData.
|
sl@0
|
65 |
|
sl@0
|
66 |
@see C3GPParse::InsertData
|
sl@0
|
67 |
|
sl@0
|
68 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
69 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
70 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
71 |
KErrInUse if the parser is currently engaged; C3GPParse::Complete must be called to
|
sl@0
|
72 |
finish the parsing activities before the parser can be re-initialised again.
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
EXPORT_C TInt C3GPParse::Open()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
if (iHandler)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
return KErrInUse;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
return SymbianOSError(MP4ParseOpen(&iHandler, NULL));
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
/**
|
sl@0
|
85 |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
|
sl@0
|
86 |
|
sl@0
|
87 |
@param aFilename A full path name of the file containing the data.
|
sl@0
|
88 |
|
sl@0
|
89 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
90 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
91 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
92 |
KErrAccessDenied if opening file has failed;
|
sl@0
|
93 |
KErrUnderflow if the file name length is not greater than 0;
|
sl@0
|
94 |
KErrInUse if the parser is currently engaged; C3GPParse::Complete must be called to
|
sl@0
|
95 |
finish the parsing activities before the parser can be re-initialised again.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
EXPORT_C TInt C3GPParse::Open(const TDesC& aFilename)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
if (iHandler)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
return KErrInUse;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
if (aFilename.Length() <= 0)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
return KErrUnderflow;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
// Create a zero terminated version of the file name
|
sl@0
|
109 |
RBuf fileName;
|
sl@0
|
110 |
TInt err = fileName.Create(aFilename.Length() + 1);
|
sl@0
|
111 |
if (err == KErrNone)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
fileName.Copy(aFilename);
|
sl@0
|
114 |
mp4_u16* mp4FileName = const_cast<mp4_u16*>(fileName.PtrZ());
|
sl@0
|
115 |
MP4Err mp4Err = MP4ParseOpen(&iHandler, reinterpret_cast<MP4FileName>(mp4FileName));
|
sl@0
|
116 |
|
sl@0
|
117 |
if (mp4Err == MP4_OK)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
// Set composing related values to 0.
|
sl@0
|
120 |
mp4Err = MP4SetCustomFileBufferSizes(iHandler, 0, 0, iReadBufferSize);
|
sl@0
|
121 |
if (mp4Err != MP4_OK)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
// Ignore the error
|
sl@0
|
124 |
Complete();
|
sl@0
|
125 |
}
|
sl@0
|
126 |
}
|
sl@0
|
127 |
err = SymbianOSError(mp4Err);
|
sl@0
|
128 |
}
|
sl@0
|
129 |
fileName.Close();
|
sl@0
|
130 |
return err;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
/**
|
sl@0
|
134 |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
|
sl@0
|
135 |
|
sl@0
|
136 |
@param aFile File handle of the file containing the data. It is expected to be a valid file handle,
|
sl@0
|
137 |
opened and will be closed outside of the library.
|
sl@0
|
138 |
|
sl@0
|
139 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
140 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
141 |
KErrInUse if the parser is currently engaged; C3GPParse::Complete must be called to
|
sl@0
|
142 |
finish the parsing activities before the parser can be re-initialised again.
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
EXPORT_C TInt C3GPParse::Open(const RFile& aFile)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TInt err = KErrNone;
|
sl@0
|
147 |
if (!iDuplicateFileHandleCreated)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
iDuplicateFileHandleCreated = ETrue;
|
sl@0
|
150 |
iFile.Close();
|
sl@0
|
151 |
err = iFile.Duplicate(aFile);
|
sl@0
|
152 |
if (err != KErrNone)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
return err;
|
sl@0
|
155 |
}
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
return Open(iFile);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
/**
|
sl@0
|
161 |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
|
sl@0
|
162 |
|
sl@0
|
163 |
@param aFile File handle of the file containing the data. It is expected to be a valid file handle,
|
sl@0
|
164 |
opened and will be closed outside of the library.
|
sl@0
|
165 |
|
sl@0
|
166 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
167 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
168 |
KErrInUse if the parser is currently engaged; C3GPParse::Complete must be called to
|
sl@0
|
169 |
finish the parsing activities before the parser can be re-initialised again.
|
sl@0
|
170 |
*/
|
sl@0
|
171 |
EXPORT_C TInt C3GPParse::Open(const RFile64& aFile)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
if (iHandler)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
return KErrInUse;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
const RFile64* file = &aFile;
|
sl@0
|
179 |
MP4Err mp4Err = MP4ParseOpenFileHandle64(&iHandler, (const_cast<RFile64*>(file)));
|
sl@0
|
180 |
if (mp4Err == MP4_OK)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
// Set composing related values to 0.
|
sl@0
|
183 |
mp4Err = MP4SetCustomFileBufferSizes(iHandler, 0, 0, iReadBufferSize);
|
sl@0
|
184 |
if (mp4Err != MP4_OK)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
// Ignore the error
|
sl@0
|
187 |
Complete();
|
sl@0
|
188 |
}
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
return SymbianOSError(mp4Err);
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
/**
|
sl@0
|
195 |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a CAF object.
|
sl@0
|
196 |
|
sl@0
|
197 |
@param aData A CData object pointing to a CAF object. It is expected to be opened and will be
|
sl@0
|
198 |
closed outside of the library.
|
sl@0
|
199 |
|
sl@0
|
200 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
201 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
202 |
KErrInUse if the parser is currently engaged; C3GPParse::Complete must be called to
|
sl@0
|
203 |
finish the parsing activities before the parser can be re-initialised again.
|
sl@0
|
204 |
*/
|
sl@0
|
205 |
EXPORT_C TInt C3GPParse::Open(const ContentAccess::CData& aData)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
if (iHandler)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
return KErrInUse;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
MP4Err mp4Err = MP4ParseOpenCAF(&iHandler, const_cast<ContentAccess::CData*>(&aData));
|
sl@0
|
213 |
|
sl@0
|
214 |
if (mp4Err == MP4_OK)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
// Set composing related values to 0.
|
sl@0
|
217 |
mp4Err = MP4SetCustomFileBufferSizes(iHandler, 0, 0, iReadBufferSize);
|
sl@0
|
218 |
if (mp4Err != MP4_OK)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
// Ignore the error
|
sl@0
|
221 |
Complete();
|
sl@0
|
222 |
}
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
return SymbianOSError(mp4Err);
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
/**
|
sl@0
|
229 |
Destructor. Deletes all objects.
|
sl@0
|
230 |
*/
|
sl@0
|
231 |
EXPORT_C C3GPParse::~C3GPParse()
|
sl@0
|
232 |
{
|
sl@0
|
233 |
Complete(); // Ignore the error
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
/**
|
sl@0
|
237 |
This function completes the parsing operation.
|
sl@0
|
238 |
|
sl@0
|
239 |
If C3GPParse::Complete is called before the parse is initialised, it will be ignored and KErrNone is
|
sl@0
|
240 |
returned.
|
sl@0
|
241 |
|
sl@0
|
242 |
The parser can be reused again after this call, following another call to C3GPParse::Open to
|
sl@0
|
243 |
re-initialise the parser.
|
sl@0
|
244 |
|
sl@0
|
245 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
246 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
247 |
*/
|
sl@0
|
248 |
EXPORT_C TInt C3GPParse::Complete()
|
sl@0
|
249 |
{
|
sl@0
|
250 |
MP4Err mp4Err = MP4_OK;
|
sl@0
|
251 |
if (iHandler)
|
sl@0
|
252 |
{
|
sl@0
|
253 |
mp4Err = MP4ParseClose(iHandler);
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|
sl@0
|
256 |
if (iAsyncReadBuffer)
|
sl@0
|
257 |
{
|
sl@0
|
258 |
CancelReadFrame();
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
// Always reset the class member data even MP4ParseClose returns error
|
sl@0
|
262 |
Reset();
|
sl@0
|
263 |
return SymbianOSError(mp4Err);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
// Helper function to reset class member data.
|
sl@0
|
267 |
void C3GPParse::Reset()
|
sl@0
|
268 |
{
|
sl@0
|
269 |
iVideoType = E3GPNoVideo;
|
sl@0
|
270 |
iAudioType = E3GPNoAudio;
|
sl@0
|
271 |
iAsyncReadBuffer = NULL;
|
sl@0
|
272 |
iCallback = NULL; // Parse doesn't own the callback. Set it to NULL.
|
sl@0
|
273 |
iAudioAvgBitRate = 0;
|
sl@0
|
274 |
iStreamAvgBitRate = 0;
|
sl@0
|
275 |
iVideoPropertiesSaved = EFalse;
|
sl@0
|
276 |
iAudioPropertiesSaved = EFalse;
|
sl@0
|
277 |
iStreamPropertiesSaved = EFalse;
|
sl@0
|
278 |
iVideoError = KErrNone;
|
sl@0
|
279 |
iAudioError = KErrNone;
|
sl@0
|
280 |
iStreamError = KErrNone;
|
sl@0
|
281 |
iHandler = NULL;
|
sl@0
|
282 |
iDuplicateFileHandleCreated = EFalse;
|
sl@0
|
283 |
iFile.Close();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
/**
|
sl@0
|
287 |
This function inserts MP4/3GP/3G2 data into the parser.
|
sl@0
|
288 |
|
sl@0
|
289 |
It is only necessary to call this function if no parameter has been supplied when
|
sl@0
|
290 |
C3GPParse::Open is called. Several functions can return KErr3gpLibMoreDataRequired if the library
|
sl@0
|
291 |
does not have enough data to return the information that the caller requests. In this case, more data
|
sl@0
|
292 |
needs to be inserted to the library before calling those functions again.
|
sl@0
|
293 |
|
sl@0
|
294 |
This function makes a copy of the data inserted into the library so the caller can use the input buffer
|
sl@0
|
295 |
for other purposes. If the function returns KErrNoMemory, the buffer contents have not been copied into
|
sl@0
|
296 |
the library and the caller needs to reduce the buffer content before calling again.
|
sl@0
|
297 |
|
sl@0
|
298 |
If an empty string is supplied for the argument aBuffer, it indicates that there is be no more data
|
sl@0
|
299 |
to feed through this function. Such a function call must be done to indicate that all 3GP/MP4/3G2
|
sl@0
|
300 |
data has been written to the library's internal memory.
|
sl@0
|
301 |
|
sl@0
|
302 |
@param aBuffer The descriptor containing the data to be inserted.
|
sl@0
|
303 |
|
sl@0
|
304 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
305 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
306 |
KErrNoMemory if parser cannot allocate enough memory for the data;
|
sl@0
|
307 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
308 |
*/
|
sl@0
|
309 |
EXPORT_C TInt C3GPParse::InsertData(const TDesC8& aBuffer)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
if (!iHandler)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
return KErrNotReady;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
return SymbianOSError(MP4ParseWriteData(iHandler, const_cast<mp4_u8*>(aBuffer.Ptr()), aBuffer.Length()));
|
sl@0
|
317 |
}
|
sl@0
|
318 |
|
sl@0
|
319 |
/**
|
sl@0
|
320 |
This function returns the parameters describing the video stream.
|
sl@0
|
321 |
|
sl@0
|
322 |
If no file or CAF object is supplied during parser initialisation, this should be called after
|
sl@0
|
323 |
enough data has been inserted into the library buffers so that the 3GP headers containing the
|
sl@0
|
324 |
information can be read.
|
sl@0
|
325 |
|
sl@0
|
326 |
The aFrameRate parameter refers to the frame rate of the original video material.
|
sl@0
|
327 |
|
sl@0
|
328 |
@param aType The type of video stream. Refer to T3GPVideoType for supported video type.
|
sl@0
|
329 |
@param aLength Duration of video in milliseconds.
|
sl@0
|
330 |
@param aFrameRate Average frame rate of video (in Hz).
|
sl@0
|
331 |
@param aAvgBitRate Average bit rate of video.
|
sl@0
|
332 |
@param aSize Width and height of video image measured in pixels.
|
sl@0
|
333 |
@param aTimeScale Timescale of video track.
|
sl@0
|
334 |
|
sl@0
|
335 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
336 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
337 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
338 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
339 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
340 |
KErr3gpLibMoreDataRequired if more data is required before the requested information can be
|
sl@0
|
341 |
retrieved; See C3GPParse::InsertData.
|
sl@0
|
342 |
*/
|
sl@0
|
343 |
EXPORT_C TInt C3GPParse::GetVideoProperties(T3GPVideoType& aType, TUint& aLength, TReal& aFrameRate,
|
sl@0
|
344 |
TUint& aAvgBitRate, TSize& aSize, TUint& aTimeScale) const
|
sl@0
|
345 |
{
|
sl@0
|
346 |
if (!iHandler)
|
sl@0
|
347 |
{
|
sl@0
|
348 |
return KErrNotReady;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
TInt err = DoGetVideoProperties();
|
sl@0
|
352 |
|
sl@0
|
353 |
if (err == KErrNone)
|
sl@0
|
354 |
{
|
sl@0
|
355 |
aLength = iVideoLength;
|
sl@0
|
356 |
aType = iVideoType;
|
sl@0
|
357 |
aFrameRate = iVideoFrameRate;
|
sl@0
|
358 |
aSize.iWidth = iVideoSize.iWidth;
|
sl@0
|
359 |
aSize.iHeight = iVideoSize.iHeight;
|
sl@0
|
360 |
aTimeScale = iVideoTimeScale;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
else
|
sl@0
|
363 |
{
|
sl@0
|
364 |
return err;
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
// Get average bit rate of the stream in bps
|
sl@0
|
368 |
err = DoGetStreamProperties();
|
sl@0
|
369 |
if (err != KErrNone)
|
sl@0
|
370 |
{
|
sl@0
|
371 |
return err;
|
sl@0
|
372 |
}
|
sl@0
|
373 |
|
sl@0
|
374 |
// Video average bit rate is calculated from GetStreamDescription’s aAvgBitRate substructs Audio’s aAvgBitRate
|
sl@0
|
375 |
// GetAudioProperties has not been called
|
sl@0
|
376 |
err = DoGetAudioProperties();
|
sl@0
|
377 |
if (err == KErrNone)
|
sl@0
|
378 |
{
|
sl@0
|
379 |
aAvgBitRate = iStreamAvgBitRate - iAudioAvgBitRate;
|
sl@0
|
380 |
}
|
sl@0
|
381 |
else
|
sl@0
|
382 |
{
|
sl@0
|
383 |
// if the audio stream is not usable, ignore the error since the stream
|
sl@0
|
384 |
// in concern is video stream. The audio stream error can be dealt with by
|
sl@0
|
385 |
// users when it asks for audio properties.
|
sl@0
|
386 |
aAvgBitRate = iStreamAvgBitRate;
|
sl@0
|
387 |
}
|
sl@0
|
388 |
|
sl@0
|
389 |
return KErrNone;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
/**
|
sl@0
|
393 |
This function returns the parameters describing the audio stream.
|
sl@0
|
394 |
|
sl@0
|
395 |
If no file or CAF object is supplied during parser initialisation, this should be called after
|
sl@0
|
396 |
enough data has been inserted into the library so that the 3GP headers containing the information
|
sl@0
|
397 |
can be read.
|
sl@0
|
398 |
|
sl@0
|
399 |
@param aType The type of audio stream. Refer to T3GPFrameType for supported audio type values.
|
sl@0
|
400 |
@param aLength Duration of audio in milliseconds.
|
sl@0
|
401 |
@param aFramesPerSample Number of audio frames in each sample.
|
sl@0
|
402 |
@param aAvgBitRate Average bit rate of audio.
|
sl@0
|
403 |
@param aTimeScale Timescale of audio track.
|
sl@0
|
404 |
|
sl@0
|
405 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
406 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
407 |
KErrNotSupported if input does not contain audio;
|
sl@0
|
408 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
409 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
410 |
KErr3gpLibMoreDataRequired if more data is required before the requested information can be
|
sl@0
|
411 |
retrieved. See C3GPParse::InsertData.
|
sl@0
|
412 |
*/
|
sl@0
|
413 |
EXPORT_C TInt C3GPParse::GetAudioProperties(T3GPAudioType& aType, TUint& aLength, TInt& aFramesPerSample,
|
sl@0
|
414 |
TUint& aAvgBitRate, TUint& aTimeScale) const
|
sl@0
|
415 |
{
|
sl@0
|
416 |
if (!iHandler)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
return KErrNotReady;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
|
sl@0
|
421 |
TInt err = DoGetAudioProperties();
|
sl@0
|
422 |
|
sl@0
|
423 |
if (err == KErrNone)
|
sl@0
|
424 |
{
|
sl@0
|
425 |
aLength = iAudioLength;
|
sl@0
|
426 |
aType = iAudioType;
|
sl@0
|
427 |
aFramesPerSample = iAudioFramesPerSample;
|
sl@0
|
428 |
aAvgBitRate = iAudioAvgBitRate;
|
sl@0
|
429 |
aTimeScale = iAudioTimeScale;
|
sl@0
|
430 |
iAudioPropertiesSaved = ETrue;
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
return err;
|
sl@0
|
434 |
}
|
sl@0
|
435 |
|
sl@0
|
436 |
/**
|
sl@0
|
437 |
This function returns the parameters that describe the contents of the input file or buffer.
|
sl@0
|
438 |
|
sl@0
|
439 |
If no file or CAF object is supplied during parser initialisation, this should be called after
|
sl@0
|
440 |
enough data has been inserted into the library so that the headers containing the information can
|
sl@0
|
441 |
be read.
|
sl@0
|
442 |
|
sl@0
|
443 |
@param aSize Length of the stream in bytes.
|
sl@0
|
444 |
@param aAvgBitRate Average bit rate of the stream in bps.
|
sl@0
|
445 |
|
sl@0
|
446 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
447 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
448 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
449 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
450 |
KErr3gpLibMoreDataRequired if more data is required before the requested information can be
|
sl@0
|
451 |
retrieved. See C3GPParse::InsertData.
|
sl@0
|
452 |
*/
|
sl@0
|
453 |
EXPORT_C TInt C3GPParse::GetContainerProperties(TUint& aSize, TUint& aAvgBitRate) const
|
sl@0
|
454 |
{
|
sl@0
|
455 |
if (!iHandler)
|
sl@0
|
456 |
{
|
sl@0
|
457 |
return KErrNotReady;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
TInt err = DoGetStreamProperties();
|
sl@0
|
461 |
if (err == KErrNone)
|
sl@0
|
462 |
{
|
sl@0
|
463 |
aSize = iStreamSize;
|
sl@0
|
464 |
aAvgBitRate = iStreamAvgBitRate;
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
return err;
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
/**
|
sl@0
|
471 |
This function returns the number of bytes that the library instance has in its allocated buffers.
|
sl@0
|
472 |
|
sl@0
|
473 |
The function is only valid when the parser is initialized without any parameters. Zero is
|
sl@0
|
474 |
returned when in file mode, that is, the parser has been initialized with a valid filename, file handle
|
sl@0
|
475 |
or a CAF object.
|
sl@0
|
476 |
|
sl@0
|
477 |
@see C3GPParse::InsertData.
|
sl@0
|
478 |
|
sl@0
|
479 |
@param aNum Number of allocated bytes in the library.
|
sl@0
|
480 |
|
sl@0
|
481 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
482 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
483 |
KErrNotSupported if the parser has been initialised with a file name or file handle;
|
sl@0
|
484 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
485 |
*/
|
sl@0
|
486 |
EXPORT_C TInt C3GPParse::GetNumBufferedBytes(TInt& aNum) const
|
sl@0
|
487 |
{
|
sl@0
|
488 |
if (!iHandler)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
return KErrNotReady;
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
mp4_u32 numBytes = 0;
|
sl@0
|
494 |
MP4Err mp4Err = MP4ParseGetBufferedBytes(iHandler, &numBytes);
|
sl@0
|
495 |
aNum = numBytes;
|
sl@0
|
496 |
|
sl@0
|
497 |
return SymbianOSError(mp4Err);
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
/**
|
sl@0
|
501 |
This function returns the type of the next audio/video frame in the stream.
|
sl@0
|
502 |
|
sl@0
|
503 |
This function has no effect on the parser’s current position.
|
sl@0
|
504 |
|
sl@0
|
505 |
@param aType Type of the next frame. Refer to the definition of T3GPFrameType for all possible values.
|
sl@0
|
506 |
|
sl@0
|
507 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
508 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
509 |
KErrNotFound if frame does not exist (the previous frame was the last one);
|
sl@0
|
510 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
511 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
512 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
513 |
information can be returned.
|
sl@0
|
514 |
*/
|
sl@0
|
515 |
EXPORT_C TInt C3GPParse::GetFrameType(T3GPFrameType& aType) const
|
sl@0
|
516 |
{
|
sl@0
|
517 |
if (!iHandler)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
return KErrNotReady;
|
sl@0
|
520 |
}
|
sl@0
|
521 |
mp4_u32 frameType = 0;
|
sl@0
|
522 |
MP4Err mp4Err = MP4ParseNextFrameType(iHandler, &frameType);
|
sl@0
|
523 |
if (mp4Err == MP4_OK)
|
sl@0
|
524 |
{
|
sl@0
|
525 |
if (
|
sl@0
|
526 |
frameType == MP4_TYPE_MPEG4_VIDEO ||
|
sl@0
|
527 |
frameType == MP4_TYPE_H263_PROFILE_0 ||
|
sl@0
|
528 |
frameType == MP4_TYPE_H263_PROFILE_3 ||
|
sl@0
|
529 |
frameType == MP4_TYPE_AVC_PROFILE_BASELINE ||
|
sl@0
|
530 |
frameType == MP4_TYPE_AVC_PROFILE_MAIN ||
|
sl@0
|
531 |
frameType == MP4_TYPE_AVC_PROFILE_EXTENDED ||
|
sl@0
|
532 |
frameType == MP4_TYPE_AVC_PROFILE_HIGH
|
sl@0
|
533 |
)
|
sl@0
|
534 |
{
|
sl@0
|
535 |
aType = E3GPVideo;
|
sl@0
|
536 |
}
|
sl@0
|
537 |
else if (frameType == MP4_TYPE_MPEG4_AUDIO || frameType == MP4_TYPE_AMR_NB ||
|
sl@0
|
538 |
frameType == MP4_TYPE_AMR_WB || frameType == MP4_TYPE_QCELP_13K)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
aType = E3GPAudio;
|
sl@0
|
541 |
}
|
sl@0
|
542 |
else
|
sl@0
|
543 |
{
|
sl@0
|
544 |
// This should not happen
|
sl@0
|
545 |
Panic(KErrCorrupt);
|
sl@0
|
546 |
}
|
sl@0
|
547 |
}
|
sl@0
|
548 |
return SymbianOSError(mp4Err);
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
/**
|
sl@0
|
552 |
This function returns the size of the immediate next video frame based on the current
|
sl@0
|
553 |
position of the parser.
|
sl@0
|
554 |
|
sl@0
|
555 |
Calling this function does not change the current position of the parser.
|
sl@0
|
556 |
|
sl@0
|
557 |
@param aSize Size of the next video frame in bytes.
|
sl@0
|
558 |
|
sl@0
|
559 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
560 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
561 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
562 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
563 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
564 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
565 |
information can be returned.
|
sl@0
|
566 |
*/
|
sl@0
|
567 |
EXPORT_C TInt C3GPParse::GetVideoFrameSize(TUint& aSize) const
|
sl@0
|
568 |
{
|
sl@0
|
569 |
if (!iHandler)
|
sl@0
|
570 |
{
|
sl@0
|
571 |
return KErrNotReady;
|
sl@0
|
572 |
}
|
sl@0
|
573 |
|
sl@0
|
574 |
// Check if 3GP input data contains video stream
|
sl@0
|
575 |
TInt err = DoGetVideoProperties();
|
sl@0
|
576 |
if (err != KErrNone)
|
sl@0
|
577 |
{
|
sl@0
|
578 |
return err;
|
sl@0
|
579 |
}
|
sl@0
|
580 |
|
sl@0
|
581 |
// video type from 3GP file header has been saved
|
sl@0
|
582 |
mp4_u32 frameSize = 0;
|
sl@0
|
583 |
MP4Err mp4Err = MP4ParseNextFrameSize(iHandler, iVideoMp4Type, &frameSize);
|
sl@0
|
584 |
if (mp4Err == MP4_OK)
|
sl@0
|
585 |
{
|
sl@0
|
586 |
aSize = frameSize;
|
sl@0
|
587 |
}
|
sl@0
|
588 |
|
sl@0
|
589 |
return SymbianOSError(mp4Err);
|
sl@0
|
590 |
}
|
sl@0
|
591 |
|
sl@0
|
592 |
/**
|
sl@0
|
593 |
This function returns the total size of the audio frames in the immediate audio sample based on the
|
sl@0
|
594 |
current position of the parser.
|
sl@0
|
595 |
|
sl@0
|
596 |
This function has no effect on the parser’s current position.
|
sl@0
|
597 |
|
sl@0
|
598 |
@param aSize Size of the next audio sample in bytes.
|
sl@0
|
599 |
|
sl@0
|
600 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
601 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
602 |
KErrNotSupported if the input does not contain audio;
|
sl@0
|
603 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
604 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
605 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
606 |
information can be returned.
|
sl@0
|
607 |
*/
|
sl@0
|
608 |
EXPORT_C TInt C3GPParse::GetAudioFramesSize(TUint& aSize) const
|
sl@0
|
609 |
{
|
sl@0
|
610 |
if (!iHandler)
|
sl@0
|
611 |
{
|
sl@0
|
612 |
return KErrNotReady;
|
sl@0
|
613 |
}
|
sl@0
|
614 |
|
sl@0
|
615 |
// Check if 3GP input data contains audio stream
|
sl@0
|
616 |
TInt err = DoGetAudioProperties();
|
sl@0
|
617 |
if (err != KErrNone)
|
sl@0
|
618 |
{
|
sl@0
|
619 |
return err;
|
sl@0
|
620 |
}
|
sl@0
|
621 |
|
sl@0
|
622 |
// audio type from 3GP file header has been saved. Directely use iAudioMp4Type as input
|
sl@0
|
623 |
mp4_u32 frameSize = 0;
|
sl@0
|
624 |
|
sl@0
|
625 |
MP4Err mp4Err = MP4ParseNextFrameSize(iHandler, iAudioMp4Type, &frameSize);
|
sl@0
|
626 |
if (mp4Err == MP4_OK)
|
sl@0
|
627 |
{
|
sl@0
|
628 |
aSize = frameSize;
|
sl@0
|
629 |
}
|
sl@0
|
630 |
|
sl@0
|
631 |
return SymbianOSError(mp4Err);
|
sl@0
|
632 |
}
|
sl@0
|
633 |
|
sl@0
|
634 |
/**
|
sl@0
|
635 |
This function reads the next video frame from the 3GP file/stream and returns it to the caller.
|
sl@0
|
636 |
The current position of video stream will be moved forward.
|
sl@0
|
637 |
|
sl@0
|
638 |
The next frame depends on the position in the input 3GP file. C3GPParse::Seek can be used to change
|
sl@0
|
639 |
the current position in the 3GP file.
|
sl@0
|
640 |
|
sl@0
|
641 |
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData
|
sl@0
|
642 |
to insert more data before calling the function again.
|
sl@0
|
643 |
|
sl@0
|
644 |
Since there are separate cursors for storing current positions of video and audio streams, calling this
|
sl@0
|
645 |
function does not affect the position of the next audio stream.
|
sl@0
|
646 |
|
sl@0
|
647 |
@param aBuffer Video frame is returned here.
|
sl@0
|
648 |
@param aKeyFrame Returns ETrue if the current frame is a key frame (intra), otherwise the value is EFalse.
|
sl@0
|
649 |
@param aTimeStampInMs Video frame presentation time in milliseconds from the beginning of the video sequence.
|
sl@0
|
650 |
@param aTimeStampInTimescale Video frame presentation time in timescale from the beginning of the video sequence.
|
sl@0
|
651 |
|
sl@0
|
652 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
653 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
654 |
KErrNotSupported if the 3GP input data contains no video stream;
|
sl@0
|
655 |
KErrNotFound if frame does not exist (the previous frame was the last one);
|
sl@0
|
656 |
KErrOverflow if requested frame does not fit into the given buffer; Caller can use
|
sl@0
|
657 |
C3GPParse::GetVideoFrameSize to retrieve the minimum buffer size needed
|
sl@0
|
658 |
to fit this video frame;
|
sl@0
|
659 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
660 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
661 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
662 |
information can be returned.
|
sl@0
|
663 |
*/
|
sl@0
|
664 |
EXPORT_C TInt C3GPParse::ReadVideoFrame(TDes8& aBuffer, TBool& aKeyFrame, TUint& aTimeStampInMs,
|
sl@0
|
665 |
TUint& aTimeStampInTimescale) const
|
sl@0
|
666 |
{
|
sl@0
|
667 |
if (!iHandler)
|
sl@0
|
668 |
{
|
sl@0
|
669 |
return KErrNotReady;
|
sl@0
|
670 |
}
|
sl@0
|
671 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
672 |
{
|
sl@0
|
673 |
return KErrOverflow;
|
sl@0
|
674 |
}
|
sl@0
|
675 |
|
sl@0
|
676 |
// Check if 3GP input data contains video stream
|
sl@0
|
677 |
TInt err = DoGetVideoProperties();
|
sl@0
|
678 |
if (err != KErrNone)
|
sl@0
|
679 |
{
|
sl@0
|
680 |
return err;
|
sl@0
|
681 |
}
|
sl@0
|
682 |
|
sl@0
|
683 |
mp4_u32 frameSize = 0;
|
sl@0
|
684 |
mp4_u32 timeStamp = 0;
|
sl@0
|
685 |
mp4_bool keyFrame = EFalse;
|
sl@0
|
686 |
mp4_u32 timestamp2 = 0;
|
sl@0
|
687 |
|
sl@0
|
688 |
MP4Err mp4Err = MP4ParseReadVideoFrame(iHandler, const_cast<mp4_u8*>(aBuffer.Ptr()), aBuffer.MaxLength(),
|
sl@0
|
689 |
&frameSize, &timeStamp, &keyFrame, ×tamp2);
|
sl@0
|
690 |
|
sl@0
|
691 |
if (mp4Err == MP4_OK)
|
sl@0
|
692 |
{
|
sl@0
|
693 |
aBuffer.SetLength(frameSize);
|
sl@0
|
694 |
aKeyFrame = keyFrame;
|
sl@0
|
695 |
aTimeStampInMs = timeStamp;
|
sl@0
|
696 |
aTimeStampInTimescale = timestamp2;
|
sl@0
|
697 |
}
|
sl@0
|
698 |
return SymbianOSError(mp4Err);
|
sl@0
|
699 |
}
|
sl@0
|
700 |
|
sl@0
|
701 |
/**
|
sl@0
|
702 |
Return size of video DecoderSpecificInfo.
|
sl@0
|
703 |
For files with MPEG-4 video this data is read from the esds atom. For files with AVC video
|
sl@0
|
704 |
this data is read from the avcC atom.
|
sl@0
|
705 |
|
sl@0
|
706 |
Note: Only MPEG-4 video and H.264/AVC video streams contain DecoderSpecificInfo.
|
sl@0
|
707 |
|
sl@0
|
708 |
@param aSize Size of video DecoderSpecificInfo.
|
sl@0
|
709 |
|
sl@0
|
710 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
711 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
712 |
KErrNotSupported if the 3GP input data contains no MPEG-4 / AVC video stream;
|
sl@0
|
713 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
714 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
715 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
716 |
information can be returned.
|
sl@0
|
717 |
*/
|
sl@0
|
718 |
EXPORT_C TInt C3GPParse::GetVideoDecoderSpecificInfoSize(TInt& aSize) const
|
sl@0
|
719 |
{
|
sl@0
|
720 |
if (!iHandler)
|
sl@0
|
721 |
{
|
sl@0
|
722 |
return KErrNotReady;
|
sl@0
|
723 |
}
|
sl@0
|
724 |
|
sl@0
|
725 |
// Check if 3GP input data contains video stream and the video type is either
|
sl@0
|
726 |
// MPEG-4 or H.264/AVC
|
sl@0
|
727 |
TInt err = DoGetVideoProperties();
|
sl@0
|
728 |
if (err == KErrNone)
|
sl@0
|
729 |
{
|
sl@0
|
730 |
if (!(
|
sl@0
|
731 |
iVideoType == E3GPMpeg4Video ||
|
sl@0
|
732 |
iVideoType == E3GPAvcProfileBaseline ||
|
sl@0
|
733 |
iVideoType == E3GPAvcProfileMain ||
|
sl@0
|
734 |
iVideoType == E3GPAvcProfileExtended ||
|
sl@0
|
735 |
iVideoType == E3GPAvcProfileHigh
|
sl@0
|
736 |
))
|
sl@0
|
737 |
{
|
sl@0
|
738 |
return KErrNotSupported;
|
sl@0
|
739 |
}
|
sl@0
|
740 |
}
|
sl@0
|
741 |
else
|
sl@0
|
742 |
{
|
sl@0
|
743 |
return err;
|
sl@0
|
744 |
}
|
sl@0
|
745 |
|
sl@0
|
746 |
mp4_u32 decspecinfosize = 0;
|
sl@0
|
747 |
MP4Err mp4Err = MP4ParseReadVideoDecoderSpecificInfo(iHandler, NULL, 0, &decspecinfosize);
|
sl@0
|
748 |
|
sl@0
|
749 |
if ( mp4Err == MP4_OK || mp4Err == MP4_BUFFER_TOO_SMALL)
|
sl@0
|
750 |
{
|
sl@0
|
751 |
aSize = decspecinfosize;
|
sl@0
|
752 |
mp4Err = MP4_OK;
|
sl@0
|
753 |
}
|
sl@0
|
754 |
|
sl@0
|
755 |
return SymbianOSError(mp4Err);
|
sl@0
|
756 |
}
|
sl@0
|
757 |
|
sl@0
|
758 |
/**
|
sl@0
|
759 |
This function reads DecoderSpecificInfo data from 3GP metadata and returns it to the caller.
|
sl@0
|
760 |
For files with MPEG-4 video this data is read from the esds atom. For files with AVC video
|
sl@0
|
761 |
this data is read from the avcC atom.
|
sl@0
|
762 |
|
sl@0
|
763 |
Note: Only MPEG-4 video and H.264/AVC video streams contain DecoderSpecificInfo.
|
sl@0
|
764 |
|
sl@0
|
765 |
@see C3GPParse::GetVideoDecoderSpecificInfoSize
|
sl@0
|
766 |
|
sl@0
|
767 |
@param aInfo The descriptor to store the video decoder information.
|
sl@0
|
768 |
|
sl@0
|
769 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
770 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
771 |
KErrNotSupported if the 3GP input data contains no MPEG-4 / AVC video stream;
|
sl@0
|
772 |
KErrOverflow if requested frame does not fit into the given buffer;
|
sl@0
|
773 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
774 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
775 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
776 |
information can be returned.
|
sl@0
|
777 |
*/
|
sl@0
|
778 |
EXPORT_C TInt C3GPParse::GetVideoDecoderSpecificInfo(TDes8& aInfo) const
|
sl@0
|
779 |
{
|
sl@0
|
780 |
if (!iHandler)
|
sl@0
|
781 |
{
|
sl@0
|
782 |
return KErrNotReady;
|
sl@0
|
783 |
}
|
sl@0
|
784 |
if (aInfo.MaxLength() <= 0)
|
sl@0
|
785 |
{
|
sl@0
|
786 |
return KErrOverflow;
|
sl@0
|
787 |
}
|
sl@0
|
788 |
|
sl@0
|
789 |
// Check if 3GP input data contains video stream and the video type is either
|
sl@0
|
790 |
// MPEG-4 or H.264/AVC
|
sl@0
|
791 |
TInt err = DoGetVideoProperties();
|
sl@0
|
792 |
if (err == KErrNone)
|
sl@0
|
793 |
{
|
sl@0
|
794 |
if (!(
|
sl@0
|
795 |
iVideoType == E3GPMpeg4Video ||
|
sl@0
|
796 |
iVideoType == E3GPAvcProfileBaseline ||
|
sl@0
|
797 |
iVideoType == E3GPAvcProfileMain ||
|
sl@0
|
798 |
iVideoType == E3GPAvcProfileExtended ||
|
sl@0
|
799 |
iVideoType == E3GPAvcProfileHigh
|
sl@0
|
800 |
))
|
sl@0
|
801 |
{
|
sl@0
|
802 |
return KErrNotSupported;
|
sl@0
|
803 |
}
|
sl@0
|
804 |
}
|
sl@0
|
805 |
else
|
sl@0
|
806 |
{
|
sl@0
|
807 |
return err;
|
sl@0
|
808 |
}
|
sl@0
|
809 |
|
sl@0
|
810 |
mp4_u32 decspecinfosize = 0;
|
sl@0
|
811 |
MP4Err mp4Err = MP4ParseReadVideoDecoderSpecificInfo(iHandler, const_cast<mp4_u8*>(aInfo.Ptr()),
|
sl@0
|
812 |
aInfo.MaxLength(),&decspecinfosize);
|
sl@0
|
813 |
if (mp4Err == MP4_OK)
|
sl@0
|
814 |
{
|
sl@0
|
815 |
aInfo.SetLength(decspecinfosize);
|
sl@0
|
816 |
}
|
sl@0
|
817 |
return SymbianOSError(mp4Err);
|
sl@0
|
818 |
}
|
sl@0
|
819 |
|
sl@0
|
820 |
/**
|
sl@0
|
821 |
This function reads the audio frames that are stored in the current audio sample from the
|
sl@0
|
822 |
3GP file/stream and returns them to the caller. The current position of audio stream will be moved forward.
|
sl@0
|
823 |
|
sl@0
|
824 |
Note: The next frame depends on the position in the input 3GP file. C3GPParse::Seek can
|
sl@0
|
825 |
be used to change the current position in the 3GP file.
|
sl@0
|
826 |
|
sl@0
|
827 |
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData
|
sl@0
|
828 |
to insert more data before calling the function again.
|
sl@0
|
829 |
|
sl@0
|
830 |
Note: aReturnedFrames may differ from the correct value when accessing the last audio sample.
|
sl@0
|
831 |
|
sl@0
|
832 |
Note: Since there are separate cursors for storing current positions for video and audio streams, calling
|
sl@0
|
833 |
this function does not change current position of the parser for video stream.
|
sl@0
|
834 |
|
sl@0
|
835 |
@param aBuffer Audio frames are returned here.
|
sl@0
|
836 |
@param aReturnedFrames Number of the returned frames or 0 if not known.
|
sl@0
|
837 |
@param aTimeStampInMs Audio frame presentation time in milliseconds from the beginning of the
|
sl@0
|
838 |
audio sequence.
|
sl@0
|
839 |
@param aTimeStampInTimescale Audio frame presentation time in timescale from the beginning
|
sl@0
|
840 |
of the audio sequence.
|
sl@0
|
841 |
|
sl@0
|
842 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
843 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
844 |
KErrNotSupported if the 3GP input data contains no audio stream;
|
sl@0
|
845 |
KErrOverflow if requested frame does not fit into the given buffer; Caller can use
|
sl@0
|
846 |
C3GPParse::GetAudioFrameSize to retrieve the minimum size needed to
|
sl@0
|
847 |
fit this audio frame;
|
sl@0
|
848 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
849 |
KErrNotFound if no more frames available;
|
sl@0
|
850 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
851 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
852 |
information can be returned.
|
sl@0
|
853 |
*/
|
sl@0
|
854 |
EXPORT_C TInt C3GPParse::ReadAudioFrames(TDes8& aBuffer, TInt& aReturnedFrames, TUint& aTimeStampInMs,
|
sl@0
|
855 |
TUint& aTimeStampInTimescale) const
|
sl@0
|
856 |
{
|
sl@0
|
857 |
if (!iHandler)
|
sl@0
|
858 |
{
|
sl@0
|
859 |
return KErrNotReady;
|
sl@0
|
860 |
}
|
sl@0
|
861 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
862 |
{
|
sl@0
|
863 |
return KErrOverflow;
|
sl@0
|
864 |
}
|
sl@0
|
865 |
|
sl@0
|
866 |
// Check if 3GP input data contains audio stream
|
sl@0
|
867 |
TInt err = DoGetAudioProperties();
|
sl@0
|
868 |
if (err != KErrNone)
|
sl@0
|
869 |
{
|
sl@0
|
870 |
return err;
|
sl@0
|
871 |
}
|
sl@0
|
872 |
|
sl@0
|
873 |
mp4_u32 numOfFrames = 0;
|
sl@0
|
874 |
mp4_u32 timeStampInMs = 0;
|
sl@0
|
875 |
mp4_u32 timeStampInTimescale = 0;
|
sl@0
|
876 |
mp4_u32 audioSize = 0;
|
sl@0
|
877 |
MP4Err mp4Err = MP4ParseReadAudioFrames(iHandler, const_cast<mp4_u8*>(aBuffer.Ptr()), aBuffer.MaxLength(),
|
sl@0
|
878 |
&audioSize, &timeStampInMs, &numOfFrames, &timeStampInTimescale);
|
sl@0
|
879 |
if (mp4Err == MP4_OK)
|
sl@0
|
880 |
{
|
sl@0
|
881 |
aBuffer.SetLength(audioSize);
|
sl@0
|
882 |
aReturnedFrames = numOfFrames;
|
sl@0
|
883 |
aTimeStampInMs = timeStampInMs;
|
sl@0
|
884 |
aTimeStampInTimescale = timeStampInTimescale;
|
sl@0
|
885 |
}
|
sl@0
|
886 |
return SymbianOSError(mp4Err);
|
sl@0
|
887 |
}
|
sl@0
|
888 |
|
sl@0
|
889 |
/**
|
sl@0
|
890 |
Returns size of audio DecoderSpecificInfo data from 3GP metadata.
|
sl@0
|
891 |
|
sl@0
|
892 |
@param aSize Size of DecoderSpecificInfo to be returned (in bytes).
|
sl@0
|
893 |
|
sl@0
|
894 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
895 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
896 |
KErrNotSupported if the stream does not contain audio stream stored in MPEG-4 audio sample boxes.
|
sl@0
|
897 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
898 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
899 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
900 |
information can be returned.
|
sl@0
|
901 |
*/
|
sl@0
|
902 |
EXPORT_C TInt C3GPParse::GetAudioDecoderSpecificInfoSize(TInt& aSize) const
|
sl@0
|
903 |
{
|
sl@0
|
904 |
if (!iHandler)
|
sl@0
|
905 |
{
|
sl@0
|
906 |
return KErrNotReady;
|
sl@0
|
907 |
}
|
sl@0
|
908 |
|
sl@0
|
909 |
// Check if 3GP input data contains audio stream
|
sl@0
|
910 |
TInt err = DoGetAudioProperties();
|
sl@0
|
911 |
if (err != KErrNone)
|
sl@0
|
912 |
{
|
sl@0
|
913 |
return err;
|
sl@0
|
914 |
}
|
sl@0
|
915 |
|
sl@0
|
916 |
mp4_u32 decspecinfosize = 0;
|
sl@0
|
917 |
MP4Err mp4Err = MP4ParseReadAudioDecoderSpecificInfo(iHandler, NULL, 0, &decspecinfosize);
|
sl@0
|
918 |
if ( mp4Err == MP4_OK || mp4Err == MP4_BUFFER_TOO_SMALL)
|
sl@0
|
919 |
{
|
sl@0
|
920 |
aSize = decspecinfosize;
|
sl@0
|
921 |
mp4Err = MP4_OK;
|
sl@0
|
922 |
}
|
sl@0
|
923 |
return SymbianOSError(mp4Err);
|
sl@0
|
924 |
}
|
sl@0
|
925 |
|
sl@0
|
926 |
/**
|
sl@0
|
927 |
This function reads DecoderSpecificInfo data from 3GP metadata and returns it to the caller.
|
sl@0
|
928 |
|
sl@0
|
929 |
Note: AMR DecoderSpecificInfo data structure is returned in runtime in an architecture-specific
|
sl@0
|
930 |
Endian format, that is, no Endian conversion is necessary for the data.
|
sl@0
|
931 |
|
sl@0
|
932 |
@see C3GPParse::GetAudioDecoderSpecificInfoSize
|
sl@0
|
933 |
|
sl@0
|
934 |
@param aBuffer DecoderSpecificInfo is returned here.
|
sl@0
|
935 |
|
sl@0
|
936 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
937 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
938 |
KErrNotSupported if the stream does not contain audio stream stored in MPEG-4 audio sample boxes.
|
sl@0
|
939 |
KErrOverflow if requested frame does not fit into the given buffer;
|
sl@0
|
940 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
941 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
942 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
943 |
information can be returned.
|
sl@0
|
944 |
*/
|
sl@0
|
945 |
EXPORT_C TInt C3GPParse::GetAudioDecoderSpecificInfo(TDes8& aBuffer) const
|
sl@0
|
946 |
{
|
sl@0
|
947 |
if (!iHandler)
|
sl@0
|
948 |
{
|
sl@0
|
949 |
return KErrNotReady;
|
sl@0
|
950 |
}
|
sl@0
|
951 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
952 |
{
|
sl@0
|
953 |
return KErrOverflow;
|
sl@0
|
954 |
}
|
sl@0
|
955 |
|
sl@0
|
956 |
// Check if 3GP input data contains audio stream
|
sl@0
|
957 |
TInt err = DoGetAudioProperties();
|
sl@0
|
958 |
if (err != KErrNone)
|
sl@0
|
959 |
{
|
sl@0
|
960 |
return err;
|
sl@0
|
961 |
}
|
sl@0
|
962 |
|
sl@0
|
963 |
mp4_u32 decspecinfosize = 0;
|
sl@0
|
964 |
MP4Err mp4Err = MP4ParseReadAudioDecoderSpecificInfo(iHandler, const_cast<mp4_u8*>(aBuffer.Ptr()),
|
sl@0
|
965 |
aBuffer.MaxLength(),&decspecinfosize);
|
sl@0
|
966 |
if (mp4Err == MP4_OK)
|
sl@0
|
967 |
{
|
sl@0
|
968 |
aBuffer.SetLength(decspecinfosize);
|
sl@0
|
969 |
}
|
sl@0
|
970 |
return SymbianOSError(mp4Err);
|
sl@0
|
971 |
}
|
sl@0
|
972 |
|
sl@0
|
973 |
/**
|
sl@0
|
974 |
Returns the timestamp of the next video frame. The current position of the video stream will be moved forward.
|
sl@0
|
975 |
|
sl@0
|
976 |
The function can be used to find out which frames have been coded to optimize the input frame selection
|
sl@0
|
977 |
if video frame rate needs to be modified.
|
sl@0
|
978 |
|
sl@0
|
979 |
When this function call returns KErrEof, there are no more video frames left in the 3GP file and
|
sl@0
|
980 |
the timestamp returned with the previous call was the timestamp of the last video frame.
|
sl@0
|
981 |
|
sl@0
|
982 |
Note: C3GPParse::Seek can be used to change the current position in the 3GP file.
|
sl@0
|
983 |
|
sl@0
|
984 |
@param aTimeStampInMs Timestamp in milliseconds is returned here.
|
sl@0
|
985 |
@param aTimeStampInTimescale Timestamp in timescale is returned here.
|
sl@0
|
986 |
|
sl@0
|
987 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
988 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
989 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
990 |
KErrEof if no more video frames left;
|
sl@0
|
991 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
992 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
993 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
994 |
information can be returned.
|
sl@0
|
995 |
*/
|
sl@0
|
996 |
EXPORT_C TInt C3GPParse::GetVideoTimestamp(TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const
|
sl@0
|
997 |
{
|
sl@0
|
998 |
if (!iHandler)
|
sl@0
|
999 |
{
|
sl@0
|
1000 |
return KErrNotReady;
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
|
sl@0
|
1003 |
// Check if 3GP input data contains video stream
|
sl@0
|
1004 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1005 |
if (err != KErrNone)
|
sl@0
|
1006 |
{
|
sl@0
|
1007 |
return err;
|
sl@0
|
1008 |
}
|
sl@0
|
1009 |
|
sl@0
|
1010 |
mp4_u32 timeStampInMs = 0;
|
sl@0
|
1011 |
mp4_u32 timeStampInTimescale = 0;
|
sl@0
|
1012 |
MP4Err mp4Err = MP4ParseGetNextVideoTimestamp(iHandler, &timeStampInMs, &timeStampInTimescale);
|
sl@0
|
1013 |
if (mp4Err == MP4_OK)
|
sl@0
|
1014 |
{
|
sl@0
|
1015 |
aTimeStampInMs = timeStampInMs;
|
sl@0
|
1016 |
aTimeStampInTimescale = timeStampInTimescale;
|
sl@0
|
1017 |
}
|
sl@0
|
1018 |
return SymbianOSError(mp4Err);
|
sl@0
|
1019 |
}
|
sl@0
|
1020 |
|
sl@0
|
1021 |
/**
|
sl@0
|
1022 |
This function determines whether the input 3GP stream is streamable, that is, whether the media data is arranged
|
sl@0
|
1023 |
in such a manner that playback can be started without downloading the entire stream.
|
sl@0
|
1024 |
|
sl@0
|
1025 |
@param aStreamable Returns ETrue if the file is streamable. Otherwise, returns EFalse.
|
sl@0
|
1026 |
|
sl@0
|
1027 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1028 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1029 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
1030 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
1031 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
1032 |
information can be returned.
|
sl@0
|
1033 |
*/
|
sl@0
|
1034 |
EXPORT_C TInt C3GPParse::GetStreamable(TBool& aStreamable) const
|
sl@0
|
1035 |
{
|
sl@0
|
1036 |
if (!iHandler)
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
return KErrNotReady;
|
sl@0
|
1039 |
}
|
sl@0
|
1040 |
|
sl@0
|
1041 |
MP4Err mp4Err = MP4ParseIsStreamable(iHandler);
|
sl@0
|
1042 |
if (mp4Err == MP4_OK)
|
sl@0
|
1043 |
{
|
sl@0
|
1044 |
aStreamable = ETrue;
|
sl@0
|
1045 |
}
|
sl@0
|
1046 |
else
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
aStreamable = EFalse;
|
sl@0
|
1049 |
}
|
sl@0
|
1050 |
return SymbianOSError(mp4Err);
|
sl@0
|
1051 |
}
|
sl@0
|
1052 |
|
sl@0
|
1053 |
/**
|
sl@0
|
1054 |
This function seeks the position specified by the aPosition parameter in the input 3GP file/stream.
|
sl@0
|
1055 |
|
sl@0
|
1056 |
The position is considered to start from the beginning of the presentation time line in the 3GP file.
|
sl@0
|
1057 |
Thus audio and video positions cannot be given separately.
|
sl@0
|
1058 |
|
sl@0
|
1059 |
The function will set the current audio and video positions in the following manner:
|
sl@0
|
1060 |
|
sl@0
|
1061 |
If there is only audio data in the file, the current position is set to the audio frame at or just
|
sl@0
|
1062 |
before the given position.
|
sl@0
|
1063 |
|
sl@0
|
1064 |
If there is only video in the file and the key frame is EFalse, the current position is set to the
|
sl@0
|
1065 |
video frame at or just before the given position. If the key frame is set to ETrue, the current
|
sl@0
|
1066 |
position is set to the first key frame at or before the current position.
|
sl@0
|
1067 |
|
sl@0
|
1068 |
If there are both audio and video in the file, video is first positioned as explained above and then
|
sl@0
|
1069 |
audio is sought to the closest position in relation to video.
|
sl@0
|
1070 |
|
sl@0
|
1071 |
If the position to seek is greater than the duration of video or audio, the video or audio position is
|
sl@0
|
1072 |
set to the position of the last video or audio frame as explained above.
|
sl@0
|
1073 |
|
sl@0
|
1074 |
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData
|
sl@0
|
1075 |
to insert more data before calling the function again.
|
sl@0
|
1076 |
|
sl@0
|
1077 |
@param aPosition Position to seek in milliseconds in the 3GP presentation time line.
|
sl@0
|
1078 |
@param aKeyFrame If set to ETrue, the first video key frame before a given point is sought. If
|
sl@0
|
1079 |
set to EFalse, the first video frame before a given point is sought.
|
sl@0
|
1080 |
@param aAudioPosition Position of audio after seeking (in milliseconds).
|
sl@0
|
1081 |
@param aVideoPosition Position of video after seeking (in milliseconds).
|
sl@0
|
1082 |
|
sl@0
|
1083 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1084 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1085 |
KErrNotFound if cannot seek the requested position;
|
sl@0
|
1086 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
1087 |
information can be returned.
|
sl@0
|
1088 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
1089 |
*/
|
sl@0
|
1090 |
EXPORT_C TInt C3GPParse::Seek(TUint aPosition, TBool aKeyFrame, TUint& aAudioPosition, TUint& aVideoPosition) const
|
sl@0
|
1091 |
{
|
sl@0
|
1092 |
if (!iHandler)
|
sl@0
|
1093 |
{
|
sl@0
|
1094 |
return KErrNotReady;
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
|
sl@0
|
1097 |
mp4_u32 audioPosition = 0;
|
sl@0
|
1098 |
mp4_u32 videoPosition = 0;
|
sl@0
|
1099 |
mp4_bool keyFrame = aKeyFrame;
|
sl@0
|
1100 |
MP4Err mp4Err = MP4ParseSeek(iHandler, aPosition, &audioPosition, &videoPosition, keyFrame);
|
sl@0
|
1101 |
if (mp4Err == MP4_OK)
|
sl@0
|
1102 |
{
|
sl@0
|
1103 |
aAudioPosition = audioPosition;
|
sl@0
|
1104 |
aVideoPosition = videoPosition;
|
sl@0
|
1105 |
}
|
sl@0
|
1106 |
return SymbianOSError(mp4Err);
|
sl@0
|
1107 |
}
|
sl@0
|
1108 |
|
sl@0
|
1109 |
/**
|
sl@0
|
1110 |
This function determines whether the next frame of the type aType is available.
|
sl@0
|
1111 |
|
sl@0
|
1112 |
This function has no effect on the parser’s current position.
|
sl@0
|
1113 |
|
sl@0
|
1114 |
@param aType The type of frame to check for. Refer to T3GPFrameType for supported types.
|
sl@0
|
1115 |
@param aAvailable Return ETrue if the type of frame specified by aType is available.
|
sl@0
|
1116 |
|
sl@0
|
1117 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1118 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1119 |
KErrNotFound if frame of the requested type is not available;
|
sl@0
|
1120 |
KErrCorrupt if 3GP stream is invalid;
|
sl@0
|
1121 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
1122 |
KErr3gpLibMoreDataRequired if 3GP library needs more data before the requested
|
sl@0
|
1123 |
information can be returned.
|
sl@0
|
1124 |
*/
|
sl@0
|
1125 |
EXPORT_C TInt C3GPParse::GetFrameAvailability(T3GPFrameType aType, TBool& aAvailable) const
|
sl@0
|
1126 |
{
|
sl@0
|
1127 |
if (!iHandler)
|
sl@0
|
1128 |
{
|
sl@0
|
1129 |
return KErrNotReady;
|
sl@0
|
1130 |
}
|
sl@0
|
1131 |
|
sl@0
|
1132 |
aAvailable = EFalse;
|
sl@0
|
1133 |
TInt err = KErrNone;
|
sl@0
|
1134 |
MP4Err mp4Err = MP4_OK;
|
sl@0
|
1135 |
if (aType == E3GPAudio)
|
sl@0
|
1136 |
{
|
sl@0
|
1137 |
// Check if 3GP input data contains audio stream
|
sl@0
|
1138 |
err = DoGetAudioProperties();
|
sl@0
|
1139 |
if (err == KErrNotSupported)
|
sl@0
|
1140 |
{
|
sl@0
|
1141 |
// If there is no requested type, err will be KErrNotSupported. But in here, KErrNotFound is
|
sl@0
|
1142 |
// more proper.
|
sl@0
|
1143 |
err = KErrNotFound;
|
sl@0
|
1144 |
}
|
sl@0
|
1145 |
else if (err == KErrNone)
|
sl@0
|
1146 |
{
|
sl@0
|
1147 |
mp4Err = MP4ParseIsFrameAvailable(iHandler, iAudioMp4Type);
|
sl@0
|
1148 |
err = SymbianOSError(mp4Err);
|
sl@0
|
1149 |
}
|
sl@0
|
1150 |
}
|
sl@0
|
1151 |
else if (aType == E3GPVideo)
|
sl@0
|
1152 |
{
|
sl@0
|
1153 |
// Check if 3GP input data contains video stream
|
sl@0
|
1154 |
err = DoGetVideoProperties();
|
sl@0
|
1155 |
if (err == KErrNotSupported)
|
sl@0
|
1156 |
{
|
sl@0
|
1157 |
// If there is no requested type, err will be KErrNotSupported. But in here, KErrNotFound is
|
sl@0
|
1158 |
// more proper.
|
sl@0
|
1159 |
err = KErrNotFound;
|
sl@0
|
1160 |
}
|
sl@0
|
1161 |
else if (err == KErrNone)
|
sl@0
|
1162 |
{
|
sl@0
|
1163 |
mp4Err = MP4ParseIsFrameAvailable(iHandler, iVideoMp4Type);
|
sl@0
|
1164 |
err = SymbianOSError(mp4Err);
|
sl@0
|
1165 |
}
|
sl@0
|
1166 |
}
|
sl@0
|
1167 |
else
|
sl@0
|
1168 |
{
|
sl@0
|
1169 |
Panic(KErrArgument); // This should not happen.
|
sl@0
|
1170 |
}
|
sl@0
|
1171 |
|
sl@0
|
1172 |
if (err == KErrNone)
|
sl@0
|
1173 |
{
|
sl@0
|
1174 |
aAvailable = ETrue;
|
sl@0
|
1175 |
}
|
sl@0
|
1176 |
return err;
|
sl@0
|
1177 |
}
|
sl@0
|
1178 |
|
sl@0
|
1179 |
/**
|
sl@0
|
1180 |
Returns the number of video frames.
|
sl@0
|
1181 |
|
sl@0
|
1182 |
@param aNum Number of video frames.
|
sl@0
|
1183 |
|
sl@0
|
1184 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1185 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1186 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
1187 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1188 |
*/
|
sl@0
|
1189 |
EXPORT_C TInt C3GPParse::GetNumberOfVideoFrames(TUint& aNum) const
|
sl@0
|
1190 |
{
|
sl@0
|
1191 |
if (!iHandler)
|
sl@0
|
1192 |
{
|
sl@0
|
1193 |
return KErrNotReady;
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
|
sl@0
|
1196 |
// Check if 3GP input data contains video stream
|
sl@0
|
1197 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1198 |
if (err != KErrNone)
|
sl@0
|
1199 |
{
|
sl@0
|
1200 |
return err;
|
sl@0
|
1201 |
}
|
sl@0
|
1202 |
|
sl@0
|
1203 |
mp4_u32 numVideoFrame = 0;
|
sl@0
|
1204 |
MP4Err mp4Err = MP4ParseGetNumberOfVideoFrames(iHandler, &numVideoFrame);
|
sl@0
|
1205 |
if (mp4Err == MP4_OK)
|
sl@0
|
1206 |
{
|
sl@0
|
1207 |
aNum = numVideoFrame;
|
sl@0
|
1208 |
}
|
sl@0
|
1209 |
return SymbianOSError(mp4Err);
|
sl@0
|
1210 |
}
|
sl@0
|
1211 |
|
sl@0
|
1212 |
/**
|
sl@0
|
1213 |
This function gives the video sample entry index of the next video frame to be read.
|
sl@0
|
1214 |
|
sl@0
|
1215 |
The smallest index value is 1.
|
sl@0
|
1216 |
|
sl@0
|
1217 |
@param aIndex Returns the Visual Sample Entry index of the next video frame to be read.
|
sl@0
|
1218 |
|
sl@0
|
1219 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1220 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1221 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
1222 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1223 |
*/
|
sl@0
|
1224 |
EXPORT_C TInt C3GPParse::GetVideoSampleEntryIndex(TUint& aIndex) const
|
sl@0
|
1225 |
{
|
sl@0
|
1226 |
if (!iHandler)
|
sl@0
|
1227 |
{
|
sl@0
|
1228 |
return KErrNotReady;
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
|
sl@0
|
1231 |
// Check if 3GP input data contains video stream
|
sl@0
|
1232 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1233 |
if (err != KErrNone)
|
sl@0
|
1234 |
{
|
sl@0
|
1235 |
return err;
|
sl@0
|
1236 |
}
|
sl@0
|
1237 |
|
sl@0
|
1238 |
mp4_u32 index = 0;
|
sl@0
|
1239 |
MP4Err mp4Err = MP4ParseGetVideoSampleEntryIndex(iHandler, &index);
|
sl@0
|
1240 |
if (mp4Err == MP4_OK)
|
sl@0
|
1241 |
{
|
sl@0
|
1242 |
aIndex = index;
|
sl@0
|
1243 |
}
|
sl@0
|
1244 |
return SymbianOSError(mp4Err);
|
sl@0
|
1245 |
}
|
sl@0
|
1246 |
|
sl@0
|
1247 |
/**
|
sl@0
|
1248 |
Returns video frame size.
|
sl@0
|
1249 |
|
sl@0
|
1250 |
@param aIndex Index of video frame.
|
sl@0
|
1251 |
@param aSize Return the size of the video frame.
|
sl@0
|
1252 |
|
sl@0
|
1253 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1254 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1255 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
1256 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1257 |
*/
|
sl@0
|
1258 |
EXPORT_C TInt C3GPParse::GetVideoFrameSize(TUint aIndex, TUint& aSize) const
|
sl@0
|
1259 |
{
|
sl@0
|
1260 |
if (!iHandler)
|
sl@0
|
1261 |
{
|
sl@0
|
1262 |
return KErrNotReady;
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
|
sl@0
|
1265 |
// Check if 3GP input data contains video stream
|
sl@0
|
1266 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1267 |
if (err != KErrNone)
|
sl@0
|
1268 |
{
|
sl@0
|
1269 |
return err;
|
sl@0
|
1270 |
}
|
sl@0
|
1271 |
|
sl@0
|
1272 |
mp4_u32 videoFrameSize = 0;
|
sl@0
|
1273 |
MP4Err mp4Err = MP4ParseGetVideoFrameSize(iHandler, aIndex, &videoFrameSize);
|
sl@0
|
1274 |
if (mp4Err == MP4_OK)
|
sl@0
|
1275 |
{
|
sl@0
|
1276 |
aSize = videoFrameSize;
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
return SymbianOSError(mp4Err);
|
sl@0
|
1279 |
}
|
sl@0
|
1280 |
|
sl@0
|
1281 |
/**
|
sl@0
|
1282 |
Returns video frame start time.
|
sl@0
|
1283 |
|
sl@0
|
1284 |
@param aIndex Index of video frame.
|
sl@0
|
1285 |
@param aTimeStampInMs Result in milliseconds.
|
sl@0
|
1286 |
@param aTimeStampInTimescale Result is returned here.
|
sl@0
|
1287 |
|
sl@0
|
1288 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1289 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1290 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
1291 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1292 |
*/
|
sl@0
|
1293 |
EXPORT_C TInt C3GPParse::GetVideoFrameStartTime(TUint aIndex, TUint& aTimeStampInMs, TUint& aTimeStampInTimescale) const
|
sl@0
|
1294 |
{
|
sl@0
|
1295 |
if (!iHandler)
|
sl@0
|
1296 |
{
|
sl@0
|
1297 |
return KErrNotReady;
|
sl@0
|
1298 |
}
|
sl@0
|
1299 |
|
sl@0
|
1300 |
// Check if 3GP input data contains video stream
|
sl@0
|
1301 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1302 |
if (err != KErrNone)
|
sl@0
|
1303 |
{
|
sl@0
|
1304 |
return err;
|
sl@0
|
1305 |
}
|
sl@0
|
1306 |
|
sl@0
|
1307 |
mp4_u32 timeStampInMs = 0;
|
sl@0
|
1308 |
mp4_u32 timeStampInTimescale = 0;
|
sl@0
|
1309 |
MP4Err mp4Err = MP4ParseGetVideoFrameStartTime(iHandler, aIndex, &timeStampInTimescale, &timeStampInMs);
|
sl@0
|
1310 |
if (mp4Err == MP4_OK)
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
aTimeStampInMs = timeStampInMs;
|
sl@0
|
1313 |
aTimeStampInTimescale = timeStampInTimescale;
|
sl@0
|
1314 |
}
|
sl@0
|
1315 |
return SymbianOSError(mp4Err);
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
|
sl@0
|
1318 |
/**
|
sl@0
|
1319 |
Checks if a video frame of with index aIndex exists.
|
sl@0
|
1320 |
|
sl@0
|
1321 |
@param aIndex Index of video frame.
|
sl@0
|
1322 |
@param aKeyFrame Return ETrue if the video frame is a key frame.
|
sl@0
|
1323 |
|
sl@0
|
1324 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1325 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1326 |
KErrNotSupported if the input does not contain video;
|
sl@0
|
1327 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1328 |
*/
|
sl@0
|
1329 |
EXPORT_C TInt C3GPParse::GetVideoFrameKeyType(TUint aIndex, TBool& aKeyFrame) const
|
sl@0
|
1330 |
{
|
sl@0
|
1331 |
if (!iHandler)
|
sl@0
|
1332 |
{
|
sl@0
|
1333 |
return KErrNotReady;
|
sl@0
|
1334 |
}
|
sl@0
|
1335 |
|
sl@0
|
1336 |
// Check if 3GP input data contains video stream
|
sl@0
|
1337 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1338 |
if (err != KErrNone)
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
return err;
|
sl@0
|
1341 |
}
|
sl@0
|
1342 |
|
sl@0
|
1343 |
mp4_bool keyFrame = EFalse;
|
sl@0
|
1344 |
MP4Err mp4Err = MP4ParseGetVideoFrameType(iHandler, aIndex, &keyFrame);
|
sl@0
|
1345 |
if (mp4Err == MP4_OK)
|
sl@0
|
1346 |
{
|
sl@0
|
1347 |
aKeyFrame = keyFrame;
|
sl@0
|
1348 |
}
|
sl@0
|
1349 |
return SymbianOSError(mp4Err);
|
sl@0
|
1350 |
}
|
sl@0
|
1351 |
|
sl@0
|
1352 |
/**
|
sl@0
|
1353 |
This function gives the audio sample entry index of the next audio frame to be read.
|
sl@0
|
1354 |
|
sl@0
|
1355 |
The smallest index value is 1.
|
sl@0
|
1356 |
|
sl@0
|
1357 |
@param aIndex Returns the Audio Sample Entry index of the next video frame to be read.
|
sl@0
|
1358 |
|
sl@0
|
1359 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1360 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1361 |
KErrNotSupported if the input does not contain audio;
|
sl@0
|
1362 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1363 |
*/
|
sl@0
|
1364 |
EXPORT_C TInt C3GPParse::GetAudioSampleEntryIndex(TUint& aIndex) const
|
sl@0
|
1365 |
{
|
sl@0
|
1366 |
if (!iHandler)
|
sl@0
|
1367 |
{
|
sl@0
|
1368 |
return KErrNotReady;
|
sl@0
|
1369 |
}
|
sl@0
|
1370 |
|
sl@0
|
1371 |
// Check if 3GP input data contains audio stream
|
sl@0
|
1372 |
TInt err = DoGetAudioProperties();
|
sl@0
|
1373 |
if (err != KErrNone)
|
sl@0
|
1374 |
{
|
sl@0
|
1375 |
return err;
|
sl@0
|
1376 |
}
|
sl@0
|
1377 |
|
sl@0
|
1378 |
mp4_u32 audioSampleEntryIndex = 0;
|
sl@0
|
1379 |
MP4Err mp4Err = MP4ParseGetAudioSampleEntryIndex(iHandler, &audioSampleEntryIndex);
|
sl@0
|
1380 |
if (mp4Err == MP4_OK)
|
sl@0
|
1381 |
{
|
sl@0
|
1382 |
aIndex = audioSampleEntryIndex;
|
sl@0
|
1383 |
}
|
sl@0
|
1384 |
return SymbianOSError(mp4Err);
|
sl@0
|
1385 |
}
|
sl@0
|
1386 |
|
sl@0
|
1387 |
/**
|
sl@0
|
1388 |
This function provides the storage mode of 13K QCELP in 3G2 file.
|
sl@0
|
1389 |
|
sl@0
|
1390 |
In 3G2 files, QCELP can be registered to be stored in two ways:
|
sl@0
|
1391 |
using the QCELP Sample Entry ('sqcp') Box or
|
sl@0
|
1392 |
using the MPEG4 Audio Sample Description ('esds') Box.
|
sl@0
|
1393 |
|
sl@0
|
1394 |
@param aMode Returns the QCELP storage mode. See T3GPQcelpStorageMode.
|
sl@0
|
1395 |
|
sl@0
|
1396 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1397 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1398 |
KErrNotSupported if the 3GP input data does not contain any QCELP audio stream;
|
sl@0
|
1399 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1400 |
*/
|
sl@0
|
1401 |
EXPORT_C TInt C3GPParse::GetQcelpStorageMode(T3GPQcelpStorageMode& aMode) const
|
sl@0
|
1402 |
{
|
sl@0
|
1403 |
if (!iHandler)
|
sl@0
|
1404 |
{
|
sl@0
|
1405 |
return KErrNotReady;
|
sl@0
|
1406 |
}
|
sl@0
|
1407 |
|
sl@0
|
1408 |
// Check if 3GP input data contains any QCELP audio stream
|
sl@0
|
1409 |
TInt err = DoGetAudioProperties();
|
sl@0
|
1410 |
if (err == KErrNone)
|
sl@0
|
1411 |
{
|
sl@0
|
1412 |
if (iAudioType != E3GPQcelp13K)
|
sl@0
|
1413 |
{
|
sl@0
|
1414 |
return KErrNotSupported;
|
sl@0
|
1415 |
}
|
sl@0
|
1416 |
}
|
sl@0
|
1417 |
else
|
sl@0
|
1418 |
{
|
sl@0
|
1419 |
return err;
|
sl@0
|
1420 |
}
|
sl@0
|
1421 |
|
sl@0
|
1422 |
mp4_u8 audioQcelpStorageMode = 0;
|
sl@0
|
1423 |
MP4Err mp4Err = MP4ParseGetQCELPStorageMode(iHandler, &audioQcelpStorageMode);
|
sl@0
|
1424 |
if (mp4Err == MP4_OK)
|
sl@0
|
1425 |
{
|
sl@0
|
1426 |
if (audioQcelpStorageMode == 1)
|
sl@0
|
1427 |
{
|
sl@0
|
1428 |
aMode = E3GPMP4AudioDescriptionBox;
|
sl@0
|
1429 |
}
|
sl@0
|
1430 |
else
|
sl@0
|
1431 |
{
|
sl@0
|
1432 |
aMode = E3GPQcelpSampleEntryBox;
|
sl@0
|
1433 |
}
|
sl@0
|
1434 |
}
|
sl@0
|
1435 |
return SymbianOSError(mp4Err);
|
sl@0
|
1436 |
}
|
sl@0
|
1437 |
|
sl@0
|
1438 |
/**
|
sl@0
|
1439 |
This function provides the video level of the H263 video stream contained in the 3GP data.
|
sl@0
|
1440 |
|
sl@0
|
1441 |
@param aLevel Returns the H263 video level.
|
sl@0
|
1442 |
|
sl@0
|
1443 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1444 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1445 |
KErrNotSupported if the 3GP input data does not contain any H263 video stream;
|
sl@0
|
1446 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1447 |
*/
|
sl@0
|
1448 |
EXPORT_C TInt C3GPParse::GetH263VideoLevel(TInt& aLevel) const
|
sl@0
|
1449 |
{
|
sl@0
|
1450 |
if (!iHandler)
|
sl@0
|
1451 |
{
|
sl@0
|
1452 |
return KErrNotReady;
|
sl@0
|
1453 |
}
|
sl@0
|
1454 |
|
sl@0
|
1455 |
// Check if 3GP input data contains any H263 video stream
|
sl@0
|
1456 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1457 |
if (err == KErrNone)
|
sl@0
|
1458 |
{
|
sl@0
|
1459 |
if (!(iVideoType == E3GPH263Profile0 || iVideoType == E3GPH263Profile3))
|
sl@0
|
1460 |
{
|
sl@0
|
1461 |
return KErrNotSupported;
|
sl@0
|
1462 |
}
|
sl@0
|
1463 |
}
|
sl@0
|
1464 |
else
|
sl@0
|
1465 |
{
|
sl@0
|
1466 |
return err;
|
sl@0
|
1467 |
}
|
sl@0
|
1468 |
|
sl@0
|
1469 |
TVideoClipProperties videoClipProperties;
|
sl@0
|
1470 |
MP4Err mp4Err = MP4ParseGetVideoClipProperties(iHandler, videoClipProperties);
|
sl@0
|
1471 |
if (mp4Err == MP4_OK)
|
sl@0
|
1472 |
{
|
sl@0
|
1473 |
aLevel = videoClipProperties.iH263Level;
|
sl@0
|
1474 |
}
|
sl@0
|
1475 |
return SymbianOSError(mp4Err);
|
sl@0
|
1476 |
}
|
sl@0
|
1477 |
|
sl@0
|
1478 |
/**
|
sl@0
|
1479 |
Returns the needed size for memory buffer to store an atom of given type from user data atom (UDTA).
|
sl@0
|
1480 |
|
sl@0
|
1481 |
@param aType Type of atom to be read from UDTA. Hex value of 4 chars representing atom type
|
sl@0
|
1482 |
defined in standard. For example, 0x7469746c is 'titl', title for the media atom.
|
sl@0
|
1483 |
@param aLocation Specifies the location of user information to be retrieved. Refer to
|
sl@0
|
1484 |
T3GPUdtaLocation for supported values.
|
sl@0
|
1485 |
@param aAtomIndex Specifies the index of atom if UDTA contains multiple sub-atoms of the same
|
sl@0
|
1486 |
aUdtaAtomType to retrieve when supplied as input parameter. Returns the
|
sl@0
|
1487 |
highest index of the matching sub-atom found in the specified location as
|
sl@0
|
1488 |
output parameter.
|
sl@0
|
1489 |
@param aSize This contains the needed size for memory buffer.
|
sl@0
|
1490 |
|
sl@0
|
1491 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1492 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1493 |
KErrNotFound if UDTA or wanted sub-atom is not available in asked location;
|
sl@0
|
1494 |
KErrAccessDenied if cannot seek to UDTA atom location;
|
sl@0
|
1495 |
KErrArgument if asked aLocation is invalid;
|
sl@0
|
1496 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1497 |
|
sl@0
|
1498 |
@panic C3GPParse KErrArgument if the location of user information is not in the range of T3GPUdtaLocation
|
sl@0
|
1499 |
*/
|
sl@0
|
1500 |
EXPORT_C TInt C3GPParse::GetUserDataAtomSize(TUint32 aType, T3GPUdtaLocation aLocation,
|
sl@0
|
1501 |
TUint& aAtomIndex, TInt& aSize) const
|
sl@0
|
1502 |
{
|
sl@0
|
1503 |
if (!iHandler)
|
sl@0
|
1504 |
{
|
sl@0
|
1505 |
return KErrNotReady;
|
sl@0
|
1506 |
}
|
sl@0
|
1507 |
|
sl@0
|
1508 |
mp4_u32 userDataAtomSize = 0;
|
sl@0
|
1509 |
mp4_u32 atomIndex = aAtomIndex;
|
sl@0
|
1510 |
mp4_u32 type = aType;
|
sl@0
|
1511 |
mp4_u8 location = UdtaLocation(aLocation);
|
sl@0
|
1512 |
MP4Err mp4Err = MP4ParseGetUserDataAtom(iHandler, location, type,
|
sl@0
|
1513 |
NULL, userDataAtomSize, atomIndex);
|
sl@0
|
1514 |
if ( mp4Err == MP4_OK || mp4Err == MP4_OUTPUT_BUFFER_TOO_SMALL)
|
sl@0
|
1515 |
{
|
sl@0
|
1516 |
aSize = userDataAtomSize;
|
sl@0
|
1517 |
aAtomIndex = atomIndex;
|
sl@0
|
1518 |
mp4Err = MP4_OK;
|
sl@0
|
1519 |
}
|
sl@0
|
1520 |
return SymbianOSError(mp4Err);
|
sl@0
|
1521 |
}
|
sl@0
|
1522 |
|
sl@0
|
1523 |
/**
|
sl@0
|
1524 |
Retrieves an atom of given type from user data atom (UDTA) to the given buffer.
|
sl@0
|
1525 |
|
sl@0
|
1526 |
The buffer returned stores an atom of structure that conforms to the definition of
|
sl@0
|
1527 |
a "full box" as specified in ISO/IEC 14496-12:2003: "Information technology – Coding
|
sl@0
|
1528 |
of audio-visual objects – Part 12: ISO base media file format."
|
sl@0
|
1529 |
|
sl@0
|
1530 |
For more information on user data atoms, see Section 8 – Asset Information of "3GPP
|
sl@0
|
1531 |
TS 26.244 version 6.1.0 – 3GP file format (Rel 6)."
|
sl@0
|
1532 |
|
sl@0
|
1533 |
@param aType Type of atom to be read from UDTA. Hex value of 4 chars representing atom type
|
sl@0
|
1534 |
defined in standard. For example, 0x7469746c is 'titl', title for the media atom.
|
sl@0
|
1535 |
@param aLocation Specifies the location of user information to be retrieved. Refer to
|
sl@0
|
1536 |
T3GPUdtaLocation for supported values.
|
sl@0
|
1537 |
@param aBuffer The descriptor to store the requested user data atom.
|
sl@0
|
1538 |
@param aAtomIndex Specifies the index of atom if UDTA contains multiple sub-atoms of the same
|
sl@0
|
1539 |
aUdtaAtomType to retrieve when supplied as input parameter. Returns the
|
sl@0
|
1540 |
highest index of the matching sub-atom found in the specified location as
|
sl@0
|
1541 |
output parameter. Only matching sub-atoms are counted when calculating the highest
|
sl@0
|
1542 |
index.
|
sl@0
|
1543 |
|
sl@0
|
1544 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1545 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1546 |
KErrNotFound if UDTA or wanted sub-atom is not available in asked location;
|
sl@0
|
1547 |
KErrAccessDenied if cannot seek to UDTA atom location;
|
sl@0
|
1548 |
KErrArgument if asked aUdtaLocation is invalid;
|
sl@0
|
1549 |
KErrOverflow if the buffer to write atom to is too small. Use C3GPParse::GetUserDataAtomSize
|
sl@0
|
1550 |
to retrieve the proper size.
|
sl@0
|
1551 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
1552 |
KErr3gpLibMoreDataRequired if if 3GP library needs more data before the requested
|
sl@0
|
1553 |
information can be returned.
|
sl@0
|
1554 |
|
sl@0
|
1555 |
@panic C3GPParse KErrArgument if the location of user information is not in the range of T3GPUdtaLocation
|
sl@0
|
1556 |
*/
|
sl@0
|
1557 |
EXPORT_C TInt C3GPParse::GetUserDataAtom(TUint32 aType, T3GPUdtaLocation aLocation, TDes8& aBuffer, TUint& aAtomIndex) const
|
sl@0
|
1558 |
{
|
sl@0
|
1559 |
if (!iHandler)
|
sl@0
|
1560 |
{
|
sl@0
|
1561 |
return KErrNotReady;
|
sl@0
|
1562 |
}
|
sl@0
|
1563 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
1564 |
{
|
sl@0
|
1565 |
return KErrOverflow;
|
sl@0
|
1566 |
}
|
sl@0
|
1567 |
|
sl@0
|
1568 |
mp4_u32 userDataAtomSize = aBuffer.MaxLength();
|
sl@0
|
1569 |
mp4_u32 atomIndex = aAtomIndex;
|
sl@0
|
1570 |
mp4_u32 type = aType;
|
sl@0
|
1571 |
mp4_u8 location = UdtaLocation(aLocation);
|
sl@0
|
1572 |
MP4Err mp4Err = MP4ParseGetUserDataAtom(iHandler, location, type,
|
sl@0
|
1573 |
const_cast<mp4_u8*>(aBuffer.Ptr()), userDataAtomSize, atomIndex);
|
sl@0
|
1574 |
if ( mp4Err == MP4_OK )
|
sl@0
|
1575 |
{
|
sl@0
|
1576 |
aType = type;
|
sl@0
|
1577 |
aBuffer.SetLength(userDataAtomSize);
|
sl@0
|
1578 |
aAtomIndex = atomIndex;
|
sl@0
|
1579 |
}
|
sl@0
|
1580 |
return SymbianOSError(mp4Err);
|
sl@0
|
1581 |
}
|
sl@0
|
1582 |
|
sl@0
|
1583 |
/**
|
sl@0
|
1584 |
This function gets the next frame's dependency information from SDTP box.
|
sl@0
|
1585 |
|
sl@0
|
1586 |
@param aDependencies Returns the next frame's dependency information. See T3GPFrameDependencies.
|
sl@0
|
1587 |
|
sl@0
|
1588 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1589 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1590 |
KErrNotSupported if the input does not contain video stream;
|
sl@0
|
1591 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open;
|
sl@0
|
1592 |
KErr3gpLibMoreDataRequired if if 3GP library needs more data before the requested
|
sl@0
|
1593 |
information can be returned.
|
sl@0
|
1594 |
*/
|
sl@0
|
1595 |
EXPORT_C TInt C3GPParse::GetVideoFrameDependencies(T3GPFrameDependencies& aDependencies) const
|
sl@0
|
1596 |
{
|
sl@0
|
1597 |
if (!iHandler)
|
sl@0
|
1598 |
{
|
sl@0
|
1599 |
return KErrNotReady;
|
sl@0
|
1600 |
}
|
sl@0
|
1601 |
|
sl@0
|
1602 |
// Check if 3GP input data contains video stream
|
sl@0
|
1603 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1604 |
if (err != KErrNone)
|
sl@0
|
1605 |
{
|
sl@0
|
1606 |
return err;
|
sl@0
|
1607 |
}
|
sl@0
|
1608 |
|
sl@0
|
1609 |
mp4_u8 dependsOn;
|
sl@0
|
1610 |
mp4_u8 isDependedOn;
|
sl@0
|
1611 |
mp4_u8 hasRedundancy;
|
sl@0
|
1612 |
MP4Err mp4Err = MP4ParseNextVideoFrameDependencies(iHandler, &dependsOn, &isDependedOn, &hasRedundancy);
|
sl@0
|
1613 |
if (mp4Err == MP4_OK)
|
sl@0
|
1614 |
{
|
sl@0
|
1615 |
switch (dependsOn)
|
sl@0
|
1616 |
{
|
sl@0
|
1617 |
case 1:
|
sl@0
|
1618 |
aDependencies.iDependsOn = E3GPDependencyExists;
|
sl@0
|
1619 |
break;
|
sl@0
|
1620 |
case 2:
|
sl@0
|
1621 |
aDependencies.iDependsOn = E3GPDependencyNone;
|
sl@0
|
1622 |
break;
|
sl@0
|
1623 |
case 0:
|
sl@0
|
1624 |
aDependencies.iDependsOn = E3GPDependencyUnknown;
|
sl@0
|
1625 |
break;
|
sl@0
|
1626 |
default:
|
sl@0
|
1627 |
Panic(KErrCorrupt);
|
sl@0
|
1628 |
}
|
sl@0
|
1629 |
|
sl@0
|
1630 |
switch (isDependedOn)
|
sl@0
|
1631 |
{
|
sl@0
|
1632 |
case 1:
|
sl@0
|
1633 |
aDependencies.iIsDependedOn = E3GPDependencyExists;
|
sl@0
|
1634 |
break;
|
sl@0
|
1635 |
case 2:
|
sl@0
|
1636 |
aDependencies.iIsDependedOn = E3GPDependencyNone;
|
sl@0
|
1637 |
break;
|
sl@0
|
1638 |
case 0:
|
sl@0
|
1639 |
aDependencies.iIsDependedOn = E3GPDependencyUnknown;
|
sl@0
|
1640 |
break;
|
sl@0
|
1641 |
default:
|
sl@0
|
1642 |
Panic(KErrCorrupt);
|
sl@0
|
1643 |
}
|
sl@0
|
1644 |
|
sl@0
|
1645 |
switch (hasRedundancy)
|
sl@0
|
1646 |
{
|
sl@0
|
1647 |
case 1:
|
sl@0
|
1648 |
aDependencies.iHasRedundancy = E3GPRedundancyExists;
|
sl@0
|
1649 |
break;
|
sl@0
|
1650 |
case 2:
|
sl@0
|
1651 |
aDependencies.iHasRedundancy = E3GPRedundancyNone;
|
sl@0
|
1652 |
break;
|
sl@0
|
1653 |
case 0:
|
sl@0
|
1654 |
aDependencies.iHasRedundancy = E3GPRedundancyUnknown;
|
sl@0
|
1655 |
break;
|
sl@0
|
1656 |
default:
|
sl@0
|
1657 |
Panic(KErrCorrupt);
|
sl@0
|
1658 |
}
|
sl@0
|
1659 |
}
|
sl@0
|
1660 |
return SymbianOSError(mp4Err);
|
sl@0
|
1661 |
}
|
sl@0
|
1662 |
|
sl@0
|
1663 |
/**
|
sl@0
|
1664 |
This function gets frame properties, from aStartIndex for a count of aNumberOfFrames frames.
|
sl@0
|
1665 |
|
sl@0
|
1666 |
Properties obtained are start time, frame type, and frame size, stored in the T3GPFrameInfoParameters
|
sl@0
|
1667 |
struct.
|
sl@0
|
1668 |
|
sl@0
|
1669 |
@param aStartIndex Index to start getting info for the array.
|
sl@0
|
1670 |
@param aNumberOfFrames Number of frames to retrieve frame info.
|
sl@0
|
1671 |
@param aArray An array of T3GPFrameInfoParameters struct to store video frame properties.
|
sl@0
|
1672 |
The input array will be flushed of all existing elements before use.
|
sl@0
|
1673 |
|
sl@0
|
1674 |
@return KErrNone if successful. Otherwise, returns one of the system wide error codes.
|
sl@0
|
1675 |
KErrGeneral if an error has no specific categorisation;
|
sl@0
|
1676 |
KErrNotSupported if the input does not contain video stream;
|
sl@0
|
1677 |
KErrNoMemory if an attempt to allocate memory has failed;
|
sl@0
|
1678 |
KErrAccessDenied if opening file has failed;
|
sl@0
|
1679 |
KErrNotReady if the parser has not yet been initialised; See C3GPParse::Open.
|
sl@0
|
1680 |
*/
|
sl@0
|
1681 |
EXPORT_C TInt C3GPParse:: GetVideoFrameProperties(TUint aStartIndex, TUint aNumberOfFrames,
|
sl@0
|
1682 |
RArray<T3GPFrameInfoParameters>& aArray) const
|
sl@0
|
1683 |
{
|
sl@0
|
1684 |
if (!iHandler)
|
sl@0
|
1685 |
{
|
sl@0
|
1686 |
return KErrNotReady;
|
sl@0
|
1687 |
}
|
sl@0
|
1688 |
|
sl@0
|
1689 |
// Check if 3GP input data contains video stream
|
sl@0
|
1690 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1691 |
if (err != KErrNone)
|
sl@0
|
1692 |
{
|
sl@0
|
1693 |
return err;
|
sl@0
|
1694 |
}
|
sl@0
|
1695 |
|
sl@0
|
1696 |
// Check if the input parameters are valid before retrieving video frame properties.
|
sl@0
|
1697 |
TUint totalNumOfVideoFrames;
|
sl@0
|
1698 |
err = GetNumberOfVideoFrames(totalNumOfVideoFrames);
|
sl@0
|
1699 |
if (err != KErrNone)
|
sl@0
|
1700 |
{
|
sl@0
|
1701 |
return err;
|
sl@0
|
1702 |
}
|
sl@0
|
1703 |
|
sl@0
|
1704 |
if (aStartIndex >= totalNumOfVideoFrames || aNumberOfFrames > totalNumOfVideoFrames)
|
sl@0
|
1705 |
{
|
sl@0
|
1706 |
return KErrGeneral;
|
sl@0
|
1707 |
}
|
sl@0
|
1708 |
|
sl@0
|
1709 |
TFrameInfoParameters* infoArray = new TFrameInfoParameters[aNumberOfFrames];
|
sl@0
|
1710 |
|
sl@0
|
1711 |
if (!infoArray)
|
sl@0
|
1712 |
{
|
sl@0
|
1713 |
return KErrNoMemory;
|
sl@0
|
1714 |
}
|
sl@0
|
1715 |
|
sl@0
|
1716 |
mp4_u32 startIndex = aStartIndex;
|
sl@0
|
1717 |
mp4_u32 numberOfFrames = aNumberOfFrames;
|
sl@0
|
1718 |
MP4Err mp4Err = MP4GetVideoFrameProperties(iHandler, startIndex, numberOfFrames, infoArray);
|
sl@0
|
1719 |
|
sl@0
|
1720 |
if ( mp4Err == MP4_OK )
|
sl@0
|
1721 |
{
|
sl@0
|
1722 |
aArray.Reset();
|
sl@0
|
1723 |
T3GPFrameInfoParameters infoParams;
|
sl@0
|
1724 |
|
sl@0
|
1725 |
for (TInt i=0; i<aNumberOfFrames; ++i)
|
sl@0
|
1726 |
{
|
sl@0
|
1727 |
infoParams.iSize = infoArray[i].iSize;
|
sl@0
|
1728 |
infoParams.iStartTime = infoArray[i].iStartTime;
|
sl@0
|
1729 |
infoParams.iIsRandomAccessPoint = infoArray[i].iType;
|
sl@0
|
1730 |
err = aArray.Append(infoParams);
|
sl@0
|
1731 |
if (err != KErrNone)
|
sl@0
|
1732 |
{
|
sl@0
|
1733 |
delete [] infoArray;
|
sl@0
|
1734 |
infoArray = NULL;
|
sl@0
|
1735 |
return err;
|
sl@0
|
1736 |
}
|
sl@0
|
1737 |
}
|
sl@0
|
1738 |
}
|
sl@0
|
1739 |
else
|
sl@0
|
1740 |
{
|
sl@0
|
1741 |
err = SymbianOSError(mp4Err);
|
sl@0
|
1742 |
}
|
sl@0
|
1743 |
delete [] infoArray;
|
sl@0
|
1744 |
infoArray = NULL;
|
sl@0
|
1745 |
return err;
|
sl@0
|
1746 |
}
|
sl@0
|
1747 |
|
sl@0
|
1748 |
/**
|
sl@0
|
1749 |
This function reads the current video frame from an input file and returns it to the caller asynchronously.
|
sl@0
|
1750 |
The current position of video stream will be moved forward.
|
sl@0
|
1751 |
|
sl@0
|
1752 |
This function is not supported when the parser is in buffer mode.
|
sl@0
|
1753 |
|
sl@0
|
1754 |
C3GPParse::CancelReadFrame can be used to cancel an outstanding asynchronous frame read request.
|
sl@0
|
1755 |
|
sl@0
|
1756 |
Note: Only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time.
|
sl@0
|
1757 |
|
sl@0
|
1758 |
Upon completion, successfully or otherwise, the callback function M3GPParseCallback::VideoFrameAvailable is called.
|
sl@0
|
1759 |
|
sl@0
|
1760 |
@param aCallback Reference to class derived from M3GPAsyncObserver designed to receive notification of
|
sl@0
|
1761 |
asynchronous event completion.
|
sl@0
|
1762 |
@param aBuffer The descriptor to store the video frames.
|
sl@0
|
1763 |
*/
|
sl@0
|
1764 |
EXPORT_C void C3GPParse::ReadVideoFrame(M3GPParseCallback& aCallback, TDes8& aBuffer)
|
sl@0
|
1765 |
{
|
sl@0
|
1766 |
if (!iHandler)
|
sl@0
|
1767 |
{
|
sl@0
|
1768 |
aCallback.VideoFrameAvailable(KErrNotReady, EFalse, 0, 0);
|
sl@0
|
1769 |
return;
|
sl@0
|
1770 |
}
|
sl@0
|
1771 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
1772 |
{
|
sl@0
|
1773 |
aCallback.VideoFrameAvailable(KErrOverflow, EFalse, 0, 0);
|
sl@0
|
1774 |
return;
|
sl@0
|
1775 |
}
|
sl@0
|
1776 |
if (iAsyncReadBuffer)
|
sl@0
|
1777 |
{
|
sl@0
|
1778 |
aCallback.VideoFrameAvailable(KErrInUse, EFalse, 0, 0);
|
sl@0
|
1779 |
return;
|
sl@0
|
1780 |
}
|
sl@0
|
1781 |
|
sl@0
|
1782 |
// Check if 3GP input data contains video stream
|
sl@0
|
1783 |
TInt err = DoGetVideoProperties();
|
sl@0
|
1784 |
if (err != KErrNone)
|
sl@0
|
1785 |
{
|
sl@0
|
1786 |
aCallback.VideoFrameAvailable(err, EFalse, 0, 0);
|
sl@0
|
1787 |
return;
|
sl@0
|
1788 |
}
|
sl@0
|
1789 |
|
sl@0
|
1790 |
iCallback = &aCallback;
|
sl@0
|
1791 |
mp4_u32 bufferSize = aBuffer.MaxLength();
|
sl@0
|
1792 |
MP4Err mp4Err = MP4ParseReadVideoFrameAsync(iHandler, this,
|
sl@0
|
1793 |
const_cast<mp4_u8*>(aBuffer.Ptr()), &bufferSize);
|
sl@0
|
1794 |
if (mp4Err != MP4_OK)
|
sl@0
|
1795 |
{
|
sl@0
|
1796 |
aCallback.VideoFrameAvailable(SymbianOSError(mp4Err), EFalse, 0, 0);
|
sl@0
|
1797 |
}
|
sl@0
|
1798 |
else
|
sl@0
|
1799 |
{
|
sl@0
|
1800 |
// MP4ParseReadVideoFrameAsync success. Store aBuffer since its length has
|
sl@0
|
1801 |
// not been set.
|
sl@0
|
1802 |
iAsyncReadBuffer = &aBuffer;
|
sl@0
|
1803 |
}
|
sl@0
|
1804 |
}
|
sl@0
|
1805 |
|
sl@0
|
1806 |
/**
|
sl@0
|
1807 |
This function reads the audio frames that are stored in the current audio sample from the input
|
sl@0
|
1808 |
file and returns them to the caller asynchronously. The current position of audio stream
|
sl@0
|
1809 |
will be moved forward.
|
sl@0
|
1810 |
|
sl@0
|
1811 |
This function is not supported when the parser is in buffer mode.
|
sl@0
|
1812 |
|
sl@0
|
1813 |
C3GPParse::CancelReadFrame can be used to cancel an outstanding asynchronous frame read request.
|
sl@0
|
1814 |
|
sl@0
|
1815 |
Note: Only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time.
|
sl@0
|
1816 |
|
sl@0
|
1817 |
Upon completion, successfully or otherwise, the callback function M3GPParseCallback::AudioFramesAvailable is called.
|
sl@0
|
1818 |
|
sl@0
|
1819 |
@param aCallback Reference to class derived from M3GPAsyncObserver designed to receive notification of
|
sl@0
|
1820 |
asynchronous event completion.
|
sl@0
|
1821 |
@param aBuffer The descriptor to store the audio frames.
|
sl@0
|
1822 |
*/
|
sl@0
|
1823 |
EXPORT_C void C3GPParse::ReadAudioFrames(M3GPParseCallback& aCallback, TDes8& aBuffer)
|
sl@0
|
1824 |
{
|
sl@0
|
1825 |
if (!iHandler)
|
sl@0
|
1826 |
{
|
sl@0
|
1827 |
aCallback.AudioFramesAvailable(KErrNotReady, 0, 0, 0);
|
sl@0
|
1828 |
return;
|
sl@0
|
1829 |
}
|
sl@0
|
1830 |
if (aBuffer.MaxLength() <= 0)
|
sl@0
|
1831 |
{
|
sl@0
|
1832 |
aCallback.AudioFramesAvailable(KErrOverflow, 0, 0, 0);
|
sl@0
|
1833 |
return;
|
sl@0
|
1834 |
}
|
sl@0
|
1835 |
if (iAsyncReadBuffer)
|
sl@0
|
1836 |
{
|
sl@0
|
1837 |
aCallback.AudioFramesAvailable(KErrInUse, 0, 0, 0);
|
sl@0
|
1838 |
return;
|
sl@0
|
1839 |
}
|
sl@0
|
1840 |
|
sl@0
|
1841 |
// Check if 3GP input data contains audio stream
|
sl@0
|
1842 |
TInt err = DoGetAudioProperties();
|
sl@0
|
1843 |
if (err != KErrNone)
|
sl@0
|
1844 |
{
|
sl@0
|
1845 |
aCallback.AudioFramesAvailable(err, 0, 0, 0);
|
sl@0
|
1846 |
return;
|
sl@0
|
1847 |
}
|
sl@0
|
1848 |
|
sl@0
|
1849 |
iCallback = &aCallback;
|
sl@0
|
1850 |
mp4_u32 bufferSize = aBuffer.MaxLength();
|
sl@0
|
1851 |
MP4Err mp4Err = MP4ParseReadAudioFramesAsync(iHandler, this,
|
sl@0
|
1852 |
const_cast<mp4_u8*>(aBuffer.Ptr()), &bufferSize);
|
sl@0
|
1853 |
if (mp4Err != MP4_OK)
|
sl@0
|
1854 |
{
|
sl@0
|
1855 |
aCallback.AudioFramesAvailable(SymbianOSError(mp4Err), 0, 0, 0);
|
sl@0
|
1856 |
}
|
sl@0
|
1857 |
else
|
sl@0
|
1858 |
{
|
sl@0
|
1859 |
// MP4ParseReadAudioFramesAsync success. Store aBuffer since its length has
|
sl@0
|
1860 |
// not been set.
|
sl@0
|
1861 |
iAsyncReadBuffer = &aBuffer;
|
sl@0
|
1862 |
}
|
sl@0
|
1863 |
}
|
sl@0
|
1864 |
|
sl@0
|
1865 |
/**
|
sl@0
|
1866 |
This function cancels the outstanding asynchronous read audio/video frame request.
|
sl@0
|
1867 |
|
sl@0
|
1868 |
No callback function will be called.
|
sl@0
|
1869 |
|
sl@0
|
1870 |
Note: As only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time,
|
sl@0
|
1871 |
this function can be used to cancel audio or video read request.
|
sl@0
|
1872 |
*/
|
sl@0
|
1873 |
EXPORT_C void C3GPParse::CancelReadFrame()
|
sl@0
|
1874 |
{
|
sl@0
|
1875 |
if (!iHandler)
|
sl@0
|
1876 |
{
|
sl@0
|
1877 |
return;
|
sl@0
|
1878 |
}
|
sl@0
|
1879 |
if (iAsyncReadBuffer)
|
sl@0
|
1880 |
{
|
sl@0
|
1881 |
MP4CancelReadFrame(iHandler);
|
sl@0
|
1882 |
iAsyncReadBuffer = NULL;
|
sl@0
|
1883 |
iCallback = NULL;
|
sl@0
|
1884 |
}
|
sl@0
|
1885 |
}
|
sl@0
|
1886 |
|
sl@0
|
1887 |
// Receive asynchronous parse video frames operation completion notification.
|
sl@0
|
1888 |
void C3GPParse::M3GPMP4LibVideoFrameAvailable(MP4Err aError, mp4_u32 aFrameSize, mp4_u32 aTimeStamp,
|
sl@0
|
1889 |
mp4_bool aKeyFrame, mp4_u32 aTimestamp2)
|
sl@0
|
1890 |
{
|
sl@0
|
1891 |
// Check if there is an outstanding asynchronous request
|
sl@0
|
1892 |
if (iAsyncReadBuffer)
|
sl@0
|
1893 |
{
|
sl@0
|
1894 |
if (aError == MP4_OK)
|
sl@0
|
1895 |
{
|
sl@0
|
1896 |
// Set the buffer length for the asynchronous read video frame
|
sl@0
|
1897 |
iAsyncReadBuffer->SetLength(aFrameSize);
|
sl@0
|
1898 |
}
|
sl@0
|
1899 |
iAsyncReadBuffer = NULL;
|
sl@0
|
1900 |
// Parser can send out the callback to the client
|
sl@0
|
1901 |
TBool keyFrame = aKeyFrame;
|
sl@0
|
1902 |
TUint timeStampInMs = aTimeStamp;
|
sl@0
|
1903 |
TUint timeStampInTimescale = aTimestamp2;
|
sl@0
|
1904 |
iCallback->VideoFrameAvailable(SymbianOSError(aError), keyFrame, timeStampInMs, timeStampInTimescale);
|
sl@0
|
1905 |
}
|
sl@0
|
1906 |
|
sl@0
|
1907 |
iCallback = NULL;
|
sl@0
|
1908 |
}
|
sl@0
|
1909 |
|
sl@0
|
1910 |
// Receive asyncronous parse audio frames operation completion notification.
|
sl@0
|
1911 |
void C3GPParse::M3GPMP4LibAudioFramesAvailable(MP4Err aError, mp4_u32 aAudioSize, mp4_u32 aTimeStamp,
|
sl@0
|
1912 |
mp4_u32 aReturnedFrames, mp4_u32 aTimestamp2)
|
sl@0
|
1913 |
{
|
sl@0
|
1914 |
// Check if there is an outstanding asynchronous request
|
sl@0
|
1915 |
if (iAsyncReadBuffer)
|
sl@0
|
1916 |
{
|
sl@0
|
1917 |
if (aError == MP4_OK)
|
sl@0
|
1918 |
{
|
sl@0
|
1919 |
// Set the buffer length for the asynchronous read audio frame
|
sl@0
|
1920 |
iAsyncReadBuffer->SetLength(aAudioSize);
|
sl@0
|
1921 |
}
|
sl@0
|
1922 |
iAsyncReadBuffer = NULL;
|
sl@0
|
1923 |
// Parser can send out the callback to the client
|
sl@0
|
1924 |
TUint returnedFrames = aReturnedFrames;
|
sl@0
|
1925 |
TUint timeStampInMs = aTimeStamp;
|
sl@0
|
1926 |
TUint timeStampInTimescale = aTimestamp2;
|
sl@0
|
1927 |
iCallback->AudioFramesAvailable(SymbianOSError(aError), returnedFrames, timeStampInMs, timeStampInTimescale);
|
sl@0
|
1928 |
}
|
sl@0
|
1929 |
|
sl@0
|
1930 |
iCallback = NULL;
|
sl@0
|
1931 |
}
|
sl@0
|
1932 |
|
sl@0
|
1933 |
// Helper function to convert c style error code to Symbian OS standard error code
|
sl@0
|
1934 |
TInt C3GPParse::SymbianOSError(MP4Err aError) const
|
sl@0
|
1935 |
{
|
sl@0
|
1936 |
TInt error = KErrNone;
|
sl@0
|
1937 |
|
sl@0
|
1938 |
switch (aError)
|
sl@0
|
1939 |
{
|
sl@0
|
1940 |
case (MP4_OK):
|
sl@0
|
1941 |
break;
|
sl@0
|
1942 |
case (MP4_ERROR):
|
sl@0
|
1943 |
error = KErrGeneral;
|
sl@0
|
1944 |
break;
|
sl@0
|
1945 |
case (MP4_OUT_OF_MEMORY):
|
sl@0
|
1946 |
error = KErrNoMemory;
|
sl@0
|
1947 |
break;
|
sl@0
|
1948 |
case (MP4_NOT_AVAILABLE):
|
sl@0
|
1949 |
error = KErr3gpLibMoreDataRequired;
|
sl@0
|
1950 |
break;
|
sl@0
|
1951 |
case (MP4_FILE_MODE):
|
sl@0
|
1952 |
case (MP4_NOT_STREAMABLE):
|
sl@0
|
1953 |
case (MP4_NO_VIDEO):
|
sl@0
|
1954 |
case (MP4_NO_AUDIO):
|
sl@0
|
1955 |
error = KErrNotSupported;
|
sl@0
|
1956 |
break;
|
sl@0
|
1957 |
case (MP4_BUFFER_TOO_SMALL):
|
sl@0
|
1958 |
case (MP4_OUTPUT_BUFFER_TOO_SMALL):
|
sl@0
|
1959 |
error = KErrOverflow;
|
sl@0
|
1960 |
break;
|
sl@0
|
1961 |
case (MP4_END_OF_VIDEO):
|
sl@0
|
1962 |
error = KErrEof;
|
sl@0
|
1963 |
break;
|
sl@0
|
1964 |
case (MP4_CANT_SEEK):
|
sl@0
|
1965 |
case (MP4_NO_FRAME):
|
sl@0
|
1966 |
case (MP4_NO_REQUESTED_FRAME):
|
sl@0
|
1967 |
case (MP4_UDTA_NOT_FOUND):
|
sl@0
|
1968 |
error = KErrNotFound;
|
sl@0
|
1969 |
break;
|
sl@0
|
1970 |
case (MP4_FILE_ERROR):
|
sl@0
|
1971 |
error = KErrAccessDenied;
|
sl@0
|
1972 |
break;
|
sl@0
|
1973 |
case (MP4_INVALID_INPUT_STREAM):
|
sl@0
|
1974 |
error = KErrCorrupt;
|
sl@0
|
1975 |
break;
|
sl@0
|
1976 |
case (MP4_INVALID_TYPE):
|
sl@0
|
1977 |
error = KErrArgument;
|
sl@0
|
1978 |
break;
|
sl@0
|
1979 |
default:
|
sl@0
|
1980 |
// Mapped all possible errors returned by the MP4_library. Anything else should NOT happen
|
sl@0
|
1981 |
Panic(KErrArgument);
|
sl@0
|
1982 |
}
|
sl@0
|
1983 |
return error;
|
sl@0
|
1984 |
}
|
sl@0
|
1985 |
|
sl@0
|
1986 |
// Help function to get video properties
|
sl@0
|
1987 |
TInt C3GPParse::DoGetVideoProperties() const
|
sl@0
|
1988 |
{
|
sl@0
|
1989 |
if (!iVideoPropertiesSaved || iVideoError == KErr3gpLibMoreDataRequired)
|
sl@0
|
1990 |
{
|
sl@0
|
1991 |
MP4Err mp4Err = MP4_OK;
|
sl@0
|
1992 |
mp4_u32 length = 0;
|
sl@0
|
1993 |
mp4_u32 type = 0;
|
sl@0
|
1994 |
mp4_u32 width = 0;
|
sl@0
|
1995 |
mp4_u32 height = 0;
|
sl@0
|
1996 |
mp4_u32 timeScale = 0;
|
sl@0
|
1997 |
mp4_double frameRate = 0;
|
sl@0
|
1998 |
|
sl@0
|
1999 |
mp4Err = MP4ParseRequestVideoDescription(iHandler, &length, &frameRate, &type, &width, &height, &timeScale);
|
sl@0
|
2000 |
iVideoPropertiesSaved = ETrue;
|
sl@0
|
2001 |
if (mp4Err == MP4_OK)
|
sl@0
|
2002 |
{
|
sl@0
|
2003 |
iVideoType = WrapperVideoType(type);
|
sl@0
|
2004 |
if (iVideoType == E3GPNoVideo)
|
sl@0
|
2005 |
{
|
sl@0
|
2006 |
iVideoError = KErrNotSupported;
|
sl@0
|
2007 |
return KErrNotSupported;
|
sl@0
|
2008 |
}
|
sl@0
|
2009 |
iVideoLength = length;
|
sl@0
|
2010 |
iVideoMp4Type = type; // Type of video stream
|
sl@0
|
2011 |
iVideoSize.iWidth = width;
|
sl@0
|
2012 |
iVideoSize.iHeight = height;
|
sl@0
|
2013 |
iVideoTimeScale = timeScale;
|
sl@0
|
2014 |
iVideoFrameRate = frameRate;
|
sl@0
|
2015 |
}
|
sl@0
|
2016 |
iVideoError = SymbianOSError(mp4Err);
|
sl@0
|
2017 |
}
|
sl@0
|
2018 |
return iVideoError;
|
sl@0
|
2019 |
}
|
sl@0
|
2020 |
|
sl@0
|
2021 |
// Help function to get audio properties
|
sl@0
|
2022 |
TInt C3GPParse::DoGetAudioProperties() const
|
sl@0
|
2023 |
{
|
sl@0
|
2024 |
if (!iAudioPropertiesSaved || iAudioError == KErr3gpLibMoreDataRequired)
|
sl@0
|
2025 |
{
|
sl@0
|
2026 |
MP4Err mp4Err = MP4_OK;
|
sl@0
|
2027 |
mp4_u32 audioLength = 0;
|
sl@0
|
2028 |
mp4_u32 audioType = 0;
|
sl@0
|
2029 |
mp4_u32 averateBitRate = 0;
|
sl@0
|
2030 |
mp4_u32 timeScale = 0;
|
sl@0
|
2031 |
mp4_u8 framesPerSample = 0;
|
sl@0
|
2032 |
|
sl@0
|
2033 |
mp4Err = MP4ParseRequestAudioDescription(iHandler, &audioLength, &audioType,
|
sl@0
|
2034 |
&framesPerSample, &timeScale, &averateBitRate);
|
sl@0
|
2035 |
iAudioPropertiesSaved = ETrue;
|
sl@0
|
2036 |
if (mp4Err == MP4_OK)
|
sl@0
|
2037 |
{
|
sl@0
|
2038 |
iAudioLength = audioLength;
|
sl@0
|
2039 |
iAudioMp4Type = audioType; // Type of audio stream
|
sl@0
|
2040 |
iAudioType = WrapperAudioType(audioType);
|
sl@0
|
2041 |
iAudioFramesPerSample = framesPerSample;
|
sl@0
|
2042 |
iAudioAvgBitRate = averateBitRate;
|
sl@0
|
2043 |
iAudioTimeScale = timeScale;
|
sl@0
|
2044 |
}
|
sl@0
|
2045 |
iAudioError = SymbianOSError(mp4Err);
|
sl@0
|
2046 |
}
|
sl@0
|
2047 |
return iAudioError;
|
sl@0
|
2048 |
}
|
sl@0
|
2049 |
|
sl@0
|
2050 |
// Help function to get stream properties
|
sl@0
|
2051 |
TInt C3GPParse::DoGetStreamProperties() const
|
sl@0
|
2052 |
{
|
sl@0
|
2053 |
if (!iStreamPropertiesSaved || iStreamError == KErr3gpLibMoreDataRequired)
|
sl@0
|
2054 |
{
|
sl@0
|
2055 |
MP4Err mp4Err = MP4_OK;
|
sl@0
|
2056 |
mp4_u32 streamSize = 0;
|
sl@0
|
2057 |
mp4_u32 streamAvgBitRate;
|
sl@0
|
2058 |
mp4Err = MP4ParseRequestStreamDescription(iHandler,&streamSize, &streamAvgBitRate);
|
sl@0
|
2059 |
iStreamPropertiesSaved = ETrue;
|
sl@0
|
2060 |
if (mp4Err == MP4_OK)
|
sl@0
|
2061 |
{
|
sl@0
|
2062 |
iStreamSize = streamSize;
|
sl@0
|
2063 |
iStreamAvgBitRate = streamAvgBitRate;
|
sl@0
|
2064 |
}
|
sl@0
|
2065 |
iStreamError = SymbianOSError(mp4Err);
|
sl@0
|
2066 |
}
|
sl@0
|
2067 |
return iStreamError;
|
sl@0
|
2068 |
}
|
sl@0
|
2069 |
|
sl@0
|
2070 |
// Helper function to map Mp4 enum type to T3GPVideoType for video
|
sl@0
|
2071 |
T3GPVideoType C3GPParse::WrapperVideoType(TUint aType) const
|
sl@0
|
2072 |
{
|
sl@0
|
2073 |
T3GPVideoType videoType = E3GPNoVideo;
|
sl@0
|
2074 |
switch (aType)
|
sl@0
|
2075 |
{
|
sl@0
|
2076 |
case (MP4_TYPE_MPEG4_VIDEO):
|
sl@0
|
2077 |
videoType = E3GPMpeg4Video;
|
sl@0
|
2078 |
break;
|
sl@0
|
2079 |
case (MP4_TYPE_H263_PROFILE_0):
|
sl@0
|
2080 |
videoType = E3GPH263Profile0;
|
sl@0
|
2081 |
break;
|
sl@0
|
2082 |
case (MP4_TYPE_H263_PROFILE_3):
|
sl@0
|
2083 |
videoType = E3GPH263Profile3;
|
sl@0
|
2084 |
break;
|
sl@0
|
2085 |
case (MP4_TYPE_AVC_PROFILE_BASELINE):
|
sl@0
|
2086 |
videoType = E3GPAvcProfileBaseline;
|
sl@0
|
2087 |
break;
|
sl@0
|
2088 |
case (MP4_TYPE_AVC_PROFILE_MAIN):
|
sl@0
|
2089 |
videoType = E3GPAvcProfileMain;
|
sl@0
|
2090 |
break;
|
sl@0
|
2091 |
case (MP4_TYPE_AVC_PROFILE_EXTENDED):
|
sl@0
|
2092 |
videoType = E3GPAvcProfileExtended;
|
sl@0
|
2093 |
break;
|
sl@0
|
2094 |
|
sl@0
|
2095 |
case (MP4_TYPE_AVC_PROFILE_HIGH):
|
sl@0
|
2096 |
videoType = E3GPAvcProfileHigh;
|
sl@0
|
2097 |
break;
|
sl@0
|
2098 |
case MP4_TYPE_NONE:
|
sl@0
|
2099 |
break;
|
sl@0
|
2100 |
default:
|
sl@0
|
2101 |
Panic(KErrCorrupt); // This should not happen.
|
sl@0
|
2102 |
break;
|
sl@0
|
2103 |
}
|
sl@0
|
2104 |
return videoType;
|
sl@0
|
2105 |
}
|
sl@0
|
2106 |
|
sl@0
|
2107 |
// Helper function to map Mp4 enum type to T3GPAudioType for audio
|
sl@0
|
2108 |
T3GPAudioType C3GPParse::WrapperAudioType(TUint aType) const
|
sl@0
|
2109 |
{
|
sl@0
|
2110 |
T3GPAudioType audioType = E3GPNoAudio;
|
sl@0
|
2111 |
switch (aType)
|
sl@0
|
2112 |
{
|
sl@0
|
2113 |
case (MP4_TYPE_MPEG4_AUDIO):
|
sl@0
|
2114 |
audioType = E3GPMpeg4Audio;
|
sl@0
|
2115 |
break;
|
sl@0
|
2116 |
case (MP4_TYPE_AMR_NB):
|
sl@0
|
2117 |
audioType = E3GPAmrNB;
|
sl@0
|
2118 |
break;
|
sl@0
|
2119 |
case (MP4_TYPE_AMR_WB):
|
sl@0
|
2120 |
audioType = E3GPAmrWB;
|
sl@0
|
2121 |
break;
|
sl@0
|
2122 |
case (MP4_TYPE_QCELP_13K):
|
sl@0
|
2123 |
audioType = E3GPQcelp13K;
|
sl@0
|
2124 |
break;
|
sl@0
|
2125 |
default:
|
sl@0
|
2126 |
Panic(KErrCorrupt); // This should not happen.
|
sl@0
|
2127 |
}
|
sl@0
|
2128 |
return audioType;
|
sl@0
|
2129 |
}
|
sl@0
|
2130 |
|
sl@0
|
2131 |
// Helper function to map enum type of the location of the user data in the file
|
sl@0
|
2132 |
mp4_u8 C3GPParse::UdtaLocation(T3GPUdtaLocation aLocation) const
|
sl@0
|
2133 |
{
|
sl@0
|
2134 |
mp4_u8 location = MP4_UDTA_NONE;
|
sl@0
|
2135 |
|
sl@0
|
2136 |
switch (aLocation )
|
sl@0
|
2137 |
{
|
sl@0
|
2138 |
case (E3GPUdtaMoov):
|
sl@0
|
2139 |
location = MP4_UDTA_MOOV;
|
sl@0
|
2140 |
break;
|
sl@0
|
2141 |
case (E3GPUdtaVideoTrak):
|
sl@0
|
2142 |
location = MP4_UDTA_VIDEOTRAK;
|
sl@0
|
2143 |
break;
|
sl@0
|
2144 |
case (E3GPUdtaAudioTrak):
|
sl@0
|
2145 |
location = MP4_UDTA_AUDIOTRAK;
|
sl@0
|
2146 |
break;
|
sl@0
|
2147 |
default:
|
sl@0
|
2148 |
Panic(KErrArgument);
|
sl@0
|
2149 |
}
|
sl@0
|
2150 |
return location;
|
sl@0
|
2151 |
}
|
sl@0
|
2152 |
|
sl@0
|
2153 |
|
sl@0
|
2154 |
void C3GPParse::Panic(TInt aPanic)
|
sl@0
|
2155 |
// Panic client
|
sl@0
|
2156 |
{
|
sl@0
|
2157 |
_LIT(K3GPParsePanicName, "C3GPParse");
|
sl@0
|
2158 |
User::Panic(K3GPParsePanicName, aPanic);
|
sl@0
|
2159 |
}
|
sl@0
|
2160 |
|
sl@0
|
2161 |
|