Symbian3/PDK/Source/GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Wed, 16 Jun 2010 10:24:13 +0100
changeset 10 d4524d6a4472
parent 5 f345bda72bc4
child 14 578be2adaf3e
permissions -rw-r--r--
removal of PIPS 'antiword' example pending a decision on its license

<?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-4D4A2853-B573-5B16-B9E3-0E4853C90BCD"><title>Setting up a 3GP Parser</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial describes how to set up a 3GP Parser. </p> <section><title>Purpose</title> <p>The purpose of this tutorial is to show you how to set up a 3GP Parser to read a 3GP, 3G2 or MP4 file. </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 Parser. </p> <p><b>Introduction</b> </p> <p>The <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse</apiname></xref> class provides the setup functions for the 3GP Parser. </p> </section> <section><title>Using a 3GP Parser </title> <p>The following tasks are covered in this tutorial: </p> <ol id="GUID-D227E117-629E-518D-BFB5-4B0B70C37D83"><li id="GUID-EC4CDA5A-7D48-5A74-81C8-686AF59503AF"><p><xref href="GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD.dita#GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD/GUID-C974E036-C0B7-5647-B3B5-37308CCF13E9">Creating an instance of a 3GP Parser</xref>  </p> </li> <li id="GUID-A6D3622A-9278-5E05-ACB4-9774723FAD98"><p><xref href="GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD.dita#GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD/GUID-A38F0C28-0032-5F14-9974-4F009E5E1D66"> Initialising a 3GP Parser for reading 3GP, 3G2 or MP4 data</xref>. </p> </li> </ol> <p id="GUID-C974E036-C0B7-5647-B3B5-37308CCF13E9"><b>Creating an instance of a 3GP Parser</b> </p> <p>Create an instance of a 3GP Parser by calling one of the overloads of <codeph>C3GPParse::NewL()</codeph>: </p> <ul><li id="GUID-0BE2F217-9B24-5706-94E7-D5AF8B802A69"><p>To use the default read buffer size, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::NewL()</apiname></xref>: </p> <codeblock id="GUID-9367A0B1-F823-558B-8E0F-57A6D7658309" xml:space="preserve">static IMPORT_C C3GPParse *NewL();</codeblock> <p>The default value for the read buffer size is 8KB. </p> </li> <li id="GUID-37F2A90D-9475-509D-8520-ADB4D8CFF64B"><p>To set the read buffer size, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::NewL(TInt)</apiname></xref> and set <codeph>aReadBufferSize</codeph> to be the required buffer size: </p> <codeblock id="GUID-4BABCEEF-D578-5293-80AF-53884E624418" xml:space="preserve">static IMPORT_C C3GPParse *NewL(TInt aReadBufferSize);</codeblock> </li> </ul> <p id="GUID-A38F0C28-0032-5F14-9974-4F009E5E1D66"><b>Initialising a 3GP Parser for reading 3GP, 3G2 or MP4 data</b> </p> <p>Initialise the 3GP Parser for reading data by calling one of the overloads of <codeph>C3GPParse::Open()</codeph>: </p> <ul><li id="GUID-1B661055-7400-5BB8-AA88-9A9271F74C7E"><p>To initialise the 3GP Parser for reading data from a buffer, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Open()</apiname></xref>: </p> <codeblock id="GUID-56EE6BA2-F576-5C06-BCF5-B8E6DC89781E" xml:space="preserve">IMPORT_C TInt Open();</codeblock> </li> <li id="GUID-C45DCCCC-54D5-512D-9A49-88ABC3AEF565"><p>To initialise the 3GP Parser for reading data from a file, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Open(const TDesC &amp;)</apiname></xref> and set <codeph>aFilename</codeph> to be the full path name of the file: </p> <codeblock id="GUID-453DD876-E654-58B9-86B3-08644D523E85" xml:space="preserve">IMPORT_C TInt Open(const TDesC &amp;aFilename);</codeblock> </li> <li id="GUID-2FFF08F9-D664-54C5-9397-7610D6533475"><p>To initialise the 3GP Parser for reading data from a file, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Open(const RFile &amp;)</apiname></xref> and set <codeph>aFile</codeph> to be the file handle of the file: </p> <codeblock id="GUID-80DD9752-49ED-5094-9BE8-3E2A0BD448F7" xml:space="preserve">IMPORT_C TInt Open(const RFile &amp;aFile);</codeblock> </li> <li id="GUID-98D947B0-F673-5502-AF9C-1E1C38C0D300"><p>To initialise the 3GP Parser for reading data from a CAF object, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Open(const ContentAccess::CData &amp;)</apiname></xref> and set <codeph>aData</codeph> to be <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>CData</apiname></xref> object pointing to a CAF object: </p> <codeblock id="GUID-7774C612-6ACB-5152-8B72-0DCFE7057F78" xml:space="preserve">IMPORT_C TInt Open(const ContentAccess::CData &amp;aData);</codeblock> </li> </ul> </section> <section><title>Example</title> <p>The following example shows you how to set up a 3GP Parser to read a 3GP, 3G2 or MP4 file through an opened <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>RFile</apiname></xref> handle. </p> <codeblock id="GUID-31864237-C01E-5686-A6FF-788F2BEF19A9" xml:space="preserve">CMyApp::ReadFileL(const RFile&amp; aFile)
    {
    ...
    C3GPParse* parser = C3GPParse::NewL();
    CleanupStack::PushL(parser);
    User::LeaveIfError(parser-&gt;Open(aFile));
    CleanupStack::Pop(parser);
    ...
    }  </codeblock> <p>You can use either a file handle or a file path to specify the input file in <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Open()</apiname></xref>. In the event that the input file is encrypted, a <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>CData</apiname></xref> object should be supplied instead, for example: </p> <codeblock id="GUID-06F6E398-7AFB-51C7-8EF1-534649BFA2E3" xml:space="preserve">CMyApp::ReadFileL(const RFile&amp; aFile)
    {
    ...
    C3GPParse* parser = C3GPParse::NewL();
    CleanupStack::PushL(parser);

    CData* data = CData::NewLC(aFile, ...);
    User::LeaveIfError(parser-&gt;Open(*data));

    CleanupStack::Pop(2);    // parser, data
    ...
    }</codeblock> </section> <section><title>See also</title> <p><xref href="GUID-12C74671-1988-55E7-8320-FE77024A523C.dita"> Supplying Data to a 3GP Parser</xref>  </p> <p><xref href="GUID-CC4BA8E7-BCAB-58F7-AC5D-BA75A82D04AE.dita">Getting Audio and Video Stream Metadata</xref>  </p> <p><xref href="GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita">Reading Video and Audio Content</xref>  </p> </section> </conbody></concept>