devsound/devsoundrefplugin/tsrc/CIPlugins/src/g711encoderconfigtestdevice.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 "g711encoderconfigtestdevice.h"
       
    20 #include "devsoundciutestdevices.hrh"
       
    21 
       
    22 
       
    23 /*
       
    24 CMMFG711EncoderConfig implementation
       
    25 */
       
    26 CMMFG711EncoderConfig* CMMFG711EncoderConfig::NewL()
       
    27 	{
       
    28 	CMMFG711EncoderConfig* self = new(ELeave) CMMFG711EncoderConfig();
       
    29 	return self;
       
    30 	}
       
    31 
       
    32 CMMFG711EncoderConfig::~CMMFG711EncoderConfig()
       
    33 	{
       
    34 	}
       
    35 
       
    36 //Actual implementation of method SetEncoderMode
       
    37 TInt CMMFG711EncoderConfig::SetEncoderMode(TEncodeMode aEncodeMode)
       
    38 	{
       
    39 	RFs		fs;
       
    40 	RFile	file;
       
    41 	TInt	err = KErrNone;
       
    42 
       
    43 	if ( KErrNone != (err = fs.Connect()) )
       
    44 		{
       
    45 		return err;
       
    46 		}
       
    47 
       
    48 	// this file name will be use on the testStep to compare the stored value.	
       
    49 	_LIT(KFileName, "c:\\temp\\g711EncoderConfig.txt");
       
    50 	fs.MkDirAll(KFileName);
       
    51 
       
    52 	if ( KErrNone != (err = file.Replace(fs, KFileName, EFileWrite)) )
       
    53 		{
       
    54 		return err;	
       
    55 		}
       
    56 
       
    57 	TBuf8<4> data;
       
    58 	data.Format(_L8("%d"), aEncodeMode);
       
    59 
       
    60 	file.Write(data);
       
    61 	file.Close();
       
    62 	fs.Close();
       
    63 
       
    64 	return err;
       
    65 	}
       
    66 
       
    67 //Actual implementation of method SetVadMode
       
    68 TInt CMMFG711EncoderConfig::SetVadMode(TBool aVadModeOn)
       
    69 	{
       
    70 	iVadModeOn = aVadModeOn;
       
    71 	return KErrNone;
       
    72 	}
       
    73 
       
    74 //Actual implementation of method GetVadMode
       
    75 TInt CMMFG711EncoderConfig::GetVadMode(TBool& aVadModeOn)
       
    76 	{
       
    77 	aVadModeOn = iVadModeOn;
       
    78 	return KErrNone;
       
    79 	}
       
    80 
       
    81 
       
    82 /*
       
    83 CG711EncoderConfigTestDevice implementation
       
    84 */
       
    85 CMMFHwDevice* CG711EncoderConfigTestDevice::NewL()
       
    86 	{
       
    87 	CG711EncoderConfigTestDevice* self=new(ELeave) CG711EncoderConfigTestDevice();
       
    88 	CleanupStack::PushL(self);
       
    89 	self->ConstructL();
       
    90 	CleanupStack::Pop(self);
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 CG711EncoderConfigTestDevice::~CG711EncoderConfigTestDevice()
       
    95 	{
       
    96 	delete iG711EncoderConfig;
       
    97 	}
       
    98 
       
    99 CG711EncoderConfigTestDevice::CG711EncoderConfigTestDevice()
       
   100 	{
       
   101 	}
       
   102 
       
   103 void CG711EncoderConfigTestDevice::ConstructL()
       
   104 	{
       
   105 	}
       
   106 
       
   107 TInt CG711EncoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
       
   108 	{
       
   109 	return 0;
       
   110 	}
       
   111 
       
   112 TInt CG711EncoderConfigTestDevice::Stop()
       
   113 	{
       
   114 	return 0;
       
   115 	}
       
   116 
       
   117 TInt CG711EncoderConfigTestDevice::Pause()
       
   118 	{
       
   119 	return 0;
       
   120 	}
       
   121 
       
   122 TInt CG711EncoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
       
   123 	{
       
   124 	return 0;
       
   125 	}
       
   126 
       
   127 TAny* CG711EncoderConfigTestDevice::CustomInterface(TUid aInterfaceId)
       
   128 	{
       
   129 	// Just return something non-NULL to keep the
       
   130 	// DevSound initialisation process happy
       
   131 	TAny* ret = static_cast<TAny*>(this);
       
   132 
       
   133 	// Now for the CIs we want to test...
       
   134 	if (aInterfaceId == KUidG711EncoderIntfc)
       
   135 		{
       
   136 		if (!iG711EncoderConfig)
       
   137 			{
       
   138 			TRAPD(err, iG711EncoderConfig = CMMFG711EncoderConfig::NewL());
       
   139 			if (err == KErrNone && iG711EncoderConfig)
       
   140 				{
       
   141 				MG711EncoderIntfc* ptr = this;
       
   142 				ret = static_cast<TAny*>(ptr);
       
   143 				}
       
   144 			else
       
   145 				{
       
   146 				ret = NULL;
       
   147 				}
       
   148 			}
       
   149 		}
       
   150 
       
   151 	return ret;
       
   152 	}
       
   153 
       
   154 TInt CG711EncoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
       
   155 	{
       
   156 	return 0;
       
   157 	}
       
   158 
       
   159 TInt CG711EncoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
       
   160 	{
       
   161 	return 0;
       
   162 	}
       
   163 
       
   164 TInt CG711EncoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
       
   165 	{
       
   166 	return 0;
       
   167 	}
       
   168 
       
   169 TInt CG711EncoderConfigTestDevice::StopAndDeleteCodec()
       
   170 	{
       
   171 	return 0;
       
   172 	}
       
   173 
       
   174 TInt CG711EncoderConfigTestDevice::DeleteCodec()
       
   175 	{
       
   176 	return 0;
       
   177 	}
       
   178 
       
   179 CMMFSwCodec& CG711EncoderConfigTestDevice::Codec()
       
   180 	{
       
   181 	return *iCodec;
       
   182 	}
       
   183 
       
   184 TInt CG711EncoderConfigTestDevice::SetEncoderMode(TEncodeMode aEncodeMode)
       
   185 	{
       
   186 	TInt result = KErrBadHandle;
       
   187 
       
   188 	if (iG711EncoderConfig)
       
   189 		{
       
   190 		result = iG711EncoderConfig->SetEncoderMode(aEncodeMode);
       
   191 		}
       
   192 
       
   193 	return result;
       
   194 	}
       
   195 
       
   196 TInt CG711EncoderConfigTestDevice::SetVadMode(TBool aVadModeOn)
       
   197 	{
       
   198 	TInt result = KErrBadHandle;
       
   199 
       
   200 	if (iG711EncoderConfig)
       
   201 		{
       
   202 		result = iG711EncoderConfig->SetVadMode(aVadModeOn);
       
   203 		}
       
   204 
       
   205 	return result;
       
   206 	}
       
   207 
       
   208 TInt CG711EncoderConfigTestDevice::GetVadMode(TBool& aVadModeOn)
       
   209 	{
       
   210 	TInt result = KErrBadHandle;
       
   211 
       
   212 	if (iG711EncoderConfig)
       
   213 		{
       
   214 		result = iG711EncoderConfig->GetVadMode(aVadModeOn);
       
   215 		}
       
   216 
       
   217 	return result;
       
   218 	}