epoc32/include/mmf/server/mmfcodec.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
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@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.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\mmfcodec.h
williamr@2
    15
// 
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
#ifndef MMFCODEC_H
williamr@2
    19
#define MMFCODEC_H
williamr@2
    20
williamr@2
    21
williamr@2
    22
#include <e32base.h>
williamr@2
    23
#include <ecom/ecom.h>
williamr@2
    24
#include <mmf/common/mmfutilities.h>
williamr@4
    25
#include <mmf/plugin/mmfplugininterfaceuids.hrh>
williamr@2
    26
williamr@2
    27
/*
williamr@2
    28
 * This UID is the INTERFACE_UID for CMMFCodec.  It is used to search for codec plugins in plugin DLLs.
williamr@2
    29
 * All codec plugin DLLs must include interface_uid = KMmfUidPluginInterfaceCodec in their .rss files.
williamr@2
    30
 */
williamr@2
    31
williamr@2
    32
/**
williamr@2
    33
@publishedAll
williamr@2
    34
@released
williamr@2
    35
williamr@2
    36
Indicates the result of processing data from the source buffer to a destination buffer
williamr@2
    37
and provides functions to compare the result code.
williamr@2
    38
*/
williamr@2
    39
class TCodecProcessResult
williamr@2
    40
	{
williamr@2
    41
public:
williamr@2
    42
	/**
williamr@2
    43
	Flag to track the codec's processing status.
williamr@2
    44
	*/
williamr@2
    45
	enum TCodecProcessResultStatus
williamr@2
    46
	{
williamr@2
    47
	/** 
williamr@2
    48
	The codec successfully has completed its processing.
williamr@2
    49
williamr@2
    50
	A codec should return this code when it has fully processed the source buffer, and is finished
williamr@2
    51
	with the destination buffer. The codec should finish with the destination buffer when it has 
williamr@2
    52
	been filled. The EProcessComplete return code indicates that the codec has finished
williamr@2
    53
	with the destination buffer. This informs the data path that the destination buffer may now be 
williamr@2
    54
	passed onto the data sink. If the codec returns EProcessComplete this means that the codec is
williamr@2
    55
	expecting a new source buffer and a new destination buffer the next time it's ProcessL() method
williamr@2
    56
	is called.
williamr@2
    57
	*/
williamr@2
    58
	EProcessComplete,
williamr@2
    59
	/** 
williamr@2
    60
	Could not empty the source buffer because the destination buffer became full.
williamr@2
    61
williamr@2
    62
	A codec should return this code when it has not been able to fully process the source buffer. 
williamr@2
    63
	This would usually be the case if the codec has filled the destination buffer (or the remaining 
williamr@2
    64
	space available in the destination buffer is insufficient to perform any further useful 
williamr@2
    65
	processing) before the source buffer has been processed. The EProcessIncomplete return code 
williamr@2
    66
	indicates that the codec has finished with the destination buffer. This informs the data path 
williamr@2
    67
	that the destination buffer may now be passed onto the data sink. If the codec returns 
williamr@2
    68
	EProcessIncomplete this means that the codec is expecting the same source buffer but a new 
williamr@2
    69
	destination buffer the next time it's ProcessL() method is called.
williamr@2
    70
	*/
williamr@2
    71
	EProcessIncomplete,
williamr@2
    72
williamr@2
    73
	/**
williamr@2
    74
	Codec came across an end of data.
williamr@2
    75
williamr@2
    76
	This can be returned if a codec is able to determine that there is no more source data. It is
williamr@2
    77
	not necessary for the codec to return this however as in most cases the codec will not be able
williamr@2
    78
	to determine when the end of data has been reached.
williamr@2
    79
	*/
williamr@2
    80
	EEndOfData,
williamr@2
    81
williamr@2
    82
	/** 
williamr@2
    83
	Could not fill the destination buffer because the source buffer has been emptied 
williamr@2
    84
williamr@2
    85
	A codec should return this code when is has fully processed the source buffer and there is still
williamr@2
    86
	sufficient space available in the destination buffer for the codec to continue using the same
williamr@2
    87
	destination buffer. The EDstNotFilled return code indicates that the codec has not finished with
williamr@2
    88
	the destination buffer. If the codec returns EDstNotFilled this means that the codec is
williamr@2
    89
	expecting a new source buffer but the same destination buffer the next time its ProcessL()
williamr@2
    90
	method is called.
williamr@2
    91
	*/
williamr@2
    92
	EDstNotFilled,
williamr@2
    93
williamr@2
    94
	/** 
williamr@2
    95
	An error occured.
williamr@2
    96
	
williamr@2
    97
	This is no longer required as if an error occurs in the codec's ProcessL()function, it should 
williamr@2
    98
	leave. When used with a datapath, returning EProcessError has the same effect as leaving with 
williamr@2
    99
	KErrCorrupt.
williamr@2
   100
	*/
williamr@2
   101
	EProcessError,
williamr@2
   102
williamr@2
   103
	/**
williamr@2
   104
	@deprecated
williamr@2
   105
williamr@2
   106
	As 'EFrameIncomplete' but also requests a call to GetNewDataPosition.
williamr@2
   107
	*/
williamr@2
   108
	EProcessIncompleteRepositionRequest,
williamr@2
   109
williamr@2
   110
	/**
williamr@2
   111
	@deprecated
williamr@2
   112
williamr@2
   113
	As 'EFrameComplete' but also requests a call to GetNewDataPosition.
williamr@2
   114
	*/
williamr@2
   115
	EProcessCompleteRepositionRequest
williamr@2
   116
	};
williamr@2
   117
williamr@2
   118
	/** 
williamr@2
   119
	Overloaded operator to test equality.
williamr@2
   120
	
williamr@2
   121
	@param  aStatus
williamr@2
   122
	        The status to compare the result of the process function.
williamr@2
   123
williamr@2
   124
	@return A boolean indicating if the two status codes are the same. ETrue if they are, EFalse
williamr@2
   125
	        otherwise.
williamr@2
   126
	*/
williamr@2
   127
	TBool operator==(const TCodecProcessResultStatus aStatus) const {return (iStatus == aStatus);}
williamr@2
   128
williamr@2
   129
	/** 
williamr@2
   130
	Overloaded operator to test inequality.
williamr@2
   131
williamr@2
   132
	@param  aStatus
williamr@2
   133
	        The status to compare the result of the process function.
williamr@2
   134
	@return A boolean indicating if the two status codes are not the same. ETrue if they are not, 
williamr@2
   135
	        EFalse otherwise.
williamr@2
   136
	*/
williamr@2
   137
	TBool operator!=(const TCodecProcessResultStatus aStatus) const {return (iStatus != aStatus);}
williamr@2
   138
williamr@2
   139
	/**
williamr@2
   140
	The codec's processing status.
williamr@2
   141
williamr@2
   142
	@see enum TCodecProcessResultStatus
williamr@2
   143
	*/
williamr@2
   144
	TCodecProcessResultStatus iStatus;
williamr@2
   145
williamr@2
   146
	/** 
williamr@2
   147
	The number of source bytes processed.
williamr@2
   148
williamr@2
   149
	The number of bytes of source data that have been processed.
williamr@2
   150
williamr@2
   151
	A codec should set this, and iDstBytesAdded, to indicate the source bytes processed for a 
williamr@2
   152
	particular call (i.e. not the total number of source bytes processed or destination bytes 
williamr@2
   153
	added). The codec should also ensure that the length of the destination buffer matches the 
williamr@2
   154
	length of the processed data in the destination buffer. Note that the codec should not 
williamr@2
   155
	reallocate the maximum length of the destination buffer.
williamr@2
   156
	*/
williamr@2
   157
	TUint iSrcBytesProcessed;
williamr@2
   158
williamr@2
   159
	/** 
williamr@2
   160
	The number of bytes added to the destination buffer.
williamr@2
   161
williamr@2
   162
	A codec should set this, and iSrcBytesProcessed, to indicate the source bytes processed for a 
williamr@2
   163
	particular call (i.e. not the total number of source bytes processed or destination bytes 
williamr@2
   164
	added). The codec should also ensure that the length of the destination buffer matches the 
williamr@2
   165
	length of the processed data in the destination buffer. Note that the codec should not 
williamr@2
   166
	reallocate the maximum length of the destination buffer.
williamr@2
   167
	*/
williamr@2
   168
	TUint iDstBytesAdded;
williamr@2
   169
public:
williamr@2
   170
williamr@2
   171
	/**
williamr@2
   172
	Default constructor.
williamr@2
   173
	*/
williamr@2
   174
	TCodecProcessResult()
williamr@2
   175
		:iStatus(EProcessError), iSrcBytesProcessed(0), iDstBytesAdded(0) {};
williamr@2
   176
private:
williamr@2
   177
	/**
williamr@2
   178
	This member is internal and not intended for use.
williamr@2
   179
	*/
williamr@2
   180
	TInt iReserved1;
williamr@2
   181
	TInt iReserved2;
williamr@2
   182
	TInt iReserved3;
williamr@2
   183
	};
williamr@2
   184
williamr@2
   185
williamr@2
   186
class TFourCC; //forward reference
williamr@2
   187
class CMMFBuffer; //forward reference
williamr@2
   188
williamr@2
   189
/**
williamr@2
   190
@publishedAll
williamr@2
   191
@released
williamr@2
   192
williamr@2
   193
ECom plugin class for a codec that processes source data in a certain fourCC coding type and
williamr@2
   194
converts it to a destination buffer of another fourCC coding type.
williamr@2
   195
The function is synchronous as it is expected that the codec will be operating in its own thread
williamr@2
   196
of execution - usually via a CMMFDataPath or CMMFDataPathProxy
williamr@2
   197
williamr@2
   198
The codec can be instantiated in 3 different ways:
williamr@2
   199
williamr@2
   200
1.	NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType).
williamr@2
   201
williamr@2
   202
This instantiate a codec that can convert the aSrcDatatype to a aDstDataType.
williamr@2
   203
williamr@2
   204
2.	NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType, const TDesC& aPreferredSupplier).
williamr@2
   205
williamr@2
   206
This is similar to the above but is used where there may be multiple codecs that
williamr@2
   207
perform the same conversion - the idea is that a 3rd party deveoper may develop there own
williamr@2
   208
controller and codecs and can ensure the controller uses their codecs by setting the preferredSupplier
williamr@2
   209
to themselves.
williamr@2
   210
williamr@2
   211
3.	NewL(TUid aUid).
williamr@2
   212
williamr@2
   213
This is used to explicitly instantiated a codec where the uid is known.  This might be used by
williamr@2
   214
controlers that only support one codec type.
williamr@2
   215
williamr@2
   216
The processing of the data is handled by the codecs ProcessL() member.
williamr@2
   217
The intention is that the source buffer for conversion is converted to the appropriate coding type
williamr@2
   218
in the destination buffer.  The buffers can be of any size.  Since the buffers can be of any size there is no
williamr@2
   219
guarantee that all the source buffer can be processed to fill the destination buffer or that the
williamr@2
   220
all the source buffer may be processed before the destination is full.  Therefore the
williamr@2
   221
ProcessL needs to return a TCodecProcessResult returing the number of source bytes processed
williamr@2
   222
and the number of destination bytes processed along with a process result code defined thus:
williamr@2
   223
- EProcessComplete: the codec processed all the source data into the sink buffer
williamr@2
   224
- EProcessIncomplete: the codec filled sink buffer before all the source buffer was processed
williamr@2
   225
- EDstNotFilled: the codec processed the source buffer but the sink buffer was not filled
williamr@2
   226
- EEndOfData: the codec detected the end data - all source data in processed but sink may not be full
williamr@2
   227
- EProcessError: the codec process error condition
williamr@2
   228
williamr@2
   229
The ProcessL should start processing the source buffer from the iPosition data member of the source data
williamr@2
   230
and start filling the destination buffer from its iPosition.
williamr@2
   231
*/
williamr@2
   232
class CMMFCodec  : public CBase
williamr@2
   233
{
williamr@2
   234
public:
williamr@2
   235
	//The function which instantiates an object of this type
williamr@2
   236
	// using the TFourCC codes as the resolver parameters.
williamr@2
   237
	IMPORT_C static CMMFCodec* NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType);
williamr@2
   238
	IMPORT_C static CMMFCodec* NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType, const TDesC& aPreferredSupplier);
williamr@2
   239
	IMPORT_C static CMMFCodec* NewL(TUid aUid);
williamr@2
   240
williamr@2
   241
	static void SelectByPreference( RImplInfoPtrArray& aPlugInArray, const TDesC& aPreferredSupplier ) ;
williamr@2
   242
williamr@2
   243
	inline virtual void ConfigureL(TUid aConfigType, const TDesC8& aConfigData);
williamr@2
   244
williamr@2
   245
	/**
williamr@2
   246
	Codec reset.
williamr@2
   247
williamr@2
   248
	Used to flush out status information when a reposition occurs. This is a virtual function that 
williamr@2
   249
	is provided should the codec require resetting prior to use.
williamr@2
   250
	*/
williamr@2
   251
	virtual void ResetL() {}
williamr@2
   252
	//Standardised destructor.
williamr@2
   253
	inline virtual ~CMMFCodec();
williamr@2
   254
williamr@2
   255
williamr@2
   256
	/**
williamr@2
   257
	Processes the data in the specified source buffer and writes the processed data to the specified 
williamr@2
   258
	destination buffer.
williamr@2
   259
williamr@2
   260
	This function is synchronous, when the function returns the data has been processed. The source 
williamr@2
   261
	buffer is converted to the appropriate coding type in the destination buffer. The buffers can be 
williamr@2
   262
	of any size, therefore there is no guarantee that all the source buffer can be processed to fill 
williamr@2
   263
	the destination buffer or that all the source buffer may be processed before the destination is 
williamr@2
   264
	full. This function therefore returns the number of source, and destination, bytes processed
williamr@2
   265
	along with a process result code indicating completion status.
williamr@2
   266
williamr@2
   267
	The aSource and aSink buffers passed in are derived from CMMFBuffer. The buffer type (e.g. a 
williamr@2
   268
	CMMFDataBuffer) passed in should be supported by the codec otherwise this function should leave 
williamr@2
   269
	with KErrNotSupported. The position of the source buffer should be checked by calling the source 
williamr@2
   270
	buffer's Position() member which indicates the current source read position in bytes. The codec 
williamr@2
   271
	should start processing from the current source buffer read position. The position of the
williamr@2
   272
	destination buffer should be checked by calling the destination buffer's Position() method which 
williamr@2
   273
	indicates the current destination write position in bytes. The codec should start writing to the 
williamr@2
   274
	destination buffer at the current destination buffer write position.
williamr@2
   275
williamr@2
   276
	This is a virtual function that each derived class must implement.
williamr@2
   277
williamr@2
   278
	@see enum TCodecProcessResult
williamr@2
   279
williamr@2
   280
	@param  aSource
williamr@2
   281
	        The source buffer containing data to encode or decode.
williamr@2
   282
	@param  aDestination
williamr@2
   283
	        The destination buffer to hold the data after encoding or decoding.
williamr@2
   284
williamr@2
   285
	@return The result of the processing.
williamr@2
   286
	*/
williamr@2
   287
	virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSource, CMMFBuffer& aDestination) = 0;
williamr@2
   288
williamr@2
   289
	/**
williamr@2
   290
	@internalComponent
williamr@2
   291
williamr@2
   292
	Gets a pointer to the extension specified by an identifier. The extension can be either an
williamr@2
   293
	interface or function. If the extension is not supported NULL value is given and returns
williamr@2
   294
	KErrExtensionNotSupported.
williamr@2
   295
williamr@2
   296
	@param	aExtensionId
williamr@2
   297
		Extension identifier.
williamr@2
   298
	@param	aExtPtr
williamr@2
   299
		Pointer to get the extension.
williamr@2
   300
	@return	If successful returns KErrNone otherwise KErrExtensionNotSupported.		
williamr@2
   301
	*/
williamr@2
   302
	TInt ExtensionInterface(TUint aExtensionId, TAny*& aExtPtr);
williamr@2
   303
williamr@2
   304
private:
williamr@2
   305
	TUid iDtor_ID_Key;
williamr@2
   306
};
williamr@2
   307
williamr@2
   308
/**
williamr@2
   309
Destructor.
williamr@2
   310
williamr@2
   311
Destroys any variables then informs ECom that this specific instance of the interface has been
williamr@2
   312
destroyed.
williamr@2
   313
*/
williamr@2
   314
inline CMMFCodec::~CMMFCodec()
williamr@2
   315
	{
williamr@2
   316
	// Destroy any instance variables and then
williamr@2
   317
	// inform ecom that this specific 
williamr@2
   318
	// instance of the interface has been destroyed.
williamr@2
   319
	REComSession::DestroyedImplementation(iDtor_ID_Key);
williamr@2
   320
	}
williamr@2
   321
williamr@2
   322
/**
williamr@2
   323
Sets codec configuration.
williamr@2
   324
williamr@2
   325
This is a virtual function which does not need to be implemented
williamr@2
   326
by a codec, but may be if required. This function provides additional configuration
williamr@2
   327
information for the codec. The configuration is passed in as a descriptor.
williamr@2
   328
The default version leaves with KErrNotSupported.
williamr@2
   329
williamr@2
   330
@param  aConfigType
williamr@2
   331
        The UID of the configuration data.
williamr@2
   332
@param  aConfigData
williamr@2
   333
        The configuration information.
williamr@2
   334
*/
williamr@2
   335
inline void CMMFCodec::ConfigureL(TUid /*aConfigType*/, const TDesC8& /*aConfigData*/)
williamr@2
   336
{
williamr@2
   337
	User::Leave(KErrNotSupported);
williamr@2
   338
}
williamr@2
   339
williamr@2
   340
#endif
williamr@4
   341