os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSConfigVideoFormatDialog.cpp
First public contribution.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the MVS Application for TechView
17 #include "MVSConfigVideoFormatDialog.h"
23 void CMVSConfigVideoFormatDialog::SetupDialogLD(CMVSAppUi* aAppUi,TUid aControllerId,CSettingsManager* aSettingsManager)
25 CMVSConfigVideoFormatDialog* dialog = new (ELeave) CMVSConfigVideoFormatDialog(aAppUi,aControllerId);
26 CleanupStack::PushL(dialog);
28 aSettingsManager->ReadVideoDataL(dialog,aControllerId);
29 CleanupStack::Pop(dialog);
30 dialog->ExecuteLD(R_MVS_DIALOG_VIDEOPLUGINS);
34 void CMVSConfigVideoFormatDialog::ConstructL()
36 iMimeTypeArray = new(ELeave) CDesC8ArrayFlat(8);
37 iArrFrameRate = new(ELeave) CDesCArrayFlat(8);
38 iArrFrameSize = new(ELeave) CDesCArrayFlat(8);
39 iArrVideoMimeType = new(ELeave) CDesCArrayFlat(8);
42 void CMVSConfigVideoFormatDialog::PreLayoutDynInitL()
44 CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
46 CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
48 CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));
50 CEikCheckBox* restoresettings = static_cast<CEikCheckBox*>(Control(EMVSRestoreVideoSettings));
52 CEikCheckBox* audioenable = static_cast<CEikCheckBox*>(Control(EMVSEnableAudio));
57 CDesCArray* tempArray = NULL;
60 frameRateCtl->SetArrayL(iArrFrameRate);
61 frameRateCtl->SetArrayExternalOwnership(ETrue);
62 tempArray = frameRateCtl->DesCArray();
63 //get supported frame rates
64 TRAP(err,iAppUi->GetSupportedFrameRatesL(iFrameRateArray));
65 if(err == KErrNotSupported)
67 _LIT(KFrameRateSupport, "Frame Rates not supported");
68 User::InfoPrint(KFrameRateSupport);
73 //copy from array to CDescCArray
75 for(TInt i = 0; i < iFrameRateArray.Count();i++)
77 td.Num(iFrameRateArray[i]);
78 tempArray->AppendL(td);
86 frameSizeCtl->SetArrayL(iArrFrameSize);
87 frameSizeCtl->SetArrayExternalOwnership(ETrue);
88 tempArray = frameSizeCtl->DesCArray();
89 //get supported sample rates
90 TRAP(err,iAppUi->GetSupportedFrameSizeArrayL(iFrameSizeArray));
91 if(err == KErrNotSupported)
93 _LIT(KSampleRateSupport, "Sample rates not supported");
94 User::InfoPrint(KSampleRateSupport);
99 //copy from array to CDescCArray
101 for(TInt i = 0; i < iFrameSizeArray.Count();i++)
103 //code to append both TWidth and THeight into single cell of the Array
104 TSize temp=iFrameSizeArray[i];
105 TInt width=temp.iWidth;
106 TInt height=temp.iHeight;
108 TInt8 size=td.Length()+1;
113 tempArray->AppendL(sd);
114 td.Delete(0,size+5);//the Delete()function adjusts this value to ensure that no data
115 sd.Delete(0,size+5);//beyond the end of the descriptor data area is deleted.
122 //get supported frame rates
123 mimeTypeCtl->SetArrayL(iArrVideoMimeType);
124 mimeTypeCtl->SetArrayExternalOwnership(ETrue);
125 TRAP(err,iAppUi->GetSupportedVideoTypesL(*iMimeTypeArray));
126 TInt counter=iMimeTypeArray->Count();
127 for(TInt i=0; i<counter; i++)
130 temp.Copy(iMimeTypeArray->MdcaPoint(i));
131 iArrVideoMimeType->AppendL(temp);
133 if(err == KErrNotSupported)
135 _LIT(KFrameRateSupport, "Frame Rates not supported");
136 User::InfoPrint(KFrameRateSupport);
142 iSettings = restoresettings;
143 restoresettings->SetObserver(this);
147 iAudioEnableCtl = audioenable;
148 iAudioEnable = EFalse;
149 audioenable->SetObserver(this);
154 CMVSConfigVideoFormatDialog::CMVSConfigVideoFormatDialog(CMVSAppUi* aAppUi,TUid aControllerId)
155 :iContollerUid(aControllerId) , iAppUi(aAppUi)
160 TKeyResponse CMVSConfigVideoFormatDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
162 if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
164 OkToExitL(EMVSButtonUpdate);
166 return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
170 TBool CMVSConfigVideoFormatDialog::OkToExitL(TInt aButtonId)
172 if(aButtonId == EMVSButtonCancel)
176 CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
178 CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
180 CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));
182 if(frameRateCtl && frameSizeCtl && mimeTypeCtl)
184 if(iFrameRateIdx != -1)
186 iFrameRateIdx = frameRateCtl->CurrentItem();
188 if(iFrameSizeIdx != -1)
190 iFrameSizeIdx = frameSizeCtl->CurrentItem();
192 iMimeTypeIdx = mimeTypeCtl->CurrentItem();
193 iAppUi->WriteVideoDataL(this,iContollerUid);
195 if(aButtonId == EMVSButtonUpdate)
197 if(iFrameRateIdx >= 0)
199 iAppUi->SetVideoFrameRateL(iFrameRateArray[iFrameRateIdx]);
201 if(iFrameSizeIdx >= 0)
203 iAppUi->SetVideoFrameSizeL(iFrameSizeArray[iFrameSizeIdx]);
207 iAppUi->SetAudioEnabledL(iAudioEnable);
211 iAppUi->SetVideoTypeL((*iMimeTypeArray)[iMimeTypeIdx]);
218 void CMVSConfigVideoFormatDialog::InternalizeL(RReadStream& aStream)
220 iFrameRateIdx = aStream.ReadInt8L();
221 iFrameSizeIdx = aStream.ReadInt8L();
225 void CMVSConfigVideoFormatDialog::ExternalizeL(RWriteStream& aStream)
227 aStream.WriteInt8L(iFrameRateIdx);
228 aStream.WriteInt8L(iFrameSizeIdx);
231 void CMVSConfigVideoFormatDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
233 CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
235 CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
237 CEikDialog::HandleControlEventL(aControl,aEventType);
238 if(frameRateCtl && frameSizeCtl)
240 if(iSettings == aControl && aEventType == EEventStateChanged)
242 if(iRestoreSettings == EFalse)
244 iRestoreSettings = ETrue;
248 iRestoreSettings = EFalse;
254 frameRateCtl->SetCurrentItem(iFrameRateIdx);
255 frameRateCtl->DrawDeferred();
259 frameSizeCtl->SetCurrentItem(iFrameSizeIdx);
260 frameSizeCtl->DrawDeferred();
265 if(iFrameRateIdx >= 0)
267 frameRateCtl->SetCurrentItem(0);
268 frameRateCtl->DrawDeferred();
271 if(iFrameSizeIdx >= 0)
273 frameSizeCtl->SetCurrentItem(0);
274 frameSizeCtl->DrawDeferred();
279 if(iAudioEnableCtl == aControl && aEventType == EEventStateChanged)
281 if(iAudioEnable == EFalse)
283 iAudioEnable = ETrue;
287 iAudioEnable = EFalse;
295 CMVSConfigVideoFormatDialog::~CMVSConfigVideoFormatDialog()
297 iFrameRateArray.Close();
298 iFrameSizeArray.Close();
299 delete iArrFrameRate;
300 delete iArrFrameSize;
301 delete iMimeTypeArray;
302 delete iArrVideoMimeType;