|
1 /* |
|
2 * Copyright (c) 2005 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 "mceg729codec.h" |
|
22 #include "mcecomg729codec.h" |
|
23 |
|
24 #ifdef MCE_COMMON_SERVER_SIDE |
|
25 |
|
26 #include <mmcccodecinformation.h> |
|
27 |
|
28 #endif//MCE_COMMON_SERVER_SIDE |
|
29 |
|
30 // Frame Size |
|
31 const TUint KMceG72FrameSize = 10; |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMceComG729Codec::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMceComG729Codec* CMceComG729Codec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
40 { |
|
41 CMceComG729Codec* self = NewLC( aSdpName ); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMceComG729Codec::NewLC |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CMceComG729Codec* CMceComG729Codec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
51 { |
|
52 CMceComG729Codec* self = new (ELeave) CMceComG729Codec(); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( aSdpName ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMceComG729Codec::~CMceComG729Codec |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CMceComG729Codec::~CMceComG729Codec() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMceComG729Codec::CMceComG729Codec |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CMceComG729Codec::CMceComG729Codec() |
|
73 : CMceComAudioCodec() |
|
74 { |
|
75 iFourCC = 0; |
|
76 iEnableVAD = EFalse; |
|
77 iSamplingFreq = KMceG729SamplingFreq; |
|
78 iPTime = KMceG729DefaultPtime; |
|
79 iMaxPTime = KMceG729DefaultMaxPtime; |
|
80 iBitrate = KMceG729Bitrate; |
|
81 iAllowedBitrates = KMceAllowedG729Bitrate8K; |
|
82 iPayloadType = KMceDefaultG729PayloadType; |
|
83 iCodecMode = KG729CodecMode; |
|
84 iFrameSize = KMceG72FrameSize; |
|
85 } |
|
86 |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CMceComG729Codec::CloneL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CMceComAudioCodec* CMceComG729Codec::CloneL() |
|
93 { |
|
94 CMceComG729Codec* copy = new (ELeave) CMceComG729Codec(); |
|
95 CleanupStack::PushL( copy ); |
|
96 |
|
97 copy->ConstructL( *this ); |
|
98 CleanupStack::Pop( copy ); |
|
99 return copy; |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CMceComG729Codec::ConstructL |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CMceComG729Codec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
108 { |
|
109 CMceComAudioCodec::ConstructL( aSdpName ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceComG729Codec::ConstructL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMceComG729Codec::ConstructL( CMceComG729Codec& aCodec ) |
|
118 { |
|
119 CMceComAudioCodec::ConstructL( aCodec ); |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMceComG729Codec::SetBitrate |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CMceComG729Codec::SetBitrate( TUint aBitrate ) |
|
128 { |
|
129 TBool isValid = ETrue; |
|
130 |
|
131 switch ( aBitrate ) |
|
132 { |
|
133 case KMceG729Bitrate: |
|
134 { |
|
135 if ( aBitrate > GetMaxBitRate() ) |
|
136 { |
|
137 isValid = EFalse; |
|
138 } |
|
139 break; |
|
140 } |
|
141 default: |
|
142 isValid = EFalse; |
|
143 break; |
|
144 } |
|
145 |
|
146 if ( isValid ) |
|
147 { |
|
148 return CMceComCodec::SetBitrate( aBitrate ); |
|
149 } |
|
150 else |
|
151 { |
|
152 return KErrNotSupported; |
|
153 } |
|
154 |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMceComG729Codec::SetAllowedBitrates |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CMceComG729Codec::SetAllowedBitrates( TUint aBitrates ) |
|
163 { |
|
164 TInt error = KErrNone; |
|
165 |
|
166 //Confirm that the bitrate mask is valid |
|
167 //I.e. after all the valid bitrates are set to zero the value should be zero |
|
168 if ( !aBitrates || |
|
169 ( aBitrates >> 8 ) > 0 ) |
|
170 { |
|
171 error = KErrArgument; |
|
172 } |
|
173 else |
|
174 { |
|
175 CMceComCodec::SetAllowedBitrates( KMceAllowedG729BitrateAllowAll ); |
|
176 iAllowedBitrates &= aBitrates; |
|
177 TUint maxBitrate = GetMaxBitRate(); |
|
178 if ( iBitrate > maxBitrate ) |
|
179 { |
|
180 error = CMceComCodec::SetBitrate( maxBitrate ); |
|
181 } |
|
182 } |
|
183 |
|
184 return error; |
|
185 |
|
186 } |
|
187 |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CMceComG729Codec::SetCodecMode |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CMceComG729Codec::SetCodecMode( TUint aCodecMode ) |
|
194 { |
|
195 if ( KG729CodecMode == aCodecMode ) |
|
196 { |
|
197 iCodecMode = aCodecMode; |
|
198 return KErrNone; |
|
199 } |
|
200 else |
|
201 { |
|
202 return KErrNotSupported; |
|
203 } |
|
204 } |
|
205 |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CMceComG729Codec::GetMaxBitRate |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TUint CMceComG729Codec::GetMaxBitRate() |
|
212 { |
|
213 if( iAllowedBitrates & KMceAllowedG729Bitrate8K ) |
|
214 { |
|
215 return KMceG729Bitrate; |
|
216 } |
|
217 else |
|
218 { |
|
219 return 0; |
|
220 } |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CMceComG729Codec::SetPTime |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CMceComG729Codec::SetPTime( TUint aPTime ) |
|
228 { |
|
229 if ( ( aPTime % KMceG72FrameSize ) == 0 ) |
|
230 { |
|
231 return CMceComAudioCodec::SetPTime( aPTime ); |
|
232 } |
|
233 else |
|
234 { |
|
235 return KErrNotSupported; |
|
236 } |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CMceComG729Codec::SetMaxPTime |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TInt CMceComG729Codec::SetMaxPTime( TUint aMaxPTime ) |
|
245 { |
|
246 if ( ( aMaxPTime % KMceG72FrameSize ) == 0 ) |
|
247 { |
|
248 return CMceComAudioCodec::SetMaxPTime( aMaxPTime ); |
|
249 } |
|
250 else |
|
251 { |
|
252 return KErrNotSupported; |
|
253 } |
|
254 } |
|
255 |
|
256 // End of File |