os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSConfigVideoFormatDialog.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSConfigVideoFormatDialog.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,303 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Part of the MVS Application for TechView
1.18 +//
1.19 +
1.20 +#include "MVSConfigVideoFormatDialog.h"
1.21 +#include "MVSApp.hrh"
1.22 +#include <badesca.h>
1.23 +
1.24 +#include "MVSAppUI.h"
1.25 +
1.26 +void CMVSConfigVideoFormatDialog::SetupDialogLD(CMVSAppUi* aAppUi,TUid aControllerId,CSettingsManager* aSettingsManager)
1.27 + {
1.28 + CMVSConfigVideoFormatDialog* dialog = new (ELeave) CMVSConfigVideoFormatDialog(aAppUi,aControllerId);
1.29 + CleanupStack::PushL(dialog);
1.30 + dialog->ConstructL();
1.31 + aSettingsManager->ReadVideoDataL(dialog,aControllerId);
1.32 + CleanupStack::Pop(dialog);
1.33 + dialog->ExecuteLD(R_MVS_DIALOG_VIDEOPLUGINS);
1.34 + }
1.35 +
1.36 +
1.37 +void CMVSConfigVideoFormatDialog::ConstructL()
1.38 + {
1.39 + iMimeTypeArray = new(ELeave) CDesC8ArrayFlat(8);
1.40 + iArrFrameRate = new(ELeave) CDesCArrayFlat(8);
1.41 + iArrFrameSize = new(ELeave) CDesCArrayFlat(8);
1.42 + iArrVideoMimeType = new(ELeave) CDesCArrayFlat(8);
1.43 + }
1.44 +
1.45 +void CMVSConfigVideoFormatDialog::PreLayoutDynInitL()
1.46 + {
1.47 + CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
1.48 +
1.49 + CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
1.50 +
1.51 + CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));
1.52 +
1.53 + CEikCheckBox* restoresettings = static_cast<CEikCheckBox*>(Control(EMVSRestoreVideoSettings));
1.54 +
1.55 + CEikCheckBox* audioenable = static_cast<CEikCheckBox*>(Control(EMVSEnableAudio));
1.56 +
1.57 + TBuf<10> td;
1.58 + TBuf<20> sd;
1.59 + TInt err = 0;
1.60 + CDesCArray* tempArray = NULL;
1.61 + if(frameRateCtl)
1.62 + {
1.63 + frameRateCtl->SetArrayL(iArrFrameRate);
1.64 + frameRateCtl->SetArrayExternalOwnership(ETrue);
1.65 + tempArray = frameRateCtl->DesCArray();
1.66 + //get supported frame rates
1.67 + TRAP(err,iAppUi->GetSupportedFrameRatesL(iFrameRateArray));
1.68 + if(err == KErrNotSupported)
1.69 + {
1.70 + _LIT(KFrameRateSupport, "Frame Rates not supported");
1.71 + User::InfoPrint(KFrameRateSupport);
1.72 + iFrameRateIdx = -1;
1.73 + }
1.74 + else
1.75 + {
1.76 + //copy from array to CDescCArray
1.77 + iFrameRateIdx = 0;
1.78 + for(TInt i = 0; i < iFrameRateArray.Count();i++)
1.79 + {
1.80 + td.Num(iFrameRateArray[i]);
1.81 + tempArray->AppendL(td);
1.82 + }
1.83 + }
1.84 + }
1.85 +
1.86 + if(frameSizeCtl)
1.87 + {
1.88 + _LIT(comma,",");
1.89 + frameSizeCtl->SetArrayL(iArrFrameSize);
1.90 + frameSizeCtl->SetArrayExternalOwnership(ETrue);
1.91 + tempArray = frameSizeCtl->DesCArray();
1.92 + //get supported sample rates
1.93 + TRAP(err,iAppUi->GetSupportedFrameSizeArrayL(iFrameSizeArray));
1.94 + if(err == KErrNotSupported)
1.95 + {
1.96 + _LIT(KSampleRateSupport, "Sample rates not supported");
1.97 + User::InfoPrint(KSampleRateSupport);
1.98 + iFrameSizeIdx = -1;
1.99 + }
1.100 + else
1.101 + {
1.102 + //copy from array to CDescCArray
1.103 + iFrameSizeIdx = 0;
1.104 + for(TInt i = 0; i < iFrameSizeArray.Count();i++)
1.105 + {
1.106 + //code to append both TWidth and THeight into single cell of the Array
1.107 + TSize temp=iFrameSizeArray[i];
1.108 + TInt width=temp.iWidth;
1.109 + TInt height=temp.iHeight;
1.110 + td.Num(width);
1.111 + TInt8 size=td.Length()+1;
1.112 + sd.Insert(0,td);
1.113 + sd.Append(comma);
1.114 + td.Num(height);
1.115 + sd.Append(td);
1.116 + tempArray->AppendL(sd);
1.117 + td.Delete(0,size+5);//the Delete()function adjusts this value to ensure that no data
1.118 + sd.Delete(0,size+5);//beyond the end of the descriptor data area is deleted.
1.119 + }
1.120 + }
1.121 + }
1.122 +
1.123 + if(mimeTypeCtl)
1.124 + {
1.125 + //get supported frame rates
1.126 + mimeTypeCtl->SetArrayL(iArrVideoMimeType);
1.127 + mimeTypeCtl->SetArrayExternalOwnership(ETrue);
1.128 + TRAP(err,iAppUi->GetSupportedVideoTypesL(*iMimeTypeArray));
1.129 + TInt counter=iMimeTypeArray->Count();
1.130 + for(TInt i=0; i<counter; i++)
1.131 + {
1.132 + TBuf16<16> temp;
1.133 + temp.Copy(iMimeTypeArray->MdcaPoint(i));
1.134 + iArrVideoMimeType->AppendL(temp);
1.135 + }
1.136 + if(err == KErrNotSupported)
1.137 + {
1.138 + _LIT(KFrameRateSupport, "Frame Rates not supported");
1.139 + User::InfoPrint(KFrameRateSupport);
1.140 + }
1.141 + }
1.142 +
1.143 + if(restoresettings)
1.144 + {
1.145 + iSettings = restoresettings;
1.146 + restoresettings->SetObserver(this);
1.147 + }
1.148 + if(audioenable)
1.149 + {
1.150 + iAudioEnableCtl = audioenable;
1.151 + iAudioEnable = EFalse;
1.152 + audioenable->SetObserver(this);
1.153 + }
1.154 + }
1.155 +
1.156 +
1.157 +CMVSConfigVideoFormatDialog::CMVSConfigVideoFormatDialog(CMVSAppUi* aAppUi,TUid aControllerId)
1.158 + :iContollerUid(aControllerId) , iAppUi(aAppUi)
1.159 + {
1.160 + }
1.161 +
1.162 +
1.163 +TKeyResponse CMVSConfigVideoFormatDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
1.164 + {
1.165 + if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
1.166 + {
1.167 + OkToExitL(EMVSButtonUpdate);
1.168 + }
1.169 + return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
1.170 + }
1.171 +
1.172 +
1.173 +TBool CMVSConfigVideoFormatDialog::OkToExitL(TInt aButtonId)
1.174 + {
1.175 + if(aButtonId == EMVSButtonCancel)
1.176 + {
1.177 + return ETrue;
1.178 + }
1.179 + CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
1.180 +
1.181 + CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
1.182 +
1.183 + CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));
1.184 +
1.185 + if(frameRateCtl && frameSizeCtl && mimeTypeCtl)
1.186 + {
1.187 + if(iFrameRateIdx != -1)
1.188 + {
1.189 + iFrameRateIdx = frameRateCtl->CurrentItem();
1.190 + }
1.191 + if(iFrameSizeIdx != -1)
1.192 + {
1.193 + iFrameSizeIdx = frameSizeCtl->CurrentItem();
1.194 + }
1.195 + iMimeTypeIdx = mimeTypeCtl->CurrentItem();
1.196 + iAppUi->WriteVideoDataL(this,iContollerUid);
1.197 + }
1.198 + if(aButtonId == EMVSButtonUpdate)
1.199 + {
1.200 + if(iFrameRateIdx >= 0)
1.201 + {
1.202 + iAppUi->SetVideoFrameRateL(iFrameRateArray[iFrameRateIdx]);
1.203 + }
1.204 + if(iFrameSizeIdx >= 0)
1.205 + {
1.206 + iAppUi->SetVideoFrameSizeL(iFrameSizeArray[iFrameSizeIdx]);
1.207 + }
1.208 + if(iAudioEnable)
1.209 + {
1.210 + iAppUi->SetAudioEnabledL(iAudioEnable);
1.211 + }
1.212 + if(iMimeTypeIdx)
1.213 + {
1.214 + iAppUi->SetVideoTypeL((*iMimeTypeArray)[iMimeTypeIdx]);
1.215 + }
1.216 + }
1.217 + return ETrue;
1.218 + }
1.219 +
1.220 +
1.221 +void CMVSConfigVideoFormatDialog::InternalizeL(RReadStream& aStream)
1.222 + {
1.223 + iFrameRateIdx = aStream.ReadInt8L();
1.224 + iFrameSizeIdx = aStream.ReadInt8L();
1.225 + }
1.226 +
1.227 +
1.228 +void CMVSConfigVideoFormatDialog::ExternalizeL(RWriteStream& aStream)
1.229 + {
1.230 + aStream.WriteInt8L(iFrameRateIdx);
1.231 + aStream.WriteInt8L(iFrameSizeIdx);
1.232 + }
1.233 +
1.234 +void CMVSConfigVideoFormatDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
1.235 + {
1.236 + CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));
1.237 +
1.238 + CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
1.239 +
1.240 + CEikDialog::HandleControlEventL(aControl,aEventType);
1.241 + if(frameRateCtl && frameSizeCtl)
1.242 + {
1.243 + if(iSettings == aControl && aEventType == EEventStateChanged)
1.244 + {
1.245 + if(iRestoreSettings == EFalse)
1.246 + {
1.247 + iRestoreSettings = ETrue;
1.248 + }
1.249 + else
1.250 + {
1.251 + iRestoreSettings = EFalse;
1.252 + }
1.253 + if(iRestoreSettings)
1.254 + {
1.255 + if(iFrameRateIdx>0)
1.256 + {
1.257 + frameRateCtl->SetCurrentItem(iFrameRateIdx);
1.258 + frameRateCtl->DrawDeferred();
1.259 + }
1.260 + if(iFrameSizeIdx>0)
1.261 + {
1.262 + frameSizeCtl->SetCurrentItem(iFrameSizeIdx);
1.263 + frameSizeCtl->DrawDeferred();
1.264 + }
1.265 + }
1.266 + else
1.267 + {
1.268 + if(iFrameRateIdx >= 0)
1.269 + {
1.270 + frameRateCtl->SetCurrentItem(0);
1.271 + frameRateCtl->DrawDeferred();
1.272 + }
1.273 +
1.274 + if(iFrameSizeIdx >= 0)
1.275 + {
1.276 + frameSizeCtl->SetCurrentItem(0);
1.277 + frameSizeCtl->DrawDeferred();
1.278 + }
1.279 + }
1.280 + return;
1.281 + }
1.282 + if(iAudioEnableCtl == aControl && aEventType == EEventStateChanged)
1.283 + {
1.284 + if(iAudioEnable == EFalse)
1.285 + {
1.286 + iAudioEnable = ETrue;
1.287 + }
1.288 + else
1.289 + {
1.290 + iAudioEnable = EFalse;
1.291 + }
1.292 + return;
1.293 + }
1.294 + }
1.295 + }
1.296 +
1.297 +
1.298 +CMVSConfigVideoFormatDialog::~CMVSConfigVideoFormatDialog()
1.299 + {
1.300 + iFrameRateArray.Close();
1.301 + iFrameSizeArray.Close();
1.302 + delete iArrFrameRate;
1.303 + delete iArrFrameSize;
1.304 + delete iMimeTypeArray;
1.305 + delete iArrVideoMimeType;
1.306 + }