class C3GPParse : public CBase |
The Parser provides APIs to parse 3GP, 3G2 and MP4 contents (from a file, a CAF object, or given through memory buffer), containing H.263/MPEG-4/H.264 video and AMR/MPEG-4/QCELP audio.
Private Member Functions | |
---|---|
C3GPParse ( TInt ) | |
TInt | DoGetAudioProperties () |
TInt | DoGetStreamProperties () |
TInt | DoGetVideoProperties () |
void | M3GPMP4LibAudioFramesAvailable ( MP4Err , mp4_u32 , mp4_u32 , mp4_u32 , mp4_u32 ) |
void | M3GPMP4LibVideoFrameAvailable ( MP4Err , mp4_u32 , mp4_u32 , mp4_bool , mp4_u32 ) |
void | Panic ( TInt ) |
void | Reset () |
TInt | SymbianOSError ( MP4Err ) |
mp4_u8 | UdtaLocation ( T3GPUdtaLocation ) |
T3GPAudioType | WrapperAudioType ( TUint ) |
T3GPVideoType | WrapperVideoType ( TUint ) |
C3GPParse | ( | TInt | aReadBufferSize = 0 | ) | [private] |
TInt aReadBufferSize = 0 |
IMPORT_C void | CancelReadFrame | ( | ) |
This function cancels the outstanding asynchronous read audio/video frame request.
No callback function will be called.
Note: As only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time, this function can be used to cancel audio or video read request.
IMPORT_C TInt | Complete | ( | ) |
This function completes the parsing operation.
If C3GPParse::Complete is called before the parse is initialised, it will be ignored and KErrNone is returned.
The parser can be reused again after this call, following another call to C3GPParse::Open to re-initialise the parser.
IMPORT_C TInt | GetAudioDecoderSpecificInfo | ( | TDes8 & | aBuffer | ) | const |
This function reads DecoderSpecificInfo data from 3GP metadata and returns it to the caller.
Note: AMR DecoderSpecificInfo data structure is returned in runtime in an architecture-specific Endian format, that is, no Endian conversion is necessary for the data.
TDes8 & aBuffer | DecoderSpecificInfo is returned here. |
IMPORT_C TInt | GetAudioDecoderSpecificInfoSize | ( | TInt & | aSize | ) | const |
Returns size of audio DecoderSpecificInfo data from 3GP metadata.
TInt & aSize | Size of DecoderSpecificInfo to be returned (in bytes). |
IMPORT_C TInt | GetAudioFramesSize | ( | TUint & | aSize | ) | const |
This function returns the total size of the audio frames in the immediate audio sample based on the current position of the parser.
This function has no effect on the parser s current position.
TUint & aSize | Size of the next audio sample in bytes. |
IMPORT_C TInt | GetAudioProperties | ( | T3GPAudioType & | aType, |
TUint & | aLength, | |||
TInt & | aFramesPerSample, | |||
TUint & | aAvgBitRate, | |||
TUint & | aTimeScale | |||
) | const |
This function returns the parameters describing the audio stream.
If no file or CAF object is supplied during parser initialisation, this should be called after enough data has been inserted into the library so that the 3GP headers containing the information can be read.
T3GPAudioType & aType | The type of audio stream. Refer to T3GPFrameType for supported audio type values. |
TUint & aLength | Duration of audio in milliseconds. |
TInt & aFramesPerSample | Number of audio frames in each sample. |
TUint & aAvgBitRate | Average bit rate of audio. |
TUint & aTimeScale | Timescale of audio track. |
IMPORT_C TInt | GetAudioSampleEntryIndex | ( | TUint & | aIndex | ) | const |
This function gives the audio sample entry index of the next audio frame to be read.
The smallest index value is 1.
TUint & aIndex | Returns the Audio Sample Entry index of the next video frame to be read. |
IMPORT_C TInt | GetContainerProperties | ( | TUint & | aSize, |
TUint & | aAvgBitRate | |||
) | const |
This function returns the parameters that describe the contents of the input file or buffer.
If no file or CAF object is supplied during parser initialisation, this should be called after enough data has been inserted into the library so that the headers containing the information can be read.
IMPORT_C TInt | GetFrameAvailability | ( | T3GPFrameType | aType, |
TBool & | aAvailable | |||
) | const |
This function determines whether the next frame of the type aType is available.
This function has no effect on the parser s current position.
T3GPFrameType aType | The type of frame to check for. Refer to T3GPFrameType for supported types. |
TBool & aAvailable | Return ETrue if the type of frame specified by aType is available. |
IMPORT_C TInt | GetFrameType | ( | T3GPFrameType & | aType | ) | const |
This function returns the type of the next audio/video frame in the stream.
This function has no effect on the parser s current position.
T3GPFrameType & aType | Type of the next frame. Refer to the definition of T3GPFrameType for all possible values. |
IMPORT_C TInt | GetH263VideoLevel | ( | TInt & | aLevel | ) | const |
This function provides the video level of the H263 video stream contained in the 3GP data.
TInt & aLevel | Returns the H263 video level. |
IMPORT_C TInt | GetNumBufferedBytes | ( | TInt & | aNum | ) | const |
This function returns the number of bytes that the library instance has in its allocated buffers.
The function is only valid when the parser is initialized without any parameters. Zero is returned when in file mode, that is, the parser has been initialized with a valid filename, file handle or a CAF object.
TInt & aNum | Number of allocated bytes in the library. |
IMPORT_C TInt | GetNumberOfVideoFrames | ( | TUint & | aNum | ) | const |
Returns the number of video frames.
TUint & aNum | Number of video frames. |
IMPORT_C TInt | GetQcelpStorageMode | ( | T3GPQcelpStorageMode & | aMode | ) | const |
This function provides the storage mode of 13K QCELP in 3G2 file.
In 3G2 files, QCELP can be registered to be stored in two ways: using the QCELP Sample Entry ('sqcp') Box or using the MPEG4 Audio Sample Description ('esds') Box.
T3GPQcelpStorageMode & aMode | Returns the QCELP storage mode. See T3GPQcelpStorageMode. |
IMPORT_C TInt | GetStreamable | ( | TBool & | aStreamable | ) | const |
This function determines whether the input 3GP stream is streamable, that is, whether the media data is arranged in such a manner that playback can be started without downloading the entire stream.
TBool & aStreamable | Returns ETrue if the file is streamable. Otherwise, returns EFalse. |
IMPORT_C TInt | GetUserDataAtom | ( | TUint32 | aType, |
T3GPUdtaLocation | aLocation, | |||
TDes8 & | aBuffer, | |||
TUint & | aAtomIndex | |||
) | const |
Retrieves an atom of given type from user data atom (UDTA) to the given buffer.
The buffer returned stores an atom of structure that conforms to the definition of a "full box" as specified in ISO/IEC 14496-12:2003: "Information technology Coding of audio-visual objects Part 12: ISO base media file format."
For more information on user data atoms, see Section 8 Asset Information of "3GPP TS 26.244 version 6.1.0 3GP file format (Rel 6)."
TUint32 aType | Type of atom to be read from UDTA. Hex value of 4 chars representing atom type defined in standard. For example, 0x7469746c is 'titl', title for the media atom. |
T3GPUdtaLocation aLocation | Specifies the location of user information to be retrieved. Refer to T3GPUdtaLocation for supported values. |
TDes8 & aBuffer | The descriptor to store the requested user data atom. |
TUint & aAtomIndex | Specifies the index of atom if UDTA contains multiple sub-atoms of the same aUdtaAtomType to retrieve when supplied as input parameter. Returns the highest index of the matching sub-atom found in the specified location as output parameter. Only matching sub-atoms are counted when calculating the highest index. |
IMPORT_C TInt | GetUserDataAtomSize | ( | TUint32 | aType, |
T3GPUdtaLocation | aLocation, | |||
TUint & | aAtomIndex, | |||
TInt & | aSize | |||
) | const |
Returns the needed size for memory buffer to store an atom of given type from user data atom (UDTA).
TUint32 aType | Type of atom to be read from UDTA. Hex value of 4 chars representing atom type defined in standard. For example, 0x7469746c is 'titl', title for the media atom. |
T3GPUdtaLocation aLocation | Specifies the location of user information to be retrieved. Refer to T3GPUdtaLocation for supported values. |
TUint & aAtomIndex | Specifies the index of atom if UDTA contains multiple sub-atoms of the same aUdtaAtomType to retrieve when supplied as input parameter. Returns the highest index of the matching sub-atom found in the specified location as output parameter. |
TInt & aSize | This contains the needed size for memory buffer. |
IMPORT_C TInt | GetVideoDecoderSpecificInfo | ( | TDes8 & | aInfo | ) | const |
This function reads DecoderSpecificInfo data from 3GP metadata and returns it to the caller. For files with MPEG-4 video this data is read from the esds atom. For files with AVC video this data is read from the avcC atom.
Note: Only MPEG-4 video and H.264/AVC video streams contain DecoderSpecificInfo.
TDes8 & aInfo | The descriptor to store the video decoder information. |
IMPORT_C TInt | GetVideoDecoderSpecificInfoSize | ( | TInt & | aSize | ) | const |
Return size of video DecoderSpecificInfo. For files with MPEG-4 video this data is read from the esds atom. For files with AVC video this data is read from the avcC atom.
Note: Only MPEG-4 video and H.264/AVC video streams contain DecoderSpecificInfo.
TInt & aSize | Size of video DecoderSpecificInfo. |
IMPORT_C TInt | GetVideoFrameDependencies | ( | T3GPFrameDependencies & | aDependencies | ) | const |
This function gets the next frame's dependency information from SDTP box.
T3GPFrameDependencies & aDependencies | Returns the next frame's dependency information. See T3GPFrameDependencies. |
IMPORT_C TInt | GetVideoFrameKeyType | ( | TUint | aIndex, |
TBool & | aKeyFrame | |||
) | const |
Checks if a video frame of with index aIndex exists.
IMPORT_C TInt | GetVideoFrameProperties | ( | TUint | aStartIndex, |
TUint | aNumberOfFrames, | |||
RArray < T3GPFrameInfoParameters > & | aArray | |||
) | const |
This function gets frame properties, from aStartIndex for a count of aNumberOfFrames frames.
Properties obtained are start time, frame type, and frame size, stored in the T3GPFrameInfoParameters struct.
TUint aStartIndex | Index to start getting info for the array. |
TUint aNumberOfFrames | Number of frames to retrieve frame info. |
RArray < T3GPFrameInfoParameters > & aArray | An array of T3GPFrameInfoParameters struct to store video frame properties. The input array will be flushed of all existing elements before use. |
IMPORT_C TInt | GetVideoFrameSize | ( | TUint & | aSize | ) | const |
This function returns the size of the immediate next video frame based on the current position of the parser.
Calling this function does not change the current position of the parser.
TUint & aSize | Size of the next video frame in bytes. |
IMPORT_C TInt | GetVideoFrameSize | ( | TUint | aIndex, |
TUint & | aSize | |||
) | const |
Returns video frame size.
IMPORT_C TInt | GetVideoFrameStartTime | ( | TUint | aIndex, |
TUint & | aTimeStampInMs, | |||
TUint & | aTimeStampInTimescale | |||
) | const |
Returns video frame start time.
IMPORT_C TInt | GetVideoProperties | ( | T3GPVideoType & | aType, |
TUint & | aLength, | |||
TReal & | aFrameRate, | |||
TUint & | aAvgBitRate, | |||
TSize & | aSize, | |||
TUint & | aTimeScale | |||
) | const |
This function returns the parameters describing the video stream.
If no file or CAF object is supplied during parser initialisation, this should be called after enough data has been inserted into the library buffers so that the 3GP headers containing the information can be read.
The aFrameRate parameter refers to the frame rate of the original video material.
T3GPVideoType & aType | The type of video stream. Refer to T3GPVideoType for supported video type. |
TUint & aLength | Duration of video in milliseconds. |
TReal & aFrameRate | Average frame rate of video (in Hz). |
TUint & aAvgBitRate | Average bit rate of video. |
TSize & aSize | Width and height of video image measured in pixels. |
TUint & aTimeScale | Timescale of video track. |
IMPORT_C TInt | GetVideoSampleEntryIndex | ( | TUint & | aIndex | ) | const |
This function gives the video sample entry index of the next video frame to be read.
The smallest index value is 1.
TUint & aIndex | Returns the Visual Sample Entry index of the next video frame to be read. |
IMPORT_C TInt | GetVideoTimestamp | ( | TUint & | aTimeStampInMs, |
TUint & | aTimeStampInTimescale | |||
) | const |
Returns the timestamp of the next video frame. The current position of the video stream will be moved forward.
The function can be used to find out which frames have been coded to optimize the input frame selection if video frame rate needs to be modified.
When this function call returns KErrEof, there are no more video frames left in the 3GP file and the timestamp returned with the previous call was the timestamp of the last video frame.
Note: C3GPParse::Seek can be used to change the current position in the 3GP file.
IMPORT_C TInt | InsertData | ( | const TDesC8 & | aBuffer | ) |
This function inserts MP4/3GP/3G2 data into the parser.
It is only necessary to call this function if no parameter has been supplied when C3GPParse::Open is called. Several functions can return KErr3gpLibMoreDataRequired if the library does not have enough data to return the information that the caller requests. In this case, more data needs to be inserted to the library before calling those functions again.
This function makes a copy of the data inserted into the library so the caller can use the input buffer for other purposes. If the function returns KErrNoMemory, the buffer contents have not been copied into the library and the caller needs to reduce the buffer content before calling again.
If an empty string is supplied for the argument aBuffer, it indicates that there is be no more data to feed through this function. Such a function call must be done to indicate that all 3GP/MP4/3G2 data has been written to the library's internal memory.
const TDesC8 & aBuffer | The descriptor containing the data to be inserted. |
void | M3GPMP4LibAudioFramesAvailable | ( | MP4Err | aError, |
mp4_u32 | aAudioSize, | |||
mp4_u32 | aTimeStamp, | |||
mp4_u32 | aReturnedFrames, | |||
mp4_u32 | aTimestamp2 | |||
) | [private] |
void | M3GPMP4LibVideoFrameAvailable | ( | MP4Err | aError, |
mp4_u32 | aFrameSize, | |||
mp4_u32 | aTimeStamp, | |||
mp4_bool | aKeyFrame, | |||
mp4_u32 | aTimestamp2 | |||
) | [private] |
IMPORT_C C3GPParse * | NewL | ( | ) | [static] |
Creates an instance of a 3GP Parser for reading 3GP/3G2/MP4 data using default buffer size.
The default value for read buffer size is 8k.
IMPORT_C C3GPParse * | NewL | ( | TInt | aReadBufferSize | ) | [static] |
Creates an instance of a 3GP Parser for reading 3GP/3G2/MP4 data, and sets the internal file read buffer size.
TInt aReadBufferSize | Size of file read buffer. |
IMPORT_C TInt | Open | ( | ) |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a buffer and expects data to be inserted through subsequent calls to C3GPParse::InsertData .
IMPORT_C TInt | Open | ( | const TDesC & | aFilename | ) |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
const TDesC & aFilename | A full path name of the file containing the data. |
IMPORT_C TInt | Open | ( | const RFile & | aFile | ) |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
const RFile & aFile | File handle of the file containing the data. It is expected to be a valid file handle, opened and will be closed outside of the library. |
IMPORT_C TInt | Open | ( | const RFile64 & | aFile | ) |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a file.
const RFile64 & aFile | File handle of the file containing the data. It is expected to be a valid file handle, opened and will be closed outside of the library. |
IMPORT_C TInt | Open | ( | const ContentAccess::CData & | aData | ) |
This function initialises the 3GP Parser for reading 3GP/3G2/MP4 data from a CAF object.
const ContentAccess::CData & aData | A CData object pointing to a CAF object. It is expected to be opened and will be closed outside of the library. |
IMPORT_C TInt | ReadAudioFrames | ( | TDes8 & | aBuffer, |
TInt & | aReturnedFrames, | |||
TUint & | aTimeStampInMs, | |||
TUint & | aTimeStampInTimescale | |||
) | const |
This function reads the audio frames that are stored in the current audio sample from the 3GP file/stream and returns them to the caller. The current position of audio stream will be moved forward.
Note: The next frame depends on the position in the input 3GP file. C3GPParse::Seek can be used to change the current position in the 3GP file.
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData to insert more data before calling the function again.
Note: aReturnedFrames may differ from the correct value when accessing the last audio sample.
Note: Since there are separate cursors for storing current positions for video and audio streams, calling this function does not change current position of the parser for video stream.
TDes8 & aBuffer | Audio frames are returned here. |
TInt & aReturnedFrames | Number of the returned frames or 0 if not known. |
TUint & aTimeStampInMs | Audio frame presentation time in milliseconds from the beginning of the audio sequence. |
TUint & aTimeStampInTimescale | Audio frame presentation time in timescale from the beginning of the audio sequence. |
IMPORT_C void | ReadAudioFrames | ( | M3GPParseCallback & | aCallback, |
TDes8 & | aBuffer | |||
) |
This function reads the audio frames that are stored in the current audio sample from the input file and returns them to the caller asynchronously. The current position of audio stream will be moved forward.
This function is not supported when the parser is in buffer mode.
C3GPParse::CancelReadFrame can be used to cancel an outstanding asynchronous frame read request.
Note: Only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time.
Upon completion, successfully or otherwise, the callback function M3GPParseCallback::AudioFramesAvailable is called.
M3GPParseCallback & aCallback | Reference to class derived from M3GPAsyncObserver designed to receive notification of asynchronous event completion. |
TDes8 & aBuffer | The descriptor to store the audio frames. |
IMPORT_C TInt | ReadVideoFrame | ( | TDes8 & | aBuffer, |
TBool & | aKeyFrame, | |||
TUint & | aTimeStampInMs, | |||
TUint & | aTimeStampInTimescale | |||
) | const |
This function reads the next video frame from the 3GP file/stream and returns it to the caller. The current position of video stream will be moved forward.
The next frame depends on the position in the input 3GP file. C3GPParse::Seek can be used to change the current position in the 3GP file.
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData to insert more data before calling the function again.
Since there are separate cursors for storing current positions of video and audio streams, calling this function does not affect the position of the next audio stream.
TDes8 & aBuffer | Video frame is returned here. |
TBool & aKeyFrame | Returns ETrue if the current frame is a key frame (intra), otherwise the value is EFalse. |
TUint & aTimeStampInMs | Video frame presentation time in milliseconds from the beginning of the video sequence. |
TUint & aTimeStampInTimescale | Video frame presentation time in timescale from the beginning of the video sequence. |
IMPORT_C void | ReadVideoFrame | ( | M3GPParseCallback & | aCallback, |
TDes8 & | aBuffer | |||
) |
This function reads the current video frame from an input file and returns it to the caller asynchronously. The current position of video stream will be moved forward.
This function is not supported when the parser is in buffer mode.
C3GPParse::CancelReadFrame can be used to cancel an outstanding asynchronous frame read request.
Note: Only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time.
Upon completion, successfully or otherwise, the callback function M3GPParseCallback::VideoFrameAvailable is called.
M3GPParseCallback & aCallback | Reference to class derived from M3GPAsyncObserver designed to receive notification of asynchronous event completion. |
TDes8 & aBuffer | The descriptor to store the video frames. |
IMPORT_C TInt | Seek | ( | TUint | aPosition, |
TBool | aKeyFrame, | |||
TUint & | aAudioPosition, | |||
TUint & | aVideoPosition | |||
) | const |
This function seeks the position specified by the aPosition parameter in the input 3GP file/stream.
The position is considered to start from the beginning of the presentation time line in the 3GP file. Thus audio and video positions cannot be given separately.
The function will set the current audio and video positions in the following manner:
If there is only audio data in the file, the current position is set to the audio frame at or just before the given position.
If there is only video in the file and the key frame is EFalse, the current position is set to the video frame at or just before the given position. If the key frame is set to ETrue, the current position is set to the first key frame at or before the current position.
If there are both audio and video in the file, video is first positioned as explained above and then audio is sought to the closest position in relation to video.
If the position to seek is greater than the duration of video or audio, the video or audio position is set to the position of the last video or audio frame as explained above.
If the function returns KErr3gpLibMoreDataRequired, the caller needs to call C3GPParse::InsertData to insert more data before calling the function again.
TUint aPosition | Position to seek in milliseconds in the 3GP presentation time line. |
TBool aKeyFrame | If set to ETrue, the first video key frame before a given point is sought. If set to EFalse, the first video frame before a given point is sought. |
TUint & aAudioPosition | Position of audio after seeking (in milliseconds). |
TUint & aVideoPosition | Position of video after seeking (in milliseconds). |
TInt | SymbianOSError | ( | MP4Err | aError | ) | const [private] |
MP4Err aError |
mp4_u8 | UdtaLocation | ( | T3GPUdtaLocation | aLocation | ) | const [private] |
T3GPUdtaLocation aLocation |
T3GPAudioType | WrapperAudioType | ( | TUint | aType | ) | const [private] |
TUint aType |
T3GPVideoType | WrapperVideoType | ( | TUint | aType | ) | const [private] |
TUint aType |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.