|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Interface proxy for speech encoder configuration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SpeechEncoderConfigProxy.h" |
|
22 #include "SpeechEncoderConfigMsgs.h" |
|
23 #include <CustomCommandUtility.h> |
|
24 #include <CustomInterfaceUtility.h> |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 // ================= MEMBER FUNCTIONS ======================= |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CSpeechEncoderConfigProxy::CSpeechEncoderConfigProxy |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CSpeechEncoderConfigProxy::CSpeechEncoderConfigProxy( |
|
53 TMMFMessageDestinationPckg aMessageHandler, |
|
54 MCustomCommand& aCustomCommand, |
|
55 CCustomInterfaceUtility* aCustomInterfaceUtility) : |
|
56 iCustomCommand(aCustomCommand), |
|
57 iMessageHandler(aMessageHandler), |
|
58 iCustomInterfaceUtility(aCustomInterfaceUtility) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSpeechEncoderConfigProxy::ConstructL |
|
65 // Symbian 2nd phase constructor can leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CSpeechEncoderConfigProxy::ConstructL() |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CSpeechEncoderConfigProxy::NewL |
|
74 // Two-phased constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C CSpeechEncoderConfigProxy* CSpeechEncoderConfigProxy::NewL( |
|
78 TMMFMessageDestinationPckg aMessageHandler, |
|
79 MCustomCommand& aCustomCommand, |
|
80 CCustomInterfaceUtility* aCustomInterfaceUtility) |
|
81 { |
|
82 CSpeechEncoderConfigProxy* self = new(ELeave) CSpeechEncoderConfigProxy( |
|
83 aMessageHandler, |
|
84 aCustomCommand, |
|
85 aCustomInterfaceUtility); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop( self ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // Destructor |
|
93 EXPORT_C CSpeechEncoderConfigProxy::~CSpeechEncoderConfigProxy() |
|
94 { |
|
95 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); |
|
96 delete iCustomInterfaceUtility; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CSpeechEncoderConfigProxy::GetSupportedBitrates |
|
101 // Calls a subfunction which sends the appropriate custom command for this |
|
102 // function to its message handler. A subfunction is used |
|
103 // to contain multiple leaving functions for a single trap. |
|
104 // (other items were commented in a header). |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C TInt CSpeechEncoderConfigProxy::GetSupportedBitrates( |
|
108 RArray<TUint>& aSupportedBitrates) |
|
109 { |
|
110 TInt status; |
|
111 TRAP(status, GetSupportedBitratesL(aSupportedBitrates)); |
|
112 return status; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CSpeechEncoderConfigProxy::GetSupportedBitratesL |
|
117 // Sends the custom command for this function to its message handler. |
|
118 // This requires two commands. The first is a request for the number of |
|
119 // supported bitrates. A buffer is allocated locally to hold this number of |
|
120 // bitrates that will be returned. A pointer to this buffer is sent with the |
|
121 // next command which is a request for the bitrates. This buffer will be filled |
|
122 // with the bitrate values. These bitrates are then copied into the array |
|
123 // provided to this function and the local buffer is deleted. |
|
124 // (other items were commented in a header). |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CSpeechEncoderConfigProxy::GetSupportedBitratesL( |
|
128 RArray<TUint>& aSupportedBitrates) |
|
129 { |
|
130 aSupportedBitrates.Reset(); |
|
131 |
|
132 TPckgBuf<TUint> numberOfBitratesPckg; |
|
133 User::LeaveIfError(iCustomCommand.CustomCommandSync( |
|
134 iMessageHandler, |
|
135 ESecmGetNumOfSupportedBitrates, |
|
136 KNullDesC8, |
|
137 KNullDesC8, |
|
138 numberOfBitratesPckg)); |
|
139 HBufC8* buf = HBufC8::NewLC(numberOfBitratesPckg()*sizeof(TUint)); |
|
140 // buf is left on cleanup |
|
141 TPtr8 ptr = buf->Des(); |
|
142 |
|
143 User::LeaveIfError(iCustomCommand.CustomCommandSync( |
|
144 iMessageHandler, |
|
145 ESecmGetSupportedBitrates, |
|
146 KNullDesC8, |
|
147 KNullDesC8, |
|
148 ptr)); |
|
149 RDesReadStream stream(ptr); |
|
150 CleanupClosePushL(stream); // stream on cleanup |
|
151 for (TInt i=0; i<numberOfBitratesPckg(); i++) |
|
152 { |
|
153 aSupportedBitrates.Append(stream.ReadUint32L()); |
|
154 } |
|
155 CleanupStack::PopAndDestroy(&stream); |
|
156 CleanupStack::PopAndDestroy(buf); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------- |
|
160 // CSpeechEncoderConfigProxy::SetBitrate |
|
161 // Sends the custom command for this function to its message handler. |
|
162 // (other items were commented in a header). |
|
163 // --------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C TInt CSpeechEncoderConfigProxy::SetBitrate(TUint aBitrate) |
|
166 { |
|
167 TPckgBuf<TInt> bitratePckg(aBitrate); |
|
168 TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, |
|
169 ESecmSetBitrate, |
|
170 bitratePckg, |
|
171 KNullDesC8); |
|
172 return status; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------- |
|
176 // CSpeechEncoderConfigProxy::GetBitrate |
|
177 // Sends the custom command for this function to its message handler. |
|
178 // (other items were commented in a header). |
|
179 // --------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TInt CSpeechEncoderConfigProxy::GetBitrate(TUint& aBitrate) |
|
182 { |
|
183 TInt bitrate = 0; |
|
184 TPckgBuf<TInt> bitratePckg(bitrate); |
|
185 TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, |
|
186 ESecmGetBitrate, |
|
187 KNullDesC8, |
|
188 KNullDesC8, |
|
189 bitratePckg); |
|
190 if (status == KErrNone) |
|
191 aBitrate = bitratePckg(); |
|
192 return status; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CSpeechEncoderConfigProxy::SetVadMode |
|
197 // Sends the custom command for this function to its message handler. |
|
198 // (other items were commented in a header). |
|
199 // --------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C TInt CSpeechEncoderConfigProxy::SetVadMode(TBool aVadMode) |
|
202 { |
|
203 TPckgBuf<TBool> pckgBuf(aVadMode); |
|
204 TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, |
|
205 ESecmSetVadMode, |
|
206 pckgBuf, |
|
207 KNullDesC8); |
|
208 return status; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // CSpeechEncoderConfigProxy::GetVadMode |
|
213 // Sends the custom command for this function to its message handler. |
|
214 // (other items were commented in a header). |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 EXPORT_C TInt CSpeechEncoderConfigProxy::GetVadMode(TBool& aVadMode) |
|
218 { |
|
219 TInt vadMode = EFalse; |
|
220 TPckgBuf<TBool> pckgBuf(vadMode); |
|
221 TInt status = iCustomCommand.CustomCommandSync(iMessageHandler, |
|
222 ESecmGetVadMode, |
|
223 KNullDesC8, |
|
224 KNullDesC8, |
|
225 pckgBuf); |
|
226 if (status == KErrNone) |
|
227 aVadMode = pckgBuf(); |
|
228 return status; |
|
229 } |
|
230 |
|
231 |
|
232 |
|
233 // End of File |