This tutorial describes how to read video and audio content.
The purpose of this tutorial is to show you how to read video and audio content synchronously and asynchronously.
Required background
The 3GP Library Overview introduces the 3GP Parser.
Introduction
Video and audio content is read frame by frame. Video and audio frames do not necessarily have to be read in the same order that they are stored in a file. There are separate index counters for video and audio streams, which makes it possible to get all video stream data first, then get the data in the audio stream. Random access to video and audio frames is also possible with other functions provided by the C3GPParse class.
The following tasks are covered in this tutorial:
To read a video frame, call one of the overloads of C3GPParse::ReadVideoFrame():
To read the next video frame from a 3GP file or stream and return it synchronously, call C3GPParse::ReadVideoFrame(TDes8, TBool &, TUint &s, TUint &):
IMPORT_C TInt ReadVideoFrame(TDes8 &aBuffer, TBool &aKeyFrame, TUint &aTimeStampInMs, TUint &aTimeStampInTimescale) const;
The video frame that is read depends on the current position in the input 3GP file. You can use the C3GPParse::Seek() function to change the current position in the 3GP file.
To read the current video frame from an input file and return it asynchronously, call C3GPParse::ReadVideoFrame(M3GPParseCallback &, TDes8 &):
IMPORT_C void ReadVideoFrame(M3GPParseCallback &aCallback, TDes8 &aBuffer);
Upon completion, successful or otherwise, the callback function M3GPParseCallback::VideoFrameAvailable(TInt, TUints, TUint, TUint) is called.
Note: The asynchronous C3GPParse::ReadVideoFrame() function is not supported when the 3GP Parser is in buffer mode.
Note: There are separate cursors for storing current positions of video and audio streams. Calling C3GPParse::ReadVideoFrame() does not affect the position of the next audio stream.
To read audio frames, call one of the overloads of C3GPParse::ReadAudioFrames():
To read the audio frames that are stored in the current audio sample from the 3GP file or stream and return them synchronously, call C3GPParse::ReadAudioFrames(TDes8 &, TInt &, TUint &, TUint &):
IMPORT_C TInt ReadAudioFrames(TDes8 &aBuffer, TInt &aReturnedFrames, TUint &aTimeStampInMs, TUint &aTimeStampInTimescale) const;
The next frame read depends on the current position in the input 3GP file. You can use the C3GPParse::Seek() function to change the current position in the 3GP file.
To read the audio frames that are stored in the current audio sample from the 3GP file or stream and return them asynchronously, call C3GPParse::ReadAudioFrames(M3GPParseCallback &, TDes8 &):
IMPORT_C void ReadAudioFrames(M3GPParseCallback &aCallback, TDes8 &aBuffer);
Upon completion, successful or otherwise, the callback function M3GPParseCallback::AudioFramesAvailable(TInt, TUint, TUint, TUint) is called.
Note: The asynchronous C3GPParse::ReadAudioFrames() function is not supported when the 3GP Parser is in buffer mode.
Note: There are separate cursors for storing current positions for video and audio streams. Calling C3GPParse::ReadAudioFrames() does not change the current position of the video stream.
The following example shows you how to read video and audio frames:
CMyApp::ReadFileL(const RFile& aFile) { ... // See example code in Setting up a 3GP Parser and Getting Audio and Video Stream Metadata. ... TInt err = KErrNone; while (err != KErrNotFound) { TInt err = parser->ReadVideoFrame(...); if (err == KErrNone) { // do something with the video data ... } } err = KErrNone while (err != KErrNotFound) { // retrieve audio frames TInt err = parser->ReadAudioFrames(...); if (err == KErrNone) { // do something with the audio data ... } ...
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.