epoc32/include/mmf/common/mmfutilities.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
// include\mmf\common\mmfutilities.h
williamr@2
    15
// 
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
#ifndef __MMF_COMMON_UTILITIES_H__
williamr@2
    19
#define __MMF_COMMON_UTILITIES_H__
williamr@2
    20
williamr@2
    21
#include <e32base.h>
williamr@2
    22
#include <mmf/server/mmfdatabuffer.h>
williamr@2
    23
#include <mmf/common/mmffourcc.h>
williamr@2
    24
williamr@2
    25
williamr@2
    26
/** 
williamr@2
    27
@publishedAll
williamr@2
    28
@released
williamr@2
    29
williamr@2
    30
Identifies the particular stream of the given media type.
williamr@2
    31
*/
williamr@2
    32
class TMediaId
williamr@2
    33
	{
williamr@2
    34
public:
williamr@2
    35
williamr@2
    36
	/**
williamr@2
    37
	Constructs the class with the supplied arguments.
williamr@2
    38
williamr@2
    39
	This constructor is used when there are multiple streams of the same media type on the same
williamr@2
    40
	MDataSource.
williamr@2
    41
williamr@2
    42
	@param  aMediaType
williamr@2
    43
	        The media type (video, audio etc.).
williamr@2
    44
	@param  aStreamId
williamr@2
    45
	        Identifies a specific stream when there are multiple streams of the same media type on 
williamr@2
    46
	        the same MDataSource.
williamr@2
    47
	*/
williamr@2
    48
	TMediaId(TUid aMediaType, TUint aStreamId);
williamr@2
    49
williamr@2
    50
	/**
williamr@2
    51
    Constructs the class with the supplied argument.
williamr@2
    52
williamr@2
    53
	This constructor is used when there is a single stream of the same media type on the same
williamr@2
    54
	MDataSource.
williamr@2
    55
williamr@2
    56
	@param  aMediaType
williamr@2
    57
	        The media type (video, audio etc.).
williamr@2
    58
	*/
williamr@2
    59
	TMediaId(TUid aMediaType);
williamr@2
    60
williamr@2
    61
	/**
williamr@2
    62
	Default constructor.
williamr@2
    63
	*/
williamr@2
    64
	TMediaId();
williamr@2
    65
public:
williamr@2
    66
	/**
williamr@2
    67
	The media type (KUidMediaTypeAudio, KUidMediaTypeVideo, etc).
williamr@2
    68
	*/
williamr@2
    69
	TUid iMediaType;
williamr@2
    70
williamr@2
    71
	/**
williamr@2
    72
	Identifies a particular media stream used in case where multiple streams
williamr@2
    73
	of the same media type are present on the same MDataSource.
williamr@2
    74
	*/
williamr@2
    75
	TUint iStreamId;
williamr@2
    76
private:
williamr@2
    77
	/**
williamr@2
    78
	This member is internal and not intended for use.
williamr@2
    79
	*/
williamr@2
    80
	TInt iReserved1;
williamr@2
    81
	TInt iReserved2;
williamr@2
    82
	TInt iReserved3;
williamr@2
    83
	};
williamr@2
    84
williamr@2
    85
/**
williamr@2
    86
@publishedAll
williamr@2
    87
@released
williamr@2
    88
williamr@2
    89
The FourCC code that represents NULL.
williamr@2
    90
*/
williamr@2
    91
const TInt KFourCCNULL = KMMFFourCCCodeNULL;
williamr@2
    92
williamr@2
    93
/**
williamr@2
    94
@publishedAll
williamr@2
    95
@released
williamr@2
    96
williamr@2
    97
A class that holds a four character code, representing supported data encodings for the
williamr@2
    98
conversion destination. The four character codes are packed into a single TUint32.
williamr@2
    99
williamr@2
   100
FourCC codes are a representation of the datatypes used to identify codecs. FourCC codes are used in 
williamr@2
   101
codec .rss files as a match string used by ECOM to correctly load the required DLL.
williamr@2
   102
*/
williamr@2
   103
class TFourCC
williamr@2
   104
{
williamr@2
   105
public:
williamr@2
   106
williamr@2
   107
	/**
williamr@2
   108
	Default constructor initialises the class to KMMFFourCCCodeNULL.
williamr@2
   109
	*/
williamr@2
   110
	TFourCC() {iFourCC = KMMFFourCCCodeNULL;} //'NULL'
williamr@2
   111
williamr@2
   112
	/**
williamr@2
   113
	Packs the four arguments into a single TUint32.
williamr@2
   114
williamr@2
   115
	The four arguments are packed in little-endian format.
williamr@2
   116
williamr@2
   117
	@param  aChar1
williamr@2
   118
	        A character that represents part of the FourCC code. This character will be the least 
williamr@2
   119
	        significant byte of the code.
williamr@2
   120
	@param  aChar2
williamr@2
   121
            A character that represents part of the FourCC code.
williamr@2
   122
	@param  aChar3
williamr@2
   123
            A character that represents part of the FourCC code.
williamr@2
   124
	@param  aChar4
williamr@2
   125
	        A character that represents part of the FourCC code. This character will be the most 
williamr@2
   126
	        significant byte of the code.
williamr@2
   127
	*/
williamr@2
   128
	TFourCC(TUint8 aChar1, TUint8 aChar2, TUint8 aChar3, TUint8 aChar4) {iFourCC =(aChar4<<24)+(aChar3<<16)+(aChar2<<8)+aChar1;}
williamr@2
   129
williamr@2
   130
	/**
williamr@2
   131
	Constructs a FourCC code with the given 8 bit desciptor where the descriptor contains the
williamr@2
   132
	characters that make up the FourCC code.
williamr@2
   133
williamr@2
   134
	@param  aDes
williamr@2
   135
	        The descriptor containing the characters from which to make the FourCC code.
williamr@2
   136
	*/
williamr@2
   137
	TFourCC(const TDesC8& aDes) {iFourCC =(aDes[3]<<24)+(aDes[2]<<16)+(aDes[1]<<8)+aDes[0];}
williamr@2
   138
williamr@2
   139
	/**
williamr@2
   140
    Constructor with a TInt32 in little-endian format.
williamr@2
   141
williamr@2
   142
	@param  aFourCC
williamr@2
   143
            The FourCC code.
williamr@2
   144
	*/
williamr@2
   145
	TFourCC(TInt32 aFourCC) {iFourCC = aFourCC;}
williamr@2
   146
williamr@2
   147
	/**
williamr@2
   148
    Returns the FourCC code in little-endian format.
williamr@2
   149
williamr@2
   150
	@return The FourCC code in little-endian format.
williamr@2
   151
	*/
williamr@2
   152
	TUint32 FourCC() {return iFourCC;}
williamr@2
   153
	inline void FourCC( TPtr8* aDes ) const ;
williamr@2
   154
williamr@2
   155
	/**
williamr@2
   156
    Sets the FourCC code equal to the value in the supplied argument.
williamr@2
   157
williamr@2
   158
	@param  aFourCC
williamr@2
   159
	        The required TFourCC containting the FourCC code.
williamr@2
   160
	*/
williamr@2
   161
	void Set(TFourCC aFourCC) {iFourCC = aFourCC.iFourCC;}
williamr@2
   162
williamr@2
   163
	/**
williamr@2
   164
    Sets the FourCC code equal to the supplied argument.
williamr@2
   165
williamr@2
   166
	@param  aFourCC
williamr@2
   167
	        The required FourCC code.
williamr@2
   168
	*/
williamr@2
   169
	void Set(TUint32 aFourCC) {iFourCC = aFourCC;}
williamr@2
   170
williamr@2
   171
	/**
williamr@2
   172
	Equality operator.
williamr@2
   173
williamr@2
   174
	@param  aA
williamr@2
   175
	        The TFourCC code that *this will be tested against.
williamr@2
   176
williamr@2
   177
	@return A boolean indicating if the two values are equal. ETrue if the two values are equal, 
williamr@2
   178
	        otherwise false.
williamr@2
   179
	*/
williamr@2
   180
	TBool operator==(const TFourCC& aA) const {return (iFourCC == aA.iFourCC);}
williamr@2
   181
williamr@2
   182
	/**
williamr@2
   183
    Equality operator.
williamr@2
   184
williamr@2
   185
	@param  aUint
williamr@2
   186
	        The FourCC code that *this will be tested against.
williamr@2
   187
williamr@2
   188
	@return A boolean indicating if the two values are equal. ETrue if the two values are equal, 
williamr@2
   189
	        otherwise false.
williamr@2
   190
	*/
williamr@2
   191
	TBool operator==(const TUint32& aUint) const {return (iFourCC == aUint);}
williamr@2
   192
williamr@2
   193
	/**
williamr@2
   194
    Inequality operator.
williamr@2
   195
williamr@2
   196
	@param  aA
williamr@2
   197
	        The TFourCC code that *this will be tested against.
williamr@2
   198
	
williamr@2
   199
	@return A boolean indicating if the two values are not equal. ETrue if the two values are 
williamr@2
   200
	        unequal, otherwise false.
williamr@2
   201
	*/
williamr@2
   202
	TBool operator!=(const TFourCC& aA) const {return (iFourCC != aA.iFourCC);}
williamr@2
   203
williamr@2
   204
	/**
williamr@2
   205
    Inequality operator.
williamr@2
   206
williamr@2
   207
	@param  aUint
williamr@2
   208
	        The FourCC code that *this will be tested against.
williamr@2
   209
	*/
williamr@2
   210
	TBool operator!=(const TUint32& aUint) const {return (iFourCC != aUint);}
williamr@2
   211
williamr@2
   212
private:
williamr@2
   213
	TUint32 iFourCC;
williamr@2
   214
};
williamr@2
   215
williamr@2
   216
/**
williamr@2
   217
@internalAll
williamr@2
   218
williamr@2
   219
Base utility class to change the sample rate of audio data in a buffer
williamr@2
   220
*/
williamr@2
   221
class CMMFChannelAndSampleRateConverter : public CBase
williamr@2
   222
	{
williamr@2
   223
public:
williamr@2
   224
	/**
williamr@2
   225
	Reads the audio data from the source buffer,
williamr@2
   226
	converts the number of channels and the sample rate
williamr@2
   227
	and copies the result to the destination buffer
williamr@2
   228
williamr@2
   229
	@param  aSrcBuffer
williamr@2
   230
	        A pointer to a source buffer containing the audio data to convert.
williamr@2
   231
	@param  aDstBuffer
williamr@2
   232
	        A pointer to a destination buffer.
williamr@2
   233
williamr@2
   234
	@return The length of the destination buffer.
williamr@2
   235
	*/
williamr@2
   236
	virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer) =0;
williamr@2
   237
	virtual void Reset() {};
williamr@2
   238
williamr@2
   239
	/*
williamr@2
   240
	Indicates what buffer size is required to hold the converted data.
williamr@2
   241
	*/
williamr@2
   242
	virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize) {return aSrcBufferSize;}
williamr@2
   243
williamr@2
   244
	void SetRates(TInt aSrcRate,TInt aSrcChannels,TInt aDstRate,TInt aDstChannels);
williamr@2
   245
public:
williamr@2
   246
	/*
williamr@2
   247
	The sample rate of the data in the source buffer
williamr@2
   248
	*/
williamr@2
   249
	TInt iFromRate;
williamr@2
   250
	/*
williamr@2
   251
	The sample rate of the data in the destination buffer
williamr@2
   252
	*/
williamr@2
   253
	TInt iToRate;
williamr@2
   254
	/*
williamr@2
   255
	The number of channels of data in the source buffer
williamr@2
   256
	*/
williamr@2
   257
	TInt iFromChannels;
williamr@2
   258
	/*
williamr@2
   259
	The number of channels of data in the destination buffer
williamr@2
   260
	*/
williamr@2
   261
	TInt iToChannels;
williamr@2
   262
protected:
williamr@2
   263
	TReal iRatio;
williamr@2
   264
	TInt iFraction;
williamr@2
   265
	TInt iIndex;
williamr@2
   266
	};
williamr@2
   267
williamr@2
   268
/**
williamr@2
   269
@internalAll
williamr@2
   270
*/
williamr@2
   271
class CMMFStereoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   272
	{
williamr@2
   273
	public:
williamr@2
   274
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   275
		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
williamr@2
   276
williamr@2
   277
	};
williamr@2
   278
williamr@2
   279
/**
williamr@2
   280
@internalAll
williamr@2
   281
*/
williamr@2
   282
class CMMFStereoToMonoConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   283
	{
williamr@2
   284
	public:
williamr@2
   285
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   286
		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
williamr@2
   287
	};
williamr@2
   288
williamr@2
   289
/**
williamr@2
   290
@internalAll
williamr@2
   291
*/
williamr@2
   292
class CMMFStereoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   293
	{
williamr@2
   294
	public:
williamr@2
   295
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   296
	};
williamr@2
   297
williamr@2
   298
/**
williamr@2
   299
@internalAll
williamr@2
   300
*/
williamr@2
   301
class CMMFMonoToMonoRateConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   302
	{
williamr@2
   303
	public:
williamr@2
   304
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   305
	};
williamr@2
   306
williamr@2
   307
/**
williamr@2
   308
@internalAll
williamr@2
   309
*/
williamr@2
   310
class CMMFMonoToStereoConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   311
	{
williamr@2
   312
	public:
williamr@2
   313
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   314
		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
williamr@2
   315
	};
williamr@2
   316
williamr@2
   317
/**
williamr@2
   318
@internalAll
williamr@2
   319
*/
williamr@2
   320
class CMMFMonoToStereoRateConverter : public CMMFChannelAndSampleRateConverter
williamr@2
   321
	{
williamr@2
   322
	public:
williamr@2
   323
		virtual TInt Convert(const CMMFDataBuffer& aSrcBuffer, CMMFDataBuffer& aDstBuffer);
williamr@2
   324
		virtual TUint MaxConvertBufferSize(TUint aSrcBufferSize);
williamr@2
   325
	};
williamr@2
   326
williamr@2
   327
/**
williamr@2
   328
@internalAll
williamr@2
   329
williamr@2
   330
Factory class to create the appropriate CMMFChannelAndSampleRateConverter-derived
williamr@2
   331
class depending on the supplied number of channels and bit rate
williamr@2
   332
*/
williamr@2
   333
class CMMFChannelAndSampleRateConverterFactory : public CBase
williamr@2
   334
	{
williamr@2
   335
williamr@2
   336
public:
williamr@2
   337
	IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL(TInt aFromRate,TInt aFromChannels,
williamr@2
   338
												 TInt aToRate,TInt aToChannels);
williamr@2
   339
	IMPORT_C CMMFChannelAndSampleRateConverter* CreateConverterL();
williamr@2
   340
	CMMFChannelAndSampleRateConverter* Converter() {return iConverter;}
williamr@2
   341
	IMPORT_C ~CMMFChannelAndSampleRateConverterFactory();
williamr@2
   342
	TInt Rate() {return iToRate;}
williamr@2
   343
	TInt Channels() {return iToChannels;}
williamr@2
   344
public:
williamr@2
   345
	/**
williamr@2
   346
	The sample rate of the data in the source buffer
williamr@2
   347
	*/
williamr@2
   348
	TInt iFromRate;
williamr@2
   349
	/**
williamr@2
   350
	The sample rate of the data in the destination buffer
williamr@2
   351
	*/
williamr@2
   352
	TInt iToRate;
williamr@2
   353
	/**
williamr@2
   354
	The number of channels of data in the source buffer
williamr@2
   355
	*/
williamr@2
   356
	TInt iFromChannels;
williamr@2
   357
	/**
williamr@2
   358
	The number of channels of data in the destination buffer
williamr@2
   359
	*/
williamr@2
   360
	TInt iToChannels;
williamr@2
   361
private:
williamr@2
   362
	CMMFChannelAndSampleRateConverter* iConverter;
williamr@2
   363
	};
williamr@2
   364
williamr@2
   365
#include <mmf/common/mmfutilities.inl>
williamr@2
   366
williamr@2
   367
#endif