os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/ilbcdecoderconfigtestdevice.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/ilbcdecoderconfigtestdevice.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,217 @@
     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 "ilbcdecoderconfigtestdevice.h"
    1.23 +#include "devsoundciutestdevices.hrh"
    1.24 +
    1.25 +/*
    1.26 +CMMFIlbcDecoderConfig implementation
    1.27 +*/
    1.28 +CMMFIlbcDecoderConfig* CMMFIlbcDecoderConfig::NewL()
    1.29 +	{
    1.30 +	CMMFIlbcDecoderConfig* self = new(ELeave) CMMFIlbcDecoderConfig();
    1.31 +	return self;
    1.32 +	}
    1.33 +
    1.34 +CMMFIlbcDecoderConfig::~CMMFIlbcDecoderConfig()
    1.35 +	{
    1.36 +	}
    1.37 +
    1.38 +//Actual implementation of method SetDecoderMode
    1.39 +TInt CMMFIlbcDecoderConfig::SetDecoderMode(TDecodeMode aDecodeMode)
    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\\IlbcDecoderConfig.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<4> data;
    1.60 +	data.Format(_L8("%d"), aDecodeMode);
    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 SetCng
    1.70 +TInt CMMFIlbcDecoderConfig::SetComfortNoiseGeneration(TBool aCng)
    1.71 +	{
    1.72 +	iCng = aCng;
    1.73 +	return KErrNone;
    1.74 +	}
    1.75 +
    1.76 +//Actual implementation of method GetCng
    1.77 +TInt CMMFIlbcDecoderConfig::GetComfortNoiseGeneration(TBool& aCng)
    1.78 +	{
    1.79 +	aCng = iCng;
    1.80 +	return KErrNone;
    1.81 +	}
    1.82 +
    1.83 +
    1.84 +/*
    1.85 +CIlbcDecoderConfigTestDevice implementation
    1.86 +*/
    1.87 +CMMFHwDevice* CIlbcDecoderConfigTestDevice::NewL()
    1.88 +	{
    1.89 +	CIlbcDecoderConfigTestDevice* self=new(ELeave) CIlbcDecoderConfigTestDevice();
    1.90 +	CleanupStack::PushL(self);
    1.91 +	self->ConstructL();
    1.92 +	CleanupStack::Pop(self);
    1.93 +	return self;
    1.94 +	}
    1.95 +
    1.96 +CIlbcDecoderConfigTestDevice::~CIlbcDecoderConfigTestDevice()
    1.97 +	{
    1.98 +	delete iIlbcDecoderConfig;
    1.99 +	}
   1.100 +
   1.101 +CIlbcDecoderConfigTestDevice::CIlbcDecoderConfigTestDevice()
   1.102 +	{
   1.103 +	}
   1.104 +
   1.105 +void CIlbcDecoderConfigTestDevice::ConstructL()
   1.106 +	{
   1.107 +	}
   1.108 +
   1.109 +TInt CIlbcDecoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
   1.110 +	{
   1.111 +	return 0;
   1.112 +	}
   1.113 +
   1.114 +TInt CIlbcDecoderConfigTestDevice::Stop()
   1.115 +	{
   1.116 +	return 0;
   1.117 +	}
   1.118 +
   1.119 +TInt CIlbcDecoderConfigTestDevice::Pause()
   1.120 +	{
   1.121 +	return 0;
   1.122 +	}
   1.123 +
   1.124 +TInt CIlbcDecoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
   1.125 +	{
   1.126 +	return 0;
   1.127 +	}
   1.128 +
   1.129 +TAny* CIlbcDecoderConfigTestDevice::CustomInterface(TUid aInterfaceId)
   1.130 +	{
   1.131 +	// Just return something non-NULL to keep the
   1.132 +	// DevSound initialisation process happy
   1.133 +	TAny* ret = static_cast<TAny*>(this);
   1.134 +
   1.135 +	// Now for the CIs we want to test...
   1.136 +	if (aInterfaceId == KUidIlbcDecoderIntfc)
   1.137 +		{
   1.138 +		if (!iIlbcDecoderConfig)
   1.139 +			{
   1.140 +			TRAPD(err, iIlbcDecoderConfig = CMMFIlbcDecoderConfig::NewL());
   1.141 +			if (err == KErrNone && iIlbcDecoderConfig)
   1.142 +				{
   1.143 +				MIlbcDecoderIntfc* ptr = this;
   1.144 +				ret = static_cast<TAny*>(ptr);
   1.145 +				}
   1.146 +			else
   1.147 +				{
   1.148 +				ret = NULL;
   1.149 +				}
   1.150 +			}
   1.151 +		}
   1.152 +
   1.153 +	return ret;
   1.154 +	}
   1.155 +
   1.156 +TInt CIlbcDecoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
   1.157 +	{
   1.158 +	return 0;
   1.159 +	}
   1.160 +
   1.161 +TInt CIlbcDecoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
   1.162 +	{
   1.163 +	return 0;
   1.164 +	}
   1.165 +
   1.166 +TInt CIlbcDecoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   1.167 +	{
   1.168 +	return 0;
   1.169 +	}
   1.170 +
   1.171 +TInt CIlbcDecoderConfigTestDevice::StopAndDeleteCodec()
   1.172 +	{
   1.173 +	return 0;
   1.174 +	}
   1.175 +
   1.176 +TInt CIlbcDecoderConfigTestDevice::DeleteCodec()
   1.177 +	{
   1.178 +	return 0;
   1.179 +	}
   1.180 +
   1.181 +CMMFSwCodec& CIlbcDecoderConfigTestDevice::Codec()
   1.182 +	{
   1.183 +	return *iCodec;
   1.184 +	}
   1.185 +
   1.186 +TInt CIlbcDecoderConfigTestDevice::SetDecoderMode(TDecodeMode aDecodeMode)
   1.187 +	{
   1.188 +	TInt result = KErrBadHandle;
   1.189 +
   1.190 +	if (iIlbcDecoderConfig)
   1.191 +		{
   1.192 +		result = iIlbcDecoderConfig->SetDecoderMode(aDecodeMode);
   1.193 +		}
   1.194 +
   1.195 +	return result;
   1.196 +	}
   1.197 +
   1.198 +TInt CIlbcDecoderConfigTestDevice::SetComfortNoiseGeneration(TBool aCng)
   1.199 +	{
   1.200 +	TInt result = KErrBadHandle;
   1.201 +
   1.202 +	if (iIlbcDecoderConfig)
   1.203 +		{
   1.204 +		result = iIlbcDecoderConfig->SetComfortNoiseGeneration(aCng);
   1.205 +		}
   1.206 +
   1.207 +	return result;
   1.208 +	}
   1.209 +
   1.210 +TInt CIlbcDecoderConfigTestDevice::GetComfortNoiseGeneration(TBool& aCng)
   1.211 +	{
   1.212 +	TInt result = KErrBadHandle;
   1.213 +
   1.214 +	if (iIlbcDecoderConfig)
   1.215 +		{
   1.216 +		result = iIlbcDecoderConfig->GetComfortNoiseGeneration(aCng);
   1.217 +		}
   1.218 +
   1.219 +	return result;
   1.220 +	}