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