This tutorial describes how to add data to a 3GP Composer.
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:
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.
The following tasks are covered in this tutorial:
To write a video frame to the output file, call one of the overloads of C3GPCompose::WriteVideoFrame():
To use the default frame dependency information, call C3GPCompose::WriteVideoFrame(const TDesC8 &, TUint, TBool):
IMPORT_C TInt WriteVideoFrame(const TDesC8 &aBuffer, TUint aDuration, TBool aKeyFrame);
The default values for frame dependency information are E3GPDependencyUnknown and E3GPRedundancyUnknown. For more information, see T3GPFrameDependencies.
To specify your own frame dependency information, call C3GPCompose::WriteVideoFrame(const TDesC8&, TUint, TBool):
IMPORT_C TInt WriteVideoFrame(const TDesC8 &aBuffer, TUint aDuration, TBool aKeyFrame, const T3GPFrameDependencies &aDependencies);
Frame dependency information lets you define dependencies between video frames. For more information, see T3GPFrameDependencies.
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().
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.
To write user data:
Call C3GPCompose::SetUserData(T3GPUdtaLocation, const TDesC8&) and set the aBuffer parameter to be a descriptor containing the user information to write and aLocation to be its location:
IMPORT_C TInt SetUserData(T3GPUdtaLocation aLocation, const TDesC8 &aBuffer);
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(...)); ... }
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.