os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/sbcencodertestdevice.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh>
    17 
    18 #include "sbcencodertestdevice.h"
    19 
    20 
    21 /*****************************************************************************/
    22 // Implementation
    23 
    24 CMMFHwDevice* CSbcEncoderTestDevice::NewL()
    25 	{
    26 	CSbcEncoderTestDevice* self = new(ELeave) CSbcEncoderTestDevice();
    27 	CleanupStack::PushL(self);
    28 	self->ConstructL();
    29 	CleanupStack::Pop(self);
    30 	return self;
    31 	}
    32 
    33 /*****************************************************************************/
    34 CSbcEncoderTestDevice::~CSbcEncoderTestDevice()
    35 	{
    36 	}
    37 
    38 /*****************************************************************************/
    39 CSbcEncoderTestDevice::CSbcEncoderTestDevice()
    40 	{
    41 	}
    42 
    43 /*****************************************************************************/
    44 void CSbcEncoderTestDevice::ConstructL()
    45 	{
    46 	}
    47 	
    48 /*****************************************************************************/
    49 TInt CSbcEncoderTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
    50 	{
    51 	return 0;
    52 	}
    53 
    54 /*****************************************************************************/
    55 TInt CSbcEncoderTestDevice::Stop()
    56 	{
    57 	return 0;
    58 	}
    59 	
    60 /*****************************************************************************/
    61 TInt CSbcEncoderTestDevice::Pause()
    62 	{
    63 	return 0;
    64 	}
    65 
    66 /*****************************************************************************/		
    67 TInt CSbcEncoderTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
    68 	{
    69 	return 0;
    70 	}
    71 	
    72 /*****************************************************************************/	
    73 TAny* CSbcEncoderTestDevice::CustomInterface(TUid aInterfaceId)
    74 	{
    75 	MSbcEncoderIntfc* interface = NULL;
    76 	
    77 	// DevSound initialisation requires something to be returned for both of
    78 	// these two uids: KMmfPlaySettingsCustomInterface, KMmfRecordSettingsCustomInterface
    79 	if ((aInterfaceId == KUidSbcEncoderIntfc) || // This interface
    80 		(aInterfaceId.iUid == KMmfPlaySettingsCustomInterface) ||
    81 		(aInterfaceId.iUid == KMmfRecordSettingsCustomInterface))
    82 		{
    83 		interface = this;
    84 		}
    85 	
    86 	return interface;
    87 	}
    88 
    89 /*****************************************************************************/
    90 TInt CSbcEncoderTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
    91 	{
    92 	return 0;
    93 	}
    94 	
    95 /*****************************************************************************/	
    96 TInt CSbcEncoderTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
    97 	{
    98 	return 0;
    99 	}
   100 	
   101 /*****************************************************************************/	
   102 TInt CSbcEncoderTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   103 	{
   104 	return 0;
   105 	}
   106 	
   107 /*****************************************************************************/	
   108 TInt CSbcEncoderTestDevice::StopAndDeleteCodec()
   109 	{
   110 	return 0;
   111 	}
   112 	
   113 /*****************************************************************************/	
   114 TInt CSbcEncoderTestDevice::DeleteCodec()
   115 	{
   116 	return 0;
   117 	}
   118 
   119 /*****************************************************************************/
   120 CMMFSwCodec& CSbcEncoderTestDevice::Codec()
   121 	{
   122 	return *iCodec;
   123 	}
   124 
   125 /*****************************************************************************/
   126 TInt CSbcEncoderTestDevice::GetSupportedSamplingFrequencies ( RArray<TUint>& aSamplingFrequencies )
   127 	{
   128 	TInt retVal = KErrNone;
   129 	// Assume the strategy is to hard code a set of frequencies...
   130 	//
   131 	// Reset the input array
   132 	aSamplingFrequencies.Reset();
   133 	// Populate the array
   134 	TUint value = 0;
   135 	for (TInt i = 0; i < 10; i++)
   136 		{
   137 		retVal = aSamplingFrequencies.Append(value);
   138 		if (retVal != KErrNone)
   139 			{
   140 			break;
   141 			}
   142 		value += 1000;
   143 		}
   144 
   145 	return retVal;
   146 	}
   147 
   148 TInt CSbcEncoderTestDevice::GetSupportedChannelModes ( RArray<TSbcChannelMode>& aChannelModes )
   149 	{
   150 	TInt retVal = KErrNone;
   151 	aChannelModes.Reset();
   152 	retVal = aChannelModes.Append(ESbcChannelMono);
   153 	if (retVal == KErrNone)
   154 		{
   155 		retVal = aChannelModes.Append(ESbcChannelDual);
   156 		if (retVal == KErrNone)
   157 			{
   158 			retVal = aChannelModes.Append(ESbcChannelStereo);
   159 			if (retVal == KErrNone)
   160 				{
   161 				retVal = aChannelModes.Append(ESbcChannelJointStereo);
   162 				}
   163 			}				
   164 		}
   165 	return retVal;
   166 	}
   167 
   168 TInt CSbcEncoderTestDevice::GetSupportedNumOfSubbands ( RArray<TUint>& aNumOfSubbands )
   169 	{
   170 	TInt retVal = KErrNone;
   171 	aNumOfSubbands.Reset();
   172 	TUint val = 100;
   173 	for (TInt i = 0; i < 5; i++)
   174 		{
   175 		retVal = aNumOfSubbands.Append(val);
   176 		if (retVal != KErrNone)
   177 			{
   178 			break;
   179 			}
   180 		val += 100;
   181 		}
   182 	return retVal;
   183 	}
   184  
   185 TInt CSbcEncoderTestDevice::GetSupportedAllocationMethods ( RArray<TSbcAllocationMethod>& aAllocationMethods )
   186 	{
   187 	TInt retVal = KErrNone;
   188 	aAllocationMethods.Reset();
   189 	retVal = aAllocationMethods.Append(ESbcAllocationSNR);
   190 	if (retVal == KErrNone)
   191 		{
   192 		retVal = aAllocationMethods.Append(ESbcAllocationLoudness);
   193 		}
   194 	return retVal;
   195 	}
   196 
   197 TInt CSbcEncoderTestDevice::GetSupportedNumOfBlocks ( RArray<TUint>& aNumOfBlocks )
   198 	{
   199 	TInt retVal = KErrNone;
   200 	aNumOfBlocks.Reset();
   201 	TUint val = 1;
   202 	for (TInt i = 0; i < 10; i++, val++)
   203 		{
   204 		retVal = aNumOfBlocks.Append(val);
   205 		if (retVal != KErrNone)
   206 			{
   207 			break;
   208 			}
   209 		}
   210 	return retVal;
   211 	}
   212 
   213 TInt CSbcEncoderTestDevice::GetSupportedBitpoolRange (TUint& aMinSupportedBitpoolSize, TUint& aMaxSupportedBitpoolSize)
   214 	{
   215 	// Arbitrary values
   216 	aMinSupportedBitpoolSize = 1;
   217 	aMaxSupportedBitpoolSize = 2;
   218 	
   219 	return KErrNone;
   220 	}
   221 
   222 void CSbcEncoderTestDevice::SetSamplingFrequency ( TUint aSamplingFrequency )
   223 	{
   224 	iSamplingFrequency = aSamplingFrequency;
   225 	}
   226 
   227 void CSbcEncoderTestDevice::SetChannelMode (TSbcChannelMode aChannelMode )
   228 	{
   229 	iChannelMode = aChannelMode;
   230 	}
   231 
   232 void CSbcEncoderTestDevice::SetNumOfSubbands ( TUint aNumOfSubbands )
   233 	{
   234 	iNumOfSubbands = aNumOfSubbands;
   235 	}
   236 
   237 void CSbcEncoderTestDevice::SetAllocationMethod (TSbcAllocationMethod aAllocationMethod )
   238 	{
   239 	iAllocMethod = aAllocationMethod;
   240 	}
   241 
   242 void CSbcEncoderTestDevice::SetBitpoolSize (TUint aBitpoolSize )
   243 	{
   244 	iBitpoolSize = aBitpoolSize;
   245 	}
   246 
   247 TInt CSbcEncoderTestDevice::ApplyConfig()
   248 	{
   249 	iApplyConfig = ETrue;
   250 	return KErrNone;
   251 	}
   252 
   253 TInt CSbcEncoderTestDevice::GetSamplingFrequency ( TUint& aSamplingFrequency )
   254 	{
   255 	TInt retVal = KErrNone;
   256 	aSamplingFrequency = iSamplingFrequency;
   257 	return retVal;
   258 	}
   259 
   260 TInt CSbcEncoderTestDevice::GetChannelMode (TSbcChannelMode& aChannelMode )
   261 	{
   262 	TInt retVal = KErrNone;
   263 	aChannelMode = iChannelMode;	
   264 	return retVal;
   265 	}
   266 
   267 TInt CSbcEncoderTestDevice::GetNumOfSubbands ( TUint& aNumOfSubbands )
   268 	{
   269 	TInt retVal = KErrNone;
   270 	aNumOfSubbands = iNumOfSubbands;
   271 
   272 	return retVal;
   273 	}
   274 
   275 TInt CSbcEncoderTestDevice::GetAllocationMethod (TSbcAllocationMethod& aAllocationMethod )
   276 	{
   277 	TInt retVal = KErrNone;
   278 	aAllocationMethod = iAllocMethod;
   279 	return retVal;
   280 	}
   281 
   282 TInt CSbcEncoderTestDevice::GetBitpoolSize (TUint& aBitpoolSize )
   283 	{
   284 	TInt retVal = KErrNone;
   285 	aBitpoolSize = iBitpoolSize;
   286 	return retVal;
   287 	}
   288 
   289 void CSbcEncoderTestDevice::SetNumOfBlocks ( TUint aNumOfBlocks )
   290 	{
   291 	iNumOfBlocks = aNumOfBlocks;
   292 	}
   293 
   294 TInt CSbcEncoderTestDevice::GetNumOfBlocks ( TUint& aNumOfBlocks )
   295 	{
   296 	TInt retVal = KErrNone;
   297 	aNumOfBlocks = iNumOfBlocks;
   298 	return retVal;
   299 	}
   300