|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "amrtocentryoa.h" |
|
23 #include "amrpayloadformatter.h" |
|
24 #include "streamformatter.h" |
|
25 #include "amrcommonutil.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CAmrTocEntryOA::CAmrTocEntryOA |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CAmrTocEntryOA::CAmrTocEntryOA() : CAmrTocEntry() |
|
37 { |
|
38 DP_AMR_ENCODE( "CAmrTocEntryOA::CAmrTocEntryOA" ); |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CAmrTocEntryOA::NewL |
|
44 // Two-phased constructor. |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CAmrTocEntryOA* CAmrTocEntryOA::NewL() |
|
48 { |
|
49 DP_AMR_ENCODE( "CAmrTocEntryOA::NewL" ); |
|
50 |
|
51 CAmrTocEntryOA* self = new( ELeave ) CAmrTocEntryOA( ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // Destructor |
|
57 CAmrTocEntryOA::~CAmrTocEntryOA() |
|
58 { |
|
59 DP_AMR_ENCODE( "CAmrTocEntryOA::~CAmrTocEntryOA" ); |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CAmrTocEntryOA::Encode |
|
65 // Encode the `table of contents' ( TOC ) entry fields into a given buffer. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CAmrTocEntryOA::Encode( TUint8* aBuffer, |
|
69 TInt& aByteIndex, TInt& aBitIndex ) |
|
70 { |
|
71 DP_AMR_ENCODE( "CAmrTocEntryOA::Encode" ); |
|
72 |
|
73 //A ToC entry takes the following format in octet-aligned mode: |
|
74 // 0 1 2 3 4 5 6 7 |
|
75 // +-+-+-+-+-+-+-+-+ |
|
76 // |F| FT |Q|P|P| |
|
77 // +-+-+-+-+-+-+-+-+ |
|
78 // P bits: padding bits, MUST be set to zero. |
|
79 |
|
80 // Call base-clase Encode function |
|
81 CAmrTocEntry::Encode( aBuffer, aByteIndex, aBitIndex ); |
|
82 |
|
83 TStreamEncoder encoder; |
|
84 encoder.Initialize( aBuffer, aByteIndex, aBitIndex ); |
|
85 encoder.Encode( 0, KNumValue2 ); // 2 Padding bits, must be ZERO |
|
86 |
|
87 // Update Byte and Bit positions |
|
88 aByteIndex = encoder.ByteIndex( ); |
|
89 aBitIndex = encoder.BitIndex( ); |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CAmrTocEntryOA::Decode |
|
95 // Decode the `table of contents' ( TOC ) entry fields from a given buffer. |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CAmrTocEntryOA::Decode( const TUint8* aBuffer, |
|
99 TInt& aByteIndex, TInt& aBitIndex ) |
|
100 { |
|
101 DP_AMR_ENCODE( "CAmrTocEntryOA::Decode" ); |
|
102 |
|
103 // Call base-class Decode function |
|
104 CAmrTocEntry::Decode( aBuffer, aByteIndex, aBitIndex ); |
|
105 |
|
106 TStreamDecoder decoder; |
|
107 decoder.Initialize( aBuffer, aByteIndex, aBitIndex ); |
|
108 decoder.Decode( KNumValue2 ); // Skip 2 Padding bits |
|
109 |
|
110 // Update Byte and Bit positions |
|
111 aByteIndex = decoder.ByteIndex( ); |
|
112 aBitIndex = decoder.BitIndex( ); |
|
113 } |
|
114 |