os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSConfigVideoFormatDialog.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
#include "MVSConfigVideoFormatDialog.h"
sl@0
    18
#include "MVSApp.hrh"
sl@0
    19
#include <badesca.h>
sl@0
    20
sl@0
    21
#include "MVSAppUI.h" 
sl@0
    22
sl@0
    23
void CMVSConfigVideoFormatDialog::SetupDialogLD(CMVSAppUi* aAppUi,TUid aControllerId,CSettingsManager* aSettingsManager)
sl@0
    24
	{
sl@0
    25
	CMVSConfigVideoFormatDialog* dialog = new (ELeave) CMVSConfigVideoFormatDialog(aAppUi,aControllerId); 
sl@0
    26
    CleanupStack::PushL(dialog);
sl@0
    27
    dialog->ConstructL();
sl@0
    28
    aSettingsManager->ReadVideoDataL(dialog,aControllerId);
sl@0
    29
    CleanupStack::Pop(dialog);
sl@0
    30
    dialog->ExecuteLD(R_MVS_DIALOG_VIDEOPLUGINS);
sl@0
    31
    }
sl@0
    32
sl@0
    33
sl@0
    34
void CMVSConfigVideoFormatDialog::ConstructL() 
sl@0
    35
	{
sl@0
    36
	iMimeTypeArray = new(ELeave) CDesC8ArrayFlat(8);
sl@0
    37
	iArrFrameRate = new(ELeave) CDesCArrayFlat(8);	
sl@0
    38
	iArrFrameSize = new(ELeave) CDesCArrayFlat(8);
sl@0
    39
	iArrVideoMimeType = new(ELeave) CDesCArrayFlat(8);	
sl@0
    40
 	}
sl@0
    41
sl@0
    42
void CMVSConfigVideoFormatDialog::PreLayoutDynInitL()
sl@0
    43
    {
sl@0
    44
   	CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));	
sl@0
    45
	 
sl@0
    46
	CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));	
sl@0
    47
	
sl@0
    48
	CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));	
sl@0
    49
		  		
sl@0
    50
    CEikCheckBox* restoresettings = static_cast<CEikCheckBox*>(Control(EMVSRestoreVideoSettings));	
sl@0
    51
    
sl@0
    52
    CEikCheckBox* audioenable = static_cast<CEikCheckBox*>(Control(EMVSEnableAudio));	
sl@0
    53
    
sl@0
    54
    TBuf<10> td;
sl@0
    55
    TBuf<20> sd;
sl@0
    56
 	TInt err = 0;
sl@0
    57
	CDesCArray*	tempArray = NULL;
sl@0
    58
	if(frameRateCtl)
sl@0
    59
		{
sl@0
    60
		frameRateCtl->SetArrayL(iArrFrameRate);
sl@0
    61
		frameRateCtl->SetArrayExternalOwnership(ETrue);
sl@0
    62
		tempArray = frameRateCtl->DesCArray(); 	   		
sl@0
    63
		//get supported frame rates
sl@0
    64
		TRAP(err,iAppUi->GetSupportedFrameRatesL(iFrameRateArray));	
sl@0
    65
		if(err == KErrNotSupported)	
sl@0
    66
			{
sl@0
    67
			_LIT(KFrameRateSupport, "Frame Rates not supported");
sl@0
    68
			User::InfoPrint(KFrameRateSupport);			
sl@0
    69
			iFrameRateIdx = -1;
sl@0
    70
			}
sl@0
    71
		else
sl@0
    72
			{
sl@0
    73
			//copy from array to  CDescCArray 
sl@0
    74
		    iFrameRateIdx = 0;
sl@0
    75
		    for(TInt i = 0; i < iFrameRateArray.Count();i++) 
sl@0
    76
			    {
sl@0
    77
				td.Num(iFrameRateArray[i]);
sl@0
    78
				tempArray->AppendL(td);
sl@0
    79
			    }
sl@0
    80
			}	
sl@0
    81
		}
sl@0
    82
		
sl@0
    83
	if(frameSizeCtl)
sl@0
    84
	    {
sl@0
    85
	    _LIT(comma,",");
sl@0
    86
	    frameSizeCtl->SetArrayL(iArrFrameSize);
sl@0
    87
	    frameSizeCtl->SetArrayExternalOwnership(ETrue);
sl@0
    88
	    tempArray = frameSizeCtl->DesCArray();
sl@0
    89
		//get supported sample rates
sl@0
    90
		TRAP(err,iAppUi->GetSupportedFrameSizeArrayL(iFrameSizeArray));
sl@0
    91
		if(err == KErrNotSupported)
sl@0
    92
			{
sl@0
    93
			_LIT(KSampleRateSupport, "Sample rates not supported");
sl@0
    94
			User::InfoPrint(KSampleRateSupport);			
sl@0
    95
			iFrameSizeIdx = -1;
sl@0
    96
			}
sl@0
    97
		else
sl@0
    98
			{
sl@0
    99
			//copy from array to  CDescCArray
sl@0
   100
			iFrameSizeIdx = 0; 
sl@0
   101
		    for(TInt i = 0; i < iFrameSizeArray.Count();i++) 
sl@0
   102
		    	{
sl@0
   103
		    	//code to append both TWidth and THeight into single cell of the Array
sl@0
   104
		    	TSize temp=iFrameSizeArray[i];
sl@0
   105
		    	TInt width=temp.iWidth;
sl@0
   106
		    	TInt height=temp.iHeight;
sl@0
   107
		    	td.Num(width);
sl@0
   108
		    	TInt8 size=td.Length()+1;
sl@0
   109
		    	sd.Insert(0,td);
sl@0
   110
		    	sd.Append(comma);
sl@0
   111
		    	td.Num(height);
sl@0
   112
		    	sd.Append(td);
sl@0
   113
		    	tempArray->AppendL(sd);
sl@0
   114
		    	td.Delete(0,size+5);//the Delete()function adjusts this value to ensure that no data
sl@0
   115
		    	sd.Delete(0,size+5);//beyond the end of the descriptor data area is deleted.
sl@0
   116
		     	}
sl@0
   117
			}	
sl@0
   118
	    }
sl@0
   119
	    
sl@0
   120
    if(mimeTypeCtl)
sl@0
   121
		{
sl@0
   122
	  	//get supported frame rates
sl@0
   123
		mimeTypeCtl->SetArrayL(iArrVideoMimeType);
sl@0
   124
		mimeTypeCtl->SetArrayExternalOwnership(ETrue);
sl@0
   125
		TRAP(err,iAppUi->GetSupportedVideoTypesL(*iMimeTypeArray));	
sl@0
   126
		TInt counter=iMimeTypeArray->Count();
sl@0
   127
		for(TInt i=0; i<counter; i++)
sl@0
   128
			{
sl@0
   129
			TBuf16<16> temp;
sl@0
   130
			temp.Copy(iMimeTypeArray->MdcaPoint(i)); 		
sl@0
   131
			iArrVideoMimeType->AppendL(temp);
sl@0
   132
			}
sl@0
   133
		if(err == KErrNotSupported)	
sl@0
   134
			{
sl@0
   135
			_LIT(KFrameRateSupport, "Frame Rates not supported");
sl@0
   136
			User::InfoPrint(KFrameRateSupport);			
sl@0
   137
			}
sl@0
   138
		}
sl@0
   139
sl@0
   140
    if(restoresettings)
sl@0
   141
    	{
sl@0
   142
    	iSettings = restoresettings;
sl@0
   143
    	restoresettings->SetObserver(this);	
sl@0
   144
    	}
sl@0
   145
    if(audioenable)
sl@0
   146
    	{
sl@0
   147
    	iAudioEnableCtl = audioenable;
sl@0
   148
    	iAudioEnable = EFalse;
sl@0
   149
    	audioenable->SetObserver(this);
sl@0
   150
    	}
sl@0
   151
    }
sl@0
   152
sl@0
   153
sl@0
   154
CMVSConfigVideoFormatDialog::CMVSConfigVideoFormatDialog(CMVSAppUi* aAppUi,TUid aControllerId)
sl@0
   155
	:iContollerUid(aControllerId) , iAppUi(aAppUi)
sl@0
   156
    {
sl@0
   157
    } 
sl@0
   158
sl@0
   159
sl@0
   160
TKeyResponse CMVSConfigVideoFormatDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
sl@0
   161
	{
sl@0
   162
	if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
sl@0
   163
		{
sl@0
   164
		OkToExitL(EMVSButtonUpdate);
sl@0
   165
		}
sl@0
   166
	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
sl@0
   167
	}
sl@0
   168
sl@0
   169
sl@0
   170
TBool CMVSConfigVideoFormatDialog::OkToExitL(TInt aButtonId)
sl@0
   171
    {
sl@0
   172
    if(aButtonId == EMVSButtonCancel)
sl@0
   173
    	{
sl@0
   174
    	return ETrue;
sl@0
   175
    	}   
sl@0
   176
    CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));	
sl@0
   177
	 
sl@0
   178
	CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));
sl@0
   179
	
sl@0
   180
	CEikChoiceList* mimeTypeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoMimeCodec));
sl@0
   181
sl@0
   182
	if(frameRateCtl && frameSizeCtl && mimeTypeCtl)
sl@0
   183
		{
sl@0
   184
		if(iFrameRateIdx != -1)
sl@0
   185
			{
sl@0
   186
			iFrameRateIdx = frameRateCtl->CurrentItem();	
sl@0
   187
			}
sl@0
   188
		if(iFrameSizeIdx != -1)
sl@0
   189
			{
sl@0
   190
			iFrameSizeIdx = frameSizeCtl->CurrentItem();	
sl@0
   191
			}
sl@0
   192
	    iMimeTypeIdx = mimeTypeCtl->CurrentItem();
sl@0
   193
		iAppUi->WriteVideoDataL(this,iContollerUid);	
sl@0
   194
		}
sl@0
   195
	if(aButtonId == EMVSButtonUpdate)
sl@0
   196
		{
sl@0
   197
		if(iFrameRateIdx >= 0)
sl@0
   198
			{
sl@0
   199
		 	iAppUi->SetVideoFrameRateL(iFrameRateArray[iFrameRateIdx]);	
sl@0
   200
		 	}
sl@0
   201
		if(iFrameSizeIdx >= 0) 	 
sl@0
   202
			{
sl@0
   203
		 	iAppUi->SetVideoFrameSizeL(iFrameSizeArray[iFrameSizeIdx]);	
sl@0
   204
		 	}
sl@0
   205
		if(iAudioEnable)
sl@0
   206
			{
sl@0
   207
			iAppUi->SetAudioEnabledL(iAudioEnable);
sl@0
   208
			}
sl@0
   209
		if(iMimeTypeIdx)
sl@0
   210
			{
sl@0
   211
			iAppUi->SetVideoTypeL((*iMimeTypeArray)[iMimeTypeIdx]);
sl@0
   212
			}
sl@0
   213
		}
sl@0
   214
	return ETrue;
sl@0
   215
    }
sl@0
   216
sl@0
   217
sl@0
   218
void CMVSConfigVideoFormatDialog::InternalizeL(RReadStream& aStream)
sl@0
   219
	{
sl@0
   220
	iFrameRateIdx = aStream.ReadInt8L();
sl@0
   221
    iFrameSizeIdx = aStream.ReadInt8L();
sl@0
   222
	}
sl@0
   223
sl@0
   224
sl@0
   225
void CMVSConfigVideoFormatDialog::ExternalizeL(RWriteStream& aStream)
sl@0
   226
	{
sl@0
   227
	aStream.WriteInt8L(iFrameRateIdx);
sl@0
   228
	aStream.WriteInt8L(iFrameSizeIdx);	
sl@0
   229
	}
sl@0
   230
sl@0
   231
void CMVSConfigVideoFormatDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
sl@0
   232
	{
sl@0
   233
	CEikChoiceList* frameRateCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameRate));	
sl@0
   234
	 
sl@0
   235
	CEikChoiceList* frameSizeCtl = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectVideoFrameSize));	
sl@0
   236
	    
sl@0
   237
	CEikDialog::HandleControlEventL(aControl,aEventType);
sl@0
   238
	if(frameRateCtl && frameSizeCtl)
sl@0
   239
		{
sl@0
   240
		if(iSettings == aControl && aEventType == EEventStateChanged)
sl@0
   241
			{
sl@0
   242
			if(iRestoreSettings == EFalse)
sl@0
   243
				{
sl@0
   244
				iRestoreSettings = ETrue;
sl@0
   245
				}
sl@0
   246
			else
sl@0
   247
				{
sl@0
   248
				iRestoreSettings = EFalse;	
sl@0
   249
				}
sl@0
   250
			if(iRestoreSettings)
sl@0
   251
				{
sl@0
   252
				if(iFrameRateIdx>0)
sl@0
   253
					{
sl@0
   254
					frameRateCtl->SetCurrentItem(iFrameRateIdx);
sl@0
   255
					frameRateCtl->DrawDeferred();
sl@0
   256
					}
sl@0
   257
				if(iFrameSizeIdx>0)
sl@0
   258
					{
sl@0
   259
					frameSizeCtl->SetCurrentItem(iFrameSizeIdx);	
sl@0
   260
					frameSizeCtl->DrawDeferred();
sl@0
   261
					}
sl@0
   262
				}
sl@0
   263
			else
sl@0
   264
				{
sl@0
   265
				if(iFrameRateIdx >= 0)
sl@0
   266
					{
sl@0
   267
					frameRateCtl->SetCurrentItem(0);
sl@0
   268
	    			frameRateCtl->DrawDeferred();
sl@0
   269
					}
sl@0
   270
	    	
sl@0
   271
	    		if(iFrameSizeIdx >= 0)
sl@0
   272
	    			{
sl@0
   273
	    			frameSizeCtl->SetCurrentItem(0);	
sl@0
   274
	    			frameSizeCtl->DrawDeferred();
sl@0
   275
	    			}
sl@0
   276
				}
sl@0
   277
			return;
sl@0
   278
	    	}
sl@0
   279
	    if(iAudioEnableCtl == aControl && aEventType == EEventStateChanged)
sl@0
   280
	    	{
sl@0
   281
	    	if(iAudioEnable == EFalse)
sl@0
   282
	    		{
sl@0
   283
	    		iAudioEnable = ETrue;
sl@0
   284
	    		}
sl@0
   285
	    	else
sl@0
   286
	    		{
sl@0
   287
	    		iAudioEnable = EFalse;
sl@0
   288
	    		}
sl@0
   289
	    	return;
sl@0
   290
	    	}
sl@0
   291
		}
sl@0
   292
	}
sl@0
   293
sl@0
   294
sl@0
   295
CMVSConfigVideoFormatDialog::~CMVSConfigVideoFormatDialog()
sl@0
   296
	{
sl@0
   297
	iFrameRateArray.Close();
sl@0
   298
	iFrameSizeArray.Close();
sl@0
   299
	delete iArrFrameRate; 	  	          
sl@0
   300
	delete iArrFrameSize;
sl@0
   301
	delete iMimeTypeArray;
sl@0
   302
	delete iArrVideoMimeType;
sl@0
   303
	}