Update contrib.
1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // include\mmf\common\mmfutilities.h
18 #ifndef __MMF_COMMON_HELPER_H__
19 #define __MMF_COMMON_HELPER_H__
22 #include <mmf/server/mmfdatabuffer.h>
23 #include <mmf/common/mmffourcc.h>
29 Base utility class to change the sample rate of audio data in a buffer
31 class CMMFChannelAndSampleRateConverter : public CBase
35 Reads the audio data from the source buffer,
36 converts the number of channels and the sample rate
37 and copies the result to the destination buffer
40 A pointer to a source buffer containing the audio data to convert.
42 A pointer to a destination buffer.
44 @return The length of the destination buffer.
46 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer) =0;
47 virtual void Reset() {};
50 Indicates what buffer size is required to hold the converted data.
52 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize) {return aSrcBufferSize;}
54 void SetRates(TInt aSrcRate,TInt aSrcChannels,TInt aDstRate,TInt aDstChannels);
57 The sample rate of the data in the source buffer
61 The sample rate of the data in the destination buffer
65 The number of channels of data in the source buffer
69 The number of channels of data in the destination buffer
81 class CMMFStereoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
84 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
85 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
92 class CMMFStereoToMonoConverter : public CMMFChannelAndSampleRateConverter
95 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
96 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
102 class CMMFStereoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
105 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
111 class CMMFMonoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
114 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
120 class CMMFMonoToStereoConverter : public CMMFChannelAndSampleRateConverter
123 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
124 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
130 class CMMFMonoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
133 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
134 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
140 Factory class to create the appropriate CMMFChannelAndSampleRateConverter-derived
141 class depending on the supplied number of channels and bit rate
143 class CMMFChannelAndSampleRateConverterFactory : public CBase
147 IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL(TInt aFromRate,TInt aFromChannels,
148 TInt aToRate,TInt aToChannels);
149 IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL();
150 CMMFChannelAndSampleRateConverter* Converter() {return iConverter;}
151 IMPORT_C ~CMMFChannelAndSampleRateConverterFactory();
152 TInt Rate() {return iToRate;}
153 TInt Channels() {return iToChannels;}
156 The sample rate of the data in the source buffer
160 The sample rate of the data in the destination buffer
164 The number of channels of data in the source buffer
168 The number of channels of data in the destination buffer
172 CMMFChannelAndSampleRateConverter* iConverter;
175 #endif //__MMF_COMMON_HELPER_H__