Symbian3/PDK/Source/GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 5 f345bda72bc4
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     1
<?xml version="1.0" encoding="utf-8"?>
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     2
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     3
<!-- This component and the accompanying materials are made available under the terms of the License 
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     4
"Eclipse Public License v1.0" which accompanies this distribution, 
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     5
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     6
<!-- Initial Contributors:
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     7
    Nokia Corporation - initial contribution.
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     8
Contributors: 
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
     9
-->
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    10
<!DOCTYPE concept
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    11
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    12
<concept xml:lang="en" id="GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF"><title>Reading Video and Audio Content</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial describes how to read video and audio content. </p> <section><title>Purpose</title> <p>The purpose of this tutorial is to show you how to read video and audio content synchronously and asynchronously. </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>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 <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse</apiname></xref> class. </p> </section> <section><title>Using frames </title> <p>The following tasks are covered in this tutorial: </p> <ul><li id="GUID-F9080598-D27A-5B02-B61E-6992BF7BA50D"><p><xref href="GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita#GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF/GUID-F7226C7F-F8CB-5441-A3C1-DE0AE2EC1401"> Reading a video frame</xref>  </p> </li> <li id="GUID-2F2AD986-C87C-5919-B584-022A1A8C47FB"><p><xref href="GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF.dita#GUID-EFD05CAF-A8CF-5C2E-B7C9-51023D2438DF/GUID-F898BF2E-78C6-5012-BB02-A2FF740FA68F"> Reading audio frames</xref>  </p> </li> </ul> <p id="GUID-F7226C7F-F8CB-5441-A3C1-DE0AE2EC1401"><b>Reading a video frame</b> </p> <p>To read a video frame, call one of the overloads of <codeph>C3GPParse::ReadVideoFrame()</codeph>: </p> <ul><li id="GUID-187ADC8F-3FEA-5881-8E5D-A56C01AE0826"><p>To read the next video frame from a 3GP file or stream and return it synchronously, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::ReadVideoFrame(TDes8, TBool &amp;,
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    13
                  TUint &amp;s, TUint &amp;)</apiname></xref>: </p> <codeblock id="GUID-AF885775-FF45-518E-9A38-F8CB98CBBE02" xml:space="preserve">IMPORT_C TInt ReadVideoFrame(TDes8 &amp;aBuffer, TBool &amp;aKeyFrame, TUint &amp;aTimeStampInMs, TUint &amp;aTimeStampInTimescale) const;</codeblock> <p>The video frame that is read depends on the current position in the input 3GP file. You can use the <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Seek()</apiname></xref> function to change the current position in the 3GP file. </p> </li> <li id="GUID-87555A14-848C-526E-B694-BF0A46648C14"><p>To read the current video frame from an input file and return it asynchronously, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::ReadVideoFrame(M3GPParseCallback
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    14
                  &amp;, TDes8 &amp;)</apiname></xref>: </p> <codeblock id="GUID-10D857F1-3B4E-5446-A426-5F3B32726C8F" xml:space="preserve">IMPORT_C void ReadVideoFrame(M3GPParseCallback &amp;aCallback, TDes8 &amp;aBuffer);</codeblock> <p>Upon completion, successful or otherwise, the callback function <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>M3GPParseCallback::VideoFrameAvailable(TInt, TUints, TUint,
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    15
                  TUint)</apiname></xref> is called. </p> <p> <b>Note</b>: The asynchronous <codeph>C3GPParse::ReadVideoFrame()</codeph> function is not supported when the 3GP Parser is in buffer mode. </p> </li> </ul> <p> <b> Note:</b> There are separate cursors for storing current positions of video and audio streams. Calling <codeph>C3GPParse::ReadVideoFrame()</codeph> does not affect the position of the next audio stream. </p> <p id="GUID-F898BF2E-78C6-5012-BB02-A2FF740FA68F"><b> Reading audio frames</b> </p> <p>To read audio frames, call one of the overloads of <codeph>C3GPParse::ReadAudioFrames()</codeph>: </p> <ul><li id="GUID-2CFE3DC1-8DF3-5A9D-BA2D-EC3CB787D418"><p>To read the audio frames that are stored in the current audio sample from the 3GP file or stream and return them synchronously, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::ReadAudioFrames(TDes8 &amp;, TInt &amp;, TUint &amp;,
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    16
                  TUint &amp;)</apiname></xref>: </p> <codeblock id="GUID-002077C9-8163-5E18-89F8-57DFAD76CA35" xml:space="preserve">IMPORT_C TInt ReadAudioFrames(TDes8 &amp;aBuffer, TInt &amp;aReturnedFrames, TUint &amp;aTimeStampInMs, TUint &amp;aTimeStampInTimescale) const;</codeblock> <p>The next frame read depends on the current position in the input 3GP file. You can use the <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::Seek()</apiname></xref> function to change the current position in the 3GP file. </p> </li> <li id="GUID-D15613F3-3F0F-59CC-979C-C94CE0873228"><p>To read the audio frames that are stored in the current audio sample from the 3GP file or stream and return them asynchronously, call <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>C3GPParse::ReadAudioFrames(M3GPParseCallback &amp;, TDes8
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    17
                  &amp;)</apiname></xref>: </p> <codeblock id="GUID-5549A394-9FB3-5393-963F-F5A48DCE2E89" xml:space="preserve">IMPORT_C void ReadAudioFrames(M3GPParseCallback &amp;aCallback, TDes8 &amp;aBuffer);</codeblock> <p>Upon completion, successful or otherwise, the callback function <xref href="GUID-BF3A60C9-0F4C-3712-90E3-ACBD73BE4EB6.dita"><apiname>M3GPParseCallback::AudioFramesAvailable(TInt, TUint, TUint,
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    18
                  TUint)</apiname></xref> is called. </p> <p> <b>Note</b>: The asynchronous <codeph>C3GPParse::ReadAudioFrames()</codeph> function is not supported when the 3GP Parser is in buffer mode. </p> </li> </ul> <p> <b>Note</b>: There are separate cursors for storing current positions for video and audio streams. Calling <codeph>C3GPParse::ReadAudioFrames()</codeph> does not change the current position of the video stream. </p> </section> <section><title>Example</title> <p>The following example shows you how to read video and audio frames: </p> <codeblock id="GUID-167C4870-3062-54C2-A260-8F5BB9E755AB" xml:space="preserve">CMyApp::ReadFileL(const RFile&amp; aFile)
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    19
    {
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    20
    ...
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    21
    // See example code in Setting up a 3GP Parser and Getting Audio and Video Stream Metadata. 
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    22
    ...
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    23
    TInt err = KErrNone;
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    24
    while (err != KErrNotFound)
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    25
        {
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    26
        TInt err = parser-&gt;ReadVideoFrame(...);
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    27
        if (err == KErrNone)
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    28
            {
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    29
            // do something with the video data                        
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    30
            ...
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    31
            }                
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    32
        }
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    33
        
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    34
    err = KErrNone        
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    35
    while (err != KErrNotFound)
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    36
        {
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    37
        // retrieve audio frames
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    38
        TInt err = parser-&gt;ReadAudioFrames(...);
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    39
        if (err == KErrNone)
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    40
            {
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    41
            // do something with the audio data                        
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    42
            ...
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    43
            }                
578be2adaf3e Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
Dominic Pinkman <dominic.pinkman@nokia.com>
parents: 5
diff changeset
    44
5
f345bda72bc4 Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    45
        ...</codeblock> </section> <section><title>See Also</title> <p><xref href="GUID-4D4A2853-B573-5B16-B9E3-0E4853C90BCD.dita">Setting up a 3GP Parser</xref>  </p> <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> </section> </conbody></concept>