Adding Data to a 3GP Composer

This tutorial describes how to add data to a 3GP Composer.

Purpose

To write a 3GP, 3G2 or MP4 file, you need to add data to a 3GP Composer. The purpose of this tutorial is to show you how to add the data to the 3GP Composer.

Required background

The 3GP Library Overview introduces the 3GP Composer.

Introduction

You can add the following types of data:

  • Video frames

  • Audio frames

  • User data, such as copyright information.

Note: After adding your data, you must call C3GPCompose::Complete() to commit the data to the output file. The data is only available in the output file after calling C3GPCompose::Complete(). For more information, see Completing Composition.

Using data

The following tasks are covered in this tutorial:

Writing a video frame

To write a video frame to the output file, call one of the overloads of C3GPCompose::WriteVideoFrame():

Note: You must write each video frame in the correct order. Video frames are retrieved from the output file in the same order that the frames are written using C3GPCompose::WriteVideoFrame().

Writing audio frames

To write audio frames to the output file:

  • Call C3GPCompose::WriteAudioFrames(const TDesC8 &, TUint):

    IMPORT_C TInt WriteAudioFrames(const TDesC8 &aBuffer, TUint aDuration);

    Note: Depending on the audio type, you can use C3GPCompose::WriteAudioFrames() to write either one or a number of audio frames:

    • For MPEG-4 audio, C3GPCompose::WriteAudioFrames() writes one MPEG audio frame to the output file.

    • For other audio types, C3GPCompose::WriteAudioFrames() writes a number of audio frames to the output file. The number of audio frames is specified in the aAudio input parameter when you call C3GPCompose::Open(). For more information, see Setting up a 3GP Composer.

Writing user data

To write user data:

Example

The following example shows you how to add video, audio and user data to a 3GP Composer:

CMyApp::WriteFileL(const TDesC& aFile)
    {
    ...
    // set up composer as described in Setting up a 3GP Composer. 
    ...
    User::LeaveIfError(composer->WriteVideoFrame(...));
    User::LeaveIfError(composer->WriteAudioFrames(...));
    User::LeaveIfError(composer->SetUserData(...));
    ...
    }