os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/g729encoderconfigtestdevice.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/g729encoderconfigtestdevice.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,223 @@
     1.4 +// Copyright (c) 2007-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 +//
    1.18 +
    1.19 +#include <ecom/implementationproxy.h>
    1.20 +#include <ecom/ecom.h>
    1.21 +#include <f32file.h>
    1.22 +#include "g729encoderconfigtestdevice.h"
    1.23 +#include "devsoundciutestdevices.hrh"
    1.24 +
    1.25 +/*
    1.26 +CMMFG729EncoderConfig implementation
    1.27 +*/
    1.28 +CMMFG729EncoderConfig* CMMFG729EncoderConfig::NewL()
    1.29 +	{
    1.30 +	CMMFG729EncoderConfig* self = new(ELeave) CMMFG729EncoderConfig();
    1.31 +	return self;
    1.32 +	}
    1.33 +
    1.34 +CMMFG729EncoderConfig::~CMMFG729EncoderConfig()
    1.35 +	{
    1.36 +	}
    1.37 +
    1.38 +//Actual implementation of method SetVadMode
    1.39 +TInt CMMFG729EncoderConfig::SetVadMode(TBool aVadModeOn)
    1.40 +	{
    1.41 +	RFs		fs;
    1.42 +	RFile	file;
    1.43 +	TInt	err = KErrNone;
    1.44 +
    1.45 +	if ( KErrNone != (err = fs.Connect()) )
    1.46 +		{
    1.47 +		return err;
    1.48 +		}
    1.49 +
    1.50 +	// this file name will be use on the testStep to compare the stored value.
    1.51 +	_LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt");
    1.52 +	fs.MkDirAll(KFileName);
    1.53 +
    1.54 +	if ( KErrNone != (err = file.Replace(fs, KFileName, EFileWrite)) )
    1.55 +		{
    1.56 +		return err;	
    1.57 +		}
    1.58 +
    1.59 +	TBuf8<1> data;
    1.60 +	data.Format(_L8("%d"), aVadModeOn);
    1.61 +
    1.62 +	file.Write(data);
    1.63 +	file.Close();
    1.64 +	fs.Close();
    1.65 +
    1.66 +	return err;
    1.67 +	}
    1.68 +
    1.69 +//Actual implementation of method GetVadMode
    1.70 +TInt CMMFG729EncoderConfig::GetVadMode(TBool& aVadModeOn)
    1.71 +	{
    1.72 +	RFs		fs;
    1.73 +	RFile	file;
    1.74 +	TInt	err = KErrNone;
    1.75 +
    1.76 +	if ( KErrNone != (err = fs.Connect()) )
    1.77 +		{
    1.78 +		return err;
    1.79 +		}
    1.80 +
    1.81 +	// this file name will be use on the testStep to compare the stored value.
    1.82 +	_LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt");
    1.83 +
    1.84 +	if ( KErrNone != (err = file.Open(fs, KFileName, EFileRead)) )
    1.85 +		{
    1.86 +		return err;	
    1.87 +		}
    1.88 +
    1.89 +	TBuf8<4> data;
    1.90 +	file.Read(data);
    1.91 +	file.Close();
    1.92 +
    1.93 +	fs.Delete(KFileName);
    1.94 +	fs.Close();
    1.95 +
    1.96 +	aVadModeOn = (data.Compare(_L8("0")) == 0) ? EFalse : ETrue;
    1.97 +
    1.98 +	return err;
    1.99 +	}
   1.100 +
   1.101 +
   1.102 +/*
   1.103 +CG729EncoderConfigTestDevice implementation
   1.104 +*/
   1.105 +CMMFHwDevice* CG729EncoderConfigTestDevice::NewL()
   1.106 +	{
   1.107 +	CG729EncoderConfigTestDevice* self=new(ELeave) CG729EncoderConfigTestDevice();
   1.108 +	CleanupStack::PushL(self);
   1.109 +	self->ConstructL();
   1.110 +	CleanupStack::Pop(self);
   1.111 +	return self;
   1.112 +	}
   1.113 +
   1.114 +CG729EncoderConfigTestDevice::~CG729EncoderConfigTestDevice()
   1.115 +	{
   1.116 +	delete iG729EncoderConfig;
   1.117 +	}
   1.118 +
   1.119 +CG729EncoderConfigTestDevice::CG729EncoderConfigTestDevice()
   1.120 +	{
   1.121 +	}
   1.122 +
   1.123 +void CG729EncoderConfigTestDevice::ConstructL()
   1.124 +	{
   1.125 +	}
   1.126 +
   1.127 +TInt CG729EncoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
   1.128 +	{
   1.129 +	return 0;
   1.130 +	}
   1.131 +
   1.132 +TInt CG729EncoderConfigTestDevice::Stop()
   1.133 +	{
   1.134 +	return 0;
   1.135 +	}
   1.136 +
   1.137 +TInt CG729EncoderConfigTestDevice::Pause()
   1.138 +	{
   1.139 +	return 0;
   1.140 +	}
   1.141 +
   1.142 +TInt CG729EncoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
   1.143 +	{
   1.144 +	return 0;
   1.145 +	}
   1.146 +
   1.147 +TAny* CG729EncoderConfigTestDevice::CustomInterface(TUid aInterfaceId)
   1.148 +	{
   1.149 +	// Just return something non-NULL to keep the
   1.150 +	// DevSound initialisation process happy
   1.151 +	TAny* ret = static_cast<TAny*>(this);
   1.152 +
   1.153 +	// Now for the CIs we want to test...
   1.154 +	if (aInterfaceId == KUidG729EncoderIntfc)
   1.155 +		{
   1.156 +		if (!iG729EncoderConfig)
   1.157 +			{
   1.158 +			TRAPD(err, iG729EncoderConfig = CMMFG729EncoderConfig::NewL());
   1.159 +			if (err == KErrNone && iG729EncoderConfig)
   1.160 +				{
   1.161 +				MG729EncoderIntfc* ptr = this;
   1.162 +				ret = static_cast<TAny*>(ptr);
   1.163 +				}
   1.164 +			else
   1.165 +				{
   1.166 +				ret = NULL;
   1.167 +				}
   1.168 +			}
   1.169 +		}
   1.170 +
   1.171 +	return ret;
   1.172 +	}
   1.173 +
   1.174 +TInt CG729EncoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
   1.175 +	{
   1.176 +	return 0;
   1.177 +	}
   1.178 +
   1.179 +TInt CG729EncoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
   1.180 +	{
   1.181 +	return 0;
   1.182 +	}
   1.183 +
   1.184 +TInt CG729EncoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   1.185 +	{
   1.186 +	return 0;
   1.187 +	}
   1.188 +
   1.189 +TInt CG729EncoderConfigTestDevice::StopAndDeleteCodec()
   1.190 +	{
   1.191 +	return 0;
   1.192 +	}
   1.193 +
   1.194 +TInt CG729EncoderConfigTestDevice::DeleteCodec()
   1.195 +	{
   1.196 +	return 0;
   1.197 +	}
   1.198 +
   1.199 +CMMFSwCodec& CG729EncoderConfigTestDevice::Codec()
   1.200 +	{
   1.201 +	return *iCodec;
   1.202 +	}
   1.203 +
   1.204 +TInt CG729EncoderConfigTestDevice::SetVadMode(TBool aVadModeOn)
   1.205 +	{
   1.206 +	TInt result = KErrBadHandle;
   1.207 +
   1.208 +	if (iG729EncoderConfig)
   1.209 +		{
   1.210 +		result = iG729EncoderConfig->SetVadMode(aVadModeOn);
   1.211 +		}
   1.212 +
   1.213 +	return result;
   1.214 +	}
   1.215 +
   1.216 +TInt CG729EncoderConfigTestDevice::GetVadMode(TBool& aVadModeOn)
   1.217 +	{
   1.218 +	TInt result = KErrBadHandle;
   1.219 +
   1.220 +	if (iG729EncoderConfig)
   1.221 +		{
   1.222 +		result = iG729EncoderConfig->GetVadMode(aVadModeOn);
   1.223 +		}
   1.224 +
   1.225 +	return result;
   1.226 +	}