|
1 /* |
|
2 * Copyright (c) 2005-2009 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 "t_cg711decoderintfcdata.h" |
|
22 |
|
23 /*@{*/ |
|
24 //Enumeration Literals |
|
25 _LIT(KEDecALaw, "EDecALaw"); |
|
26 _LIT(KEDecULaw, "EDecULaw" ); |
|
27 /*@}*/ |
|
28 |
|
29 /*@{*/ |
|
30 //Command literals |
|
31 _LIT(KCmdNewL, "NewL"); |
|
32 _LIT(KCmdDestructor, "~"); |
|
33 _LIT(KCmdSetDecoderMode, "SetDecoderMode"); |
|
34 _LIT(KCmdSetCng, "KCmdSetCng"); |
|
35 /*@}*/ |
|
36 |
|
37 /*@{*/ |
|
38 //INI Section name literals |
|
39 _LIT(KDecoder, "Decoder"); |
|
40 _LIT(KCng, "CNG"); |
|
41 /*@}*/ |
|
42 |
|
43 const CDataWrapperBase::TEnumEntryTable iEnumDecoders[] = |
|
44 { |
|
45 { KEDecALaw, 0/*EDecALaw */}, |
|
46 { KEDecULaw, 1/*EDecULaw*/ } |
|
47 }; |
|
48 |
|
49 |
|
50 /** |
|
51 * Private constructor. First phase construction |
|
52 */ |
|
53 CT_CG711DecoderIntfcData::CT_CG711DecoderIntfcData() |
|
54 : |
|
55 iG711Decoder(NULL), |
|
56 iCng(EFalse) |
|
57 { |
|
58 } |
|
59 |
|
60 /** |
|
61 * Second phase construction |
|
62 * |
|
63 * @internalComponent |
|
64 * @return N/A |
|
65 * @pre None |
|
66 * @post None |
|
67 * @leave system wide error |
|
68 */ |
|
69 //void CT_CG711DecoderIntfcData::ConstructL() |
|
70 // { |
|
71 // |
|
72 // } |
|
73 |
|
74 /** |
|
75 * Two phase constructor |
|
76 * |
|
77 * @leave system wide error |
|
78 */ |
|
79 CT_CG711DecoderIntfcData* CT_CG711DecoderIntfcData::NewL() |
|
80 { |
|
81 CT_CG711DecoderIntfcData* self = new (ELeave)CT_CG711DecoderIntfcData(); |
|
82 return self; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Return a pointer to the object that the data wraps |
|
87 * |
|
88 * @return pointer to the object that the data wraps |
|
89 */ |
|
90 TAny* CT_CG711DecoderIntfcData::GetObject() |
|
91 { |
|
92 return iG711Decoder; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Public destructor |
|
97 */ |
|
98 CT_CG711DecoderIntfcData::~CT_CG711DecoderIntfcData() |
|
99 { |
|
100 DestroyData(); |
|
101 } |
|
102 |
|
103 /** |
|
104 * Helper method for DoCmdDestructor |
|
105 */ |
|
106 void CT_CG711DecoderIntfcData::DestroyData() |
|
107 { |
|
108 if (iG711Decoder != NULL) |
|
109 { |
|
110 delete iG711Decoder; |
|
111 iG711Decoder = NULL; |
|
112 } |
|
113 } |
|
114 |
|
115 /** |
|
116 * Process a command read from the Ini file |
|
117 * @param aCommand - The command to process |
|
118 * @param aSection - The section get from the *.ini file of the project T_Wlan |
|
119 * @param aAsyncErrorIndex - Command index dor async calls to returns errors to |
|
120 * @return TBool - ETrue if the command is process |
|
121 * @leave - system wide error |
|
122 */ |
|
123 TBool CT_CG711DecoderIntfcData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
124 { |
|
125 TBool ret = ETrue; |
|
126 |
|
127 if (aCommand == KCmdNewL) |
|
128 { |
|
129 DoCmdNewL(); |
|
130 } |
|
131 else if (aCommand == KCmdDestructor) |
|
132 { |
|
133 DoCmdDestructor(); |
|
134 } |
|
135 else if (aCommand == KCmdSetDecoderMode) |
|
136 { |
|
137 DoCmdSetDecoderMode(aSection); |
|
138 } |
|
139 else if (aCommand == KCmdSetCng) |
|
140 { |
|
141 DoCmdSetCng(aSection); |
|
142 } |
|
143 else |
|
144 { |
|
145 ERR_PRINTF1(_L("Unknown command.")); |
|
146 ret=EFalse; |
|
147 } |
|
148 |
|
149 return ret; |
|
150 } |
|
151 |
|
152 /** |
|
153 * Create an Instance of CG711DecoderIntfc |
|
154 * @param none |
|
155 * @return none |
|
156 */ |
|
157 void CT_CG711DecoderIntfcData::DoCmdNewL() |
|
158 { |
|
159 INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdNewL()")); |
|
160 |
|
161 TRAPD(error, CT_CG711DecoderIntfcData::NewL()); |
|
162 if(KErrNone!=error) |
|
163 { |
|
164 ERR_PRINTF2(_L("> Could not create CG711HwDevice: %d"), error); |
|
165 SetError(error); |
|
166 } |
|
167 else |
|
168 { |
|
169 INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdNewL()")); |
|
170 } |
|
171 } |
|
172 |
|
173 /** |
|
174 * Destroy an instance of CG711DecoderIntfc |
|
175 * @param none |
|
176 * @return none |
|
177 */ |
|
178 void CT_CG711DecoderIntfcData::DoCmdDestructor() |
|
179 { |
|
180 INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdDestructor()")); |
|
181 DestroyData(); |
|
182 INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdDestructor()")); |
|
183 } |
|
184 |
|
185 /** |
|
186 * Set decoder mode |
|
187 * @param aSection - Section to read param from the ini file |
|
188 * @return none |
|
189 */ |
|
190 void CT_CG711DecoderIntfcData::DoCmdSetDecoderMode(const TTEFSectionName& aSection) |
|
191 { |
|
192 INFO_PRINTF1(_L("*START* CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()")); |
|
193 TInt expectedValue; |
|
194 if (!GetEnumFromConfig(aSection, KDecoder, iEnumDecoders, expectedValue)) |
|
195 { |
|
196 INFO_PRINTF2(_L("Parameter %S was not found in INI file."), &KDecoder); |
|
197 SetBlockResult(EFail); |
|
198 } |
|
199 else |
|
200 { |
|
201 TInt error = iG711Decoder->SetDecoderMode((CG711DecoderIntfc::TDecodeMode)expectedValue); |
|
202 if ( KErrNone != error ) |
|
203 { |
|
204 ERR_PRINTF2(_L("[%d] SetDecoderMode()"), error); |
|
205 SetError(error); |
|
206 } |
|
207 else |
|
208 { |
|
209 INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()")); |
|
210 } |
|
211 } |
|
212 } |
|
213 |
|
214 /** |
|
215 * @param aSection - Section to read param from the ini file |
|
216 * @return none |
|
217 */ |
|
218 void CT_CG711DecoderIntfcData::DoCmdSetCng(const TTEFSectionName& aSection) |
|
219 { |
|
220 INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdSetCng()")); |
|
221 |
|
222 if(!GetBoolFromConfig(aSection, KCng, iCng)) |
|
223 { |
|
224 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCng); |
|
225 SetBlockResult(EFail); |
|
226 return; |
|
227 } |
|
228 else |
|
229 { |
|
230 TInt error = iG711Decoder->SetCng(iCng); |
|
231 if ( KErrNone != error ) |
|
232 { |
|
233 ERR_PRINTF2(_L("[%d] SetCng() error "), error); |
|
234 SetError(error); |
|
235 return; |
|
236 } |
|
237 else |
|
238 { |
|
239 INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetCng()")); |
|
240 } |
|
241 } |
|
242 } |
|
243 |