1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
211 |
211 |
212 private: |
212 private: |
213 TUint32 iFourCC; |
213 TUint32 iFourCC; |
214 }; |
214 }; |
215 |
215 |
216 /** |
216 |
217 @internalAll |
217 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
218 |
218 #include <mmf/common/mmfhelper.h> |
219 Base utility class to change the sample rate of audio data in a buffer |
219 #endif |
220 */ |
220 |
221 class CMMFChannelAndSampleRateConverter : public CBase |
|
222 { |
|
223 public: |
|
224 /** |
|
225 Reads the audio data from the source buffer, |
|
226 converts the number of channels and the sample rate |
|
227 and copies the result to the destination buffer |
|
228 |
|
229 @param aSrcBuffer |
|
230 A pointer to a source buffer containing the audio data to convert. |
|
231 @param aDstBuffer |
|
232 A pointer to a destination buffer. |
|
233 |
|
234 @return The length of the destination buffer. |
|
235 */ |
|
236 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer) =0; |
|
237 virtual void Reset() {}; |
|
238 |
|
239 /* |
|
240 Indicates what buffer size is required to hold the converted data. |
|
241 */ |
|
242 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize) {return aSrcBufferSize;} |
|
243 |
|
244 void SetRates(TInt aSrcRate,TInt aSrcChannels,TInt aDstRate,TInt aDstChannels); |
|
245 public: |
|
246 /* |
|
247 The sample rate of the data in the source buffer |
|
248 */ |
|
249 TInt iFromRate; |
|
250 /* |
|
251 The sample rate of the data in the destination buffer |
|
252 */ |
|
253 TInt iToRate; |
|
254 /* |
|
255 The number of channels of data in the source buffer |
|
256 */ |
|
257 TInt iFromChannels; |
|
258 /* |
|
259 The number of channels of data in the destination buffer |
|
260 */ |
|
261 TInt iToChannels; |
|
262 protected: |
|
263 TReal iRatio; |
|
264 TInt iFraction; |
|
265 TInt iIndex; |
|
266 }; |
|
267 |
|
268 /** |
|
269 @internalAll |
|
270 */ |
|
271 class CMMFStereoToMonoRateConverter : public CMMFChannelAndSampleRateConverter |
|
272 { |
|
273 public: |
|
274 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
275 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize); |
|
276 |
|
277 }; |
|
278 |
|
279 /** |
|
280 @internalAll |
|
281 */ |
|
282 class CMMFStereoToMonoConverter : public CMMFChannelAndSampleRateConverter |
|
283 { |
|
284 public: |
|
285 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
286 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize); |
|
287 }; |
|
288 |
|
289 /** |
|
290 @internalAll |
|
291 */ |
|
292 class CMMFStereoToStereoRateConverter : public CMMFChannelAndSampleRateConverter |
|
293 { |
|
294 public: |
|
295 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
296 }; |
|
297 |
|
298 /** |
|
299 @internalAll |
|
300 */ |
|
301 class CMMFMonoToMonoRateConverter : public CMMFChannelAndSampleRateConverter |
|
302 { |
|
303 public: |
|
304 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
305 }; |
|
306 |
|
307 /** |
|
308 @internalAll |
|
309 */ |
|
310 class CMMFMonoToStereoConverter : public CMMFChannelAndSampleRateConverter |
|
311 { |
|
312 public: |
|
313 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
314 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize); |
|
315 }; |
|
316 |
|
317 /** |
|
318 @internalAll |
|
319 */ |
|
320 class CMMFMonoToStereoRateConverter : public CMMFChannelAndSampleRateConverter |
|
321 { |
|
322 public: |
|
323 virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer); |
|
324 virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize); |
|
325 }; |
|
326 |
|
327 /** |
|
328 @internalAll |
|
329 |
|
330 Factory class to create the appropriate CMMFChannelAndSampleRateConverter-derived |
|
331 class depending on the supplied number of channels and bit rate |
|
332 */ |
|
333 class CMMFChannelAndSampleRateConverterFactory : public CBase |
|
334 { |
|
335 |
|
336 public: |
|
337 IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL(TInt aFromRate,TInt aFromChannels, |
|
338 TInt aToRate,TInt aToChannels); |
|
339 IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL(); |
|
340 CMMFChannelAndSampleRateConverter* Converter() {return iConverter;} |
|
341 IMPORT_C ~CMMFChannelAndSampleRateConverterFactory(); |
|
342 TInt Rate() {return iToRate;} |
|
343 TInt Channels() {return iToChannels;} |
|
344 public: |
|
345 /** |
|
346 The sample rate of the data in the source buffer |
|
347 */ |
|
348 TInt iFromRate; |
|
349 /** |
|
350 The sample rate of the data in the destination buffer |
|
351 */ |
|
352 TInt iToRate; |
|
353 /** |
|
354 The number of channels of data in the source buffer |
|
355 */ |
|
356 TInt iFromChannels; |
|
357 /** |
|
358 The number of channels of data in the destination buffer |
|
359 */ |
|
360 TInt iToChannels; |
|
361 private: |
|
362 CMMFChannelAndSampleRateConverter* iConverter; |
|
363 }; |
|
364 |
221 |
365 #include <mmf/common/mmfutilities.inl> |
222 #include <mmf/common/mmfutilities.inl> |
366 |
223 |
367 #endif |
224 #endif |
|
225 |