os/mm/mmlibs/mmfw/inc/mmf/server/mmfdatabuffer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// include\mmf\server\mmfdatabuffer.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef __MMF_SERVER_DATABUFFER_H__
sl@0
    20
#define __MMF_SERVER_DATABUFFER_H__
sl@0
    21
sl@0
    22
#include <e32base.h>
sl@0
    23
sl@0
    24
sl@0
    25
#include <mmf/server/mmfbuffer.h>
sl@0
    26
sl@0
    27
/** 
sl@0
    28
@publishedAll
sl@0
    29
@released
sl@0
    30
sl@0
    31
Default buffer size if none is specified.
sl@0
    32
*/
sl@0
    33
static const TInt KMMFDataBufferDefaultBufferSize = 32;
sl@0
    34
sl@0
    35
/**
sl@0
    36
@publishedAll
sl@0
    37
@released
sl@0
    38
sl@0
    39
This class is an abstract class for databuffers that can be presented in the form of a descriptor.
sl@0
    40
A constructor is provided which instantiates a CMMFDescriptorBuffer buffer by default.
sl@0
    41
sl@0
    42
@see CMMFDescriptorBuffer
sl@0
    43
*/
sl@0
    44
class CMMFDataBuffer : public CMMFBuffer
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	IMPORT_C static CMMFDataBuffer* NewL();
sl@0
    48
	IMPORT_C static CMMFDataBuffer* NewL(TInt aMaxBufferSize);
sl@0
    49
	/**
sl@0
    50
	Destructor.
sl@0
    51
	*/
sl@0
    52
	virtual ~CMMFDataBuffer() {};
sl@0
    53
sl@0
    54
	/**
sl@0
    55
	Returns a reference to the data contained in the buffer (non const version).
sl@0
    56
sl@0
    57
	This is a virtual function that each derived class must implement.
sl@0
    58
sl@0
    59
	@return A reference to the buffer.
sl@0
    60
	*/
sl@0
    61
	virtual TDes8& Data() = 0;
sl@0
    62
sl@0
    63
	/**
sl@0
    64
	Returns a reference to the data contained in the buffer (const version).
sl@0
    65
sl@0
    66
	This is a virtual function that each derived class must implement.
sl@0
    67
sl@0
    68
	@return A reference to the buffer.
sl@0
    69
	*/
sl@0
    70
	virtual const TDesC8& Data() const = 0;
sl@0
    71
sl@0
    72
	/**
sl@0
    73
	Returns the buffer size, in bytes.
sl@0
    74
sl@0
    75
	This is a virtual function that each derived class must implement.
sl@0
    76
sl@0
    77
	@return The buffer size in bytes.
sl@0
    78
	*/
sl@0
    79
	virtual TUint BufferSize() const = 0;
sl@0
    80
sl@0
    81
	/**
sl@0
    82
	Sets the request size. 
sl@0
    83
sl@0
    84
	Used where a component, such as a data source,
sl@0
    85
	may not be able to write to the entire maximum length of the buffer
sl@0
    86
	(variable bit rate codecs for example).
sl@0
    87
sl@0
    88
	This is a virtual function that each derived class must implement.
sl@0
    89
sl@0
    90
	@param  aSize
sl@0
    91
	        The requested size, in bytes.
sl@0
    92
	*/
sl@0
    93
	virtual void SetRequestSizeL(TInt aSize) = 0;
sl@0
    94
protected:
sl@0
    95
	/**
sl@0
    96
	Protected constructor.
sl@0
    97
	*/
sl@0
    98
	CMMFDataBuffer(TUid aType): CMMFBuffer(aType) {};
sl@0
    99
	};
sl@0
   100
sl@0
   101
sl@0
   102
/**
sl@0
   103
@publishedAll
sl@0
   104
@released
sl@0
   105
sl@0
   106
This class is a wrapper class to give a descriptor the same API as a CMMFDataBuffer.
sl@0
   107
sl@0
   108
The purpose of this class is that components such as codecs can use CMMFDataBuffers transparently
sl@0
   109
without having to be concerned with whether the buffer is a descriptor buffer
sl@0
   110
or a transfer buffer.
sl@0
   111
*/
sl@0
   112
class CMMFDescriptorBuffer : public CMMFDataBuffer
sl@0
   113
	{
sl@0
   114
public:
sl@0
   115
	IMPORT_C static CMMFDescriptorBuffer* NewL();
sl@0
   116
	IMPORT_C static CMMFDescriptorBuffer* NewL(TInt aMaxBufferSize);
sl@0
   117
	IMPORT_C ~CMMFDescriptorBuffer();
sl@0
   118
	IMPORT_C void ReAllocBufferL(TInt aMaxBufferSize);
sl@0
   119
	virtual TDes8& Data();
sl@0
   120
	virtual const TDesC8& Data() const;
sl@0
   121
	virtual void SetStatus(TBufferStatus aStatus);
sl@0
   122
	virtual void SetRequestSizeL(TInt aSize);
sl@0
   123
	virtual TUint BufferSize() const;
sl@0
   124
	virtual void SetPosition (TUint aPosition);
sl@0
   125
private:
sl@0
   126
	CMMFDescriptorBuffer() : CMMFDataBuffer(KUidMmfDescriptorBuffer), iPtr(0,0,0) {};
sl@0
   127
	void ConstructL(TInt aMaxBufferSize);
sl@0
   128
private:
sl@0
   129
	TUint8* iData;
sl@0
   130
	TPtr8 iPtr;
sl@0
   131
	};
sl@0
   132
sl@0
   133
sl@0
   134
/**
sl@0
   135
@publishedAll
sl@0
   136
@released
sl@0
   137
sl@0
   138
This class is a wrapper class to give a transfer buffer/window the same API as a CMMFDataBuffer.
sl@0
   139
The purpose of this class is so that components such as codecs can use CMMFDataBuffers transparently
sl@0
   140
without having to be concerned with whether the buffer is a descriptor buffer
sl@0
   141
or a transfer buffer.
sl@0
   142
sl@0
   143
The class assumes that a valid RTransferWindow with a RTransferBuffer mapped in already exists.
sl@0
   144
sl@0
   145
Note:
sl@0
   146
CMMFTransferBuffers are not supported in EKA2.
sl@0
   147
*/
sl@0
   148
sl@0
   149
sl@0
   150
class RTransferWindow
sl@0
   151
	{
sl@0
   152
	// dummy class
sl@0
   153
	};
sl@0
   154
	
sl@0
   155
sl@0
   156
class CMMFTransferBuffer : public CMMFDataBuffer
sl@0
   157
	{
sl@0
   158
public:
sl@0
   159
sl@0
   160
	IMPORT_C static CMMFTransferBuffer* NewL(RTransferWindow& aTransferWindow, TUint aDataLength = 0);
sl@0
   161
	IMPORT_C ~CMMFTransferBuffer();
sl@0
   162
	virtual TDes8& Data();
sl@0
   163
	virtual const TDesC8& Data() const;
sl@0
   164
	virtual TUint BufferSize() const;
sl@0
   165
	virtual void SetRequestSizeL(TInt aSize);
sl@0
   166
	virtual void SetPosition (TUint aPosition);
sl@0
   167
	IMPORT_C RTransferWindow& TransferWindow();
sl@0
   168
	IMPORT_C void MapOutBuffer();
sl@0
   169
	IMPORT_C TInt UpdateTransferWindow(RTransferWindow& aTransferWindow, TUint aDataLength = 0);
sl@0
   170
sl@0
   171
private:
sl@0
   172
	/**
sl@0
   173
	Private constructor.
sl@0
   174
	*/
sl@0
   175
	CMMFTransferBuffer() : CMMFDataBuffer(KUidMmfTransferBuffer), iPtr(0,0,0){};
sl@0
   176
	void ConstructL(RTransferWindow& aTransferWindow, TUint aDataLength);
sl@0
   177
sl@0
   178
private:
sl@0
   179
	RTransferWindow iTransferWindow;
sl@0
   180
	TBool iTransferWindowMappedInOK;
sl@0
   181
	TPtr8 iPtr;
sl@0
   182
	};
sl@0
   183
sl@0
   184
sl@0
   185
/**
sl@0
   186
@publishedAll
sl@0
   187
@released
sl@0
   188
sl@0
   189
This class is a wrapper class intended to provide support for shared I/O buffers under EKA2
sl@0
   190
This class, unlike other data buffers does not own memory - rather it contains a pointer to already allocated memory
sl@0
   191
The purpose of this class is that components such as codecs can use CMMFDataBuffers transparently
sl@0
   192
without having to be concerned with whether the buffer is a standard buffer or memory residing in shared I/O
sl@0
   193
sl@0
   194
Users of this class need to be very careful when using buffers of this type.
sl@0
   195
It cannot be assumed that a buffer of this type can be written/read by any process other than the current one - example - handing CMMFPtrBuffer to the file server may not work since the file server's process may not have access to write data buffer.
sl@0
   196
*/
sl@0
   197
class CMMFPtrBuffer : public CMMFDataBuffer
sl@0
   198
	{
sl@0
   199
public:
sl@0
   200
	IMPORT_C static CMMFPtrBuffer* NewL();		//unitialised, pointer will be set via SetPtr
sl@0
   201
	IMPORT_C static CMMFPtrBuffer* NewL(const TPtr8& aPtr);
sl@0
   202
	IMPORT_C ~CMMFPtrBuffer();
sl@0
   203
	IMPORT_C void SetPtr(const TPtr8& aPtr);
sl@0
   204
	virtual TDes8& Data();
sl@0
   205
	virtual const TDesC8& Data() const;
sl@0
   206
	virtual void SetStatus(TBufferStatus aStatus);	
sl@0
   207
	virtual void SetRequestSizeL(TInt aSize);
sl@0
   208
	virtual TUint BufferSize() const;
sl@0
   209
	virtual void SetPosition (TUint aPosition);
sl@0
   210
private:
sl@0
   211
	CMMFPtrBuffer() : CMMFDataBuffer(KUidMmfPtrBuffer), iPtr(0,0,0) {};
sl@0
   212
	void ConstructL(const TPtr8& aPtr);
sl@0
   213
private:
sl@0
   214
	TPtr8 iPtr;
sl@0
   215
	};
sl@0
   216
sl@0
   217
#endif