|
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: PayloadFormat plugin capable to read RTP payload containing |
|
15 * Amr audio. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "amrpayloaddecoderoa.h" |
|
24 #include "amrcommonutil.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CAmrPayloadDecoderOA::CAmrPayloadDecoderOA |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CAmrPayloadDecoderOA::CAmrPayloadDecoderOA( TBool aIsNb ) : CAmrPayloadDecoder( aIsNb ) |
|
33 { |
|
34 DP_AMR_DECODE( "CAmrPayloadDecoderOA::CAmrPayloadDecoderOA" ); |
|
35 } |
|
36 |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CAmrPayloadDecoderOA::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void CAmrPayloadDecoderOA::ConstructL( ) |
|
44 { |
|
45 DP_AMR_DECODE( "CAmrPayloadDecoderOA::ConstructL" ); |
|
46 |
|
47 // Allocate memory for iHeaderDecoder and iTocEntryDecoder and |
|
48 // set them to NULL to avoid codescanner errors |
|
49 delete iHeaderDecoder; |
|
50 iHeaderDecoder = NULL; |
|
51 delete iTocEntryDecoder; |
|
52 iTocEntryDecoder = NULL; |
|
53 |
|
54 iHeaderDecoder = CAmrPayloadHeaderOA::NewL(); |
|
55 iTocEntryDecoder = CAmrTocEntryOA::NewL(); |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CAmrPayloadDecoderOA::NewL |
|
61 // Two-phased constructor. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CAmrPayloadDecoderOA* CAmrPayloadDecoderOA::NewL( TBool aIsNb ) |
|
65 { |
|
66 DP_AMR_DECODE( "CAmrPayloadDecoderOA::NewL" ); |
|
67 |
|
68 CAmrPayloadDecoderOA* self = new( ELeave ) CAmrPayloadDecoderOA( aIsNb ); |
|
69 |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL( ); |
|
72 CleanupStack::Pop( self ); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CAmrPayloadDecoderOA::~CAmrPayloadDecoderOA |
|
80 // Destructor |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CAmrPayloadDecoderOA::~CAmrPayloadDecoderOA() |
|
84 { |
|
85 DP_AMR_DECODE( "CAmrPayloadDecoderOA::~CAmrPayloadDecoderOA" ); |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAmrPayloadDecoderOA::DecodePayload |
|
91 // Decode payload data received in the payload buffer. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CAmrPayloadDecoderOA::DecodePayload( TUint32& aTimeStamp, |
|
95 TUint32 aTimeStampInc ) |
|
96 { |
|
97 DP_AMR_DECODE( "CAmrPayloadDecoderOA::DecodePayloadL" ); |
|
98 |
|
99 iTimeStamp = aTimeStamp; |
|
100 iTimeStampInc = aTimeStampInc; |
|
101 CAmrPayloadDecoder::Decode( iPayload, iPayloadSize ); |
|
102 aTimeStamp = iTimeStamp; |
|
103 iFrameIndex = 0; |
|
104 return iDecodedFrames; |
|
105 } |
|
106 |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CAmrPayloadDecoderOA::CalculateFramePosition |
|
110 // C++ default constructor can NOT contain any code, that |
|
111 // might leave. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CAmrPayloadDecoderOA::CalculateFramePosition( const TUint8* aBuffer, |
|
115 TInt aFrameCount ) |
|
116 { |
|
117 DP_AMR_DECODE( "CAmrPayloadDecoderOA::CalculateFramePosition" ); |
|
118 |
|
119 TUint bitCount; |
|
120 |
|
121 // Number of bytes for CMR and TOC entries |
|
122 TUint frameByteIndex = ( 1 + TUint( aFrameCount ) ); |
|
123 if ( aFrameCount > KMaxFrameCountPerPacket ) |
|
124 { |
|
125 DP_AMR_DECODE3("CAmrPayloadDecoderOA::CalculateFramePosition, aFrameCount: %d > KMaxFrameCountPerPacket: %d", \ |
|
126 aFrameCount, KMaxFrameCountPerPacket); |
|
127 } |
|
128 for ( TInt i = 0; i < aFrameCount; i++ ) |
|
129 { |
|
130 |
|
131 if ( EAmrFrameNoData == iFrames[i].iFrameType ) |
|
132 { |
|
133 iFrames[i].iBitIndex = 0; |
|
134 iFrames[i].iFrameData = NULL; |
|
135 } |
|
136 else |
|
137 { |
|
138 // Set frame byte and bit positions |
|
139 iFrames[i].iBitIndex = 0; |
|
140 iFrames[i].iFrameData = const_cast<TUint8*>( aBuffer ) + frameByteIndex; |
|
141 } |
|
142 |
|
143 bitCount = TUint( SpeechBitCount( iFrames[i].iFrameType ) ); |
|
144 frameByteIndex += bitCount >> KNumValue3; |
|
145 if ( bitCount & KBitIndex7 ) |
|
146 { |
|
147 frameByteIndex++; |
|
148 } |
|
149 } |
|
150 } |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |