sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "g729encoderconfigtestdevice.h" sl@0: #include "devsoundciutestdevices.hrh" sl@0: sl@0: /* sl@0: CMMFG729EncoderConfig implementation sl@0: */ sl@0: CMMFG729EncoderConfig* CMMFG729EncoderConfig::NewL() sl@0: { sl@0: CMMFG729EncoderConfig* self = new(ELeave) CMMFG729EncoderConfig(); sl@0: return self; sl@0: } sl@0: sl@0: CMMFG729EncoderConfig::~CMMFG729EncoderConfig() sl@0: { sl@0: } sl@0: sl@0: //Actual implementation of method SetVadMode sl@0: TInt CMMFG729EncoderConfig::SetVadMode(TBool aVadModeOn) sl@0: { sl@0: RFs fs; sl@0: RFile file; sl@0: TInt err = KErrNone; sl@0: sl@0: if ( KErrNone != (err = fs.Connect()) ) sl@0: { sl@0: return err; sl@0: } sl@0: sl@0: // this file name will be use on the testStep to compare the stored value. sl@0: _LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt"); sl@0: fs.MkDirAll(KFileName); sl@0: sl@0: if ( KErrNone != (err = file.Replace(fs, KFileName, EFileWrite)) ) sl@0: { sl@0: return err; sl@0: } sl@0: sl@0: TBuf8<1> data; sl@0: data.Format(_L8("%d"), aVadModeOn); sl@0: sl@0: file.Write(data); sl@0: file.Close(); sl@0: fs.Close(); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: //Actual implementation of method GetVadMode sl@0: TInt CMMFG729EncoderConfig::GetVadMode(TBool& aVadModeOn) sl@0: { sl@0: RFs fs; sl@0: RFile file; sl@0: TInt err = KErrNone; sl@0: sl@0: if ( KErrNone != (err = fs.Connect()) ) sl@0: { sl@0: return err; sl@0: } sl@0: sl@0: // this file name will be use on the testStep to compare the stored value. sl@0: _LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt"); sl@0: sl@0: if ( KErrNone != (err = file.Open(fs, KFileName, EFileRead)) ) sl@0: { sl@0: return err; sl@0: } sl@0: sl@0: TBuf8<4> data; sl@0: file.Read(data); sl@0: file.Close(); sl@0: sl@0: fs.Delete(KFileName); sl@0: fs.Close(); sl@0: sl@0: aVadModeOn = (data.Compare(_L8("0")) == 0) ? EFalse : ETrue; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: /* sl@0: CG729EncoderConfigTestDevice implementation sl@0: */ sl@0: CMMFHwDevice* CG729EncoderConfigTestDevice::NewL() sl@0: { sl@0: CG729EncoderConfigTestDevice* self=new(ELeave) CG729EncoderConfigTestDevice(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CG729EncoderConfigTestDevice::~CG729EncoderConfigTestDevice() sl@0: { sl@0: delete iG729EncoderConfig; sl@0: } sl@0: sl@0: CG729EncoderConfigTestDevice::CG729EncoderConfigTestDevice() sl@0: { sl@0: } sl@0: sl@0: void CG729EncoderConfigTestDevice::ConstructL() sl@0: { sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::Stop() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::Pause() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TAny* CG729EncoderConfigTestDevice::CustomInterface(TUid aInterfaceId) sl@0: { sl@0: // Just return something non-NULL to keep the sl@0: // DevSound initialisation process happy sl@0: TAny* ret = static_cast(this); sl@0: sl@0: // Now for the CIs we want to test... sl@0: if (aInterfaceId == KUidG729EncoderIntfc) sl@0: { sl@0: if (!iG729EncoderConfig) sl@0: { sl@0: TRAPD(err, iG729EncoderConfig = CMMFG729EncoderConfig::NewL()); sl@0: if (err == KErrNone && iG729EncoderConfig) sl@0: { sl@0: MG729EncoderIntfc* ptr = this; sl@0: ret = static_cast(ptr); sl@0: } sl@0: else sl@0: { sl@0: ret = NULL; sl@0: } sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/) sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::StopAndDeleteCodec() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::DeleteCodec() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: CMMFSwCodec& CG729EncoderConfigTestDevice::Codec() sl@0: { sl@0: return *iCodec; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::SetVadMode(TBool aVadModeOn) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iG729EncoderConfig) sl@0: { sl@0: result = iG729EncoderConfig->SetVadMode(aVadModeOn); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: TInt CG729EncoderConfigTestDevice::GetVadMode(TBool& aVadModeOn) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iG729EncoderConfig) sl@0: { sl@0: result = iG729EncoderConfig->GetVadMode(aVadModeOn); sl@0: } sl@0: sl@0: return result; sl@0: }