devsound/devsoundrefplugin/tsrc/CIPlugins/src/g729encoderconfigtestdevice.cpp
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <ecom/implementationproxy.h>
       
    17 #include <ecom/ecom.h>
       
    18 #include <f32file.h>
       
    19 #include "g729encoderconfigtestdevice.h"
       
    20 #include "devsoundciutestdevices.hrh"
       
    21 
       
    22 /*
       
    23 CMMFG729EncoderConfig implementation
       
    24 */
       
    25 CMMFG729EncoderConfig* CMMFG729EncoderConfig::NewL()
       
    26 	{
       
    27 	CMMFG729EncoderConfig* self = new(ELeave) CMMFG729EncoderConfig();
       
    28 	return self;
       
    29 	}
       
    30 
       
    31 CMMFG729EncoderConfig::~CMMFG729EncoderConfig()
       
    32 	{
       
    33 	}
       
    34 
       
    35 //Actual implementation of method SetVadMode
       
    36 TInt CMMFG729EncoderConfig::SetVadMode(TBool aVadModeOn)
       
    37 	{
       
    38 	RFs		fs;
       
    39 	RFile	file;
       
    40 	TInt	err = KErrNone;
       
    41 
       
    42 	if ( KErrNone != (err = fs.Connect()) )
       
    43 		{
       
    44 		return err;
       
    45 		}
       
    46 
       
    47 	// this file name will be use on the testStep to compare the stored value.
       
    48 	_LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt");
       
    49 	fs.MkDirAll(KFileName);
       
    50 
       
    51 	if ( KErrNone != (err = file.Replace(fs, KFileName, EFileWrite)) )
       
    52 		{
       
    53 		return err;	
       
    54 		}
       
    55 
       
    56 	TBuf8<1> data;
       
    57 	data.Format(_L8("%d"), aVadModeOn);
       
    58 
       
    59 	file.Write(data);
       
    60 	file.Close();
       
    61 	fs.Close();
       
    62 
       
    63 	return err;
       
    64 	}
       
    65 
       
    66 //Actual implementation of method GetVadMode
       
    67 TInt CMMFG729EncoderConfig::GetVadMode(TBool& aVadModeOn)
       
    68 	{
       
    69 	RFs		fs;
       
    70 	RFile	file;
       
    71 	TInt	err = KErrNone;
       
    72 
       
    73 	if ( KErrNone != (err = fs.Connect()) )
       
    74 		{
       
    75 		return err;
       
    76 		}
       
    77 
       
    78 	// this file name will be use on the testStep to compare the stored value.
       
    79 	_LIT(KFileName, "c:\\temp\\g729EncoderConfig.txt");
       
    80 
       
    81 	if ( KErrNone != (err = file.Open(fs, KFileName, EFileRead)) )
       
    82 		{
       
    83 		return err;	
       
    84 		}
       
    85 
       
    86 	TBuf8<4> data;
       
    87 	file.Read(data);
       
    88 	file.Close();
       
    89 
       
    90 	fs.Delete(KFileName);
       
    91 	fs.Close();
       
    92 
       
    93 	aVadModeOn = (data.Compare(_L8("0")) == 0) ? EFalse : ETrue;
       
    94 
       
    95 	return err;
       
    96 	}
       
    97 
       
    98 
       
    99 /*
       
   100 CG729EncoderConfigTestDevice implementation
       
   101 */
       
   102 CMMFHwDevice* CG729EncoderConfigTestDevice::NewL()
       
   103 	{
       
   104 	CG729EncoderConfigTestDevice* self=new(ELeave) CG729EncoderConfigTestDevice();
       
   105 	CleanupStack::PushL(self);
       
   106 	self->ConstructL();
       
   107 	CleanupStack::Pop(self);
       
   108 	return self;
       
   109 	}
       
   110 
       
   111 CG729EncoderConfigTestDevice::~CG729EncoderConfigTestDevice()
       
   112 	{
       
   113 	delete iG729EncoderConfig;
       
   114 	}
       
   115 
       
   116 CG729EncoderConfigTestDevice::CG729EncoderConfigTestDevice()
       
   117 	{
       
   118 	}
       
   119 
       
   120 void CG729EncoderConfigTestDevice::ConstructL()
       
   121 	{
       
   122 	}
       
   123 
       
   124 TInt CG729EncoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
       
   125 	{
       
   126 	return 0;
       
   127 	}
       
   128 
       
   129 TInt CG729EncoderConfigTestDevice::Stop()
       
   130 	{
       
   131 	return 0;
       
   132 	}
       
   133 
       
   134 TInt CG729EncoderConfigTestDevice::Pause()
       
   135 	{
       
   136 	return 0;
       
   137 	}
       
   138 
       
   139 TInt CG729EncoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
       
   140 	{
       
   141 	return 0;
       
   142 	}
       
   143 
       
   144 TAny* CG729EncoderConfigTestDevice::CustomInterface(TUid aInterfaceId)
       
   145 	{
       
   146 	// Just return something non-NULL to keep the
       
   147 	// DevSound initialisation process happy
       
   148 	TAny* ret = static_cast<TAny*>(this);
       
   149 
       
   150 	// Now for the CIs we want to test...
       
   151 	if (aInterfaceId == KUidG729EncoderIntfc)
       
   152 		{
       
   153 		if (!iG729EncoderConfig)
       
   154 			{
       
   155 			TRAPD(err, iG729EncoderConfig = CMMFG729EncoderConfig::NewL());
       
   156 			if (err == KErrNone && iG729EncoderConfig)
       
   157 				{
       
   158 				MG729EncoderIntfc* ptr = this;
       
   159 				ret = static_cast<TAny*>(ptr);
       
   160 				}
       
   161 			else
       
   162 				{
       
   163 				ret = NULL;
       
   164 				}
       
   165 			}
       
   166 		}
       
   167 
       
   168 	return ret;
       
   169 	}
       
   170 
       
   171 TInt CG729EncoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
       
   172 	{
       
   173 	return 0;
       
   174 	}
       
   175 
       
   176 TInt CG729EncoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
       
   177 	{
       
   178 	return 0;
       
   179 	}
       
   180 
       
   181 TInt CG729EncoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
       
   182 	{
       
   183 	return 0;
       
   184 	}
       
   185 
       
   186 TInt CG729EncoderConfigTestDevice::StopAndDeleteCodec()
       
   187 	{
       
   188 	return 0;
       
   189 	}
       
   190 
       
   191 TInt CG729EncoderConfigTestDevice::DeleteCodec()
       
   192 	{
       
   193 	return 0;
       
   194 	}
       
   195 
       
   196 CMMFSwCodec& CG729EncoderConfigTestDevice::Codec()
       
   197 	{
       
   198 	return *iCodec;
       
   199 	}
       
   200 
       
   201 TInt CG729EncoderConfigTestDevice::SetVadMode(TBool aVadModeOn)
       
   202 	{
       
   203 	TInt result = KErrBadHandle;
       
   204 
       
   205 	if (iG729EncoderConfig)
       
   206 		{
       
   207 		result = iG729EncoderConfig->SetVadMode(aVadModeOn);
       
   208 		}
       
   209 
       
   210 	return result;
       
   211 	}
       
   212 
       
   213 TInt CG729EncoderConfigTestDevice::GetVadMode(TBool& aVadModeOn)
       
   214 	{
       
   215 	TInt result = KErrBadHandle;
       
   216 
       
   217 	if (iG729EncoderConfig)
       
   218 		{
       
   219 		result = iG729EncoderConfig->GetVadMode(aVadModeOn);
       
   220 		}
       
   221 
       
   222 	return result;
       
   223 	}