os/mm/mmlibs/mmfw/inc/mmf/common/mmfhelper.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/common/mmfhelper.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,176 @@
     1.4 +// Copyright (c) 2002-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 +// include\mmf\common\mmfutilities.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __MMF_COMMON_HELPER_H__
    1.22 +#define __MMF_COMMON_HELPER_H__
    1.23 +
    1.24 +#include <e32base.h>
    1.25 +#include <mmf/server/mmfdatabuffer.h>
    1.26 +#include <mmf/common/mmffourcc.h>
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +@internalAll
    1.31 +
    1.32 +Base utility class to change the sample rate of audio data in a buffer
    1.33 +*/
    1.34 +class CMMFChannelAndSampleRateConverter : public CBase
    1.35 +	{
    1.36 +public:
    1.37 +	/**
    1.38 +	Reads the audio data from the source buffer,
    1.39 +	converts the number of channels and the sample rate
    1.40 +	and copies the result to the destination buffer
    1.41 +
    1.42 +	@param  aSrcBuffer
    1.43 +	        A pointer to a source buffer containing the audio data to convert.
    1.44 +	@param  aDstBuffer
    1.45 +	        A pointer to a destination buffer.
    1.46 +
    1.47 +	@return The length of the destination buffer.
    1.48 +	*/
    1.49 +	virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer) =0;
    1.50 +	virtual void Reset() {};
    1.51 +
    1.52 +	/*
    1.53 +	Indicates what buffer size is required to hold the converted data.
    1.54 +	*/
    1.55 +	virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize) {return aSrcBufferSize;}
    1.56 +
    1.57 +	void SetRates(TInt aSrcRate,TInt aSrcChannels,TInt aDstRate,TInt aDstChannels);
    1.58 +public:
    1.59 +	/*
    1.60 +	The sample rate of the data in the source buffer
    1.61 +	*/
    1.62 +	TInt iFromRate;
    1.63 +	/*
    1.64 +	The sample rate of the data in the destination buffer
    1.65 +	*/
    1.66 +	TInt iToRate;
    1.67 +	/*
    1.68 +	The number of channels of data in the source buffer
    1.69 +	*/
    1.70 +	TInt iFromChannels;
    1.71 +	/*
    1.72 +	The number of channels of data in the destination buffer
    1.73 +	*/
    1.74 +	TInt iToChannels;
    1.75 +protected:
    1.76 +	TReal iRatio;
    1.77 +	TInt iFraction;
    1.78 +	TInt iIndex;
    1.79 +	};
    1.80 +
    1.81 +/**
    1.82 +@internalAll
    1.83 +*/
    1.84 +class CMMFStereoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
    1.85 +	{
    1.86 +	public:
    1.87 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
    1.88 +		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
    1.89 +
    1.90 +	};
    1.91 +
    1.92 +/**
    1.93 +@internalAll
    1.94 +*/
    1.95 +class CMMFStereoToMonoConverter : public CMMFChannelAndSampleRateConverter
    1.96 +	{
    1.97 +	public:
    1.98 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
    1.99 +		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
   1.100 +	};
   1.101 +
   1.102 +/**
   1.103 +@internalAll
   1.104 +*/
   1.105 +class CMMFStereoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
   1.106 +	{
   1.107 +	public:
   1.108 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
   1.109 +	};
   1.110 +
   1.111 +/**
   1.112 +@internalAll
   1.113 +*/
   1.114 +class CMMFMonoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
   1.115 +	{
   1.116 +	public:
   1.117 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
   1.118 +	};
   1.119 +
   1.120 +/**
   1.121 +@internalAll
   1.122 +*/
   1.123 +class CMMFMonoToStereoConverter : public CMMFChannelAndSampleRateConverter
   1.124 +	{
   1.125 +	public:
   1.126 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
   1.127 +		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
   1.128 +	};
   1.129 +
   1.130 +/**
   1.131 +@internalAll
   1.132 +*/
   1.133 +class CMMFMonoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
   1.134 +	{
   1.135 +	public:
   1.136 +		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
   1.137 +		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
   1.138 +	};
   1.139 +
   1.140 +/**
   1.141 +@internalAll
   1.142 +
   1.143 +Factory class to create the appropriate CMMFChannelAndSampleRateConverter-derived
   1.144 +class depending on the supplied number of channels and bit rate
   1.145 +*/
   1.146 +class CMMFChannelAndSampleRateConverterFactory : public CBase
   1.147 +	{
   1.148 +
   1.149 +public:
   1.150 +	IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL(TInt aFromRate,TInt aFromChannels,
   1.151 +												 TInt aToRate,TInt aToChannels);
   1.152 +	IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL();
   1.153 +	CMMFChannelAndSampleRateConverter* Converter() {return iConverter;}
   1.154 +	IMPORT_C ~CMMFChannelAndSampleRateConverterFactory();
   1.155 +	TInt Rate() {return iToRate;}
   1.156 +	TInt Channels() {return iToChannels;}
   1.157 +public:
   1.158 +	/**
   1.159 +	The sample rate of the data in the source buffer
   1.160 +	*/
   1.161 +	TInt iFromRate;
   1.162 +	/**
   1.163 +	The sample rate of the data in the destination buffer
   1.164 +	*/
   1.165 +	TInt iToRate;
   1.166 +	/**
   1.167 +	The number of channels of data in the source buffer
   1.168 +	*/
   1.169 +	TInt iFromChannels;
   1.170 +	/**
   1.171 +	The number of channels of data in the destination buffer
   1.172 +	*/
   1.173 +	TInt iToChannels;
   1.174 +private:
   1.175 +	CMMFChannelAndSampleRateConverter* iConverter;
   1.176 +	};
   1.177 +
   1.178 +#endif //__MMF_COMMON_HELPER_H__
   1.179 +