diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita Tue Mar 30 11:56:28 2010 +0100 @@ -0,0 +1,45 @@ + + + + + +Reading Video and Audio Content

This tutorial describes how to read video and audio content.

Purpose

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.

Using frames

The following tasks are covered in this tutorial:

  • Reading a video frame

  • Reading audio frames

Reading a video frame

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.

Reading audio frames

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.

Example

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 + ... + } + + ...
See Also

Setting up a 3GP Parser

Supplying Data to a 3GP Parser

Getting Audio and Video Stream Metadata

\ No newline at end of file