sl@0
|
1 |
// Copyright (c) 2003-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 |
// source\mmf\server\baseclasses\mmfdatabuffer.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <mmf/server/mmfdatabuffer.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
Method to instantiate a CMMFDataBuffer defaults to a CMMFDescriptorBuffer
|
sl@0
|
25 |
to maintain buffer compatiblity with MFAD ie. instantiating a CMMFDataBuffer defaults to creating
|
sl@0
|
26 |
a CMMFDescriptorBuffer. This NewL creates a CMMFDescriptorBuffer with a default size of 32 bytes.
|
sl@0
|
27 |
|
sl@0
|
28 |
@return A pointer to a new CMMFDescriptorBuffer.
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
EXPORT_C CMMFDataBuffer* CMMFDataBuffer::NewL()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
return CMMFDescriptorBuffer::NewL();
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
Method to instantiate a CMMFDataBuffer defaults to a CMMFDescriptorBuffer by default
|
sl@0
|
37 |
to maintain buffer compatiblity with MFAD ie. instantiating a CMMFDataBuffer defaults to
|
sl@0
|
38 |
creating a CMMFDescriptorBuffer. This NewL creates a CMMFDescriptorBuffer with a size of
|
sl@0
|
39 |
aMaxBufferSize bytes.
|
sl@0
|
40 |
|
sl@0
|
41 |
@param aMaxBufferSize
|
sl@0
|
42 |
The size in bytes of the descriptor buffer to be created.
|
sl@0
|
43 |
|
sl@0
|
44 |
@return A pointer to a new CMMFDescriptorBuffer.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
EXPORT_C CMMFDataBuffer* CMMFDataBuffer::NewL(TInt aMaxBufferSize)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
return CMMFDescriptorBuffer::NewL(aMaxBufferSize);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
Method to instantiate a CMMFDescriptorBuffer.
|
sl@0
|
54 |
|
sl@0
|
55 |
Defaults to a CMMFDescriptorBuffer automatically. This NewL creates a CMMFDescriptorBuffer with a
|
sl@0
|
56 |
default size of 32 bytes.
|
sl@0
|
57 |
|
sl@0
|
58 |
@return A pointer to a new CMMFDescriptorBuffer.
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
EXPORT_C CMMFDescriptorBuffer* CMMFDescriptorBuffer::NewL()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
CMMFDescriptorBuffer* self = new(ELeave) CMMFDescriptorBuffer;
|
sl@0
|
63 |
CleanupStack::PushL(self);
|
sl@0
|
64 |
self->ConstructL(KMMFDataBufferDefaultBufferSize);
|
sl@0
|
65 |
CleanupStack::Pop(); // self
|
sl@0
|
66 |
return self;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Method to instantiate a CMMFDescriptorBuffer.
|
sl@0
|
72 |
This NewL creates a CMMFDescriptorBuffer with a size of aMaxBufferSize bytes.
|
sl@0
|
73 |
|
sl@0
|
74 |
@param aMaxBufferSize
|
sl@0
|
75 |
The size in bytes of the descriptor buffer to be created.
|
sl@0
|
76 |
|
sl@0
|
77 |
@return A pointer to a new CMMFDescriptorBuffer.
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
EXPORT_C CMMFDescriptorBuffer* CMMFDescriptorBuffer::NewL(TInt aMaxBufferSize)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CMMFDescriptorBuffer* self = new(ELeave) CMMFDescriptorBuffer;
|
sl@0
|
82 |
CleanupStack::PushL(self);
|
sl@0
|
83 |
self->ConstructL(aMaxBufferSize);
|
sl@0
|
84 |
CleanupStack::Pop(); // self
|
sl@0
|
85 |
return self;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
/**
|
sl@0
|
89 |
@internalTechnology
|
sl@0
|
90 |
|
sl@0
|
91 |
Internal.
|
sl@0
|
92 |
|
sl@0
|
93 |
@param aMaxBufferSize
|
sl@0
|
94 |
The size in bytes of the descriptor buffer to be created.
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
void CMMFDescriptorBuffer::ConstructL(TInt aMaxBufferSize)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
iData = new(ELeave) TUint8[aMaxBufferSize];
|
sl@0
|
99 |
iPtr.Set(iData, 0, aMaxBufferSize);
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
/**
|
sl@0
|
103 |
Destructor.
|
sl@0
|
104 |
|
sl@0
|
105 |
Destructor also deletes the buffer contained in the CMMFDescriptorBuffer.
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
EXPORT_C CMMFDescriptorBuffer::~CMMFDescriptorBuffer()
|
sl@0
|
108 |
{
|
sl@0
|
109 |
delete[] iData;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
Reallocates the max size in bytes of a CMMFDescriptorBuffer.
|
sl@0
|
114 |
|
sl@0
|
115 |
@param aMaxBufferSize
|
sl@0
|
116 |
The new size in bytes of the descriptor buffer.
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
EXPORT_C void CMMFDescriptorBuffer::ReAllocBufferL(TInt aMaxBufferSize)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
TUint8* tmp = new(ELeave) TUint8[aMaxBufferSize];
|
sl@0
|
121 |
delete[] iData;
|
sl@0
|
122 |
iData = tmp;
|
sl@0
|
123 |
iPtr.Set(iData, 0, aMaxBufferSize);
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
/**
|
sl@0
|
127 |
Returns a descriptor to the data contained in the CMMFDescriptorBuffer.
|
sl@0
|
128 |
|
sl@0
|
129 |
@return A reference to a TPtr containing the CMMFDescriptorBuffer data.
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
TDes8& CMMFDescriptorBuffer::Data()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
return iPtr;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
Returns a descriptor to the data contained in the CMMFDescriptorBuffer.
|
sl@0
|
138 |
|
sl@0
|
139 |
@return A const reference to a TPtr containing the CMMFDescriptorBuffer data.
|
sl@0
|
140 |
*/
|
sl@0
|
141 |
const TDesC8& CMMFDescriptorBuffer::Data() const
|
sl@0
|
142 |
{
|
sl@0
|
143 |
return iPtr;
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
/**
|
sl@0
|
147 |
Returns the actual data size (ie. not the maximum length) of the
|
sl@0
|
148 |
data contained in the CMMFDescriptorBuffer.
|
sl@0
|
149 |
|
sl@0
|
150 |
@return The size in bytes of the data contained in the CMMFDescriptorBuffer.
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
TUint CMMFDescriptorBuffer::BufferSize() const
|
sl@0
|
153 |
{
|
sl@0
|
154 |
return iPtr.Length();
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
Sets the position.
|
sl@0
|
159 |
|
sl@0
|
160 |
This method is used by components (eg codecs) which read data from a buffer
|
sl@0
|
161 |
and wish to store a read position marker for further reads.
|
sl@0
|
162 |
Note: The position cannot exceed the size of the actual data not the max length.
|
sl@0
|
163 |
|
sl@0
|
164 |
@param aPosition
|
sl@0
|
165 |
The position.
|
sl@0
|
166 |
*/
|
sl@0
|
167 |
void CMMFDescriptorBuffer::SetPosition (TUint aPosition)
|
sl@0
|
168 |
{//used for repositioning
|
sl@0
|
169 |
if (aPosition <= (TUint)iPtr.Length())
|
sl@0
|
170 |
iPosition = aPosition;
|
sl@0
|
171 |
else
|
sl@0
|
172 |
iPosition = (TUint)iPtr.Length();//tried to position beyond end of data
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
Sets the request size.
|
sl@0
|
177 |
|
sl@0
|
178 |
This function is used in cases where a component (eg a data source) may not be able
|
sl@0
|
179 |
or be desirable to write to the entire max length of the buffer (eg variable bit rate codecs).
|
sl@0
|
180 |
In which case the SetRequestSizeL() can be set which can be read by the RequestSize()
|
sl@0
|
181 |
function in the component so that it knows to only write data upto the request size
|
sl@0
|
182 |
and not fill the buffer up to its max length.
|
sl@0
|
183 |
|
sl@0
|
184 |
@param aSize
|
sl@0
|
185 |
The request size.
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
void CMMFDescriptorBuffer::SetRequestSizeL(TInt aSize)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
if (aSize < 0)
|
sl@0
|
190 |
User::Leave(KErrUnderflow);
|
sl@0
|
191 |
else if (aSize > iPtr.MaxLength())
|
sl@0
|
192 |
User::Leave(KErrOverflow);
|
sl@0
|
193 |
else
|
sl@0
|
194 |
iRequestSize = aSize;
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
Overriden method to set the status and resets the data size to 0 when the buffer becomes available.
|
sl@0
|
200 |
|
sl@0
|
201 |
@param aStatus
|
sl@0
|
202 |
The buffer status. See TBufferStatus for possible options.
|
sl@0
|
203 |
*/
|
sl@0
|
204 |
void CMMFDescriptorBuffer::SetStatus(TBufferStatus aStatus)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
CMMFBuffer::SetStatus(aStatus);
|
sl@0
|
207 |
if ((iStatus == EAvailable)&&iData)
|
sl@0
|
208 |
{//need to set size to 0
|
sl@0
|
209 |
iPtr.Zero();
|
sl@0
|
210 |
}
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
|
sl@0
|
214 |
/**
|
sl@0
|
215 |
This function is not supported under EKA2.
|
sl@0
|
216 |
|
sl@0
|
217 |
Method to instantiate a CMMFTransferBuffer. This NewL creates a CMMFTransferBuffer.
|
sl@0
|
218 |
|
sl@0
|
219 |
@param aTransferWindow
|
sl@0
|
220 |
This is a valid RTransferWindow that has an RTransferBuffer mapped in.
|
sl@0
|
221 |
@param aDataLength
|
sl@0
|
222 |
This parameter sets the length of the actual data present in the transferbuffer.
|
sl@0
|
223 |
This is because the length of actual data may be less than the length of the mapped in
|
sl@0
|
224 |
transfer buffer.
|
sl@0
|
225 |
|
sl@0
|
226 |
@return A pointer to a new CMMFTransferBuffer.
|
sl@0
|
227 |
*/
|
sl@0
|
228 |
|
sl@0
|
229 |
EXPORT_C CMMFTransferBuffer* CMMFTransferBuffer::NewL(RTransferWindow& aTransferWindow, TUint aDataLength)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
//this method is not supported under EKA2
|
sl@0
|
232 |
User::Panic(_L("Not supported!"), KErrNotSupported);
|
sl@0
|
233 |
aTransferWindow = aTransferWindow; //suppressed unused argument warnings
|
sl@0
|
234 |
aDataLength = aDataLength; //suppressed unused argument warnings
|
sl@0
|
235 |
return NULL; //can't construct anything useful
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
/**
|
sl@0
|
239 |
@internalTechnology
|
sl@0
|
240 |
|
sl@0
|
241 |
This method is not supported under EKA2.
|
sl@0
|
242 |
|
sl@0
|
243 |
Internal ConstructL.
|
sl@0
|
244 |
|
sl@0
|
245 |
Note this method checks if a transfer buffer has been mapped in and
|
sl@0
|
246 |
will leave with KErrNotReady if the RTransferWindow does not have a mapped
|
sl@0
|
247 |
in RTransferBuffer.
|
sl@0
|
248 |
|
sl@0
|
249 |
@param aTransferWindow
|
sl@0
|
250 |
This is a reference to a valid RTransferWindow that has an RTransferBuffer mapped in.
|
sl@0
|
251 |
@param aDataLength
|
sl@0
|
252 |
The length of the data.
|
sl@0
|
253 |
*/
|
sl@0
|
254 |
void CMMFTransferBuffer::ConstructL(RTransferWindow& aTransferWindow, TUint aDataLength)
|
sl@0
|
255 |
{
|
sl@0
|
256 |
//this method is not supported under EKA2
|
sl@0
|
257 |
aTransferWindow = aTransferWindow; //suppressed unused argument warnings
|
sl@0
|
258 |
aDataLength = aDataLength; //suppressed unused argument warnings
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
|
sl@0
|
262 |
/**
|
sl@0
|
263 |
CMMFTransferBuffer destructor
|
sl@0
|
264 |
|
sl@0
|
265 |
Destructor maps out RTransferBuffer and closes RTransferWindow.
|
sl@0
|
266 |
*/
|
sl@0
|
267 |
EXPORT_C CMMFTransferBuffer::~CMMFTransferBuffer()
|
sl@0
|
268 |
{
|
sl@0
|
269 |
}
|
sl@0
|
270 |
|
sl@0
|
271 |
/**
|
sl@0
|
272 |
Returns a descriptor to the data contained in the CMMFTransferBuffer.
|
sl@0
|
273 |
|
sl@0
|
274 |
@return A reference to a TPtr containing the CMMFTransferBuffer data.
|
sl@0
|
275 |
*/
|
sl@0
|
276 |
TDes8& CMMFTransferBuffer::Data()
|
sl@0
|
277 |
{
|
sl@0
|
278 |
return iPtr;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
/**
|
sl@0
|
282 |
Returns a descriptor to the data contained in the CMMFTransferBuffer.
|
sl@0
|
283 |
|
sl@0
|
284 |
@return A const reference to a TPtr containing the CMMFTransferBuffer data.
|
sl@0
|
285 |
*/
|
sl@0
|
286 |
const TDesC8& CMMFTransferBuffer::Data() const
|
sl@0
|
287 |
{
|
sl@0
|
288 |
return iPtr;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
/**
|
sl@0
|
292 |
Returns the actual data size (ie. not the max length) of the
|
sl@0
|
293 |
data contained in the CMMFTransferBuffer.
|
sl@0
|
294 |
|
sl@0
|
295 |
@return The size in bytes of the data contained in the CMMFTransferBuffer.
|
sl@0
|
296 |
*/
|
sl@0
|
297 |
TUint CMMFTransferBuffer::BufferSize() const
|
sl@0
|
298 |
{
|
sl@0
|
299 |
return iPtr.Length();
|
sl@0
|
300 |
}
|
sl@0
|
301 |
|
sl@0
|
302 |
|
sl@0
|
303 |
/**
|
sl@0
|
304 |
Sets the position.
|
sl@0
|
305 |
|
sl@0
|
306 |
This method is used by components (eg codecs) which read data from a buffer
|
sl@0
|
307 |
and wish to store a read position marker for further reads.
|
sl@0
|
308 |
|
sl@0
|
309 |
Note: The position cannot exceed the size of the actual data not the max length.
|
sl@0
|
310 |
|
sl@0
|
311 |
@param aPosition
|
sl@0
|
312 |
The position.
|
sl@0
|
313 |
*/
|
sl@0
|
314 |
void CMMFTransferBuffer::SetPosition (TUint aPosition)
|
sl@0
|
315 |
{//used for repositioning
|
sl@0
|
316 |
aPosition = aPosition; //suppress compiler warning
|
sl@0
|
317 |
}
|
sl@0
|
318 |
|
sl@0
|
319 |
/**
|
sl@0
|
320 |
Sets the request size.
|
sl@0
|
321 |
|
sl@0
|
322 |
This function is used in cases where a component (eg. a data source) may not be able
|
sl@0
|
323 |
or be desirable to write to the entire max length of the buffer (eg. variable bit rate codecs).
|
sl@0
|
324 |
In this case, the SetRequestSizeL can be set which can be read by the RequestSize()
|
sl@0
|
325 |
function in the component so that it knows to only write data upto the request size
|
sl@0
|
326 |
and not fill the buffer up to its max length.
|
sl@0
|
327 |
|
sl@0
|
328 |
@param aSize
|
sl@0
|
329 |
The request size.
|
sl@0
|
330 |
*/
|
sl@0
|
331 |
void CMMFTransferBuffer::SetRequestSizeL(TInt aSize)
|
sl@0
|
332 |
{
|
sl@0
|
333 |
aSize = aSize; //suppress compiler warning
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
|
sl@0
|
337 |
/**
|
sl@0
|
338 |
This function is not supported under EKA2.
|
sl@0
|
339 |
|
sl@0
|
340 |
Returns a reference to the transfer window currently used
|
sl@0
|
341 |
by the CMMFtransferBuffer.
|
sl@0
|
342 |
|
sl@0
|
343 |
@return A reference to the current RTransferWindow.
|
sl@0
|
344 |
*/
|
sl@0
|
345 |
EXPORT_C RTransferWindow& CMMFTransferBuffer::TransferWindow()
|
sl@0
|
346 |
{
|
sl@0
|
347 |
return iTransferWindow;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
|
sl@0
|
351 |
/**
|
sl@0
|
352 |
This method is not supported under EKA2.
|
sl@0
|
353 |
|
sl@0
|
354 |
Modifies the CMMFTransferBuffer by updating the RTransferWindow.
|
sl@0
|
355 |
|
sl@0
|
356 |
This method is used if the same CMMFTransferBuffer is used throughout
|
sl@0
|
357 |
eg. if a single CMMFTransferBuffer is created upfront but a different
|
sl@0
|
358 |
transfer window (or the same transfer window with a different buffer mapped in
|
sl@0
|
359 |
is used). That is the same CMMFTransferBuffer but the actrual buffer may be different.
|
sl@0
|
360 |
|
sl@0
|
361 |
Note: If the updated RTransferWindow is new, then the old buffer must
|
sl@0
|
362 |
be mapped out first by a call to CMMFTransferBuffer::MapOutBuffer() and the
|
sl@0
|
363 |
RtransferWindow handle closed outside the CMMFTransferBuffer.
|
sl@0
|
364 |
|
sl@0
|
365 |
@param aTransferWindow
|
sl@0
|
366 |
The RTransferWindow to update - can be a new RTransferWindow
|
sl@0
|
367 |
or the same RTransferWindow with a new RTransferBuffer mapped in.
|
sl@0
|
368 |
@param aDataLength
|
sl@0
|
369 |
The length of the data.
|
sl@0
|
370 |
|
sl@0
|
371 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
sl@0
|
372 |
another of the system-wide error codes.
|
sl@0
|
373 |
*/
|
sl@0
|
374 |
EXPORT_C TInt CMMFTransferBuffer::UpdateTransferWindow(RTransferWindow& aTransferWindow, TUint aDataLength)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
//this method is not supported under EKA2
|
sl@0
|
377 |
aTransferWindow = aTransferWindow; //suppressed unused argument warnings
|
sl@0
|
378 |
aDataLength = aDataLength; //suppressed unused argument warnings
|
sl@0
|
379 |
return KErrNotSupported;
|
sl@0
|
380 |
}
|
sl@0
|
381 |
|
sl@0
|
382 |
/**
|
sl@0
|
383 |
Maps the buffer out of the transfer window.
|
sl@0
|
384 |
|
sl@0
|
385 |
This method should be called in preference to
|
sl@0
|
386 |
calling MapOutBuffer directly on the RtransferWindow
|
sl@0
|
387 |
so that the CMMFTransferBuffer knows that it is no longer
|
sl@0
|
388 |
available.
|
sl@0
|
389 |
*/
|
sl@0
|
390 |
EXPORT_C void CMMFTransferBuffer::MapOutBuffer()
|
sl@0
|
391 |
{
|
sl@0
|
392 |
}
|
sl@0
|
393 |
|
sl@0
|
394 |
|
sl@0
|
395 |
|
sl@0
|
396 |
/**
|
sl@0
|
397 |
Function to instantiate a CMMFPtrBuffer.
|
sl@0
|
398 |
This NewL creates an unititalised CMMFPtrBuffer.
|
sl@0
|
399 |
|
sl@0
|
400 |
@return A pointer to a new CMMFPtrBuffer.
|
sl@0
|
401 |
*/
|
sl@0
|
402 |
EXPORT_C CMMFPtrBuffer* CMMFPtrBuffer::NewL()
|
sl@0
|
403 |
{
|
sl@0
|
404 |
CMMFPtrBuffer* self = new(ELeave) CMMFPtrBuffer;
|
sl@0
|
405 |
|
sl@0
|
406 |
return self;
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
|
sl@0
|
410 |
/**
|
sl@0
|
411 |
Function to instantiate a CMMFPtrBuffer.
|
sl@0
|
412 |
This NewL creates a CMMFPtrBuffer which owns a TPtr8.
|
sl@0
|
413 |
|
sl@0
|
414 |
@param aPtr
|
sl@0
|
415 |
A reference to a TPtr containing the CMMFPtrBuffer data.
|
sl@0
|
416 |
|
sl@0
|
417 |
@return A pointer to a new CMMFPtrBuffer.
|
sl@0
|
418 |
*/
|
sl@0
|
419 |
EXPORT_C CMMFPtrBuffer* CMMFPtrBuffer::NewL(const TPtr8& aPtr)
|
sl@0
|
420 |
{
|
sl@0
|
421 |
CMMFPtrBuffer* self = new(ELeave) CMMFPtrBuffer;
|
sl@0
|
422 |
CleanupStack::PushL(self);
|
sl@0
|
423 |
self->ConstructL(aPtr);
|
sl@0
|
424 |
CleanupStack::Pop(self); // self
|
sl@0
|
425 |
return self;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
/**
|
sl@0
|
429 |
* ConstructL
|
sl@0
|
430 |
*
|
sl@0
|
431 |
* Internal ConstructL
|
sl@0
|
432 |
* @internalTechnology
|
sl@0
|
433 |
* @param "aPtr"
|
sl@0
|
434 |
* Reference to a TPtr containing the CMMFPtrBuffer data
|
sl@0
|
435 |
*/
|
sl@0
|
436 |
void CMMFPtrBuffer::ConstructL(const TPtr8& aPtr)
|
sl@0
|
437 |
{
|
sl@0
|
438 |
iPtr.Set(aPtr);
|
sl@0
|
439 |
}
|
sl@0
|
440 |
|
sl@0
|
441 |
/**
|
sl@0
|
442 |
Destructor.
|
sl@0
|
443 |
|
sl@0
|
444 |
Destructor does no deletion, as this buffer class does not own the memory.
|
sl@0
|
445 |
*/
|
sl@0
|
446 |
EXPORT_C CMMFPtrBuffer::~CMMFPtrBuffer()
|
sl@0
|
447 |
{
|
sl@0
|
448 |
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
/**
|
sl@0
|
452 |
Returns a descriptor to the data contained in the CMMFPtrBuffer.
|
sl@0
|
453 |
|
sl@0
|
454 |
@return A reference to a TPtr containing the CMMFPtrBuffer data.
|
sl@0
|
455 |
*/
|
sl@0
|
456 |
TDes8& CMMFPtrBuffer::Data()
|
sl@0
|
457 |
{
|
sl@0
|
458 |
return iPtr;
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
/**
|
sl@0
|
462 |
Returns a descriptor to the data contained in the CMMFPtrBuffer.
|
sl@0
|
463 |
|
sl@0
|
464 |
@return A const reference to a TPtr containing the CMMFPtrBuffer data.
|
sl@0
|
465 |
*/
|
sl@0
|
466 |
const TDesC8& CMMFPtrBuffer::Data() const
|
sl@0
|
467 |
{
|
sl@0
|
468 |
return iPtr;
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
/**
|
sl@0
|
472 |
Returns the actual data size (ie. not the max length) of the
|
sl@0
|
473 |
data contained in the CMMFPtrBuffer.
|
sl@0
|
474 |
|
sl@0
|
475 |
@return The size in bytes of the data contained in the CMMFPtrBuffer.
|
sl@0
|
476 |
*/
|
sl@0
|
477 |
TUint CMMFPtrBuffer::BufferSize() const
|
sl@0
|
478 |
{
|
sl@0
|
479 |
return iPtr.Length();
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
/**
|
sl@0
|
483 |
Sets the position.
|
sl@0
|
484 |
|
sl@0
|
485 |
This function is used by components (eg. codecs) which read data from a buffer
|
sl@0
|
486 |
and wish to store a read position marker for further reads.
|
sl@0
|
487 |
|
sl@0
|
488 |
Note: The position cannot exceed the size of the actual data not the maximum length.
|
sl@0
|
489 |
|
sl@0
|
490 |
@param aPosition
|
sl@0
|
491 |
The position.
|
sl@0
|
492 |
*/
|
sl@0
|
493 |
void CMMFPtrBuffer::SetPosition (TUint aPosition)
|
sl@0
|
494 |
{//used for repositioning
|
sl@0
|
495 |
if (aPosition <= (TUint)iPtr.Length())
|
sl@0
|
496 |
iPosition = aPosition;
|
sl@0
|
497 |
else
|
sl@0
|
498 |
iPosition = (TUint)iPtr.Length();//tried to position beyond end of data
|
sl@0
|
499 |
}
|
sl@0
|
500 |
|
sl@0
|
501 |
/**
|
sl@0
|
502 |
Sets the request size.
|
sl@0
|
503 |
|
sl@0
|
504 |
This method is used in cases where a component (eg. a data source) may not be able
|
sl@0
|
505 |
or be desirable to write to the entire max length of the buffer (eg. variable bit rate codecs).
|
sl@0
|
506 |
In this case, the SetRequestSizeL() can be set which can be read by the RequestSize()
|
sl@0
|
507 |
function in the component so that it knows to only write data upto the requested size
|
sl@0
|
508 |
and not fill the buffer up to its maximum length.
|
sl@0
|
509 |
|
sl@0
|
510 |
@param aSize
|
sl@0
|
511 |
The request size.
|
sl@0
|
512 |
*/
|
sl@0
|
513 |
void CMMFPtrBuffer::SetRequestSizeL(TInt aSize)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
if (aSize < 0)
|
sl@0
|
516 |
User::Leave(KErrUnderflow);
|
sl@0
|
517 |
else if (aSize > iPtr.MaxLength())
|
sl@0
|
518 |
User::Leave(KErrOverflow);
|
sl@0
|
519 |
else
|
sl@0
|
520 |
iRequestSize = aSize;
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
|
sl@0
|
524 |
/**
|
sl@0
|
525 |
Overriden method to set the status.
|
sl@0
|
526 |
Resets the data size to 0 when the buffer becomes available.
|
sl@0
|
527 |
|
sl@0
|
528 |
@param aStatus
|
sl@0
|
529 |
The buffer status. See enum TBufferStatus.
|
sl@0
|
530 |
*/
|
sl@0
|
531 |
void CMMFPtrBuffer::SetStatus(TBufferStatus aStatus)
|
sl@0
|
532 |
{
|
sl@0
|
533 |
CMMFBuffer::SetStatus(aStatus);
|
sl@0
|
534 |
if (iStatus == EAvailable)
|
sl@0
|
535 |
{//need to set size to 0
|
sl@0
|
536 |
iPtr.Zero();
|
sl@0
|
537 |
}
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
|
sl@0
|
541 |
/**
|
sl@0
|
542 |
Takes a TPtr8 to pre-allocated memory.
|
sl@0
|
543 |
|
sl@0
|
544 |
@param aPtr
|
sl@0
|
545 |
The pointer refernce.
|
sl@0
|
546 |
*/
|
sl@0
|
547 |
EXPORT_C void CMMFPtrBuffer::SetPtr(const TPtr8& aPtr)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
iPtr.Set(aPtr);
|
sl@0
|
550 |
}
|
sl@0
|
551 |
|
sl@0
|
552 |
|
sl@0
|
553 |
//This functions needs updating
|
sl@0
|
554 |
//should more CMMFDataBuffers be supported in future
|
sl@0
|
555 |
/**
|
sl@0
|
556 |
Static method which returns ETrue if the buffer UID is a supported
|
sl@0
|
557 |
CMMFDataBuffer type.
|
sl@0
|
558 |
|
sl@0
|
559 |
Note:
|
sl@0
|
560 |
If the buffer is not a CMMFDataBuffer this method should
|
sl@0
|
561 |
return EFalse.
|
sl@0
|
562 |
|
sl@0
|
563 |
@param aUid
|
sl@0
|
564 |
The UID of the CMMFBuffer to be checked for support.
|
sl@0
|
565 |
@return The buffer size.
|
sl@0
|
566 |
*/
|
sl@0
|
567 |
EXPORT_C TBool CMMFBuffer::IsSupportedDataBuffer(TUid aUid)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
return((aUid == KUidMmfDescriptorBuffer)
|
sl@0
|
570 |
|| (aUid == KUidMmfTransferBuffer)
|
sl@0
|
571 |
|| (aUid == KUidMmfPtrBuffer));
|
sl@0
|
572 |
}
|
sl@0
|
573 |
|
sl@0
|
574 |
|
sl@0
|
575 |
/**
|
sl@0
|
576 |
Static method which returns ETrue if the buffer UID is a buffer
|
sl@0
|
577 |
that is safe to be used with the file server. If the buffer type
|
sl@0
|
578 |
is not safe to be used with the file server, then the client would
|
sl@0
|
579 |
need to copy the contents of the buffer, prior to passing it onto
|
sl@0
|
580 |
the file server.
|
sl@0
|
581 |
|
sl@0
|
582 |
This implementation assumes the CMMFPtrBuffer is safe for file server copy. If this is not the case
|
sl@0
|
583 |
then remove the PtrBuffer set to ETrue.
|
sl@0
|
584 |
|
sl@0
|
585 |
@param aUid
|
sl@0
|
586 |
The UID of the CMMFBuffer to be checked for support.
|
sl@0
|
587 |
|
sl@0
|
588 |
@return The buffer size.
|
sl@0
|
589 |
*/
|
sl@0
|
590 |
EXPORT_C TBool CMMFBuffer::IsFileServerSafe(TUid aUid)
|
sl@0
|
591 |
{
|
sl@0
|
592 |
TBool isFileServerSafe = EFalse;
|
sl@0
|
593 |
|
sl@0
|
594 |
if (aUid == KUidMmfDescriptorBuffer)
|
sl@0
|
595 |
isFileServerSafe = ETrue;
|
sl@0
|
596 |
if (aUid == KUidMmfPtrBuffer) //remove this if target CMMFPtrBuffers
|
sl@0
|
597 |
isFileServerSafe = ETrue; //are not safe for file server copy
|
sl@0
|
598 |
|
sl@0
|
599 |
return isFileServerSafe;
|
sl@0
|
600 |
}
|