Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-32B58425-81AC-59D6-A17F-21BD06ACB658"><title>Adding Data to a 3GP Composer</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial describes how to add data to a 3GP Composer. </p> <section><title>Purpose</title> <p>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. </p> <p><b>Required background</b> </p> <p>The <xref href="GUID-EF71F4BF-2206-5489-BDB9-2F85ED74D6E2.dita">3GP Library Overview</xref> introduces the 3GP Composer. </p> <p><b>Introduction</b> </p> <p>You can add the following types of data: </p> <ul><li id="GUID-3059E95A-C3EC-57BD-99AA-208C8A0B9F92"><p>Video frames </p> </li> <li id="GUID-07861919-D240-557E-A2D5-3A9EB7D9C34D"><p>Audio frames </p> </li> <li id="GUID-16B526C9-33A4-5C88-8033-B6EF32B01860"><p>User data, such as copyright information. </p> </li> </ul> <p> <b>Note</b>: After adding your data, you must call <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>C3GPCompose::Complete()</apiname></xref> to commit the data to the output file. The data is only available in the output file after calling <codeph>C3GPCompose::Complete()</codeph>. For more information, see <xref href="GUID-460089B6-CA35-5DB7-ABC0-A688D6EE77D5.dita">Completing Composition</xref>. </p> </section> <section><title>Using data </title> <p>The following tasks are covered in this tutorial: </p> <ul><li id="GUID-16DFD633-CD78-5465-BD83-CA46E69B57D5"><p><xref href="GUID-32B58425-81AC-59D6-A17F-21BD06ACB658.dita#GUID-32B58425-81AC-59D6-A17F-21BD06ACB658/GUID-979C71F5-D8E8-5FDC-B58C-9F2A697F12C2">Writing a video frame</xref> </p> </li> <li id="GUID-28E304B4-8675-538D-BD74-7AB7B4793DC4"><p><xref href="GUID-32B58425-81AC-59D6-A17F-21BD06ACB658.dita#GUID-32B58425-81AC-59D6-A17F-21BD06ACB658/GUID-D56D13C1-434B-5A63-9065-8204DB740377"> Writing audio frames</xref> </p> </li> <li id="GUID-A3E5A817-4AC5-585B-A16E-EF5B5B721337"><p><xref href="GUID-32B58425-81AC-59D6-A17F-21BD06ACB658.dita#GUID-32B58425-81AC-59D6-A17F-21BD06ACB658/GUID-F6DA9C45-AF6B-5B05-8DAA-971B20CCB334">Writing user data</xref> </p> </li> </ul> <p id="GUID-979C71F5-D8E8-5FDC-B58C-9F2A697F12C2"><b>Writing a video frame</b> </p> <p>To write a video frame to the output file, call one of the overloads of <codeph>C3GPCompose::WriteVideoFrame()</codeph>: </p> <ul><li id="GUID-D2ED3CB0-9EBE-515E-8C73-56484CBA5C8D"><p>To use the default frame dependency information, call <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>C3GPCompose::WriteVideoFrame(const TDesC8 &, TUint,
TBool)</apiname></xref>: </p> <codeblock id="GUID-E55E89F7-F03C-5691-BB9A-71A64CC43F2D" xml:space="preserve">IMPORT_C TInt WriteVideoFrame(const TDesC8 &aBuffer, TUint aDuration, TBool aKeyFrame);</codeblock> <p>The default values for frame dependency information are <codeph>E3GPDependencyUnknown</codeph> and <codeph>E3GPRedundancyUnknown</codeph>. For more information, see <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>T3GPFrameDependencies</apiname></xref>. </p> </li> <li id="GUID-F68C592F-3786-529F-8211-74CA1CE70044"><p>To specify your own frame dependency information, call <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>C3GPCompose::WriteVideoFrame(const TDesC8&, TUint,
TBool)</apiname></xref>: </p> <codeblock id="GUID-6F86A2AE-E15D-5766-BF21-79C445356262" xml:space="preserve">IMPORT_C TInt WriteVideoFrame(const TDesC8 &aBuffer, TUint aDuration, TBool aKeyFrame, const T3GPFrameDependencies &aDependencies);</codeblock> <p>Frame dependency information lets you define dependencies between video frames. For more information, see <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>T3GPFrameDependencies</apiname></xref>. </p> </li> </ul> <p> <b>Note</b>: 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 <codeph>C3GPCompose::WriteVideoFrame()</codeph>. </p> <p id="GUID-D56D13C1-434B-5A63-9065-8204DB740377"><b>Writing audio frames</b> </p> <p>To write audio frames to the output file: </p> <ul><li id="GUID-515C36D7-9F04-547A-BB75-C6BA8FD905D9"><p>Call <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>C3GPCompose::WriteAudioFrames(const TDesC8 &,
TUint)</apiname></xref>: </p> <codeblock id="GUID-C45C503B-FE1F-5DDB-A9D7-40DD1CE49EF1" xml:space="preserve">IMPORT_C TInt WriteAudioFrames(const TDesC8 &aBuffer, TUint aDuration);</codeblock> <p> <b>Note</b>: Depending on the audio type, you can use <codeph>C3GPCompose::WriteAudioFrames()</codeph> to write either one or a number of audio frames: </p> <ul><li id="GUID-4A922734-3A1B-54DB-B527-AE19E3F61478"><p>For MPEG-4 audio, <codeph>C3GPCompose::WriteAudioFrames()</codeph> writes one MPEG audio frame to the output file. </p> </li> <li id="GUID-E1AF1B94-B0CC-5B8D-AD67-5DD0335E296E"><p>For other audio types, <codeph>C3GPCompose::WriteAudioFrames()</codeph> writes a number of audio frames to the output file. The number of audio frames is specified in the <codeph>aAudio</codeph> input parameter when you call <codeph>C3GPCompose::Open()</codeph>. For more information, see <xref href="GUID-28DF11D8-F895-5D4B-8C6D-AEAB3172F3B6.dita">Setting up a 3GP Composer</xref>. </p> </li> </ul> </li> </ul> <p id="GUID-F6DA9C45-AF6B-5B05-8DAA-971B20CCB334"><b>Writing user data</b> </p> <p>To write user data: </p> <ul><li id="GUID-DF9FA409-5290-5788-8957-AAAC32059FE0"><p>Call <xref href="GUID-C463561F-4BDA-3CBE-9588-AFDB5FD889A2.dita"><apiname>C3GPCompose::SetUserData(T3GPUdtaLocation, const
TDesC8&)</apiname></xref> and set the <codeph>aBuffer</codeph> parameter to be a descriptor containing the user information to write and <codeph>aLocation</codeph> to be its location: </p> <codeblock id="GUID-AF0EE6E0-11C6-5EB3-BEC1-81400A31FB76" xml:space="preserve">IMPORT_C TInt SetUserData(T3GPUdtaLocation aLocation, const TDesC8 &aBuffer);</codeblock> </li> </ul> </section> <section><title>Example</title> <p>The following example shows you how to add video, audio and user data to a 3GP Composer: </p> <codeblock id="GUID-13E9F9EF-8B1C-559E-B19B-49F125203413" xml:space="preserve">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(...));
...
}</codeblock> </section> <section><title>See also</title> <p><xref href="GUID-28DF11D8-F895-5D4B-8C6D-AEAB3172F3B6.dita">Setting up a 3GP Composer</xref> </p> <p><xref href="GUID-460089B6-CA35-5DB7-ABC0-A688D6EE77D5.dita">Completing Composition</xref> </p> </section> </conbody></concept>