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