os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/ilbcdecoderconfigtestdevice.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 "ilbcdecoderconfigtestdevice.h"
    20 #include "devsoundciutestdevices.hrh"
    21 
    22 /*
    23 CMMFIlbcDecoderConfig implementation
    24 */
    25 CMMFIlbcDecoderConfig* CMMFIlbcDecoderConfig::NewL()
    26 	{
    27 	CMMFIlbcDecoderConfig* self = new(ELeave) CMMFIlbcDecoderConfig();
    28 	return self;
    29 	}
    30 
    31 CMMFIlbcDecoderConfig::~CMMFIlbcDecoderConfig()
    32 	{
    33 	}
    34 
    35 //Actual implementation of method SetDecoderMode
    36 TInt CMMFIlbcDecoderConfig::SetDecoderMode(TDecodeMode aDecodeMode)
    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\\IlbcDecoderConfig.txt");
    49 	fs.MkDirAll(KFileName);
    50 
    51 	if ( KErrNone != (err = file.Replace(fs, KFileName, EFileWrite)) )
    52 		{
    53 		return err;	
    54 		}
    55 
    56 	TBuf8<4> data;
    57 	data.Format(_L8("%d"), aDecodeMode);
    58 
    59 	file.Write(data);
    60 	file.Close();
    61 	fs.Close();
    62 
    63 	return err;
    64 	}
    65 
    66 //Actual implementation of method SetCng
    67 TInt CMMFIlbcDecoderConfig::SetComfortNoiseGeneration(TBool aCng)
    68 	{
    69 	iCng = aCng;
    70 	return KErrNone;
    71 	}
    72 
    73 //Actual implementation of method GetCng
    74 TInt CMMFIlbcDecoderConfig::GetComfortNoiseGeneration(TBool& aCng)
    75 	{
    76 	aCng = iCng;
    77 	return KErrNone;
    78 	}
    79 
    80 
    81 /*
    82 CIlbcDecoderConfigTestDevice implementation
    83 */
    84 CMMFHwDevice* CIlbcDecoderConfigTestDevice::NewL()
    85 	{
    86 	CIlbcDecoderConfigTestDevice* self=new(ELeave) CIlbcDecoderConfigTestDevice();
    87 	CleanupStack::PushL(self);
    88 	self->ConstructL();
    89 	CleanupStack::Pop(self);
    90 	return self;
    91 	}
    92 
    93 CIlbcDecoderConfigTestDevice::~CIlbcDecoderConfigTestDevice()
    94 	{
    95 	delete iIlbcDecoderConfig;
    96 	}
    97 
    98 CIlbcDecoderConfigTestDevice::CIlbcDecoderConfigTestDevice()
    99 	{
   100 	}
   101 
   102 void CIlbcDecoderConfigTestDevice::ConstructL()
   103 	{
   104 	}
   105 
   106 TInt CIlbcDecoderConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
   107 	{
   108 	return 0;
   109 	}
   110 
   111 TInt CIlbcDecoderConfigTestDevice::Stop()
   112 	{
   113 	return 0;
   114 	}
   115 
   116 TInt CIlbcDecoderConfigTestDevice::Pause()
   117 	{
   118 	return 0;
   119 	}
   120 
   121 TInt CIlbcDecoderConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
   122 	{
   123 	return 0;
   124 	}
   125 
   126 TAny* CIlbcDecoderConfigTestDevice::CustomInterface(TUid aInterfaceId)
   127 	{
   128 	// Just return something non-NULL to keep the
   129 	// DevSound initialisation process happy
   130 	TAny* ret = static_cast<TAny*>(this);
   131 
   132 	// Now for the CIs we want to test...
   133 	if (aInterfaceId == KUidIlbcDecoderIntfc)
   134 		{
   135 		if (!iIlbcDecoderConfig)
   136 			{
   137 			TRAPD(err, iIlbcDecoderConfig = CMMFIlbcDecoderConfig::NewL());
   138 			if (err == KErrNone && iIlbcDecoderConfig)
   139 				{
   140 				MIlbcDecoderIntfc* ptr = this;
   141 				ret = static_cast<TAny*>(ptr);
   142 				}
   143 			else
   144 				{
   145 				ret = NULL;
   146 				}
   147 			}
   148 		}
   149 
   150 	return ret;
   151 	}
   152 
   153 TInt CIlbcDecoderConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
   154 	{
   155 	return 0;
   156 	}
   157 
   158 TInt CIlbcDecoderConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
   159 	{
   160 	return 0;
   161 	}
   162 
   163 TInt CIlbcDecoderConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   164 	{
   165 	return 0;
   166 	}
   167 
   168 TInt CIlbcDecoderConfigTestDevice::StopAndDeleteCodec()
   169 	{
   170 	return 0;
   171 	}
   172 
   173 TInt CIlbcDecoderConfigTestDevice::DeleteCodec()
   174 	{
   175 	return 0;
   176 	}
   177 
   178 CMMFSwCodec& CIlbcDecoderConfigTestDevice::Codec()
   179 	{
   180 	return *iCodec;
   181 	}
   182 
   183 TInt CIlbcDecoderConfigTestDevice::SetDecoderMode(TDecodeMode aDecodeMode)
   184 	{
   185 	TInt result = KErrBadHandle;
   186 
   187 	if (iIlbcDecoderConfig)
   188 		{
   189 		result = iIlbcDecoderConfig->SetDecoderMode(aDecodeMode);
   190 		}
   191 
   192 	return result;
   193 	}
   194 
   195 TInt CIlbcDecoderConfigTestDevice::SetComfortNoiseGeneration(TBool aCng)
   196 	{
   197 	TInt result = KErrBadHandle;
   198 
   199 	if (iIlbcDecoderConfig)
   200 		{
   201 		result = iIlbcDecoderConfig->SetComfortNoiseGeneration(aCng);
   202 		}
   203 
   204 	return result;
   205 	}
   206 
   207 TInt CIlbcDecoderConfigTestDevice::GetComfortNoiseGeneration(TBool& aCng)
   208 	{
   209 	TInt result = KErrBadHandle;
   210 
   211 	if (iIlbcDecoderConfig)
   212 		{
   213 		result = iIlbcDecoderConfig->GetComfortNoiseGeneration(aCng);
   214 		}
   215 
   216 	return result;
   217 	}