|
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 * Amr audio. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "amrpayloadheaderoa.h" |
|
24 #include "streamformatter.h" |
|
25 #include "amrcommonutil.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================= |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CAmrPayloadHeader::CAmrPayloadHeader |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CAmrPayloadHeaderOA::CAmrPayloadHeaderOA() : CAmrPayloadHeader() |
|
39 { |
|
40 DP_AMR_ENCODE( "CAmrPayloadHeaderOA::CAmrPayloadHeaderOA" ); |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CAmrPayloadHeaderOA::NewL |
|
46 // Two-phased constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CAmrPayloadHeaderOA* CAmrPayloadHeaderOA::NewL() |
|
50 { |
|
51 DP_AMR_ENCODE( "CAmrPayloadHeaderOA::NewL" ); |
|
52 |
|
53 CAmrPayloadHeaderOA* self = new( ELeave ) CAmrPayloadHeaderOA( ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // Destructor |
|
60 CAmrPayloadHeaderOA::~CAmrPayloadHeaderOA() |
|
61 { |
|
62 DP_AMR_ENCODE( "CAmrPayloadHeaderOA::~CAmrPayloadHeaderOA" ); |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CAmrPayloadHeaderOA::Encode |
|
68 // Encode the payload header fields into a given buffer at the given position. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CAmrPayloadHeaderOA::Encode( TUint8* aBuffer, |
|
72 TInt& aByteIndex, TInt& aBitIndex ) |
|
73 { |
|
74 DP_AMR_ENCODE( "CAmrPayloadHeaderOA::Encode" ); |
|
75 |
|
76 //In octet-aligned mode, the payload header consists of a 4 bit CMR, 4 |
|
77 //reserved bits, and optionally, an 8 bit interleaving header, as shown |
|
78 //below: |
|
79 // 0 1 |
|
80 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
|
81 // +-+-+-+-+-+-+-+-+- - - - - - - - |
|
82 // | CMR |R|R|R|R| ILL | ILP | |
|
83 // +-+-+-+-+-+-+-+-+- - - - - - - - |
|
84 // ILL and ILP are optional, PoC is not supporting these two fields. |
|
85 |
|
86 // Call base-class Encoder function |
|
87 CAmrPayloadHeader::Encode( aBuffer, aByteIndex, aBitIndex ); |
|
88 |
|
89 TStreamEncoder encoder; |
|
90 encoder.Initialize( aBuffer, aByteIndex, aBitIndex ); |
|
91 encoder.Encode( 0, KNumValue4 ); // 4 Reserved bits |
|
92 |
|
93 // Update Byte and Bit positions |
|
94 aByteIndex = encoder.ByteIndex( ); |
|
95 aBitIndex = encoder.BitIndex( ); |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CAmrPayloadHeaderOA::Decode |
|
101 // Decode the payload header from a given buffer at the given position. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CAmrPayloadHeaderOA::Decode( const TUint8* aBuffer, |
|
105 TInt& aByteIndex, TInt& aBitIndex ) |
|
106 { |
|
107 DP_AMR_ENCODE( "CAmrPayloadHeaderOA::Decode" ); |
|
108 |
|
109 // Call base-class Decoder function |
|
110 CAmrPayloadHeader::Decode( aBuffer, aByteIndex, aBitIndex ); |
|
111 |
|
112 TStreamDecoder decoder; |
|
113 decoder.Initialize( aBuffer, aByteIndex, aBitIndex ); |
|
114 decoder.Decode( KNumValue4 ); // skip 4 Reserved bits |
|
115 |
|
116 // Update Byte and Bit positions |
|
117 aByteIndex = decoder.ByteIndex( ); |
|
118 aBitIndex = decoder.BitIndex( ); |
|
119 } |