sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Part of the MVS Application for TechView
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "MVSConfigAudioFormatDialog.h"
|
sl@0
|
19 |
#include "MVSApp.hrh"
|
sl@0
|
20 |
#include <badesca.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "MVSAppUI.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
void CMVSConfigAudioFormatDialog::SetupDialogLD(CMVSAppUi* aAppUi,TUid aControllerId,CSettingsManager* aSettingsManager)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CMVSConfigAudioFormatDialog* dialog = new (ELeave) CMVSConfigAudioFormatDialog(aAppUi,aControllerId);
|
sl@0
|
28 |
CleanupStack::PushL(dialog);
|
sl@0
|
29 |
dialog->ConstructL();
|
sl@0
|
30 |
aSettingsManager->ReadAudioDataL(dialog,aControllerId);
|
sl@0
|
31 |
CleanupStack::Pop(dialog);
|
sl@0
|
32 |
dialog->ExecuteLD(R_MVS_DIALOG_CONFIGUREDATAFORMAT);
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
void CMVSConfigAudioFormatDialog::ConstructL()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
iArrBitRates = new(ELeave) CDesCArrayFlat(8);
|
sl@0
|
39 |
iArrSampleRates = new(ELeave) CDesCArrayFlat(8);
|
sl@0
|
40 |
iArrChannels = new(ELeave) CDesCArrayFlat(8);
|
sl@0
|
41 |
iArrCodecs = new(ELeave) CDesCArrayFlat(8);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
void CMVSConfigAudioFormatDialog::PreLayoutDynInitL()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
// Get a downcasted pointer to each of the controls
|
sl@0
|
48 |
CEikChoiceList* bitrateList = static_cast<CEikChoiceList*>(Control(EMVSSetBitrate));
|
sl@0
|
49 |
|
sl@0
|
50 |
CEikChoiceList* codecList = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectCodec));
|
sl@0
|
51 |
|
sl@0
|
52 |
CEikChoiceList* channelsList = static_cast<CEikChoiceList*>(Control(EMVSSetNoOfChannels));
|
sl@0
|
53 |
|
sl@0
|
54 |
CEikChoiceList* sampleratesList = static_cast<CEikChoiceList*>(Control(EMVSSetSamplerate));
|
sl@0
|
55 |
|
sl@0
|
56 |
CEikCheckBox* restoresettings = static_cast<CEikCheckBox*>(Control(EMVSRestoreAudioSettings));
|
sl@0
|
57 |
iSettings = restoresettings;
|
sl@0
|
58 |
TBuf<10> td;
|
sl@0
|
59 |
TInt err = 0;
|
sl@0
|
60 |
CDesCArray* tempArray = NULL;
|
sl@0
|
61 |
if(restoresettings)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
restoresettings->SetObserver(this);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
if(bitrateList)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
bitrateList->SetArrayL(iArrBitRates);
|
sl@0
|
68 |
bitrateList->SetArrayExternalOwnership(ETrue);
|
sl@0
|
69 |
tempArray = bitrateList->DesCArray();
|
sl@0
|
70 |
//get supported bit rates
|
sl@0
|
71 |
TRAP(err,iAppUi->GetSupportedBitRatesL(iBitRatesArray));
|
sl@0
|
72 |
if(err == KErrNotSupported)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
_LIT(KBitRateSupport, "Bitrates not supported");
|
sl@0
|
75 |
User::InfoPrint(KBitRateSupport);
|
sl@0
|
76 |
iBitRateIdx = -1;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
else
|
sl@0
|
79 |
{
|
sl@0
|
80 |
//copy from array to CDescCArray
|
sl@0
|
81 |
for(TInt i = 0; i < iBitRatesArray.Count();i++)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
td.Num(iBitRatesArray[i]);
|
sl@0
|
84 |
tempArray->AppendL(td);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
}
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
if(sampleratesList)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
sampleratesList->SetArrayL(iArrSampleRates);
|
sl@0
|
92 |
sampleratesList->SetArrayExternalOwnership(ETrue);
|
sl@0
|
93 |
tempArray = sampleratesList->DesCArray();
|
sl@0
|
94 |
//get supported sample rates
|
sl@0
|
95 |
TRAP(err,iAppUi->GetSupportedSampleRatesArrayL(iSampleRatesArray));
|
sl@0
|
96 |
if(err == KErrNotSupported)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
_LIT(KSampleRateSupport, "Samplerates not supported");
|
sl@0
|
99 |
User::InfoPrint(KSampleRateSupport);
|
sl@0
|
100 |
iSampleRateIdx = -1;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
else
|
sl@0
|
103 |
{
|
sl@0
|
104 |
//copy from array to CDescCArray
|
sl@0
|
105 |
for(TInt i = 0; i < iSampleRatesArray.Count();i++)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
td.Num(iSampleRatesArray[i]);
|
sl@0
|
108 |
tempArray->AppendL(td);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
}
|
sl@0
|
111 |
}
|
sl@0
|
112 |
|
sl@0
|
113 |
if(channelsList)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
channelsList->SetArrayL(iArrChannels);
|
sl@0
|
116 |
channelsList->SetArrayExternalOwnership(ETrue);
|
sl@0
|
117 |
tempArray = channelsList->DesCArray();
|
sl@0
|
118 |
//get supported channels
|
sl@0
|
119 |
TRAP(err,iAppUi->GetSupportedNoChannelsArrayL(iChannelsArray));
|
sl@0
|
120 |
if(err==KErrNotSupported)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
_LIT(KChannelSupport, "Channels not supported");
|
sl@0
|
123 |
User::InfoPrint(KChannelSupport);
|
sl@0
|
124 |
iChannelListIdx = -1;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
else
|
sl@0
|
127 |
{
|
sl@0
|
128 |
//copy from array to CDescCArray
|
sl@0
|
129 |
for(TInt i = 0; i < iChannelsArray.Count();i++)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
td.Num(iChannelsArray[i]);
|
sl@0
|
132 |
tempArray->AppendL(td);
|
sl@0
|
133 |
}
|
sl@0
|
134 |
}
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
if(codecList)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
codecList->SetArrayL(iArrCodecs);
|
sl@0
|
140 |
codecList->SetArrayExternalOwnership(ETrue);
|
sl@0
|
141 |
tempArray = codecList->DesCArray();
|
sl@0
|
142 |
|
sl@0
|
143 |
//get supported codecs
|
sl@0
|
144 |
char *pch = NULL;
|
sl@0
|
145 |
TUint32 unValue;
|
sl@0
|
146 |
TRAP(err,iAppUi->GetSupportedCodecsArrayL(iCodecsArray));
|
sl@0
|
147 |
if(err==KErrNotSupported)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
_LIT(KCodecSupport, "Codecs not supported");
|
sl@0
|
150 |
User::InfoPrint(KCodecSupport);
|
sl@0
|
151 |
iCodecListIdx = -1;
|
sl@0
|
152 |
}
|
sl@0
|
153 |
else
|
sl@0
|
154 |
{
|
sl@0
|
155 |
tempArray->Reset();
|
sl@0
|
156 |
//copy from array to CDescCArray
|
sl@0
|
157 |
for(TInt i = 0; i < iCodecsArray.Count(); i++)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
unValue = iCodecsArray[i].FourCC();
|
sl@0
|
160 |
pch =reinterpret_cast<char*>(&unValue);
|
sl@0
|
161 |
td.Zero();
|
sl@0
|
162 |
td.Append(pch[0]);
|
sl@0
|
163 |
td.Append(pch[1]);
|
sl@0
|
164 |
td.Append(pch[2]);
|
sl@0
|
165 |
td.Append(pch[3]);
|
sl@0
|
166 |
tempArray->AppendL(td);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
}
|
sl@0
|
169 |
}
|
sl@0
|
170 |
//Seed the controls with their appropriate value.
|
sl@0
|
171 |
if(iBitRateIdx >= 0)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
bitrateList->SetCurrentItem(iBitRateIdx);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
if(iSampleRateIdx >= 0)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
sampleratesList->SetCurrentItem(iSampleRateIdx);
|
sl@0
|
178 |
}
|
sl@0
|
179 |
if(iChannelListIdx >= 0)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
channelsList->SetCurrentItem(iChannelListIdx);
|
sl@0
|
182 |
}
|
sl@0
|
183 |
if(iCodecListIdx >= 0)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
codecList->SetCurrentItem(iCodecListIdx);
|
sl@0
|
186 |
}
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
|
sl@0
|
191 |
CMVSConfigAudioFormatDialog::CMVSConfigAudioFormatDialog(CMVSAppUi* aAppUi,TUid aControllerId)
|
sl@0
|
192 |
:iContollerUid(aControllerId) , iAppUi(aAppUi)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
TBool CMVSConfigAudioFormatDialog::OkToExitL(TInt aButtonId)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
if(aButtonId == EMVSButtonCancel)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
return ETrue;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
//the values have to go to store
|
sl@0
|
205 |
// Get a downcasted pointer to each of the controls
|
sl@0
|
206 |
CEikChoiceList* bitrateList = static_cast<CEikChoiceList*>(Control(EMVSSetBitrate));
|
sl@0
|
207 |
|
sl@0
|
208 |
CEikChoiceList* codecList = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectCodec));
|
sl@0
|
209 |
|
sl@0
|
210 |
CEikChoiceList* channelsList = static_cast<CEikChoiceList*>(Control(EMVSSetNoOfChannels));
|
sl@0
|
211 |
|
sl@0
|
212 |
CEikChoiceList* sampleratesList = static_cast<CEikChoiceList*>(Control(EMVSSetSamplerate));
|
sl@0
|
213 |
|
sl@0
|
214 |
if(bitrateList && codecList && channelsList && sampleratesList)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
if(iBitRateIdx != -1)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iBitRateIdx = bitrateList->CurrentItem();
|
sl@0
|
219 |
}
|
sl@0
|
220 |
if(iSampleRateIdx != -1)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
iSampleRateIdx = sampleratesList->CurrentItem();
|
sl@0
|
223 |
}
|
sl@0
|
224 |
if(iChannelListIdx != -1)
|
sl@0
|
225 |
{
|
sl@0
|
226 |
iChannelListIdx = channelsList->CurrentItem();
|
sl@0
|
227 |
}
|
sl@0
|
228 |
if(iCodecListIdx != -1)
|
sl@0
|
229 |
{
|
sl@0
|
230 |
iCodecListIdx = codecList->CurrentItem();
|
sl@0
|
231 |
}
|
sl@0
|
232 |
iAppUi->WriteAudioDataL(this,iContollerUid);
|
sl@0
|
233 |
if(aButtonId == EMVSButtonUpdate)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
if(iBitRateIdx >= 0)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
iAppUi->SetBitRateL(iBitRatesArray[iBitRateIdx]);
|
sl@0
|
238 |
}
|
sl@0
|
239 |
if(iSampleRateIdx >= 0)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
iAppUi->SetSampleRateL(iSampleRatesArray[iSampleRateIdx]);
|
sl@0
|
242 |
}
|
sl@0
|
243 |
if(iChannelListIdx >= 0)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
iAppUi->SetChannelsL(iChannelsArray[iChannelListIdx]);
|
sl@0
|
246 |
}
|
sl@0
|
247 |
if(iCodecListIdx >= 0)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
iAppUi->SetCodecsL(iCodecsArray[iCodecListIdx]);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
}
|
sl@0
|
252 |
}
|
sl@0
|
253 |
return ETrue;
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|
sl@0
|
256 |
|
sl@0
|
257 |
TKeyResponse CMVSConfigAudioFormatDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
OkToExitL(EMVSButtonUpdate);
|
sl@0
|
262 |
}
|
sl@0
|
263 |
return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
|
sl@0
|
267 |
|
sl@0
|
268 |
void CMVSConfigAudioFormatDialog::ExternalizeL(RWriteStream& aStream)
|
sl@0
|
269 |
{
|
sl@0
|
270 |
aStream.WriteInt8L(iBitRateIdx);
|
sl@0
|
271 |
aStream.WriteInt8L(iSampleRateIdx);
|
sl@0
|
272 |
aStream.WriteInt8L(iChannelListIdx);
|
sl@0
|
273 |
aStream.WriteInt8L(iCodecListIdx);
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
|
sl@0
|
277 |
void CMVSConfigAudioFormatDialog::InternalizeL(RReadStream& aStream)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
iBitRateIdx = aStream.ReadInt8L();
|
sl@0
|
280 |
iSampleRateIdx = aStream.ReadInt8L();
|
sl@0
|
281 |
iChannelListIdx = aStream.ReadInt8L();
|
sl@0
|
282 |
iCodecListIdx = aStream.ReadInt8L();
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
|
sl@0
|
286 |
void CMVSConfigAudioFormatDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
CEikChoiceList* bitrateList = static_cast<CEikChoiceList*>(Control(EMVSSetBitrate));
|
sl@0
|
289 |
|
sl@0
|
290 |
CEikChoiceList* codecList = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectCodec));
|
sl@0
|
291 |
|
sl@0
|
292 |
CEikChoiceList* channelsList = static_cast<CEikChoiceList*>(Control(EMVSSetNoOfChannels));
|
sl@0
|
293 |
|
sl@0
|
294 |
CEikChoiceList* sampleratesList = static_cast<CEikChoiceList*>(Control(EMVSSetSamplerate));
|
sl@0
|
295 |
|
sl@0
|
296 |
CEikDialog::HandleControlEventL(aControl,aEventType);
|
sl@0
|
297 |
if(bitrateList && codecList && channelsList && sampleratesList)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
if(iSettings == aControl && aEventType == EEventStateChanged)
|
sl@0
|
300 |
{
|
sl@0
|
301 |
if(iRestoreSettings == EFalse)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
iRestoreSettings=ETrue;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
else
|
sl@0
|
306 |
{
|
sl@0
|
307 |
iRestoreSettings=EFalse;
|
sl@0
|
308 |
}
|
sl@0
|
309 |
if(iRestoreSettings)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
if(iBitRateIdx >= 0)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
bitrateList->SetCurrentItem(iBitRateIdx);
|
sl@0
|
314 |
bitrateList->DrawDeferred();
|
sl@0
|
315 |
}
|
sl@0
|
316 |
|
sl@0
|
317 |
if(iSampleRateIdx >= 0)
|
sl@0
|
318 |
{
|
sl@0
|
319 |
sampleratesList->SetCurrentItem(iSampleRateIdx);
|
sl@0
|
320 |
sampleratesList->DrawDeferred();
|
sl@0
|
321 |
}
|
sl@0
|
322 |
|
sl@0
|
323 |
if(iChannelListIdx >= 0)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
channelsList->SetCurrentItem(iChannelListIdx);
|
sl@0
|
326 |
channelsList->DrawDeferred();
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
if(iCodecListIdx >= 0)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
codecList->SetCurrentItem(iCodecListIdx);
|
sl@0
|
332 |
codecList->DrawDeferred();
|
sl@0
|
333 |
}
|
sl@0
|
334 |
}
|
sl@0
|
335 |
else
|
sl@0
|
336 |
{
|
sl@0
|
337 |
if(iBitRateIdx >= 0)
|
sl@0
|
338 |
{
|
sl@0
|
339 |
bitrateList->SetCurrentItem(0);
|
sl@0
|
340 |
bitrateList->DrawDeferred();
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
if(iSampleRateIdx >= 0)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
sampleratesList->SetCurrentItem(0);
|
sl@0
|
346 |
sampleratesList->DrawDeferred();
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
if(iChannelListIdx >= 0)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
channelsList->SetCurrentItem(0);
|
sl@0
|
352 |
channelsList->DrawDeferred();
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
if(iCodecListIdx >= 0)
|
sl@0
|
356 |
{
|
sl@0
|
357 |
codecList->SetCurrentItem(0);
|
sl@0
|
358 |
codecList->DrawDeferred();
|
sl@0
|
359 |
}
|
sl@0
|
360 |
}
|
sl@0
|
361 |
return;
|
sl@0
|
362 |
}
|
sl@0
|
363 |
}
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
|
sl@0
|
367 |
CMVSConfigAudioFormatDialog::~CMVSConfigAudioFormatDialog()
|
sl@0
|
368 |
{
|
sl@0
|
369 |
iBitRatesArray.Close();
|
sl@0
|
370 |
iSampleRatesArray.Close();
|
sl@0
|
371 |
iChannelsArray.Close();
|
sl@0
|
372 |
iCodecsArray.Close();
|
sl@0
|
373 |
delete iArrSampleRates;
|
sl@0
|
374 |
delete iArrBitRates;
|
sl@0
|
375 |
delete iArrChannels;
|
sl@0
|
376 |
delete iArrCodecs;
|
sl@0
|
377 |
}
|