Initial contribution of the Adaptation Documentation.
<?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-42665F58-7E04-5375-A039-7BBDE218DDE4"><title>How to Pack and Unpack the AMR Encoded Data</title><prolog><metadata><keywords/></metadata></prolog><conbody><section><title>How to Pack the AMR Encoded Data</title> <p>The user gets the AMR encoded data in <codeph>aAmrData</codeph>. It then attaches the AMR payload header to it and returns the packed data in <codeph>aPackedData</codeph>. The following code describes the <xref href="GUID-2283C5F3-9237-38BE-933C-353ADF676B42.dita#GUID-2283C5F3-9237-38BE-933C-353ADF676B42/GUID-F885E957-C375-3CF9-82B7-2611B0974675"><apiname>CStreamFormatter::Pack()</apiname></xref> function. </p> <codeblock id="GUID-E98C7846-AB90-5006-AB4D-1ADEAEF90A09" xml:space="preserve">// Call the Pack function
TInt Pack(const TDesC8& aAmrData,RBuf8& aPackedData)</codeblock> <p>It is the responsibility of the user to free the memory allocated to <codeph>aPackedData</codeph> descriptor. The following return values are returned by the function, depending on the availability of memory: </p> <ul><li id="GUID-84B71A7C-FC07-576D-B1C9-9D68876CB4E4"><p> <codeph>KErrNone</codeph> if successful </p> </li> <li id="GUID-5D8040A2-AA4D-517A-9450-1C84E2E5D4C5"><p> <codeph>KErrArgument</codeph> if an argument is out of range </p> </li> <li id="GUID-5BFEA7D3-04C8-5660-A7B7-9DF61C0D9B46"><p> <codeph>KErrNoMemory</codeph> if there is insufficient memory. </p> </li> </ul> <p>The following code shows how to use the <xref href="GUID-2283C5F3-9237-38BE-933C-353ADF676B42.dita#GUID-2283C5F3-9237-38BE-933C-353ADF676B42/GUID-F885E957-C375-3CF9-82B7-2611B0974675"><apiname>CStreamFormatter::Pack()</apiname></xref> API: </p> <codeblock id="GUID-137F31C6-668E-51CF-BEAE-49031124B237" xml:space="preserve"> // Create an instance of AMR Payload Formatter by passing KAmrFormatterUid
CStreamFormatter * aStreamFormatter = CStreamFormatter::NewL(TUid::Uid(KAmrFormatterUid));
// Call the pack function
TInt8 ret = aStreamFormatter->Pack(pPacket,modifiableBuf);</codeblock> </section> <section><title>How to Unpack the AMR Encoded Data</title> <p>The user gets the AMR encoded data in <codeph>aAmrData</codeph>. It then detaches AMR payload header from it and returns the actual encoded AMR data in <codeph>aUnPackedData</codeph>. The following code describes the <xref href="GUID-2283C5F3-9237-38BE-933C-353ADF676B42.dita#GUID-2283C5F3-9237-38BE-933C-353ADF676B42/GUID-1707A5BB-3BEF-3753-A909-85A7770E9A62"><apiname>CStreamFormatter::Unpack</apiname></xref> function. </p> <codeblock id="GUID-82276CC5-51E6-5C0D-8BE3-2EC9FC55A922" xml:space="preserve">// Call the Unpack function
TInt Unpack(const TDesC8& aAmrData,RBuf8& aUnPackedData)</codeblock> <p>It is the responsibility of the user to free the memory allocated to <codeph>aUnPackedData</codeph> descriptor. The following return values are returned by the function, depending on the availability of memory: </p> <ul><li id="GUID-76D6F229-E14B-5F44-A937-2ABA1B3F4E81"><p> <codeph>KErrNone</codeph> if successful </p> </li> <li id="GUID-579C3311-6134-51A7-84F0-FB90501AB763"><p> <codeph>KErrArgument</codeph> if an argument is out of range </p> </li> <li id="GUID-6CE59EB6-418F-51BE-BBAE-555F903C701C"><p> <codeph>KErrNoMemory</codeph> if there is insufficient memory. </p> </li> </ul> <p>The following code shows how to use the <xref href="GUID-2283C5F3-9237-38BE-933C-353ADF676B42.dita#GUID-2283C5F3-9237-38BE-933C-353ADF676B42/GUID-B2F9AE75-87B9-3331-91DA-8FDA72E317F2"><apiname>CStreamFormatter::Unpack()</apiname></xref> API: </p> <codeblock id="GUID-0C3DB47C-92E8-533F-8D14-750523E75B55" xml:space="preserve">// Create an instance of AMR Payload Formatter by passing KAmrFormatterUid
CStreamFormatter * aStreamFormatter = CStreamFormatter::NewL(TUid::Uid(KAmrFormatterUid));
//Call the Unpack function
TInt8 ret = aStreamFormatter->UnPack(pPacket,modifiableBuf);</codeblock> </section> </conbody></concept>