os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/gettimestampstestdevice.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/gettimestampstestdevice.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh>
    1.20 +#include "gettimestampstestdevice.h"
    1.21 +#include "cidefine.h"
    1.22 +
    1.23 +/*****************************************************************************/
    1.24 +// Implementation
    1.25 +
    1.26 +CMMFHwDevice* CGetTimestampsTestDevice::NewL()
    1.27 +	{
    1.28 +	CGetTimestampsTestDevice* self = new(ELeave) CGetTimestampsTestDevice();
    1.29 +	CleanupStack::PushL(self);
    1.30 +	self->ConstructL();
    1.31 +	CleanupStack::Pop(self);
    1.32 +	return self;
    1.33 +	}
    1.34 +
    1.35 +/*****************************************************************************/
    1.36 +CGetTimestampsTestDevice::~CGetTimestampsTestDevice()
    1.37 +	{
    1.38 +	}
    1.39 +
    1.40 +/*****************************************************************************/
    1.41 +CGetTimestampsTestDevice::CGetTimestampsTestDevice()
    1.42 +	{
    1.43 +	}
    1.44 +
    1.45 +/*****************************************************************************/
    1.46 +void CGetTimestampsTestDevice::ConstructL()
    1.47 +	{
    1.48 +	}
    1.49 +	
    1.50 +/*****************************************************************************/
    1.51 +TInt CGetTimestampsTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
    1.52 +	{
    1.53 +	return 0;
    1.54 +	}
    1.55 +
    1.56 +/*****************************************************************************/
    1.57 +TInt CGetTimestampsTestDevice::Stop()
    1.58 +	{
    1.59 +	return 0;
    1.60 +	}
    1.61 +	
    1.62 +/*****************************************************************************/
    1.63 +TInt CGetTimestampsTestDevice::Pause()
    1.64 +	{
    1.65 +	return 0;
    1.66 +	}
    1.67 +
    1.68 +/*****************************************************************************/		
    1.69 +TInt CGetTimestampsTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
    1.70 +	{
    1.71 +	return 0;
    1.72 +	}
    1.73 +	
    1.74 +/*****************************************************************************/	
    1.75 +TAny* CGetTimestampsTestDevice::CustomInterface(TUid aInterfaceId)
    1.76 +	{
    1.77 +	MMMFGetTimestamps* interface = NULL;
    1.78 +
    1.79 +	// DevSound initialisation requires something to be returned for both of
    1.80 +	// these two uids: KMmfPlaySettingsCustomInterface, KMmfRecordSettingsCustomInterface
    1.81 +	if ((aInterfaceId == KUidGetTimestamps) || // This interface
    1.82 +		(aInterfaceId.iUid == KMmfPlaySettingsCustomInterface) ||
    1.83 +		(aInterfaceId.iUid == KMmfRecordSettingsCustomInterface))
    1.84 +		{
    1.85 +		interface = this;
    1.86 +		}	
    1.87 +
    1.88 +	return interface;
    1.89 +	}
    1.90 +
    1.91 +/*****************************************************************************/
    1.92 +TInt CGetTimestampsTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
    1.93 +	{
    1.94 +	return 0;
    1.95 +	}
    1.96 +	
    1.97 +/*****************************************************************************/	
    1.98 +TInt CGetTimestampsTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
    1.99 +	{
   1.100 +	return 0;
   1.101 +	}
   1.102 +	
   1.103 +/*****************************************************************************/	
   1.104 +TInt CGetTimestampsTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   1.105 +	{
   1.106 +	return 0;
   1.107 +	}
   1.108 +	
   1.109 +/*****************************************************************************/	
   1.110 +TInt CGetTimestampsTestDevice::StopAndDeleteCodec()
   1.111 +	{
   1.112 +	return 0;
   1.113 +	}
   1.114 +	
   1.115 +/*****************************************************************************/
   1.116 +TInt CGetTimestampsTestDevice::DeleteCodec()
   1.117 +	{
   1.118 +	return 0;
   1.119 +	}
   1.120 +
   1.121 +/*****************************************************************************/
   1.122 +CMMFSwCodec& CGetTimestampsTestDevice::Codec()
   1.123 +	{
   1.124 +	return *iCodec;
   1.125 +	}
   1.126 +
   1.127 +/*****************************************************************************/
   1.128 +TInt CGetTimestampsTestDevice::MmgtSetRecordSystemTimestampsEnabled(TBool aEnable)
   1.129 +	{
   1.130 +	TRAPD(err, DoWriteToFileL(aEnable));
   1.131 +	return err;
   1.132 +	}
   1.133 +
   1.134 +TInt CGetTimestampsTestDevice::MmgtGetSystemTimestampForBuffer(const TTimeIntervalMicroSeconds& aBufferPosition,
   1.135 +																TTime& aTimestamp) const
   1.136 +	{
   1.137 +	// Expected position is...
   1.138 +	TTimeIntervalMicroSeconds expectedPos = TTimeIntervalMicroSeconds(KTimestampPosition);
   1.139 +	if (aBufferPosition == expectedPos)
   1.140 +		{
   1.141 +		// ...found so return the expected value.
   1.142 +		aTimestamp = KTimestampValue;
   1.143 +		return KErrNone;
   1.144 +		}
   1.145 +	else
   1.146 +		{
   1.147 +		return KErrArgument;
   1.148 +		}
   1.149 +	}
   1.150 +
   1.151 +void CGetTimestampsTestDevice::DoWriteToFileL(TBool aEnable)
   1.152 +	{
   1.153 +	RFs fs;
   1.154 +	CleanupClosePushL(fs);
   1.155 +	User::LeaveIfError(fs.Connect());
   1.156 +	
   1.157 +	RFile file;
   1.158 +	CleanupClosePushL(file);
   1.159 +	
   1.160 +	// File doesn't yet exist
   1.161 +	// It is the responsibility of the calling test function to delete the file after use
   1.162 +	User::LeaveIfError(file.Create(fs, KCITestFileName, EFileWrite));
   1.163 +	TBuf8<KMaxCITestFileDataLength> outputBuf;
   1.164 +	outputBuf.Num(aEnable);
   1.165 +	User::LeaveIfError(file.Write(outputBuf));
   1.166 +	CleanupStack::PopAndDestroy(2); // fs, file
   1.167 +	}