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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // include\mmf\server\mmfdatabuffer.h
19 #ifndef __MMF_SERVER_DATABUFFER_H__
20 #define __MMF_SERVER_DATABUFFER_H__
25 #include <mmf/server/mmfbuffer.h>
31 Default buffer size if none is specified.
33 static const TInt KMMFDataBufferDefaultBufferSize = 32;
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.
42 @see CMMFDescriptorBuffer
44 class CMMFDataBuffer : public CMMFBuffer
47 IMPORT_C static CMMFDataBuffer* NewL();
48 IMPORT_C static CMMFDataBuffer* NewL(TInt aMaxBufferSize);
52 virtual ~CMMFDataBuffer() {};
55 Returns a reference to the data contained in the buffer (non const version).
57 This is a virtual function that each derived class must implement.
59 @return A reference to the buffer.
61 virtual TDes8& Data() = 0;
64 Returns a reference to the data contained in the buffer (const version).
66 This is a virtual function that each derived class must implement.
68 @return A reference to the buffer.
70 virtual const TDesC8& Data() const = 0;
73 Returns the buffer size, in bytes.
75 This is a virtual function that each derived class must implement.
77 @return The buffer size in bytes.
79 virtual TUint BufferSize() const = 0;
82 Sets the request size.
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).
88 This is a virtual function that each derived class must implement.
91 The requested size, in bytes.
93 virtual void SetRequestSizeL(TInt aSize) = 0;
96 Protected constructor.
98 CMMFDataBuffer(TUid aType): CMMFBuffer(aType) {};
106 This class is a wrapper class to give a descriptor the same API as a CMMFDataBuffer.
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.
112 class CMMFDescriptorBuffer : public CMMFDataBuffer
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);
126 CMMFDescriptorBuffer() : CMMFDataBuffer(KUidMmfDescriptorBuffer), iPtr(0,0,0) {};
127 void ConstructL(TInt aMaxBufferSize);
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.
143 The class assumes that a valid RTransferWindow with a RTransferBuffer mapped in already exists.
146 CMMFTransferBuffers are not supported in EKA2.
150 class RTransferWindow
156 class CMMFTransferBuffer : public CMMFDataBuffer
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);
175 CMMFTransferBuffer() : CMMFDataBuffer(KUidMmfTransferBuffer), iPtr(0,0,0){};
176 void ConstructL(RTransferWindow& aTransferWindow, TUint aDataLength);
179 RTransferWindow iTransferWindow;
180 TBool iTransferWindowMappedInOK;
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
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.
197 class CMMFPtrBuffer : public CMMFDataBuffer
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);
211 CMMFPtrBuffer() : CMMFDataBuffer(KUidMmfPtrBuffer), iPtr(0,0,0) {};
212 void ConstructL(const TPtr8& aPtr);