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\server\mmfbuffer.h
|
williamr@2
|
15 |
//
|
williamr@2
|
16 |
//
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef __MMF_SERVER_BUFFER_H__
|
williamr@2
|
20 |
#define __MMF_SERVER_BUFFER_H__
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#include <e32base.h>
|
williamr@2
|
23 |
#include <mmf/server/mmfbuffer.hrh>
|
williamr@2
|
24 |
|
williamr@2
|
25 |
|
williamr@2
|
26 |
/**
|
williamr@2
|
27 |
@publishedAll
|
williamr@2
|
28 |
@released
|
williamr@2
|
29 |
|
williamr@2
|
30 |
Flag reflecting the current buffer status.
|
williamr@2
|
31 |
*/
|
williamr@2
|
32 |
enum TBufferStatus
|
williamr@2
|
33 |
{
|
williamr@2
|
34 |
/** The buffer is available for use */
|
williamr@2
|
35 |
EAvailable,
|
williamr@2
|
36 |
|
williamr@2
|
37 |
/** The buffer is currently being filled */
|
williamr@2
|
38 |
EBeingFilled,
|
williamr@2
|
39 |
|
williamr@2
|
40 |
/** The buffer is full */
|
williamr@2
|
41 |
EFull,
|
williamr@2
|
42 |
|
williamr@2
|
43 |
/** The buffer is currently being emptied */
|
williamr@2
|
44 |
EBeingEmptied,
|
williamr@2
|
45 |
|
williamr@2
|
46 |
/** The buffer is currently unavailable */
|
williamr@2
|
47 |
EUnAvailable
|
williamr@2
|
48 |
};
|
williamr@2
|
49 |
|
williamr@2
|
50 |
|
williamr@2
|
51 |
/**
|
williamr@2
|
52 |
@publishedAll
|
williamr@2
|
53 |
@released
|
williamr@2
|
54 |
|
williamr@2
|
55 |
Abstract representation of a buffer to contain multimedia data.
|
williamr@2
|
56 |
*/
|
williamr@2
|
57 |
class CMMFBuffer : public CBase
|
williamr@2
|
58 |
{
|
williamr@2
|
59 |
public:
|
williamr@2
|
60 |
IMPORT_C static TBool IsSupportedDataBuffer(TUid aUid);
|
williamr@2
|
61 |
IMPORT_C static TBool IsFileServerSafe(TUid aUid);
|
williamr@2
|
62 |
/**
|
williamr@2
|
63 |
Returns the buffer type.
|
williamr@2
|
64 |
|
williamr@2
|
65 |
@return The buffer type.
|
williamr@2
|
66 |
*/
|
williamr@2
|
67 |
TUid Type() const {return iType;};
|
williamr@2
|
68 |
/**
|
williamr@2
|
69 |
Sets the buffer's status.
|
williamr@2
|
70 |
|
williamr@2
|
71 |
@param aStatus
|
williamr@2
|
72 |
The buffer's status.
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
virtual void SetStatus(TBufferStatus aStatus)
|
williamr@2
|
75 |
{iStatus = aStatus; if (iStatus == EAvailable) iPosition = 0;}
|
williamr@2
|
76 |
/**
|
williamr@2
|
77 |
Returns the buffer's status.
|
williamr@2
|
78 |
|
williamr@2
|
79 |
@return The buffer's status.
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
TBufferStatus Status() {return iStatus;};
|
williamr@2
|
82 |
|
williamr@2
|
83 |
/**
|
williamr@2
|
84 |
Returns the size of the data in the buffer.
|
williamr@2
|
85 |
|
williamr@2
|
86 |
This is a virtual function that each derived class must implement.
|
williamr@2
|
87 |
|
williamr@2
|
88 |
@return The buffer size.
|
williamr@2
|
89 |
*/
|
williamr@2
|
90 |
virtual TUint BufferSize() const = 0;
|
williamr@2
|
91 |
|
williamr@2
|
92 |
/**
|
williamr@2
|
93 |
Destructor.
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
virtual ~CMMFBuffer() {};
|
williamr@2
|
96 |
inline TTimeIntervalMicroSeconds TimeToPlay() const;
|
williamr@2
|
97 |
inline void SetTimeToPlay (TTimeIntervalMicroSeconds aTime);
|
williamr@2
|
98 |
inline TUint FrameNumber() const;
|
williamr@2
|
99 |
inline void SetFrameNumber(TUint aFrame);
|
williamr@2
|
100 |
inline void NextFrame();
|
williamr@2
|
101 |
inline virtual void SetPosition (TUint aPosition);
|
williamr@2
|
102 |
inline virtual TUint Position() const;
|
williamr@2
|
103 |
inline virtual TInt RequestSize() const;
|
williamr@2
|
104 |
inline void SetLastBuffer(TBool aLastBuffer);
|
williamr@2
|
105 |
inline TBool LastBuffer() const;
|
williamr@2
|
106 |
protected:
|
williamr@2
|
107 |
CMMFBuffer(TUid aType): iType(aType), iStatus(EAvailable) {};
|
williamr@2
|
108 |
|
williamr@2
|
109 |
protected:
|
williamr@2
|
110 |
/**
|
williamr@2
|
111 |
The buffer type.
|
williamr@2
|
112 |
*/
|
williamr@2
|
113 |
TUid iType;
|
williamr@2
|
114 |
|
williamr@2
|
115 |
/**
|
williamr@2
|
116 |
The current buffer status.
|
williamr@2
|
117 |
|
williamr@2
|
118 |
@see enum TBufferStatus
|
williamr@2
|
119 |
*/
|
williamr@2
|
120 |
TBufferStatus iStatus;
|
williamr@2
|
121 |
|
williamr@2
|
122 |
/**
|
williamr@2
|
123 |
The buffer timestamp, in microseconds.
|
williamr@2
|
124 |
*/
|
williamr@2
|
125 |
TTimeIntervalMicroSeconds iTimeToPlay;
|
williamr@2
|
126 |
|
williamr@2
|
127 |
/**
|
williamr@2
|
128 |
Used to store the current read/write position. Required when the codec and data path
|
williamr@2
|
129 |
may have to read and write the buffer in more than one pass.
|
williamr@2
|
130 |
*/
|
williamr@2
|
131 |
TUint iPosition;
|
williamr@2
|
132 |
|
williamr@2
|
133 |
/**
|
williamr@2
|
134 |
The frame number.
|
williamr@2
|
135 |
*/
|
williamr@2
|
136 |
TUint iFrameNumber;
|
williamr@2
|
137 |
|
williamr@2
|
138 |
/**
|
williamr@2
|
139 |
Stores Request size, needed for dynamic buffer length.
|
williamr@2
|
140 |
*/
|
williamr@2
|
141 |
TInt iRequestSize;
|
williamr@2
|
142 |
|
williamr@2
|
143 |
/**
|
williamr@2
|
144 |
Indicates if this is the last buffer. ETrue if it is.
|
williamr@2
|
145 |
*/
|
williamr@2
|
146 |
TBool iLastBuffer;
|
williamr@2
|
147 |
};
|
williamr@2
|
148 |
|
williamr@2
|
149 |
/**
|
williamr@2
|
150 |
Returns the buffer timestamp, in microseconds.
|
williamr@2
|
151 |
|
williamr@2
|
152 |
@return The buffer timestamp, in microseconds.
|
williamr@2
|
153 |
*/
|
williamr@2
|
154 |
inline TTimeIntervalMicroSeconds CMMFBuffer::TimeToPlay() const
|
williamr@2
|
155 |
{
|
williamr@2
|
156 |
return iTimeToPlay;
|
williamr@2
|
157 |
}
|
williamr@2
|
158 |
|
williamr@2
|
159 |
/**
|
williamr@2
|
160 |
Sets the buffer timestamp, in microseconds.
|
williamr@2
|
161 |
|
williamr@2
|
162 |
@param aTime
|
williamr@2
|
163 |
The buffer timestamp, in microseconds.
|
williamr@2
|
164 |
*/
|
williamr@2
|
165 |
inline void CMMFBuffer::SetTimeToPlay (TTimeIntervalMicroSeconds aTime)
|
williamr@2
|
166 |
{
|
williamr@2
|
167 |
iTimeToPlay = aTime;
|
williamr@2
|
168 |
}
|
williamr@2
|
169 |
|
williamr@2
|
170 |
/**
|
williamr@2
|
171 |
Returns the frame number.
|
williamr@2
|
172 |
|
williamr@2
|
173 |
@return The frame number.
|
williamr@2
|
174 |
*/
|
williamr@2
|
175 |
inline TUint CMMFBuffer::FrameNumber() const
|
williamr@2
|
176 |
{
|
williamr@2
|
177 |
return iFrameNumber;
|
williamr@2
|
178 |
}
|
williamr@2
|
179 |
|
williamr@2
|
180 |
/**
|
williamr@2
|
181 |
Sets the frame number. This is used for repositioning.
|
williamr@2
|
182 |
|
williamr@2
|
183 |
@param aFrameNumber
|
williamr@2
|
184 |
The frame number.
|
williamr@2
|
185 |
*/
|
williamr@2
|
186 |
inline void CMMFBuffer::SetFrameNumber (TUint aFrameNumber)
|
williamr@2
|
187 |
{
|
williamr@2
|
188 |
iFrameNumber = aFrameNumber;
|
williamr@2
|
189 |
}
|
williamr@2
|
190 |
|
williamr@2
|
191 |
/**
|
williamr@2
|
192 |
Sets the buffer as the next frame.
|
williamr@2
|
193 |
*/
|
williamr@2
|
194 |
inline void CMMFBuffer::NextFrame()
|
williamr@2
|
195 |
{
|
williamr@2
|
196 |
iFrameNumber++;
|
williamr@2
|
197 |
}
|
williamr@2
|
198 |
|
williamr@2
|
199 |
|
williamr@2
|
200 |
/**
|
williamr@2
|
201 |
Sets the current buffer read/write position.
|
williamr@2
|
202 |
Used as read/write position on a buffer where a codec may need
|
williamr@2
|
203 |
several passes on the same buffer.
|
williamr@2
|
204 |
|
williamr@2
|
205 |
@param aPosition
|
williamr@2
|
206 |
The buffer's number.
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
inline void CMMFBuffer::SetPosition (TUint aPosition)
|
williamr@2
|
209 |
{
|
williamr@2
|
210 |
iPosition = aPosition;
|
williamr@2
|
211 |
}
|
williamr@2
|
212 |
|
williamr@2
|
213 |
/**
|
williamr@2
|
214 |
Returns the current buffer read/write position.
|
williamr@2
|
215 |
Used as read/write position on a buffer where a codec may need
|
williamr@2
|
216 |
several passes on the same buffer.
|
williamr@2
|
217 |
|
williamr@2
|
218 |
@return The buffer's number.
|
williamr@2
|
219 |
*/
|
williamr@2
|
220 |
inline TUint CMMFBuffer::Position() const
|
williamr@2
|
221 |
{
|
williamr@2
|
222 |
return iPosition;
|
williamr@2
|
223 |
}
|
williamr@2
|
224 |
|
williamr@2
|
225 |
/**
|
williamr@2
|
226 |
Tests whether the buffer is the last buffer.
|
williamr@2
|
227 |
|
williamr@2
|
228 |
@return A boolean indicating if the buffer is the last one. ETrue if it is the last buffer,
|
williamr@2
|
229 |
EFalse otherwise.
|
williamr@2
|
230 |
*/
|
williamr@2
|
231 |
inline TBool CMMFBuffer::LastBuffer() const
|
williamr@2
|
232 |
{
|
williamr@2
|
233 |
return iLastBuffer;
|
williamr@2
|
234 |
}
|
williamr@2
|
235 |
|
williamr@2
|
236 |
/**
|
williamr@2
|
237 |
Sets the buffer as the last buffer.
|
williamr@2
|
238 |
|
williamr@2
|
239 |
@param aLastBuffer
|
williamr@2
|
240 |
A boolean indicating if the buffer is the last buffer. ETrue if it is the last buffer,
|
williamr@2
|
241 |
EFalse otherwise.
|
williamr@2
|
242 |
*/
|
williamr@2
|
243 |
inline void CMMFBuffer::SetLastBuffer(TBool aLastBuffer)
|
williamr@2
|
244 |
{
|
williamr@2
|
245 |
iLastBuffer = aLastBuffer;
|
williamr@2
|
246 |
}
|
williamr@2
|
247 |
|
williamr@2
|
248 |
/**
|
williamr@2
|
249 |
Returns the size of data processed by sink or data needed by source.
|
williamr@2
|
250 |
|
williamr@2
|
251 |
@return The size of data
|
williamr@2
|
252 |
*/
|
williamr@2
|
253 |
inline TInt CMMFBuffer::RequestSize() const
|
williamr@2
|
254 |
{
|
williamr@2
|
255 |
return iRequestSize;
|
williamr@2
|
256 |
}
|
williamr@2
|
257 |
|
williamr@2
|
258 |
#endif
|